From: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
---|---|
To: | Michael Meskes <meskes(at)postgresql(dot)org> |
Cc: | PostgreSQL Hacker <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Problems with variable cursorname in ecpg |
Date: | 2010-03-31 11:35:10 |
Message-ID: | 4BB3336E.50204@cybertec.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Michael Meskes írta:
> On Wed, Mar 31, 2010 at 10:35:31AM +0200, Boszormenyi Zoltan wrote:
>
>>> I think we should make the error message/documentation a little bit clearer as
>>> people have stumbled over it.
>>>
>> Yes, we need to document it.
>>
>
> I changed the error message and documented a possible improvement in the TODO list.
>
>
>> I think you forget that in this case, only global variables are
>> usable in the DECLARE in this case, no local variables in
>> functions preceding the DECLARE are visible to it.
>>
>
> I thought about not allowing variables in declare statements that are outside a
> function. Do you think it makes sense to allow those? Forbidding these right
> now would give us more headroomfor future development.
>
I think forbidding global variables in DECLARE is not good.
Consider this code (existing code using this practice is in use):
/* globals for our cursor */
EXEC SQL BEGIN DECLARE SECTION;
char *global_curname;
EXEC SQL END DECLARE SECTION;
void open_cursor(char *curname)
{
global_curname = curname;
EXEC SQL DECLARE :global_curname CURSOR FOR ...;
EXEC SQL OPEN :global_curname;
}
... and similar codes for FETCH (into SQLDA) and CLOSE.
It works nicely for single-threaded code.
The dump_variables() code cannot distinguish between the
dynamic cursorname variable (used for $0) and the other
input variables. Considering the usefulness of the current
state, we shouldn't disallow global variables for DECLARE.
Best regards,
Zoltán Böszörményi
--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Hagander | 2010-03-31 12:19:05 | Re: sorry, too many standbys already vs. MaxWalSenders vs. max_wal_senders |
Previous Message | Boszormenyi Zoltan | 2010-03-31 11:18:02 | Re: Problems with variable cursorname in ecpg |