Re: [gnome-db] Per-table meta-data with capital letters in the table name?



On Tue, 2009-06-30 at 09:08 +0200, Vivien Malerba wrote:
> 
> 
> 2009/6/29 Murray Cumming <murrayc murrayc com>
>         On Mon, 2009-06-29 at 17:45 +0200, Vivien Malerba wrote:
>         >
>         >
>         > 2009/6/29 Murray Cumming <murrayc murrayc com>
>         >         I should take the time to make a test case, but it
>         looks like
>         >         libgda 4.0
>         >         fails to get the meta-data for a specified table if
>         the table
>         >         name has
>         >         capital letters. I guess that this is a quoting (and
>         escaping)
>         >         problem
>         >         somewhere.
>         >
>         > Yes, you need to surround any SQL identifier which is not
>         case
>         > insensitive (or which has some spaces, etc in it) with
>         double quotes.
>         > You can use gda_sql_identifier_needs_quotes().
>         
>         
>         So we need to add quotes around the table_name (and escape the
>         text),
>         when setting the table name in GdaMetaContext, as in the
>         libgdamm code
>         below? If so, that's definitely something that should be
>         mentioned in
>         the gda_connection_update_meta_store() and/or GdaMetaContext
>         documentation.
> 
> Yes, and I'll correct that documentation point.

Are you sure? The testcase at
http://bugzilla.gnome.org/show_bug.cgi?id=587051#c17 suggests the
contrary.

>         Is there a function we can use to quote and escape the table
>         name?
> 
> Yes:  gda_sql_identifier_add_quotes(); not that there is also a
> gda_sql_identifier_remove_quotes() function.
> 
> 
>         
>         
>         
>         bool Connection::update_meta_store_table(const Glib::ustring&
>         table_name, const Glib::ustring& schema_name)
>         {
>          GValue table_name_value = { 0 };
>          g_value_init(&table_name_value, G_TYPE_STRING);
>          g_value_set_static_string(&table_name_value,
>         table_name.c_str());
>         
>          GValue table_schema_value = { 0 };
>          g_value_init(&table_schema_value, G_TYPE_STRING);
>          g_value_set_static_string(&table_schema_value,
>         schema_name.c_str());
>         
>          gchar* column_names[] = { (gchar*)"table_name" ,
>         (gchar*)"table_schema"};
>          GValue* column_values[] = { &table_name_value,
>         &table_schema_value };
>         
>          GdaMetaContext mcontext = {(gchar*)"_tables",
>         schema_name.empty() ?
>         1 : 2, column_names, column_values };
>          GError* gerror = 0;
>          const bool retval = gda_connection_update_meta_store(gobj(),
>         &mcontext, &gerror);
>         
>          g_value_unset(&table_name_value);
>          g_value_unset(&table_schema_value);
>         
>          if(gerror)
>            ::Glib::Error::throw_exception(gerror);
>         
>          return retval;
>         }
>         
>         >
>         > The doc in
>         >
>         http://library.gnome.org/devel/libgda/4.0/information_schema.html#information_schema:sql_identifiers
>         > mentions the quotes usage in Libgda, but maybe I should add
>         reminders
>         > in the functions's documentation for functions where this
>         may be a
>         > problem.
>         >
>         > Vivien
>         >
>         >
>         >
>         >
>         
>         
>         --
>         murrayc murrayc com
>         www.murrayc.com
>         www.openismus.com

Armin



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