[libgda] MySQL provider: meta-store generation corrections.



commit c0bb30522c94eb43fa9d7b46d8936b91a3e2ed83
Author: Bas Driessen <bas driessen xobas com>
Date:   Wed Aug 5 22:05:32 2009 +1000

    MySQL provider: meta-store generation corrections.
    
    Patch supplied by: Carlos Savoretti <csavoretti clubsanjorge com ar>.
    
    * Add missing column in the I_STMT_COLUMN_ALL statement.
    
    * Correct column type from G_TYPE_STRING to G_TYPE_BOOLEAN in _gda_mysql_meta__tables_views.
    
    * Add missing G_TYPE_INT type to function new_row_from_mysql_stmt.

 providers/mysql/gda-mysql-meta.c      |    4 ++--
 providers/mysql/gda-mysql-recordset.c |   18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/providers/mysql/gda-mysql-meta.c b/providers/mysql/gda-mysql-meta.c
index 1fb8148..fc05d65 100644
--- a/providers/mysql/gda-mysql-meta.c
+++ b/providers/mysql/gda-mysql-meta.c
@@ -124,7 +124,7 @@ static gchar *internal_sql[] = {
 	"SELECT IFNULL(table_catalog, table_schema) AS table_catalog, table_schema, table_name, column_name, ordinal_position, column_default, is_nullable, data_type, NULL, '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, CASE WHEN extra = 'auto_increment' then '" GDA_EXTRA_AUTO_INCREMENT "' ELSE extra END, 1, column_comment FROM INFORMATION_SCHEMA.columns WHERE IFNULL(table_catalog, table_schema) = BINARY ##cat::string AND table_schema = BINARY ##schema::string AND table_name = BINARY ##name::string",
 
         /* I_STMT_COLUMNS_ALL */
-	"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, NULL, '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, CASE WHEN extra = 'auto_increment' then '" GDA_EXTRA_AUTO_INCREMENT "' ELSE extra END, 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",
+	"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, NULL, '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, CASE WHEN extra = 'auto_increment' then '" GDA_EXTRA_AUTO_INCREMENT "' ELSE extra END, 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) AS constraint_catalog, constraint_schema, constraint_name, IFNULL(constraint_catalog, constraint_schema) AS table_catalog, table_schema, table_name, constraint_type, NULL, FALSE, FALSE FROM INFORMATION_SCHEMA.table_constraints WHERE constraint_catalog = BINARY ##cat::string AND constraint_schema = BINARY ##schema::string AND table_name = BINARY ##name::string",
@@ -713,7 +713,7 @@ _gda_mysql_meta__tables_views (GdaServerProvider  *prov,
 	};
 	GType col_types_views[] = {
 		G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
-		G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE
+		G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_NONE
 	};
 	GdaDataModel *model_tables, *model_views;
 	gboolean retval;
diff --git a/providers/mysql/gda-mysql-recordset.c b/providers/mysql/gda-mysql-recordset.c
index 2729afe..05acdda 100644
--- a/providers/mysql/gda-mysql-recordset.c
+++ b/providers/mysql/gda-mysql-recordset.c
@@ -617,6 +617,9 @@ new_row_from_mysql_stmt (GdaMysqlRecordset *imodel, gint rownum, GError **error)
 		_gda_mysql_make_error (imodel->priv->cnc, NULL, imodel->priv->mysql_stmt, error);
 		return NULL;
 	}
+
+	/* g_print ("%s: SQL=%s\n", __func__, ((GdaDataSelect *) imodel)->prep_stmt->sql); */
+
 	
 	GdaRow *row = gda_row_new (((GdaDataSelect *) imodel)->prep_stmt->ncols);
 	gint col;
@@ -626,7 +629,7 @@ new_row_from_mysql_stmt (GdaMysqlRecordset *imodel, gint rownum, GError **error)
 		GValue *value = gda_row_get_value (row, i);
 		GType type = ((GdaDataSelect *) imodel)->prep_stmt->types[i];
 		
-		/*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;
@@ -799,6 +802,19 @@ new_row_from_mysql_stmt (GdaMysqlRecordset *imodel, gint rownum, GError **error)
 					break;
 				}
 			}
+			else if (type == G_TYPE_INT) {
+				if (length > 0)
+					g_value_set_int (value, atoi (strvalue));
+				else {
+					/* error: wrong column type */
+					gda_row_invalidate_value (row, value);
+					g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
+						     GDA_SERVER_PROVIDER_DATA_ERROR,
+						     _("Invalid column bind data type. %d\n"),
+						     mysql_bind_result[i].buffer_type);
+					break;
+				}
+			}
 			else if (type == G_TYPE_BOOLEAN) {
 				if (length > 0)
 					g_value_set_boolean (value, atoi (strvalue));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]