Re: bugfix for cursor arguments in named notation

Lists: pgsql-hackers
From: Yeb Havinga <yebhavinga(at)gmail(dot)com>
To: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: bugfix for cursor arguments in named notation
Date: 2012-04-04 09:47:43
Message-ID: 4F7C18BF.60802@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Using a cursor argument name equal to another plpgsql variable results
in the error:
cursor .. has no argument named ""

The attached patch fixes that.

Instead of solving the issue like is done in the patch, another way
would be to expose internal_yylex() so that could be used instead of
yylex() by read_cursor_args when reading the argument name, and would
always return the argument name in yylval.str.

--
Yeb Havinga
http://www.mgrid.net/
Mastering Medical Data

Attachment Content-Type Size
0001-Fix-cursor-has-no-argument-named-error.patch text/x-patch 0 bytes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yeb Havinga <yebhavinga(at)gmail(dot)com>
Cc: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bugfix for cursor arguments in named notation
Date: 2012-04-04 15:10:32
Message-ID: 26173.1333552232@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Yeb Havinga <yebhavinga(at)gmail(dot)com> writes:
> Using a cursor argument name equal to another plpgsql variable results
> in the error:
> cursor .. has no argument named ""

> The attached patch fixes that.

> Instead of solving the issue like is done in the patch, another way
> would be to expose internal_yylex() so that could be used instead of
> yylex() by read_cursor_args when reading the argument name, and would
> always return the argument name in yylval.str.

I think a better way would be to temporarily set
plpgsql_IdentifierLookup to IDENTIFIER_LOOKUP_DECLARE, so as to suppress
variable name lookup in the first place. The patch as you have it seems
to me to make too many assumptions about what name lookup might produce.

regards, tom lane


From: Yeb Havinga <yebhavinga(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bugfix for cursor arguments in named notation
Date: 2012-04-05 08:05:33
Message-ID: 4F7D524D.9010504@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2012-04-04 17:10, Tom Lane wrote:
> Yeb Havinga<yebhavinga(at)gmail(dot)com> writes:
>> Using a cursor argument name equal to another plpgsql variable results
>> in the error:
>> cursor .. has no argument named ""
> I think a better way would be to temporarily set
> plpgsql_IdentifierLookup to IDENTIFIER_LOOKUP_DECLARE, so as to suppress
> variable name lookup in the first place. The patch as you have it seems
> to me to make too many assumptions about what name lookup might produce.
>
>

Thank you for looking at it. Attached is a patch that implements your
suggestion.

regards,
Yeb

Attachment Content-Type Size
0001-Fix-cursor-has-no-argument-named-error.patch text/x-patch 0 bytes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yeb Havinga <yebhavinga(at)gmail(dot)com>
Cc: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bugfix for cursor arguments in named notation
Date: 2012-04-05 14:01:57
Message-ID: 1804.1333634517@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Yeb Havinga <yebhavinga(at)gmail(dot)com> writes:
> On 2012-04-04 17:10, Tom Lane wrote:
>> I think a better way would be to temporarily set
>> plpgsql_IdentifierLookup to IDENTIFIER_LOOKUP_DECLARE,

> Thank you for looking at it. Attached is a patch that implements your
> suggestion.

Oh, sorry, I assumed you'd seen that I committed a fix like that last
night.

regards, tom lane