libgda r3332 - in trunk: . libgda libgda/sqlite/sqlite-src providers/mysql
- From: vivien svn gnome org
- To: svn-commits-list gnome org
- Subject: libgda r3332 - in trunk: . libgda libgda/sqlite/sqlite-src providers/mysql
- Date: Mon, 23 Feb 2009 19:40:20 +0000 (UTC)
Author: vivien
Date: Mon Feb 23 19:40:20 2009
New Revision: 3332
URL: http://svn.gnome.org/viewvc/libgda?rev=3332&view=rev
Log:
2009-02-23 Vivien Malerba <malerba gnome-db org>
* libgda/gda-connection.c: improved debug message
* libgda/sqlite/sqlite-src/Makefile.am: define the SQLITE_OMIT_LOAD_EXTENSION flag
to avoid having to link with libdl, possible fix for bug #572277
* providers/mysql/gda-mysql-meta.c:
* providers/mysql/gda-mysql-recordset.c: general MySQL provider improvements
* providers/mysql/gda-mysql-provider.c: possible fix for bug #572394
Modified:
trunk/ChangeLog
trunk/libgda/gda-connection.c
trunk/libgda/sqlite/sqlite-src/Makefile.am
trunk/providers/mysql/gda-mysql-meta.c
trunk/providers/mysql/gda-mysql-provider.c
trunk/providers/mysql/gda-mysql-recordset.c
Modified: trunk/libgda/gda-connection.c
==============================================================================
--- trunk/libgda/gda-connection.c (original)
+++ trunk/libgda/gda-connection.c Mon Feb 23 19:40:20 2009
@@ -3143,11 +3143,14 @@
else {
lcontext.table_name = rmeta [i].table_name;
if (!rmeta [i].func (provider, cnc, store, &lcontext, error)) {
+ /*
g_print ("TH %p CNC %p ERROR, prov=%p (%s)\n", g_thread_self(), cnc,
gda_connection_get_provider (cnc),
gda_connection_get_provider_name (cnc));
+ */
if (error && *error)
- g_warning ("\t==> %s\n", (*error)->message);
+ g_warning ("%s (Provider %s)\n", (*error)->message,
+ gda_connection_get_provider_name (cnc));
WARN_META_UPDATE_FAILURE (FALSE, rmeta [i].func_name);
goto onerror;
Modified: trunk/libgda/sqlite/sqlite-src/Makefile.am
==============================================================================
--- trunk/libgda/sqlite/sqlite-src/Makefile.am (original)
+++ trunk/libgda/sqlite/sqlite-src/Makefile.am Mon Feb 23 19:40:20 2009
@@ -1,6 +1,6 @@
noinst_LTLIBRARIES = \
libsqlite.la
-AM_CPPFLAGS = -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_THREADSAFE=1
+AM_CPPFLAGS = -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_THREADSAFE=1 -DSQLITE_OMIT_LOAD_EXTENSION=1
# Download the Windows prepared SQLite (series 3.x) sources in a ZIP, and
# extract the zip in this directory (thanks to http://aaronbock.net/articles/sqlite!)
Modified: trunk/providers/mysql/gda-mysql-meta.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-meta.c (original)
+++ trunk/providers/mysql/gda-mysql-meta.c Mon Feb 23 19:40:20 2009
@@ -59,10 +59,8 @@
I_STMT_TABLES_CONSTRAINTS,
I_STMT_TABLES_CONSTRAINTS_ALL,
I_STMT_TABLES_CONSTRAINTS_NAMED,
-#if MYSQL_VERSION_ID >= 50110
I_STMT_REF_CONSTRAINTS,
I_STMT_REF_CONSTRAINTS_ALL,
-#endif
I_STMT_KEY_COLUMN_USAGE,
I_STMT_KEY_COLUMN_USAGE_ALL,
/* I_STMT_UDT, */
@@ -96,6 +94,7 @@
/*
* predefined statements' SQL
*/
+#define SHORT_NAME(t,s,f) "CASE WHEN " t "= 'information_schema' OR " t "= 'mysql' THEN " f " ELSE " s " END"
static gchar *internal_sql[] = {
/* I_STMT_CATALOG */
"SELECT DATABASE()",
@@ -103,22 +102,22 @@
/* I_STMT_BTYPES */
/* I_STMT_SCHEMAS */
- "SELECT IFNULL(catalog_name, schema_name) AS catalog_name, schema_name, NULL, CASE schema_name WHEN 'information_schema' OR 'mysql' THEN TRUE ELSE FALSE END AS schema_internal FROM INFORMATION_SCHEMA.schemata WHERE schema_name = ##cat::string",
+ "SELECT IFNULL(catalog_name, schema_name) AS catalog_name, schema_name, NULL, CASE WHEN schema_name = 'information_schema' OR schema_name = 'mysql' THEN TRUE ELSE FALSE END AS schema_internal FROM INFORMATION_SCHEMA.schemata WHERE schema_name = ##cat::string",
/* I_STMT_SCHEMAS_ALL */
- "SELECT IFNULL(catalog_name, schema_name) AS catalog_name, schema_name, NULL, CASE schema_name WHEN 'information_schema' OR 'mysql' THEN TRUE ELSE FALSE END AS schema_internal FROM INFORMATION_SCHEMA.schemata",
+ "SELECT IFNULL(catalog_name, schema_name) AS catalog_name, schema_name, NULL, CASE WHEN schema_name = 'information_schema' OR schema_name = 'mysql' THEN TRUE ELSE FALSE END AS schema_internal FROM INFORMATION_SCHEMA.schemata",
/* I_STMT_SCHEMA_NAMED */
- "SELECT IFNULL(catalog_name, schema_name) AS catalog_name, schema_name, NULL, CASE schema_name WHEN 'information_schema' OR 'mysql' THEN TRUE ELSE FALSE END AS schema_internal FROM INFORMATION_SCHEMA.schemata WHERE schema_name = ##name::string",
+ "SELECT IFNULL(catalog_name, schema_name) AS catalog_name, schema_name, NULL, CASE WHEN schema_name = 'information_schema' OR schema_name = 'mysql' THEN TRUE ELSE FALSE END AS schema_internal FROM INFORMATION_SCHEMA.schemata WHERE schema_name = ##name::string",
/* I_STMT_TABLES */
"SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, table_type, CASE table_type WHEN 'BASE TABLE' THEN TRUE ELSE FALSE END AS table_type, table_comment, table_name, CONCAT(table_schema, '.', table_name) AS table_full_name, NULL AS table_owner FROM INFORMATION_SCHEMA.tables WHERE table_catalog = ##cat::string AND schema_name = ##schema::string",
/* I_STMT_TABLES_ALL */
- "SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, table_type, CASE table_type WHEN 'BASE TABLE' THEN TRUE ELSE FALSE END AS table_type, table_comment, table_name, CONCAT(table_schema, '.', table_name) AS table_full_name, NULL AS table_owner FROM INFORMATION_SCHEMA.tables",
+ "SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, table_type, CASE table_type WHEN 'BASE TABLE' THEN TRUE ELSE FALSE END AS table_type, table_comment, " SHORT_NAME("table_schema", "table_name", "CONCAT(table_schema, '.', table_name)") " AS short_name, CONCAT(table_schema, '.', table_name) AS table_full_name, NULL AS table_owner FROM INFORMATION_SCHEMA.tables",
/* I_STMT_TABLE_NAMED */
- "SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, table_type, CASE table_type WHEN 'BASE TABLE' THEN TRUE ELSE FALSE END AS table_type, table_comment, table_name, CONCAT(table_schema, '.', table_name) AS table_full_name, NULL AS table_owner FROM FROM INFORMATION_SCHEMA.tables WHERE table_catalog = ##cat::string AND schema_name = ##schema::string",
+ "SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, table_type, CASE table_type WHEN 'BASE TABLE' THEN TRUE ELSE FALSE END AS table_type, table_comment, " SHORT_NAME("table_schema", "table_name", "CONCAT(table_schema, '.', table_name)") " as short_name, CONCAT(table_schema, '.', table_name) AS table_full_name, NULL AS table_owner FROM FROM INFORMATION_SCHEMA.tables WHERE table_catalog = ##cat::string AND schema_name = ##schema::string",
/* I_STMT_VIEWS */
"SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, view_definition, check_option, is_updatable FROM INFORMATION_SCHEMA.views ",
@@ -144,13 +143,11 @@
/* I_STMT_TABLES_CONSTRAINTS_NAMED */
"SELECT IFNULL(constraint_catalog, constraint_schema) AS constraint_catalog, constraint_schema, constraint_name, IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, constraint_type, NULL, FALSE, FALSE FROM INFORMATION_SCHEMA.table_constraints WHERE constraint_catalog = ##cat::string AND constraint_schema = ##schema::string AND table_name = ##name::string AND constraint_name = ##name2::string",
-#if MYSQL_VERSION_ID >= 50110
/* I_STMT_REF_CONSTRAINTS */
- "SELECT IFNULL(t.constraint_catalog, t.constraint_schema) AS t.constraint_catalog, t.constraint_schema, r.constraint_name, IFNULL(r.constraint_catalog, r.constraint_schema) AS r.constraint_catalog, r.constraint_schema, r.match_option, r.update_rule, delete_rule FROM INFORMATION_SCHEMA.referential_constraint r INNER JOIN INFORMATION_SCHEMA.table_constraints t ON r.constraint_schema=t.constraint_schema AND r.constraint_name=t.constraint_name AND r.table_name=t.table_name WHERE r.constraint_catalog = ##cat::string AND r.constraint_schema = ##schema::string AND r.table_name = ##name AND r.constraint_name = ##name2::string",
+ "SELECT IFNULL(t.constraint_catalog, t.constraint_schema) AS constraint_catalog, t.constraint_schema, r.constraint_name, IFNULL(r.constraint_catalog, r.constraint_schema) AS constraint_catalog, r.constraint_schema, r.match_option, r.update_rule, delete_rule FROM INFORMATION_SCHEMA.referential_constraints r INNER JOIN INFORMATION_SCHEMA.table_constraints t ON r.constraint_schema=t.constraint_schema AND r.constraint_name=t.constraint_name AND r.table_name=t.table_name WHERE r.constraint_catalog = ##cat::string AND r.constraint_schema = ##schema::string AND r.table_name = ##name AND r.constraint_name = ##name2::string",
/* I_STMT_REF_CONSTRAINTS_ALL */
- "SELECT IFNULL(t.constraint_catalog, t.constraint_schema) AS t.constraint_catalog, t.constraint_schema, r.constraint_name, IFNULL(r.constraint_catalog, r.constraint_schema) AS r.constraint_catalog, r.constraint_schema, r.match_option, r.update_rule, delete_rule FROM INFORMATION_SCHEMA.referential_constraint r INNER JOIN INFORMATION_SCHEMA.table_constraints t ON r.constraint_schema=t.constraint_schema AND r.constraint_name=t.constraint_name AND r.table_name=t.table_name",
-#endif
+ "SELECT IFNULL(t.constraint_catalog, t.constraint_schema) AS constraint_catalog, t.constraint_schema, r.constraint_name, IFNULL(r.constraint_catalog, r.constraint_schema) AS constraint_catalog, r.constraint_schema, r.match_option, r.update_rule, delete_rule FROM INFORMATION_SCHEMA.referential_constraints r INNER JOIN INFORMATION_SCHEMA.table_constraints t ON r.constraint_schema=t.constraint_schema AND r.constraint_name=t.constraint_name AND r.table_name=t.table_name",
/* I_STMT_KEY_COLUMN_USAGE */
"SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, constraint_name, column_name, ordinal_position FROM INFORMATION_SCHEMA.key_column_usage WHERE table_catalog = ##cat::string AND table_schema = ##schema::string AND table_name = ##name::string AND constraint_name = ##name2::string",
@@ -1231,23 +1228,28 @@
GdaMetaContext *context,
GError **error)
{
- // TO_IMPLEMENT;
+ MysqlConnectionData *cdata;
-#if MYSQL_VERSION_ID >= 50110
- GdaDataModel *model;
- gboolean retval;
- model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_REF_CONSTRAINTS_ALL], NULL, error);
- if (model == NULL)
- retval = FALSE;
+ cdata = (MysqlConnectionData*) gda_connection_internal_get_provider_data (cnc);
+ g_return_val_if_fail (cdata, FALSE);
+
+ if (cdata->version_long >= 50110) {
+ GdaDataModel *model;
+ gboolean retval;
+ model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_REF_CONSTRAINTS_ALL], NULL, error);
+ if (model == NULL)
+ retval = FALSE;
+ else {
+ retval = gda_meta_store_modify_with_context (store, context, model, error);
+ g_object_unref (G_OBJECT(model));
+ }
+
+ return retval;
+ }
else {
- retval = gda_meta_store_modify_with_context (store, context, model, error);
- g_object_unref (G_OBJECT(model));
+ TO_IMPLEMENT;
+ return TRUE;
}
-
- return retval;
-#else
- return TRUE;
-#endif
}
gboolean
@@ -1261,37 +1263,42 @@
const GValue *table_name,
const GValue *constraint_name)
{
- // TO_IMPLEMENT;
+ MysqlConnectionData *cdata;
-#if MYSQL_VERSION_ID >= 50110
- GdaDataModel *model;
- gboolean retval;
+ cdata = (MysqlConnectionData*) gda_connection_internal_get_provider_data (cnc);
+ g_return_val_if_fail (cdata, FALSE);
- /* Use a prepared statement for the "base" model. */
- if (! gda_holder_set_value (gda_set_get_holder (i_set, "cat"), table_catalog, error))
- return FALSE;
- if (! gda_holder_set_value (gda_set_get_holder (i_set, "schema"), table_schema, error))
- return FALSE;
- if (! gda_holder_set_value (gda_set_get_holder (i_set, "name"), table_name, error))
- return FALSE;
- if (! gda_holder_set_value (gda_set_get_holder (i_set, "name2"), constraint_name, error))
- return FALSE;
- model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_REF_CONSTRAINTS], i_set, error);
- if (model == NULL)
- retval = FALSE;
+ if (cdata->version_long >= 50110) {
+ GdaDataModel *model;
+ gboolean retval;
+
+ /* Use a prepared statement for the "base" model. */
+ if (! gda_holder_set_value (gda_set_get_holder (i_set, "cat"), table_catalog, error))
+ return FALSE;
+ if (! gda_holder_set_value (gda_set_get_holder (i_set, "schema"), table_schema, error))
+ return FALSE;
+ if (! gda_holder_set_value (gda_set_get_holder (i_set, "name"), table_name, error))
+ return FALSE;
+ if (! gda_holder_set_value (gda_set_get_holder (i_set, "name2"), constraint_name, error))
+ return FALSE;
+ model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_REF_CONSTRAINTS], i_set, error);
+ if (model == NULL)
+ retval = FALSE;
+ else {
+ retval = gda_meta_store_modify (store, context->table_name, model,
+ "table_schema=##schema::string AND table_name=##name::string AND constraint_name=##name2::string",
+ error,
+ "schema", table_schema, "name", table_name, "name2", constraint_name, NULL);
+ g_object_unref (G_OBJECT(model));
+
+ }
+
+ return retval;
+ }
else {
- retval = gda_meta_store_modify (store, context->table_name, model,
- "table_schema=##schema::string AND table_name=##name::string AND constraint_name=##name2::string",
- error,
- "schema", table_schema, "name", table_name, "name2", constraint_name, NULL);
- g_object_unref (G_OBJECT(model));
-
+ TO_IMPLEMENT;
+ return TRUE;
}
-
- return retval;
-#else
- return TRUE;
-#endif
}
gboolean
Modified: trunk/providers/mysql/gda-mysql-provider.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-provider.c (original)
+++ trunk/providers/mysql/gda-mysql-provider.c Mon Feb 23 19:40:20 2009
@@ -1356,9 +1356,12 @@
char **param_values = g_new0 (char *, nb_params + 1);
int *param_lengths = g_new0 (int, nb_params + 1);
int *param_formats = g_new0 (int, nb_params + 1);
- //g_print ("NB=%d, SQL=%s\n", nb_params, _GDA_PSTMT(ps)->sql);
+ /*g_print ("NB=%d, SQL=%s\n", nb_params, _GDA_PSTMT(ps)->sql);*/
- MYSQL_BIND *mysql_bind_param = g_new0 (MYSQL_BIND, nb_params);
+ MYSQL_BIND *mysql_bind_param = NULL;
+
+ if (nb_params > 0)
+ mysql_bind_param = g_new0 (MYSQL_BIND, nb_params);
for (i = 0, list = _GDA_PSTMT (ps)->param_ids; list; list = list->next, i++) {
const gchar *pname = (gchar *) list->data;
@@ -1453,7 +1456,7 @@
}
}
- if (mysql_stmt_bind_param (cdata->mysql_stmt, mysql_bind_param)) {
+ if (mysql_bind_param && mysql_stmt_bind_param (cdata->mysql_stmt, mysql_bind_param)) {
g_warning ("mysql_stmt_bind_param failed: %s\n", mysql_stmt_error (cdata->mysql_stmt));
}
@@ -1558,7 +1561,7 @@
GdaConnectionEvent *event;
gchar *str;
event = gda_connection_event_new (GDA_CONNECTION_EVENT_NOTICE);
- str = g_strdup_printf ("%lu", affected_rows);
+ str = g_strdup_printf ("%llu", affected_rows);
gda_connection_event_set_description (event, str);
g_free (str);
Modified: trunk/providers/mysql/gda-mysql-recordset.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-recordset.c (original)
+++ trunk/providers/mysql/gda-mysql-recordset.c Mon Feb 23 19:40:20 2009
@@ -418,8 +418,8 @@
g_warning (_("Invalid column bind data type. %d\n"),
mysql_bind_result[i].buffer_type);
}
- /* g_print ("%s(): NAME=%s, TYPE=%d, GTYPE=%s\n",
- __FUNCTION__, field->name, field->type, g_type_name (gtype)); */
+ /*g_print ("%s(): NAME=%s, TYPE=%d, GTYPE=%s\n",
+ __FUNCTION__, field->name, field->type, g_type_name (gtype));*/
}
if (mysql_stmt_bind_result (cdata->mysql_stmt, mysql_bind_result)) {
@@ -504,7 +504,7 @@
GType type = ((GdaDataSelect *) imodel)->prep_stmt->types[i];
gda_value_reset_with_type (value, type);
- //g_print ("%s: #%d : TYPE=%d, GTYPE=%s\n", __func__, i, mysql_bind_result[i].buffer_type, g_type_name (type));
+ /*g_print ("%s: #%d : TYPE=%d, GTYPE=%s\n", __func__, i, mysql_bind_result[i].buffer_type, g_type_name (type));*/
int intvalue = 0;
@@ -530,14 +530,22 @@
g_value_set_long (value, (long) intvalue);
else if (type == G_TYPE_BOOLEAN)
g_value_set_boolean (value, intvalue ? TRUE : FALSE);
- else {
+ else
g_warning (_("Type %s not mapped for value %d"),
g_type_name (type), intvalue);
- }
break;
case MYSQL_TYPE_LONGLONG:
g_memmove (&longlongvalue, mysql_bind_result[i].buffer, sizeof(long long));
g_memmove (&is_null, mysql_bind_result[i].is_null, sizeof(my_bool));
+ if (type == G_TYPE_BOOLEAN)
+ g_value_set_boolean (value, longlongvalue ? TRUE : FALSE);
+ else if (type == G_TYPE_INT)
+ g_value_set_int (value, longlongvalue);
+ else if (type == G_TYPE_LONG)
+ g_value_set_long (value, longlongvalue);
+ else
+ g_warning (_("Type %s not mapped for value %lld"),
+ g_type_name (type), longlongvalue);
break;
case MYSQL_TYPE_NULL:
if (G_IS_VALUE(value))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]