Lists: | pgsql-hackerspgsql-interfaces |
---|
From: | Bosco Rama <postgres(at)boscorama(dot)com> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | ecpg 'set' failure using host vars |
Date: | 2008-08-16 03:47:49 |
Message-ID: | 48A64DE5.4000906@boscorama.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-interfaces |
Hi,
I've been using the following set statement just fine under versions
prior to 8.3.3:
exec sql char *sm;
...
sm = "myschema"; // This may not always be constant
...
exec sql set search_path to :sm;
However, a recent upgrade from 8.2.7 to 8.3.3 (on FC9) caused the
'set' statement to suddenly start throwing the dreaded error:
ERROR: syntax error at or near "$1" in line 13256
Running in debug output mode we are seeing the following:
[22245]: ecpg_execute line 13256: QUERY: set search_path to $1 with 1 parameter on connection ecpgconn
[22245]: ecpg_execute line 13256: using PQexecParams
[22245]: free_params line 13256: parameter 1 = myschema
[22245]: ecpg_check_PQresult line 13256: Error: ERROR: syntax error at or near "$1"
LINE 1: set search_path to $1
^
When the schema is replaced by a literal it works just fine, thusly:
exec sql set search_path to myschema;
Did we miss something in the porting between versions?
Any help would be greatly appreciated.
Bosco.
From: | Michael Meskes <meskes(at)postgresql(dot)org> |
---|---|
To: | Bosco Rama <postgres(at)boscorama(dot)com> |
Cc: | pgsql-interfaces(at)postgresql(dot)org, PostgreSQL Hacker <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: ecpg 'set' failure using host vars |
Date: | 2008-08-16 08:31:56 |
Message-ID: | 20080816083156.GA26567@feivel.credativ.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-interfaces |
On Fri, Aug 15, 2008 at 08:47:49PM -0700, Bosco Rama wrote:
> [22245]: ecpg_execute line 13256: QUERY: set search_path to $1 with 1 parameter on connection ecpgconn
> [22245]: ecpg_execute line 13256: using PQexecParams
> [22245]: free_params line 13256: parameter 1 = myschema
> [22245]: ecpg_check_PQresult line 13256: Error: ERROR: syntax error at or near "$1"
> LINE 1: set search_path to $1
Without checking the sources it seems as if PQexecParams is not able to handle a parameter in a set command. Can anyone confirm this?
Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael Meskes <meskes(at)postgresql(dot)org> |
Cc: | Bosco Rama <postgres(at)boscorama(dot)com>, pgsql-interfaces(at)postgresql(dot)org, PostgreSQL Hacker <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: ecpg 'set' failure using host vars |
Date: | 2008-08-16 16:01:00 |
Message-ID: | 14940.1218902460@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-interfaces |
Michael Meskes <meskes(at)postgresql(dot)org> writes:
> Without checking the sources it seems as if PQexecParams is not able to handle a parameter in a set command. Can anyone confirm this?
The backend only supports parameters in plannable statements, ie
SELECT/INSERT/UPDATE/DELETE. (Possibly DECLARE CURSOR, I'm too
lazy to check.)
regards, tom lane
From: | Bosco Rama <postgres(at)boscorama(dot)com> |
---|---|
To: | |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: ecpg 'set' failure using host vars |
Date: | 2008-08-16 17:16:56 |
Message-ID: | 48A70B88.4050800@boscorama.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-interfaces |
Tom Lane wrote:
> Michael Meskes <meskes(at)postgresql(dot)org> writes:
>> Without checking the sources it seems as if PQexecParams is not able to handle a parameter in a set command. Can anyone confirm this?
>
> The backend only supports parameters in plannable statements, ie
> SELECT/INSERT/UPDATE/DELETE. (Possibly DECLARE CURSOR, I'm too
> lazy to check.)
>
> regards, tom lane
>
From: | Bosco Rama <postgres(at)boscorama(dot)com> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: ecpg 'set' failure using host vars |
Date: | 2008-08-16 17:20:42 |
Message-ID: | 48A70C6A.6080107@boscorama.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-interfaces |
Sorry about the 'false start' before. :-(
Tom Lane wrote:
> Michael Meskes <meskes(at)postgresql(dot)org> writes:
>> Without checking the sources it seems as if PQexecParams is not able
> to handle a parameter in a set command. Can anyone confirm this?
>
> The backend only supports parameters in plannable statements, ie
> SELECT/INSERT/UPDATE/DELETE. (Possibly DECLARE CURSOR, I'm too
> lazy to check.)
Thanks for the hint guys. I used a prepare/execute pair instead and
it worked a treat. More cumbersome but it gets the job done.
Thanks again.
Bosco.
From: | Michael Meskes <meskes(at)postgresql(dot)org> |
---|---|
To: | Bosco Rama <postgres(at)boscorama(dot)com> |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: ecpg 'set' failure using host vars |
Date: | 2008-08-18 14:58:21 |
Message-ID: | 20080818145821.GA5062@feivel.credativ.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-interfaces |
>>> Without checking the sources it seems as if PQexecParams is not able
> > to handle a parameter in a set command. Can anyone confirm this?
>>
>> The backend only supports parameters in plannable statements, ie
>> SELECT/INSERT/UPDATE/DELETE. (Possibly DECLARE CURSOR, I'm too
>> lazy to check.)
>
> Thanks for the hint guys. I used a prepare/execute pair instead and
> it worked a treat. More cumbersome but it gets the job done.
I will fix this as soon as my time permits. There is logic there in ecpg to
handle parameters on the client side.
Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!
From: | Michael Meskes <meskes(at)postgresql(dot)org> |
---|---|
To: | Bosco Rama <postgres(at)boscorama(dot)com> |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: ecpg 'set' failure using host vars |
Date: | 2008-08-19 10:31:18 |
Message-ID: | 20080819103118.GA23760@feivel.credativ.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-interfaces |
On Fri, Aug 15, 2008 at 08:47:49PM -0700, Bosco Rama wrote:
> exec sql char *sm;
> ...
> sm = "myschema"; // This may not always be constant
> ...
> exec sql set search_path to :sm;
Could you please try the attached patch and tell me whether it works for you? I will then check this in into 8.3 so that the next stable release works again as it should.
Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!
Attachment | Content-Type | Size |
---|---|---|
ecpg_set.diff | text/x-diff | 558 bytes |
From: | Bosco Rama <postgres(at)boscorama(dot)com> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: ecpg 'set' failure using host vars |
Date: | 2008-08-20 16:45:53 |
Message-ID: | 48AC4A41.40204@boscorama.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-interfaces |
Hi Michael,
Michael Meskes wrote:
> On Fri, Aug 15, 2008 at 08:47:49PM -0700, Bosco Rama wrote:
>> exec sql char *sm;
>> ...
>> sm = "myschema"; // This may not always be constant
>> ...
>> exec sql set search_path to :sm;
>
> Could you please try the attached patch and tell me whether it works
> for you? I will then check this in into 8.3 so that the next stable
> release works again as it should.
Thanks for working on this.
Unfortunately I'm just an applications person and our systems use the
FC9 distribution's pre-compiled packages only (it's a sysadmin thing).
I asked them about it and they said (and I quote): "When it becomes
part of the FC9 distribution they will 'consider' (my emphasis)
upgrading the packages." *sigh*
I really appreciate the effort and the fix but for now I have to be
satisfied with the work-around you guys suggested previously. :-(
Bosco.
From: | Michael Meskes <meskes(at)postgresql(dot)org> |
---|---|
To: | Bosco Rama <postgres(at)boscorama(dot)com> |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: ecpg 'set' failure using host vars |
Date: | 2008-08-20 16:51:30 |
Message-ID: | 20080820165130.GA5546@feivel.credativ.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-interfaces |
> I really appreciate the effort and the fix but for now I have to be
> satisfied with the work-around you guys suggested previously. :-(
I see. 8.3.4 will have the fix anyway. :-)
Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!