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;
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.
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
Cybertec Schönig & Schönig GmbH
In response to
pgsql-hackers by date
|Next:||From: Magnus Hagander||Date: 2010-03-31 12:19:05|
|Subject: Re: sorry, too many standbys already vs. MaxWalSenders vs. max_wal_senders|
|Previous:||From: Boszormenyi Zoltan||Date: 2010-03-31 11:18:02|
|Subject: Re: Problems with variable cursorname in ecpg|