libgda r3245 - in trunk: . libgda libgda/sql-parser libgda/sqlite providers/firebird providers/mysql providers/postgres providers/skel-implementation/capi
- From: vivien svn gnome org
- To: svn-commits-list gnome org
- Subject: libgda r3245 - in trunk: . libgda libgda/sql-parser libgda/sqlite providers/firebird providers/mysql providers/postgres providers/skel-implementation/capi
- Date: Sat, 25 Oct 2008 18:48:34 +0000 (UTC)
Author: vivien
Date: Sat Oct 25 18:48:34 2008
New Revision: 3245
URL: http://svn.gnome.org/viewvc/libgda?rev=3245&view=rev
Log:
2008-10-25 Vivien Malerba <malerba gnome-db org>
* libgda/gda-column.c:
* libgda/sql-parser/gda-statement-struct-insert.c:
* libgda/sqlite/gda-sqlite-provider.c:
* providers/firebird/gda-firebird-provider.c:
* providers/mysql/gda-mysql-provider.c:
* providers/postgres/gda-postgres-provider.c:
* providers/skel-implementation/capi/gda-capi-provider.c: memory leaks corretions,
for bug #546339
* libgda/gda-holder.c: improved error messages (Carlos Savoretti)
* providers/mysql/gda-mysql-meta.c:
* providers/mysql/gda-mysql-provider.c:
* providers/mysql/gda-mysql-recordset.c:
* providers/mysql/gda-mysql-util.c: improvements to the MySQL provider (Carlos Savoretti)
Modified:
trunk/ChangeLog
trunk/libgda/gda-column.c
trunk/libgda/gda-holder.c
trunk/libgda/sql-parser/gda-statement-struct-insert.c
trunk/libgda/sqlite/gda-sqlite-provider.c
trunk/providers/firebird/gda-firebird-provider.c
trunk/providers/mysql/gda-mysql-meta.c
trunk/providers/mysql/gda-mysql-provider.c
trunk/providers/mysql/gda-mysql-recordset.c
trunk/providers/mysql/gda-mysql-util.c
trunk/providers/postgres/gda-postgres-provider.c
trunk/providers/skel-implementation/capi/gda-capi-provider.c
Modified: trunk/libgda/gda-column.c
==============================================================================
--- trunk/libgda/gda-column.c (original)
+++ trunk/libgda/gda-column.c Sat Oct 25 18:48:34 2008
@@ -151,6 +151,7 @@
gda_value_free (column->priv->default_value);
g_free (column->priv->id);
+ g_free (column->priv->dbms_type);
g_free (column->priv);
column->priv = NULL;
Modified: trunk/libgda/gda-holder.c
==============================================================================
--- trunk/libgda/gda-holder.c (original)
+++ trunk/libgda/gda-holder.c Sat Oct 25 18:48:34 2008
@@ -895,13 +895,15 @@
newvalid = TRUE;
if (newnull && holder->priv->not_null) {
g_set_error (error, GDA_HOLDER_ERROR, GDA_HOLDER_VALUE_NULL_ERROR,
- _("Holder does not allow NULL values"));
+ _("(%s): Holder does not allow NULL values"),
+ holder->priv->id);
newvalid = FALSE;
changed = TRUE;
}
else if (!newnull && (G_VALUE_TYPE (value) != holder->priv->g_type)) {
g_set_error (error, GDA_HOLDER_ERROR, GDA_HOLDER_VALUE_TYPE_ERROR,
- _("Wrong value type: expected type '%s' when value's type is '%s'"),
+ _("(%s): Wrong Holder value type, expected type '%s' when value's type is '%s'"),
+ holder->priv->id,
gda_g_type_to_string (holder->priv->g_type),
gda_g_type_to_string (G_VALUE_TYPE (value)));
newvalid = FALSE;
@@ -1020,13 +1022,15 @@
newvalid = TRUE;
if (newnull && holder->priv->not_null) {
g_set_error (error, GDA_HOLDER_ERROR, GDA_HOLDER_VALUE_NULL_ERROR,
- _("Holder does not allow NULL values"));
+ _("(%s): Holder does not allow NULL values"),
+ holder->priv->id);
newvalid = FALSE;
changed = TRUE;
}
else if (!newnull && (G_VALUE_TYPE (value) != holder->priv->g_type)) {
g_set_error (error, GDA_HOLDER_ERROR, GDA_HOLDER_VALUE_TYPE_ERROR,
- _("Wrong value type: expected type '%s' when value's type is '%s'"),
+ _("(%s): Wrong value type: expected type '%s' when value's type is '%s'"),
+ holder->priv->id,
gda_g_type_to_string (holder->priv->g_type),
gda_g_type_to_string (G_VALUE_TYPE (value)));
newvalid = FALSE;
Modified: trunk/libgda/sql-parser/gda-statement-struct-insert.c
==============================================================================
--- trunk/libgda/sql-parser/gda-statement-struct-insert.c (original)
+++ trunk/libgda/sql-parser/gda-statement-struct-insert.c Sat Oct 25 18:48:34 2008
@@ -72,6 +72,8 @@
g_slist_free ((GSList *) list->data);
}
}
+ g_slist_free (insert->values_list);
+
g_slist_foreach (insert->fields_list, (GFunc) gda_sql_field_free, NULL);
g_slist_free (insert->fields_list);
if (insert->select) {
@@ -258,7 +260,7 @@
for (l = list; l; l = l->next)
gda_sql_any_part_set_parent (l->data, insert);
- insert->values_list = g_slist_prepend (NULL, list);
+ insert->values_list = g_slist_prepend (insert->values_list, list);
}
/*
Modified: trunk/libgda/sqlite/gda-sqlite-provider.c
==============================================================================
--- trunk/libgda/sqlite/gda-sqlite-provider.c (original)
+++ trunk/libgda/sqlite/gda-sqlite-provider.c Sat Oct 25 18:48:34 2008
@@ -1587,6 +1587,7 @@
return FALSE;
else {
gda_connection_add_prepared_statement (cnc, stmt, (GdaPStmt *) ps);
+ g_object_unref (ps);
return TRUE;
}
}
@@ -1688,9 +1689,7 @@
GdaSqlSelectTarget *target;
GdaSqlStatement *sql_statement = gda_sql_statement_new (GDA_SQL_STATEMENT_SELECT);
- select = g_new0 (GdaSqlStatementSelect, 1);
- GDA_SQL_ANY_PART (select)->type = GDA_SQL_ANY_STMT_SELECT;
- sql_statement->contents = select;
+ select = (GdaSqlStatementSelect*) sql_statement->contents;
/* FROM */
select->from = gda_sql_select_from_new (GDA_SQL_ANY_PART (select));
Modified: trunk/providers/firebird/gda-firebird-provider.c
==============================================================================
--- trunk/providers/firebird/gda-firebird-provider.c (original)
+++ trunk/providers/firebird/gda-firebird-provider.c Sat Oct 25 18:48:34 2008
@@ -1007,6 +1007,7 @@
return FALSE;
else {
gda_connection_add_prepared_statement (cnc, stmt, ps);
+ g_object_unref (ps);
return TRUE;
}
}
Modified: trunk/providers/mysql/gda-mysql-meta.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-meta.c (original)
+++ trunk/providers/mysql/gda-mysql-meta.c Sat Oct 25 18:48:34 2008
@@ -73,14 +73,23 @@
/* I_STMT_DOMAINS_ALL, */
/* I_STMT_DOMAINS_CONSTRAINTS, */
/* I_STMT_DOMAINS_CONSTRAINTS_ALL, */
+ I_STMT_CHARACTER_SETS,
+ I_STMT_CHARACTER_SETS_ALL,
I_STMT_VIEWS_COLUMNS,
I_STMT_VIEWS_COLUMNS_ALL,
I_STMT_TRIGGERS,
- I_STMT_TRIGGERS_ALL/* , */
+ I_STMT_TRIGGERS_ALL,
/* I_STMT_EL_TYPES_COL, */
/* I_STMT_EL_TYPES_DOM, */
/* I_STMT_EL_TYPES_UDT, */
- /* I_STMT_EL_TYPES_ALL */
+ /* I_STMT_EL_TYPES_ALL, */
+ I_STMT_ROUTINES_ALL,
+ I_STMT_ROUTINES,
+ I_STMT_ROUTINES_ONE,
+ I_STMT_ROUTINES_PAR_ALL,
+ I_STMT_ROUTINES_PAR/* , */
+ /* I_STMT_ROUTINES_COL_ALL, */
+ /* I_STMT_ROUTINES_COL */
} InternalStatementItem;
@@ -94,60 +103,66 @@
/* I_STMT_BTYPES */
/* I_STMT_SCHEMAS */
- "SELECT IFNULL(catalog_name, schema_name), schema_name, NULL, CASE schema_name WHEN 'information_schema' THEN 1 ELSE 0 END FROM information_schema.schemata WHERE schema_name = ##cat::string",
+ "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",
/* I_STMT_SCHEMAS_ALL */
- "SELECT IFNULL(catalog_name, schema_name), schema_name, NULL, CASE schema_name WHEN 'information_schema' THEN 1 ELSE 0 END FROM information_schema.schemata",
+ "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",
/* I_STMT_SCHEMA_NAMED */
- "SELECT IFNULL(catalog_name, schema_name), schema_name, NULL, CASE schema_name WHEN 'information_schema' THEN 1 ELSE 0 END FROM information_schema.schemata WHERE schema_name = ##name::string",
+ "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",
/* I_STMT_TABLES */
- "SELECT IFNULL(table_catalog, table_schema), table_schema, table_name, table_type, CASE table_type WHEN 'BASE TABLE' THEN 1 ELSE 0 END, table_comment, table_name, CONCAT(table_schema, '.', table_name), NULL 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, 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), table_schema, table_name, table_type, CASE table_type WHEN 'BASE TABLE' THEN 1 ELSE 0 END, table_comment, table_name, CONCAT(table_schema, '.', table_name), NULL 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, table_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), table_schema, table_name, table_type, CASE table_type WHEN 'BASE TABLE' THEN 1 ELSE 0 END, table_comment, table_name, CONCAT(table_schema, '.', table_name), NULL 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, 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",
/* I_STMT_VIEWS */
- "SELECT IFNULL(table_catalog, table_schema), table_schema, table_name, view_definition, check_option, is_updatable FROM information_schema.views ",
+ "SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, view_definition, check_option, is_updatable FROM INFORMATION_SCHEMA.views ",
/* I_STMT_VIEWS_ALL */
- "SELECT IFNULL(table_catalog, table_schema), table_schema, table_name, view_definition, check_option, is_updatable FROM information_schema.views ",
+ "SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, view_definition, check_option, is_updatable FROM INFORMATION_SCHEMA.views ",
/* I_STMT_VIEW_NAMED */
- "SELECT IFNULL(table_catalog, table_schema), table_schema, table_name, view_definition, check_option, is_updatable FROM information_schema.views WHERE table_catalog = ##cat::string AND schema_name = ##schema::string",
+ "SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, view_definition, check_option, is_updatable FROM INFORMATION_SCHEMA.views WHERE table_catalog = ##cat::string AND schema_name = ##schema::string",
/* I_STMT_COLUMNS_OF_TABLE */
- "SELECT IFNULL(table_catalog, table_schema), table_schema, table_name, column_name, ordinal_position, column_default, is_nullable, data_type, 'gchararray', character_maximum_length,character_octet_length, numeric_precision, numeric_scale, 0, character_set_name, character_set_name, character_set_name, collation_name, collation_name, collation_name, '', 1, column_comment FROM information_schema.columns WHERE table_catalog = ##cat::string AND table_schema = ##schema::string AND table_name = ##name::string",
+ "SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, column_name, ordinal_position, column_default, is_nullable, data_type, 'gchararray', character_maximum_length,character_octet_length, numeric_precision, numeric_scale, 0, character_set_name, character_set_name, character_set_name, collation_name, collation_name, collation_name, extra, 1, column_comment FROM INFORMATION_SCHEMA.columns WHERE table_catalog = ##cat::string AND table_schema = ##schema::string AND table_name = ##name::string",
/* I_STMT_COLUMNS_ALL */
- "SELECT IFNULL(table_catalog, table_schema), table_schema, table_name, column_name, ordinal_position, column_default, is_nullable, data_type, 'gchararray', character_maximum_length,character_octet_length, numeric_precision, numeric_scale, 0, character_set_name, character_set_name, character_set_name, collation_name, collation_name, collation_name, '', 1, column_comment FROM information_schema.columns",
+ "SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, column_name, ordinal_position, column_default, CASE is_nullable WHEN 'YES' THEN TRUE ELSE FALSE END AS is_nullable, data_type, 'gchararray', '', character_maximum_length, character_octet_length, numeric_precision, numeric_scale, 0, character_set_name, character_set_name, character_set_name, collation_name, collation_name, collation_name, extra, IF(FIND_IN_SET('insert', privileges) != 0 OR FIND_IN_SET('update', privileges) != 0, TRUE, FALSE) AS is_updatable, column_comment FROM INFORMATION_SCHEMA.columns",
/* I_STMT_TABLES_CONSTRAINTS */
- "SELECT IFNULL(constraint_catalog, constraint_schema), constraint_schema, constraint_name, IFNULL(table_catalog, table_schema), table_schema, table_name, constraint_type, NULL, 0, 0 FROM information_schema.table_constraints WHERE constraint_catalog = ##cat::string AND constraint_schema = ##schema::string AND table_name = ##name::string",
+ "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",
/* I_STMT_TABLES_CONSTRAINTS_ALL */
- "SELECT IFNULL(constraint_catalog, constraint_schema), constraint_schema, constraint_name, IFNULL(constraint_catalog, constraint_schema), table_schema, table_name, constraint_type, NULL, 0, 0 FROM information_schema.table_constraints",
+ "SELECT IFNULL(constraint_catalog, constraint_schema) AS constraint_catalog, constraint_schema, constraint_name, IFNULL(constraint_catalog, constraint_schema) AS onstraint_catalog, table_schema, table_name, constraint_type, NULL, FALSE, FALSE FROM INFORMATION_SCHEMA.table_constraints",
/* I_STMT_TABLES_CONSTRAINTS_NAMED */
- "SELECT IFNULL(constraint_catalog, constraint_schema), constraint_schema, constraint_name, IFNULL(table_catalog, table_schema), table_schema, table_name, constraint_type, NULL, 0, 0 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",
+ "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), t.constraint_schema, r.constraint_name, IFNULL(r.constraint_catalog, r.constraint_schema), 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 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",
/* I_STMT_REF_CONSTRAINTS_ALL */
- "SELECT IFNULL(t.constraint_catalog, t.constraint_schema), t.constraint_schema, r.constraint_name, IFNULL(r.constraint_catalog, r.constraint_schema), 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",
+ "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
/* I_STMT_KEY_COLUMN_USAGE */
- "SELECT IFNULL(table_catalog, table_schema), table_schema, table_name, constraint_name, column_name 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",
+ "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",
/* I_STMT_KEY_COLUMN_USAGE_ALL */
- "SELECT IFNULL(table_catalog, table_schema), table_schema, table_name, constraint_name, column_name, ordinal_position FROM information_schema.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",
+
+ /* I_STMT_CHARACTER_SETS */
+ "SELECT DATABASE() AS character_set_catalog, DATABASE() AS character_set_schema, character_set_name, default_collate_name, default_collate_name, default_collate_name, description, character_set_name, character_set_name FROM INFORMATION_SCHEMA.character_sets WHERE character_set_catalog = ##cat::string AND character_set_schema = ##schema::string AND character_set_name = ##name::string",
+
+ /* I_STMT_CHARACTER_SETS_ALL */
+ "SELECT DATABASE() AS character_set_catalog, DATABASE() AS character_set_schema, character_set_name, default_collate_name, default_collate_name, default_collate_name, description, character_set_name, character_set_name FROM INFORMATION_SCHEMA.character_sets",
/* I_STMT_UDT */
@@ -166,16 +181,16 @@
/* I_STMT_DOMAINS_CONSTRAINTS_ALL */
/* I_STMT_VIEWS_COLUMNS */
- "SELECT IFNULL(v.table_catalog, v.table_schema), v.table_schema, v.table_name, IFNULL(c.table_catalog, c.table_schema), c.table_schema, c.table_name, c.column_name FROM information_schema.columns c INNER JOIN information_schema.views v ON c.table_schema=v.table_schema AND c.table_name=v.table_name WHERE v.table_catalog = ##cat::string AND v.table_schema = ##schema::string AND v.table_name = ##name::string",
+ "SELECT IFNULL(v.table_catalog, v.table_schema) AS table_catalog, v.table_schema, v.table_name, IFNULL(c.table_catalog, c.table_schema) AS table_catalog, c.table_schema, c.table_name, c.column_name FROM INFORMATION_SCHEMA.columns c INNER JOIN INFORMATION_SCHEMA.views v ON c.table_schema=v.table_schema AND c.table_name=v.table_name WHERE v.table_catalog = ##cat::string AND v.table_schema = ##schema::string AND v.table_name = ##name::string",
/* I_STMT_VIEWS_COLUMNS_ALL */
- "SELECT IFNULL(v.table_catalog, v.table_schema), v.table_schema, v.table_name, IFNULL(c.table_catalog, c.table_schema), c.table_schema, c.table_name, c.column_name FROM information_schema.columns c INNER JOIN information_schema.views v ON c.table_schema=v.table_schema AND c.table_name=v.table_name",
+ "SELECT IFNULL(v.table_catalog, v.table_schema) AS table_catalog, v.table_schema, v.table_name, IFNULL(c.table_catalog, c.table_schema) AS table_catalog, c.table_schema, c.table_name, c.column_name FROM INFORMATION_SCHEMA.columns c INNER JOIN INFORMATION_SCHEMA.views v ON c.table_schema=v.table_schema AND c.table_name=v.table_name",
/* I_STMT_TRIGGERS */
- "SELECT IFNULL(trigger_catalog, trigger_schema), trigger_schema, trigger_name, event_manipulation, IFNULL(event_object_catalog, event_object_schema), event_object_schema, event_object_table, action_statement, action_orientation, action_timing, NULL, trigger_name, trigger_name FROM information_schema.triggers WHERE trigger_catalog = ##cat::string AND trigger_schema = ##schema::string AND trigger_name = ##name::string",
+ "SELECT IFNULL(trigger_catalog, trigger_schema) AS trigger_catalog, trigger_schema, trigger_name, event_manipulation, IFNULL(event_object_catalog, event_object_schema) AS event_object_catalog, event_object_schema, event_object_table, action_statement, action_orientation, action_timing, NULL, trigger_name, trigger_name FROM INFORMATION_SCHEMA.triggers WHERE trigger_catalog = ##cat::string AND trigger_schema = ##schema::string AND trigger_name = ##name::string",
/* I_STMT_TRIGGERS_ALL */
- "SELECT IFNULL(trigger_catalog, trigger_schema), trigger_schema, trigger_name, event_manipulation, IFNULL(event_object_catalog, event_object_schema), event_object_schema, event_object_table, action_statement, action_orientation, action_timing, NULL, trigger_name, trigger_name FROM information_schema.triggers",
+ "SELECT IFNULL(trigger_catalog, trigger_schema) AS trigger_catalog, trigger_schema, trigger_name, event_manipulation, IFNULL(event_object_catalog, event_object_schema) AS event_object_catalog, event_object_schema, event_object_table, action_statement, action_orientation, action_timing, NULL, trigger_name, trigger_name FROM INFORMATION_SCHEMA.triggers",
/* I_STMT_EL_TYPES_COL */
@@ -185,6 +200,25 @@
/* I_STMT_EL_TYPES_ALL */
+ /* I_STMT_ROUTINES_ALL */
+ "SELECT IFNULL(routine_catalog, routine_schema) AS specific_catalog, routine_schema AS specific_schema, routine_name AS specific_name, IFNULL(routine_catalog, routine_schema) AS routine_catalog, routine_schema, routine_name, routine_type, dtd_identifier AS return_type, FALSE AS returns_set, 0 AS nb_args, routine_body, routine_definition, external_name, external_language, parameter_style, CASE is_deterministic WHEN 'YES' THEN TRUE ELSE FALSE END AS is_deterministic, sql_data_access, FALSE AS is_null_call, routine_comment, routine_name, routine_name, definer FROM INFORMATION_SCHEMA.routines",
+
+ /* I_STMT_ROUTINES */
+ "SELECT IFNULL(routine_catalog, routine_schema) AS specific_catalog, routine_schema AS specific_schema, routine_name AS specific_name, IFNULL(routine_catalog, routine_schema) AS routine_catalog, routine_schema, routine_name, routine_type, dtd_identifier AS return_type, FALSE AS returns_set, 0 AS nb_args, routine_body, routine_definition, external_name, external_language, parameter_style, CASE is_deterministic WHEN 'YES' THEN TRUE ELSE FALSE END AS is_deterministic, sql_data_access, FALSE AS is_null_call, routine_comment, routine_name, routine_name, definer FROM INFORMATION_SCHEMA.routines WHERE routine_catalog = ##cat::string AND routine_schema = ##schema::string",
+
+ /* I_STMT_ROUTINES_ONE */
+ "SELECT IFNULL(routine_catalog, routine_schema) AS specific_catalog, routine_schema AS specific_schema, routine_name AS specific_name, IFNULL(routine_catalog, routine_schema) AS routine_catalog, routine_schema, routine_name, routine_type, dtd_identifier AS return_type, FALSE AS returns_set, 0 AS nb_args, routine_body, routine_definition, external_name, external_language, parameter_style, CASE is_deterministic WHEN 'YES' THEN TRUE ELSE FALSE END AS is_deterministic, sql_data_access, FALSE AS is_null_call, routine_comment, routine_name, routine_name, definer FROM INFORMATION_SCHEMA.routines WHERE routine_catalog = ##cat::string AND routine_schema = ##schema::string AND routine_name = ##name::string",
+
+ /* I_STMT_ROUTINES_PAR_ALL */
+ "SELECT IFNULL(routine_catalog, routine_schema) AS specific_catalog, routine_schema AS specific_schema, routine_name AS specific_name, IFNULL(routine_catalog, routine_schema) AS routine_catalog, routine_schema, routine_name, routine_type, dtd_identifier AS return_type, FALSE AS returns_set, 0 AS nb_args, routine_body, routine_definition, external_name, external_language, parameter_style, CASE is_deterministic WHEN 'YES' THEN TRUE ELSE FALSE END AS is_deterministic, sql_data_access, FALSE AS is_null_call, routine_comment, routine_name, routine_name, definer FROM INFORMATION_SCHEMA.routines",
+
+ /* I_STMT_ROUTINES_PAR */
+ "SELECT IFNULL(routine_catalog, routine_schema) AS specific_catalog, routine_schema AS specific_schema, routine_name AS specific_name, IFNULL(routine_catalog, routine_schema) AS routine_catalog, routine_schema, routine_name, routine_type, dtd_identifier AS return_type, FALSE AS returns_set, 0 AS nb_args, routine_body, routine_definition, external_name, external_language, parameter_style, CASE is_deterministic WHEN 'YES' THEN TRUE ELSE FALSE END AS is_deterministic, sql_data_access, FALSE AS is_null_call, routine_comment, routine_name, routine_name, definer FROM INFORMATION_SCHEMA.routines WHERE routine_catalog = ##cat::string AND routine_schema = ##schema::string AND routine_name = ##name::string",
+
+ /* I_STMT_ROUTINES_COL_ALL */
+
+ /* I_STMT_ROUTINES_COL */
+
};
/*
@@ -217,9 +251,10 @@
}
/* initialize static values here */
- i_set = gda_set_new_inline (3, "cat", G_TYPE_STRING, "",
+ i_set = gda_set_new_inline (4, "cat", G_TYPE_STRING, "",
"name", G_TYPE_STRING, "",
- "schema", G_TYPE_STRING, "");
+ "schema", G_TYPE_STRING, "",
+ "name2", G_TYPE_STRING, "");
g_static_mutex_unlock (&init_mutex);
}
@@ -302,7 +337,7 @@
for (i = 0; i < sizeof(data_types) / sizeof(BuiltinDataType); ++i) {
BuiltinDataType *data_type = &(data_types[i]);
GList *values = NULL;
- GValue *tmp_value = { 0, };
+ GValue *tmp_value = NULL;
g_value_set_string (tmp_value = gda_value_new (G_TYPE_STRING), data_type->tname);
values = g_list_append (values, tmp_value);
@@ -399,7 +434,8 @@
GdaMetaContext *context,
GError **error)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
+ /* Feature not supported by MySQL. */
return TRUE;
}
@@ -413,7 +449,8 @@
const GValue *udt_schema,
const GValue *udt_name)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
+ /* Feature not supported by MySQL. */
return TRUE;
}
@@ -425,7 +462,8 @@
GdaMetaContext *context,
GError **error)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
+ /* Feature not supported by MySQL. */
return TRUE;
}
@@ -438,7 +476,8 @@
const GValue *domain_catalog,
const GValue *domain_schema)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
+ /* Feature not supported by MySQL. */
return TRUE;
}
@@ -449,7 +488,8 @@
GdaMetaContext *context,
GError **error)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
+ /* Feature not supported by MySQL. */
return TRUE;
}
@@ -463,7 +503,8 @@
const GValue *domain_schema,
const GValue *domain_name)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
+ /* Feature not supported by MySQL. */
return TRUE;
}
@@ -474,18 +515,33 @@
GdaMetaContext *context,
GError **error)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
+ /* Feature not supported by MySQL. */
return TRUE;
}
gboolean
+_gda_mysql_meta_el_types (GdaServerProvider *prov,
+ GdaConnection *cnc,
+ GdaMetaStore *store,
+ GdaMetaContext *context,
+ GError **error,
+ const GValue *specific_name)
+{
+ //TO_IMPLEMENT;
+ /* Feature not supported by MySQL. */
+ return TRUE;
+}
+
+gboolean
_gda_mysql_meta__collations (GdaServerProvider *prov,
GdaConnection *cnc,
GdaMetaStore *store,
GdaMetaContext *context,
GError **error)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
+ /* Feature not supported by MySQL. */
return TRUE;
}
@@ -510,8 +566,19 @@
GdaMetaContext *context,
GError **error)
{
- TO_IMPLEMENT;
- return TRUE;
+ //TO_IMPLEMENT;
+
+ GdaDataModel *model;
+ gboolean retval;
+ model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_CHARACTER_SETS_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;
}
gboolean
@@ -524,8 +591,27 @@
const GValue *chset_schema,
const GValue *chset_name_n)
{
- TO_IMPLEMENT;
- return TRUE;
+ //TO_IMPLEMENT;
+
+ GdaDataModel *model;
+ gboolean retval;
+
+ if (! gda_holder_set_value (gda_set_get_holder (i_set, "cat"), chset_catalog, error))
+ return FALSE;
+ if (! gda_holder_set_value (gda_set_get_holder (i_set, "schema"), chset_schema, error))
+ return FALSE;
+ if (! gda_holder_set_value (gda_set_get_holder (i_set, "name"), chset_name_n, error))
+ return FALSE;
+ model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_CHARACTER_SETS], i_set, 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;
}
gboolean
@@ -537,9 +623,14 @@
{
// TO_IMPLEMENT;
+ GType col_types[] = {
+ 0, 0, 0,
+ G_TYPE_BOOLEAN, G_TYPE_NONE
+ };
GdaDataModel *model;
gboolean retval;
- model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_SCHEMAS_ALL], i_set, error);
+ model = gda_connection_statement_execute_select_full (cnc, internal_stmt[I_STMT_SCHEMAS_ALL], NULL,
+ GDA_STATEMENT_MODEL_RANDOM_ACCESS, col_types, error);
if (model == NULL)
retval = FALSE;
else {
@@ -561,13 +652,18 @@
{
// TO_IMPLEMENT;
+ GType col_types[] = {
+ 0, 0, 0,
+ G_TYPE_BOOLEAN, G_TYPE_NONE
+ };
GdaDataModel *model;
gboolean retval;
if (! gda_holder_set_value (gda_set_get_holder (i_set, "cat"), catalog_name, error))
return FALSE;
if (!schema_name_n) {
- model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_SCHEMAS], i_set, error);
+ model = gda_connection_statement_execute_select_full (cnc, internal_stmt[I_STMT_SCHEMAS], i_set,
+ GDA_STATEMENT_MODEL_RANDOM_ACCESS, col_types, error);
if (model == NULL)
retval = FALSE;
else {
@@ -577,7 +673,8 @@
} else {
if (! gda_holder_set_value (gda_set_get_holder (i_set, "name"), schema_name_n, error))
return FALSE;
- model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_SCHEMA_NAMED], i_set, error);
+ model = gda_connection_statement_execute_select_full (cnc, internal_stmt[I_STMT_SCHEMA_NAMED], i_set,
+ GDA_STATEMENT_MODEL_RANDOM_ACCESS, col_types, error);
if (model == NULL)
retval = FALSE;
else {
@@ -601,6 +698,10 @@
{
// TO_IMPLEMENT;
+ GType col_types_tables[] = {
+ 0, 0, 0, 0,
+ G_TYPE_BOOLEAN, G_TYPE_NONE
+ };
GdaDataModel *model_tables, *model_views;
gboolean retval;
/* Check correct mysql server version. */
@@ -617,7 +718,8 @@
/* Copy contents, just because we need to modify @context->table_name */
GdaMetaContext copy = *context;
- model_tables = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_TABLES_ALL], i_set, error);
+ model_tables = gda_connection_statement_execute_select_full (cnc, internal_stmt[I_STMT_TABLES_ALL], NULL,
+ GDA_STATEMENT_MODEL_RANDOM_ACCESS, col_types_tables, error);
if (model_tables == NULL)
retval = FALSE;
else {
@@ -626,7 +728,7 @@
g_object_unref (G_OBJECT(model_tables));
}
- model_views = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_VIEWS_ALL], i_set, error);
+ model_views = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_VIEWS_ALL], NULL, error);
if (model_views == NULL)
retval = FALSE;
else {
@@ -715,7 +817,7 @@
}
/**
- * map_mysql_to_gda:
+ * map_mysql_type_to_gda:
* @value: a #GValue string.
*
* It maps a mysql type to a gda type. This means that when a
@@ -724,11 +826,12 @@
* Returns a newly created GValue string.
*/
static inline GValue *
-map_mysql_to_gda (const GValue *value)
+map_mysql_type_to_gda (const GValue *value)
{
const gchar *string = g_value_get_string (value);
GValue *newvalue;
const gchar *newstring;
+
if (strcmp (string, "bool") == 0)
newstring = "gboolean";
else
@@ -835,8 +938,7 @@
g_value_set_string (newvalue = gda_value_new (G_TYPE_STRING),
newstring);
-
-
+
return newvalue;
}
@@ -849,10 +951,13 @@
{
// TO_IMPLEMENT;
- /* GType col_types[] = { */
- /* G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, */
- /* G_TYPE_INT, G_TYPE_NONE */
- /* }; */
+ GType col_types[] = {
+ 0, 0, 0, 0, G_TYPE_INT, G_TYPE_STRING,
+ G_TYPE_BOOLEAN,
+ 0, 0, 0, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, 0, 0, 0, 0, 0, 0, 0,
+ G_TYPE_BOOLEAN,
+ G_TYPE_NONE
+ };
GdaDataModel *model, *proxy;
gboolean retval;
/* Check correct mysql server version. */
@@ -867,8 +972,8 @@
}
/* Use a prepared statement for the "base" model. */
- model = gda_connection_statement_execute_select_full (cnc, internal_stmt[I_STMT_COLUMNS_ALL], i_set,
- GDA_STATEMENT_MODEL_RANDOM_ACCESS, /* col_types */ NULL, error);
+ model = gda_connection_statement_execute_select_full (cnc, internal_stmt[I_STMT_COLUMNS_ALL], NULL,
+ GDA_STATEMENT_MODEL_RANDOM_ACCESS, col_types, error);
if (model == NULL)
retval = FALSE;
else {
@@ -883,20 +988,19 @@
break;
}
- GValue *newvalue = map_mysql_to_gda (value);
+ GValue *newvalue = map_mysql_type_to_gda (value);
- retval = gda_data_model_set_value_at (GDA_DATA_MODEL(proxy), 8, i, newvalue, error);
+ retval = gda_data_model_set_value_at (GDA_DATA_MODEL(proxy), 9, i, newvalue, error);
gda_value_free (newvalue);
if (! retval)
break;
-
}
if (retval)
- retval = gda_meta_store_modify_with_context (store, context, proxy, error);
+ retval = gda_meta_store_modify_with_context (store, context, proxy/* model */, error);
+
g_object_unref (G_OBJECT(proxy));
g_object_unref (G_OBJECT(model));
-
}
return retval;
@@ -914,10 +1018,13 @@
{
// TO_IMPLEMENT;
- /* GType col_types[] = { */
- /* G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, */
- /* G_TYPE_INT, G_TYPE_NONE */
- /* }; */
+ GType col_types[] = {
+ 0, 0, 0, 0, G_TYPE_INT, G_TYPE_STRING,
+ G_TYPE_BOOLEAN,
+ 0, 0, 0, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, 0, 0, 0, 0, 0, 0, 0,
+ G_TYPE_BOOLEAN,
+ G_TYPE_NONE
+ };
GdaDataModel *model, *proxy;
gboolean retval;
/* Check correct mysql server version. */
@@ -939,7 +1046,7 @@
if (! gda_holder_set_value (gda_set_get_holder (i_set, "name"), table_name, error))
return FALSE;
model = gda_connection_statement_execute_select_full (cnc, internal_stmt[I_STMT_COLUMNS_OF_TABLE], i_set,
- GDA_STATEMENT_MODEL_RANDOM_ACCESS, /* col_types */ NULL, error);
+ GDA_STATEMENT_MODEL_RANDOM_ACCESS, col_types, error);
if (model == NULL)
retval = FALSE;
else {
@@ -954,13 +1061,12 @@
break;
}
- GValue *newvalue = map_mysql_to_gda (value);
+ GValue *newvalue = map_mysql_type_to_gda (value);
- retval = gda_data_model_set_value_at (GDA_DATA_MODEL(proxy), 8, i, newvalue, error);
+ retval = gda_data_model_set_value_at (GDA_DATA_MODEL(proxy), 9, i, newvalue, error);
gda_value_free (newvalue);
if (! retval)
break;
-
}
if (retval)
@@ -970,7 +1076,6 @@
"schema", table_schema, "name", table_name, NULL);
g_object_unref (G_OBJECT(proxy));
g_object_unref (G_OBJECT(model));
-
}
return retval;
@@ -998,7 +1103,7 @@
return FALSE;
}
- model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_VIEWS_COLUMNS_ALL], i_set, error);
+ model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_VIEWS_COLUMNS_ALL], NULL, error);
if (model == NULL)
retval = FALSE;
else {
@@ -1050,9 +1155,14 @@
{
// TO_IMPLEMENT;
+ GType col_types[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_NONE
+ };
GdaDataModel *model;
gboolean retval;
- model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_TABLES_CONSTRAINTS_ALL], NULL, error);
+ model = gda_connection_statement_execute_select_full (cnc, internal_stmt[I_STMT_TABLES_CONSTRAINTS_ALL], NULL,
+ GDA_STATEMENT_MODEL_RANDOM_ACCESS, col_types, error);
if (model == NULL)
retval = FALSE;
else {
@@ -1193,9 +1303,14 @@
{
// TO_IMPLEMENT;
+ GType col_types[] = {
+ 0, 0, 0, 0, 0,
+ G_TYPE_INT, G_TYPE_NONE
+ };
GdaDataModel *model;
gboolean retval;
- model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_KEY_COLUMN_USAGE_ALL], NULL, error);
+ model = gda_connection_statement_execute_select_full (cnc, internal_stmt[I_STMT_KEY_COLUMN_USAGE_ALL], NULL,
+ GDA_STATEMENT_MODEL_RANDOM_ACCESS, col_types, error);
if (model == NULL)
retval = FALSE;
else {
@@ -1263,7 +1378,7 @@
GdaMetaContext *context,
GError **error)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
return TRUE;
}
@@ -1278,7 +1393,7 @@
const GValue *table_name,
const GValue *constraint_name)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
return TRUE;
}
@@ -1365,8 +1480,19 @@
GdaMetaContext *context,
GError **error)
{
- TO_IMPLEMENT;
- return TRUE;
+ //TO_IMPLEMENT;
+
+ GdaDataModel *model;
+ gboolean retval;
+ model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_ROUTINES_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;
}
gboolean
@@ -1379,8 +1505,41 @@
const GValue *routine_schema,
const GValue *routine_name_n)
{
- TO_IMPLEMENT;
- return TRUE;
+ //TO_IMPLEMENT;
+ //
+
+ GdaDataModel *model;
+ gboolean retval;
+ /* Check correct mysql server version. */
+ MysqlConnectionData *cdata;
+ cdata = (MysqlConnectionData *) gda_connection_internal_get_provider_data (cnc);
+ if (!cdata)
+ return FALSE;
+ if (cdata->version_long < 50000) {
+ g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_SERVER_VERSION_ERROR,
+ _("Mysql version 5.0 at least is required"));
+ return FALSE;
+ }
+
+ if (! gda_holder_set_value (gda_set_get_holder (i_set, "cat"), routine_catalog, error))
+ return FALSE;
+ if (! gda_holder_set_value (gda_set_get_holder (i_set, "schema"), routine_schema, error))
+ return FALSE;
+ if (routine_name_n != NULL) {
+ if (! gda_holder_set_value (gda_set_get_holder (i_set, "name"), routine_name_n, error))
+ return FALSE;
+ model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_ROUTINES_ONE], i_set, error);
+ } else
+ model = gda_connection_statement_execute_select (cnc, internal_stmt[I_STMT_ROUTINES], i_set, 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;
}
gboolean
@@ -1390,7 +1549,7 @@
GdaMetaContext *context,
GError **error)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
return TRUE;
}
@@ -1404,7 +1563,7 @@
const GValue *rout_schema,
const GValue *rout_name)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
return TRUE;
}
@@ -1415,7 +1574,7 @@
GdaMetaContext *context,
GError **error)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
return TRUE;
}
@@ -1429,6 +1588,6 @@
const GValue *rout_schema,
const GValue *rout_name)
{
- TO_IMPLEMENT;
+ //TO_IMPLEMENT;
return TRUE;
}
Modified: trunk/providers/mysql/gda-mysql-provider.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-provider.c (original)
+++ trunk/providers/mysql/gda-mysql-provider.c Sat Oct 25 18:48:34 2008
@@ -1228,6 +1228,7 @@
_GDA_PSTMT(ps)->sql = sql;
gda_connection_add_prepared_statement (cnc, stmt, (GdaPStmt*) ps);
+ g_object_unref (ps);
return TRUE;
}
@@ -1253,7 +1254,7 @@
if (mysql_stmt_prepare (cdata->mysql_stmt, sql, strlen (sql))) {
GdaConnectionEvent *event = _gda_mysql_make_error
- (cdata->cnc, NULL, cdata->mysql_stmt, NULL);
+ (cdata->cnc, NULL, cdata->mysql_stmt, error);
ps = NULL;
} else {
ps = gda_mysql_pstmt_new (cdata->cnc, cdata->mysql, cdata->mysql_stmt);
@@ -1546,9 +1547,6 @@
flags = GDA_DATA_MODEL_ACCESS_CURSOR_FORWARD;
return_value = (GObject *) gda_mysql_recordset_new (cnc, ps, params, flags, col_types);
- if (allow_noparam)
- g_object_set (return_value, "auto-reset", TRUE, NULL);
-
gda_connection_internal_statement_executed (cnc, stmt, params, NULL); /* required: help @cnc keep some stats */
}
Modified: trunk/providers/mysql/gda-mysql-recordset.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-recordset.c (original)
+++ trunk/providers/mysql/gda-mysql-recordset.c Sat Oct 25 18:48:34 2008
@@ -128,7 +128,7 @@
const unsigned long prefetch_rows = chunk_size;
if (mysql_stmt_attr_set (recset->priv->mysql_stmt, STMT_ATTR_PREFETCH_ROWS,
(void *) &prefetch_rows)) {
- _gda_mysql_make_error (recset->priv->cnc, NULL, recset->priv->mysql_stmt, NULL);
+ g_warning ("%s: %s\n", __func__, mysql_stmt_error (recset->priv->mysql_stmt));
return;
}
recset->priv->chunk_size = chunk_size;
@@ -361,15 +361,13 @@
for (i=0, list = _GDA_PSTMT (ps)->tmpl_columns;
i < GDA_PSTMT (ps)->ncols;
i++, list = list->next) {
- GdaColumn *column;
-
- column = GDA_COLUMN (list->data);
+ GdaColumn *column = GDA_COLUMN (list->data);
/* use C API to set columns' information using gda_column_set_*() */
// TO_IMPLEMENT;
MYSQL_FIELD *field = &mysql_fields[i];
- /* field->name, field->type); */
+
GType gtype = _GDA_PSTMT(ps)->types[i];
if (gtype == 0) {
gtype = _gda_mysql_type_to_gda (cdata, field->type);
@@ -423,6 +421,7 @@
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", __func__, field->name, field->type, g_type_name (gtype));
}
if (mysql_stmt_bind_result (cdata->mysql_stmt, mysql_bind_result)) {
@@ -505,6 +504,9 @@
GValue *value = gda_row_get_value (row, i);
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));
+ //
int intvalue = 0;
long long longlongvalue = 0;
@@ -528,7 +530,7 @@
else if (type == G_TYPE_LONG)
g_value_set_long (value, (long) intvalue);
else if (type == G_TYPE_BOOLEAN)
- g_value_set_boolean (value, (gboolean) intvalue ? TRUE : FALSE);
+ g_value_set_boolean (value, intvalue ? TRUE : FALSE);
else {
g_warning (_("Type %s not mapped for value %d"),
g_type_name (type), intvalue);
@@ -559,7 +561,9 @@
gda_value_set_time (value, &time);
} else if (type == G_TYPE_DATE) {
GDate *date = g_date_new_dmy
- (timevalue.day, timevalue.month, timevalue.year);
+ ((timevalue.day != 0) ? timevalue.day : 1,
+ (timevalue.month != 0) ? timevalue.month : 1,
+ (timevalue.year != 0) ? timevalue.year : 1970);
g_value_take_boxed (value, date);
g_date_free (date);
} else if (type == GDA_TYPE_TIMESTAMP) {
@@ -591,7 +595,7 @@
g_value_set_double (value, doublevalue);
else {
g_warning (_("Type %s not mapped for value %f"),
- g_type_name (type), intvalue);
+ g_type_name (type), doublevalue);
}
setlocale (LC_NUMERIC, gda_numeric_locale);
@@ -626,7 +630,7 @@
g_value_set_double (value, atof (strvalue));
setlocale (LC_NUMERIC, gda_numeric_locale);
} else {
- g_warning (_("Type %s not mapped for value %p"),
+ g_warning (_("Type %s not mapped for value %s"),
g_type_name (type), strvalue);
}
Modified: trunk/providers/mysql/gda-mysql-util.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-util.c (original)
+++ trunk/providers/mysql/gda-mysql-util.c Sat Oct 25 18:48:34 2008
@@ -25,23 +25,6 @@
#include <glib/gi18n-lib.h>
#include "gda-mysql-util.h"
-/* static GdaConnectionEventCode */
-/* gda_mysql_sqlsate_to_gda_code (const gchar *sqlstate) */
-/* { */
-/* guint64 gda_code = g_ascii_strtoull (sqlstate, NULL, 0); */
-
-/* switch (gda_code) { */
-/* case 42501: */
-/* return GDA_CONNECTION_EVENT_CODE_INSUFFICIENT_PRIVILEGES; */
-/* case 23505: */
-/* return GDA_CONNECTION_EVENT_CODE_UNIQUE_VIOLATION; */
-/* case 23502: */
-/* return GDA_CONNECTION_EVENT_CODE_NOT_NULL_VIOLATION; */
-/* default: */
-/* return GDA_CONNECTION_EVENT_CODE_UNKNOWN; */
-/* } */
-/* } */
-
/*
* Create a new #GdaConnectionEvent object and "adds" it to @cnc
*
@@ -53,90 +36,42 @@
MYSQL_STMT *mysql_stmt,
GError **error)
{
- /* GdaConnectionEvent *error_ev; */
- /* GdaConnectionEventCode gda_code = GDA_CONNECTION_EVENT_CODE_UNKNOWN; */
- /* GdaTransactionStatus *trans; */
-
- /* error_ev = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR); */
- /* if (mysql != NULL) { */
- /* gchar *message; */
-
- /* if (pg_res != NULL) { */
- /* gchar *sqlstate; */
-
- /* message = g_strdup (PQresultErrorMessage (pg_res)); */
- /* // sqlstate = PQresultErrorField (pg_res, PG_DIAG_SQLSTATE); */
- /* gda_connection_event_set_sqlstate (error_ev, sqlstate); */
- /* gda_code = gda_mysql_sqlsate_to_gda_code (sqlstate); */
- /* } */
- /* else { */
- /* message = g_strdup (PQerrorMessage (mysql)); */
- /* gda_code = GDA_CONNECTION_EVENT_CODE_UNKNOWN; */
- /* } */
-
-
- /* gchar *ptr = message; */
- /* if (g_str_has_prefix (message, "ERROR:")) */
- /* ptr += 6; */
- /* g_strstrip (ptr); */
-
- /* gda_connection_event_set_description (error_ev, ptr); */
- /* gda_connection_event_set_gda_code (error_ev, gda_code); */
- /* g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_STATEMENT_EXEC_ERROR, ptr); */
- /* g_free (message); */
- /* } */
- /* else { */
- /* gda_connection_event_set_description (error_ev, _("No detail")); */
- /* gda_connection_event_set_gda_code (error_ev, gda_code); */
- /* g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_STATEMENT_EXEC_ERROR, */
- /* _("No detail")); */
- /* } */
-
- /* gda_connection_event_set_code (error_ev, -1); */
- /* gda_connection_event_set_source (error_ev, "gda-mysql"); */
- /* gda_connection_add_event (cnc, error_ev); */
-
- /* /\* change the transaction status if there is a problem *\/ */
- /* trans = gda_connection_get_transaction_status (cnc); */
- /* if (trans) { */
- /* if ((PQtransactionStatus (mysql) == PQTRANS_INERROR) && */
- /* (trans->state != GDA_TRANSACTION_STATUS_STATE_FAILED)) */
- /* gda_connection_internal_change_transaction_state (cnc, */
- /* GDA_TRANSACTION_STATUS_STATE_FAILED); */
- /* } */
- /* return error_ev; */
-
GdaConnectionEvent *event_error =
gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
if (mysql) {
+ gda_connection_event_set_sqlstate
+ (event_error, mysql_sqlstate (mysql));
gda_connection_event_set_description
(event_error, mysql_error (mysql));
gda_connection_event_set_code
- (event_error, mysql_errno (mysql));
+ (event_error, GDA_CONNECTION_EVENT_CODE_UNKNOWN);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_STATEMENT_EXEC_ERROR,
- mysql_sqlstate (mysql));
+ mysql_error (mysql));
- g_print ("%s: %s\n", __func__, mysql_error (mysql));
+ //g_print ("%s: %s\n", __func__, mysql_error (mysql));
} else if (mysql_stmt) {
+ gda_connection_event_set_sqlstate
+ (event_error, mysql_stmt_sqlstate (mysql_stmt));
gda_connection_event_set_description
(event_error, mysql_stmt_error (mysql_stmt));
gda_connection_event_set_code
- (event_error, mysql_stmt_errno (mysql_stmt));
+ (event_error, GDA_CONNECTION_EVENT_CODE_UNKNOWN);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_STATEMENT_EXEC_ERROR,
- mysql_stmt_sqlstate (mysql_stmt));
+ mysql_stmt_error (mysql_stmt));
- g_print ("%s: %s\n", __func__, mysql_stmt_error (mysql_stmt));
+ //g_print ("%s : %s\n", __func__, mysql_stmt_error (mysql_stmt));
} else {
+ gda_connection_event_set_sqlstate
+ (event_error, _("Unknown"));
gda_connection_event_set_description
(event_error, _("No description"));
gda_connection_event_set_code
- (event_error, -1);
+ (event_error, GDA_CONNECTION_EVENT_CODE_UNKNOWN);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_STATEMENT_EXEC_ERROR,
_("No detail"));
}
- gda_connection_event_set_code (event_error, -1);
gda_connection_event_set_source (event_error, "gda-mysql");
gda_connection_add_event (cnc, event_error);
@@ -144,39 +79,10 @@
return event_error;
}
-/* /\* to be used only while initializing a connection *\/ */
-/* int */
-/* _gda_mysql_real_query_wrap (GdaConnection *cnc, */
-/* MYSQL *mysql, */
-/* const char *query, */
-/* unsigned long length) */
-/* { */
-/* GdaConnectionEvent *event; */
-
-/* if (cnc) { */
-/* event = gda_connection_event_new (GDA_CONNECTION_EVENT_COMMAND); */
-/* gda_connection_event_set_description (event, query); */
-/* gda_connection_add_event (cnc, event); */
-/* } */
-
-/* return mysql_real_query (mysql, query, length); */
-/* } */
-
GType
_gda_mysql_type_to_gda (MysqlConnectionData *cdata,
enum enum_field_types mysql_type)
{
- /* gint i; */
-
- /* for (i = 0; i < cdata->ntypes; i++) */
- /* if (cdata->type_data[i].oid == mysql_type) */
- /* break; */
-
- /* if (cdata->type_data[i].oid != mysql_type) */
- /* return G_TYPE_STRING; */
-
- /* return cdata->type_data[i].type; */
-
GType gtype = 0;
switch (mysql_type) {
case MYSQL_TYPE_TINY:
@@ -222,6 +128,34 @@
default:
gtype = G_TYPE_STRING;
}
+
+ /* g_print ("%s: ", __func__); */
+ /* switch (mysql_type) { */
+ /* case MYSQL_TYPE_TINY: g_print ("MYSQL_TYPE_TINY"); break; */
+ /* case MYSQL_TYPE_SHORT: g_print ("MYSQL_TYPE_SHORT"); break; */
+ /* case MYSQL_TYPE_LONG: g_print ("MYSQL_TYPE_LONG"); break; */
+ /* case MYSQL_TYPE_INT24: g_print ("MYSQL_TYPE_INT24"); break; */
+ /* case MYSQL_TYPE_YEAR: g_print ("MYSQL_TYPE_YEAR"); break; */
+ /* case MYSQL_TYPE_LONGLONG: g_print ("MYSQL_TYPE_LONGLONG"); break; */
+ /* case MYSQL_TYPE_FLOAT: g_print ("MYSQL_TYPE_FLOAT"); break; */
+ /* case MYSQL_TYPE_DECIMAL: g_print ("MYSQL_TYPE_DECIMAL"); break; */
+ /* case MYSQL_TYPE_NEWDECIMAL: g_print ("MYSQL_TYPE_NEWDECIMAL"); break; */
+ /* case MYSQL_TYPE_DOUBLE: g_print ("MYSQL_TYPE_DOUBLE"); break; */
+ /* case MYSQL_TYPE_BIT: g_print ("MYSQL_TYPE_BIT"); break; */
+ /* case MYSQL_TYPE_BLOB: g_print ("MYSQL_TYPE_BLOB"); break; */
+ /* case MYSQL_TYPE_TIMESTAMP: g_print ("MYSQL_TYPE_TIMESTAMP"); break; */
+ /* case MYSQL_TYPE_DATETIME: g_print ("MYSQL_TYPE_DATETIME"); break; */
+ /* case MYSQL_TYPE_DATE: g_print ("MYSQL_TYPE_DATE"); break; */
+ /* case MYSQL_TYPE_TIME: g_print ("MYSQL_TYPE_TIME"); break; */
+ /* case MYSQL_TYPE_NULL: g_print ("MYSQL_TYPE_NULL"); break; */
+ /* case MYSQL_TYPE_STRING: g_print ("MYSQL_TYPE_STRING"); break; */
+ /* case MYSQL_TYPE_VAR_STRING: g_print ("MYSQL_TYPE_VAR_STRING"); break; */
+ /* case MYSQL_TYPE_SET: g_print ("MYSQL_TYPE_SET"); break; */
+ /* case MYSQL_TYPE_ENUM: g_print ("MYSQL_TYPE_ENUM"); break; */
+ /* case MYSQL_TYPE_GEOMETRY: g_print ("MYSQL_TYPE_GEOMETRY"); break; */
+ /* default: g_print ("UNKNOWN %d: MYSQL_TYPE_STRING", mysql_type); break; */
+ /* } */
+ /* g_print ("\n"); */
+
return gtype;
-
}
Modified: trunk/providers/postgres/gda-postgres-provider.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-provider.c (original)
+++ trunk/providers/postgres/gda-postgres-provider.c Sat Oct 25 18:48:34 2008
@@ -1697,6 +1697,7 @@
_GDA_PSTMT (ps)->sql = sql;
gda_connection_add_prepared_statement (cnc, stmt, (GdaPStmt *) ps);
+ g_object_unref (ps);
return TRUE;
out_err:
Modified: trunk/providers/skel-implementation/capi/gda-capi-provider.c
==============================================================================
--- trunk/providers/skel-implementation/capi/gda-capi-provider.c (original)
+++ trunk/providers/skel-implementation/capi/gda-capi-provider.c Sat Oct 25 18:48:34 2008
@@ -924,6 +924,7 @@
return FALSE;
else {
gda_connection_add_prepared_statement (cnc, stmt, (GdaPStmt *) ps);
+ g_object_unref (ps);
return TRUE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]