GdaMetaContext mcontext = {"_columns", 1, NULL, NULL};
GValue *gval;
+ GdaMetaStore *store;
+ GdaMetaStruct *mstruct;
+ GdaMetaDbObject *dbo;
+ GSList *list;
+ GdaMetaTableColumn *column;
- GdaDataModel *dm_fields;
-
- guint rows;
- guint row;
-
- error = NULL;
+ guint i;
mcontext.column_names = g_new (gchar *, 1);
mcontext.column_names[0] = "table_name";
g_value_take_string (mcontext.column_values[0],
gda_sql_identifier_quote (table_name, gda_conn_ref_db, NULL, FALSE, FALSE));
+ error = NULL;
if (!gda_connection_update_meta_store (gda_conn_ref_db, &mcontext, &error))
{
g_warning ("Unable to update database metastore: %s",
}
error = NULL;
+
gval = gda_value_new (G_TYPE_STRING);
g_value_take_string (gval, (gchar *)table_name);
- dm_fields = gda_connection_get_meta_store_data (gda_conn_ref_db,
- GDA_CONNECTION_META_FIELDS,
- &error,
- 1,
- "name", gval);
- if (dm_fields != NULL && error == NULL)
+
+ store = gda_connection_get_meta_store (gda_conn_ref_db);
+ mstruct = gda_meta_struct_new (store, GDA_META_STRUCT_FEATURE_NONE);
+ dbo = gda_meta_struct_complement (mstruct, GDA_META_DB_TABLE,
+ NULL, NULL,
+ gval, &error);
+
+ gda_value_free (gval);
+ if (dbo != NULL)
{
- rows = gda_data_model_get_n_rows (dm_fields);
- for (row = 0; row < rows; row++)
+ GdaMetaTable *table = GDA_META_TABLE (dbo);
+
+ i = 0;
+ for (list = table->columns; list; list = list->next, i++)
{
- g_message ("\t\tField: %s - %s - %s - %d - %d", gda_value_stringify (gda_data_model_get_value_at (dm_fields, 0, row, NULL)),
- gda_value_stringify (gda_data_model_get_value_at (dm_fields, 1, row, NULL)),
- gda_value_stringify (gda_data_model_get_value_at (dm_fields, 2, row, NULL)),
- g_value_get_int (gda_data_model_get_value_at (dm_fields, 3, row, NULL)),
- g_value_get_int (gda_data_model_get_value_at (dm_fields, 4, row, NULL)));
+ column = (GdaMetaTableColumn *)list->data;
+ g_message ("\t\tField: %s - %s - %d - %d - %d - %s",
+ column->column_name,
+ column->column_type,
+ column->gtype,
+ column->pkey,
+ column->nullok,
+ column->default_value);
+ error = NULL;
if (!gda_server_operation_set_value_at (op,
- gda_value_stringify (gda_data_model_get_value_at (dm_fields, 0, row, NULL)),
+ column->column_name,
&error,
- g_strdup_printf ("/FIELDS_A/@COLUMN_NAME/%d", row)))
+ g_strdup_printf ("/FIELDS_A/@COLUMN_NAME/%d", i)))
{
g_warning ("Error on setting GdaServerOperation's value: %s.",
error != NULL && error->message != NULL ? error->message : "no details");
continue;
}
+
+ error = NULL;
if (!gda_server_operation_set_value_at (op,
- gda_value_stringify (gda_data_model_get_value_at (dm_fields, 1, row, NULL)),
+ column->column_type,
&error,
- g_strdup_printf ("/FIELDS_A/@COLUMN_TYPE/%d", row)))
+ g_strdup_printf ("/FIELDS_A/@COLUMN_TYPE/%d", i)))
{
g_warning ("Error on setting GdaServerOperation's value: %s.",
error != NULL && error->message != NULL ? error->message : "no details");
}
}
}
- if (dm_fields != NULL)
- {
- g_object_unref (dm_fields);
- }
+ g_object_unref (mstruct);
}
static void