Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group