Re: Set-returning functions only allowed if written in language 'sql' - Mailing list pgsql-bugs

From Pavel Stehule
Subject Re: Set-returning functions only allowed if written in language 'sql'
Date
Msg-id 162867790902100154t4456692s69f42b140659f739@mail.gmail.com
Whole thread Raw
In response to Set-returning functions only allowed if written in language 'sql'  (Daniel Migowski <dmigowski@ikoffice.de>)
Responses Re: Set-returning functions only allowed if written in language 'sql'  (raf <raf@raf.org>)
List pgsql-bugs
Hello

this limit will be removed at 8.4

in older version you have to use table notation like

select * from srf()

regards
Pavel Stehule

2009/2/10 Daniel Migowski <dmigowski@ikoffice.de>:
> Hello dear PostgreSQL developers,
>
> I noticed the following strange behaviour with set-returning functions. If
> sets are allowed seems to depend on the language the function is written in,
> what makes conpletely no sense to me. See the following functions x() and
> y(). x() is written in 'sql' and works, y() is written is plpgsql and fails.
> Any reasons for this I do not realize?
>
> With best regards,
> Daniel Migowski
>
> ----------------------------
>
> CREATE FUNCTION x() RETURNS SETOF int4 AS
> $$
>   SELECT 1
>   UNION
>   SELECT 2
> $$
> LANGUAGE 'sql';
> SELECT x(); -- fine with two result rows.
>
> CREATE FUNCTION y() RETURNS SETOF int4 AS
> $$
> BEGIN
>   RETURN NEXT 1;
>   RETURN NEXT 2;
> END
> $$
> LANGUAGE 'plpgsql';
> SELECT y(); -- fails with:
> FEHLER: Funktion mit Mengenergebnis in einem Zusammenhang aufgerufen, der
> keine Mengenergebnisse verarbeiten kann
> SQL Status:0A000
> Kontext:PL/pgSQL function "y" line 2 at RETURN NEXT
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

pgsql-bugs by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Re: Set-returning functions only allowed if written in language 'sql'
Next
From: Magnus Hagander
Date:
Subject: Re: pg_listener entries deleted under heavy NOTIFY load only on Windows