Re: BUG #5032: unexpected syntax error for plpgsql function returns table - Mailing list pgsql-bugs

From Merlin Moncure
Subject Re: BUG #5032: unexpected syntax error for plpgsql function returns table
Date
Msg-id b42b73150909030520l26ae2bdbhbc8ae091f50317a0@mail.gmail.com
Whole thread Raw
In response to Re: BUG #5032: unexpected syntax error for plpgsql function returns table  (Keith Cascio <keith@CS.UCLA.EDU>)
List pgsql-bugs
On Thu, Sep 3, 2009 at 12:48 AM, Keith Cascio<keith@cs.ucla.edu> wrote:
> Pavel,
>
> On Thu, 3 Sep 2009, Pavel Stehule wrote:
>
>> it's not bug - PostgreSQL doesn't support parameter placeholder on this
>> position. Use dynamic query instead - plpgsql statement EXECUTE.
>
> Thank you for your reply. =A0I appreciate your suggestion, but it still s=
eems like
> a bug to me. =A0Please comment on the fact that the following code succee=
ds:
>
> create function reproduce() returns table(foo integer) language plpgsql as
> 'begin return query select 1 bar; end;';
>
> Output in psql is:
> CREATE FUNCTION
>
> Why should it succeed with "bar" but not with "foo"?

This is a very common gotcha in plpgsql.  I always prefix function
arguments and and locals with _;

merlin

pgsql-bugs by date:

Previous
From: Devrim GÜNDÜZ
Date:
Subject: Re: [NOVICE] psql: FATAL: the database system is in recovery mode
Next
From: Keith Cascio
Date:
Subject: Re: BUG #5032: unexpected syntax error for plpgsql function returns table