From: Boszormenyi Zoltan on
Boszormenyi Zoltan írta:
> Boszormenyi Zoltan írta:
>
>> 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.
>>
>> What we need here is an extra check in ECPGdump_a_type().
>> We need to raise an error if
>> ECPGdump_a_type(name, type, ...)
>> and
>> var = with find_variable(name);
>> on the passed name disagrees in the variable type and maybe
>> a warning if they disagree in the brace_level. The same applies
>> to the indicator variable. For that, we need to pass the brace_level
>> to ECPGdump_a_type() for both the variable and the indicator.
>>
>>
>
> I was thinking about something like the attached patch.
> It passes all the regression tests.
>

And here's the code to test with.

> 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: Boszormenyi Zoltan on
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/


--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Michael Meskes on
On Wed, Mar 31, 2010 at 01:15:20PM +0200, Boszormenyi Zoltan wrote:
> I was thinking about something like the attached patch.
> It passes all the regression tests.

Thanks. Applied.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes(a)jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers