Re: BUG #5032: unexpected syntax error for plpgsql function returns table

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Keith Cascio <keith(at)cs(dot)ucla(dot)edu>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5032: unexpected syntax error for plpgsql function returns table
Date: 2009-09-03 12:20:29
Message-ID: b42b73150909030520l26ae2bdbhbc8ae091f50317a0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Sep 3, 2009 at 12:48 AM, Keith Cascio<keith(at)cs(dot)ucla(dot)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.  I appreciate your suggestion, but it still seems like
> a bug to me.  Please comment on the fact that the following code succeeds:
>
> 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Robert Haas 2009-09-03 13:13:17 Re: BUG #5032: unexpected syntax error for plpgsql function returns table
Previous Message Bhushan Verma 2009-09-03 09:03:09 Re: [BUGS] psql: FATAL: the database system is in recovery mode