Re: [gnome-db] String escaping question





2009/1/26 Johannes Schmid <jhs jsschmid de>
Hi!

I tried to execute the following query on postgresql:

ALTER GROUP "glom_developers" ADD USER ##name::gchararray

the holder name was defined as "jhs".

The result was the following error:
Syntax error at »'jhs'«
LINE 1:  ALTER GROUP "glom_developer" ADD USER 'jhs'

The same query works as
ALTER GROUP "glom_developers" ADD USER "jhs" (note the difference
between ' and ".

Is there anything wrong with the query. Can I specify different
behaviour for the holder?

No, there is no way at the moment. The problem appears because:
* PostgreSQL does not seem to allow variables in the ALTER GROUP statement, so Libgda has to render the variable itself and renders a string (gchararray) using single quotes as any SQL string should be rendered
* PostgreSQL does not want an SQL string but rather an unquoted string which Libgda cannot render.

Here are the options:
* create the complete ALTER GROUP statement yourself including the user name literal in it
* modify Libgda to be able to handle non quoted strings

The 1st solution is the easiest, but the 2nd is the cleanest.

Modifying Libgda is not very difficult:
* create a new type of data in gda-value.[ch], for example "GdaRawString" or "GdaUnquotedString"
* optionnaly map this name to a more user friendly name such as "ustring" in gda_g_type_to_string() and gda_g_type_from_string()
* create a GdaDataHandler object for this new type
* modify the postgres provider to make it use that data handler when necessary, in gda_postgres_provider_get_data_handler()

All of this is very easy to do.

Vivien
 


Thanks,
Johannes

_______________________________________________
gnome-db-list mailing list
gnome-db-list gnome org
http://mail.gnome.org/mailman/listinfo/gnome-db-list




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