Re: counterintuitive behaviour in pl/pgsql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dan S <strd911(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: counterintuitive behaviour in pl/pgsql
Date: 2011-05-21 15:30:40
Message-ID: 1516.1305991840@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dan S <strd911(at)gmail(dot)com> writes:
> And yes I do know that I can fix the problem by renaming the output column
> to something else than i , I'm just curious about the behaviour and if it
> should work like this and why.

> CREATE OR REPLACE FUNCTION dynamic_query(i int) RETURNS TABLE (i int) as $$

This should probably throw an error. There is a check that disallows
having two input or two output parameters named the same, but the
comment about it says:

/*
* As of Postgres 9.0 we disallow using the same name for two
* input or two output function parameters. Depending on the
* function's language, conflicting input and output names might
* be bad too, but we leave it to the PL to complain if so.
*/

It looks like plpgsql didn't get the memo about checking this.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2011-05-21 15:39:51 Re: counterintuitive behaviour in pl/pgsql
Previous Message Björn Häuser 2011-05-21 15:11:14 Re: counterintuitive behaviour in pl/pgsql