Re: [gnome-db] Patch Postgres provider.
- From: Bas Driessen <bas driessen xobas com>
- To: GNOME-DB List <gnome-db-list gnome org>
- Subject: Re: [gnome-db] Patch Postgres provider.
- Date: Wed, 27 Oct 2004 23:00:11 +1000
On Wed, 2004-10-27 at 18:53, Vivien Malerba wrote:
On Wed, 27 Oct 2004 16:52:30 +1000, Bas Driessen <bas driessen xobas com> wrote:
> Hello,
>
> Attached a patch for the postgres provider. I can't find any "patch
> instructions" on your web pages, so not sure about the procedure, so please
> advise if it is not conform the rules.
>
> Anyway, when using gda_data_model_append_row and a column name is a
> reserved name like "desc" or "typeid", the INSERT query is unsuccessful and
> returns an error. What this patch does is place " arround the column names.
> So:
>
> INSERT INTO parts(part_id, desc, price) VALUES (123, 'Test', 12.34)
>
> becomes
>
> INSERT INTO parts("part_id", "desc", "price") VALUES (123, 'Test', 12.34)
>
> and all works fine.
>
> Sure, it is probably not a good idea to use reserved names for column
> names, but people will be using them not knowing that some names are
> special.
>
> Thanks,
> Bas.
>
Seems ok for me; I'll commit it to CVS soon.
Vivien
Thanks Vivien, I noticed that the problem is in the gda_data_model_update_row area as well. Attached another patch file, that should be applied after the previous one. However, there is a small problem and I don't have enough understanding of g_strdup_printf to resolve it, so hope you (or anyone else) can help.
This is the solution we need:
tmp = g_strdup_printf ("
\"%s
\" = '%s', ",
column_name,
newval);
However, g_strdup_printf does not allow to have \" as the first character and the function gda_data_model_update_row fails with a segmentation fault. I can change \" to any other character, put another character in front of it (except space, tab etc) or leave it out and it works, but as soon as the first char is \" it fails. Why??
If you have seen this before and if there is a very simple solution to this, please advise. Otherwise we have to "re-wire" this function a bit.
Thanks,
Bas.
--- gda-postgres-recordset.c.org 2004-10-27 22:40:47.421797038 +1000
+++ gda-postgres-recordset.c 2004-10-27 22:41:38.673940927 +1000
@@ -375,7 +375,7 @@
continue;
/* fills the 'where' part of the update command */
- tmp = g_strdup_printf ("AND %s = '%s' ",
+ tmp = g_strdup_printf ("AND \"%s\" = '%s' ",
column_name,
newval);
query_where = g_strconcat (query_where, tmp, NULL);
@@ -385,7 +385,7 @@
/* non-unique column: update it */
else {
/* fills the 'set' part of the update command */
- tmp = g_strdup_printf ("%s = '%s', ",
+ tmp = g_strdup_printf ("\"%s\" = '%s', ",
column_name,
newval);
query_set = g_strconcat (query_set, tmp, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]