Re: [JDBC] V3 protocol + DECLARE problems

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [JDBC] V3 protocol + DECLARE problems
Date: 2004-07-23 04:15:19
Message-ID: 410090D7.7030900@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

Tom Lane wrote:

> Hm. The copying bit bothers me, and I guess after some thought it's
> a semantic issue. If you've got
>
> DECLARE c CURSOR FOR SELECT ... WHERE foo = $1;
>
> FETCH 10 FROM c;
>
> it's not very clear when the value of $1 should be supplied. With your
> proposal the parameter value would have to be supplied in the Bind
> message for the DECLARE CURSOR command. That may be the only way to do
> it (certainly I'd not want several successive FETCHes to use different
> parameter values), but it still seems a bit weird.

It doesn't seem too weird, we're using Parse/Bind to separate the query
template from concrete parameter values. When the Bind is done, we want
to behave as if executing the DECLARE with actual parameter values
substituted into the query string originally -- that matches the
behaviour of Bind for other queries. So using the parameters to DECLARE
for the constructed portal seems right.

If we were to do it any other way, we'd have to special-case Parse or
Bind for DECLARE to expect some different (zero?) number of parameters
in the Bind. exec_bind_message does a check quite early on that the
number of parameters provided matches the number expected.

> BTW, rather than hacking the parameter list of ProcessUtility,
> I'd be inclined to just look at ActivePortal->portalParams in
> PerformCursorOpen. (Come to think of it, we could also copy
> ActivePortal's sourceText at the PortalDefineQuery step.)

Ok, I'll do that.

-O

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message elein 2004-07-23 04:31:37 Re: [HACKERS] Tutorial
Previous Message Christopher Kings-Lynne 2004-07-23 03:24:16 Re: Fixing PKs and Uniques in tablespaces

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2004-07-23 04:36:04 Re: [JDBC] V3 protocol + DECLARE problems
Previous Message Oliver Jowett 2004-07-22 22:37:50 Re: Why Is pgSQL's JDBC Slow?