[gnome-db] Meta store and check if column exists

Piotr Pokora <[email protected]>
Newsgroups gmane.comp.gnome.db
Message-ID <[email protected]>
Hi!

Do I need to update meta store (gda_connection_update_meta_store())
when I only check if particular column in table exists?

Code which works:

GdaMetaContext mcontext = {"_columns", 2, NULL, NULL};
         mcontext.column_names = g_new (gchar *, 2);
         mcontext.column_names[0] = "table_name";
         mcontext.column_names[1] = "column_name";
         mcontext.column_values = g_new (GValue *, 2);
         g_value_set_string ((mcontext.column_values[0] = gda_value_new 
(G_TYPE_STRING)), table_name);
         g_value_set_string ((mcontext.column_values[1] = gda_value_new 
(G_TYPE_STRING)), column_name);


GdaDataModel *dm_schema =
                 gda_connection_get_meta_store_data 
(mgd->priv->connection, GDA_CONNECTION_META_FIELDS, NULL, 2,
                        "name", mcontext.column_values[0],
                        "field_name", mcontext.column_values[1]);

if (gda_data_model_get_n_rows (dm_schema) == 0)
	return FALSE; /* column doesn't exist */

In case of SQLite, when column exists, and I update meta store, warn
ing is thrown: 'constraint failed'. Without such update, there's no 
warning. Of course, meta store is updated when column is created in table.

Piotras
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.