Re: Set-returning functions only allowed if written in language 'sql'

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Daniel Migowski <dmigowski(at)ikoffice(dot)de>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Set-returning functions only allowed if written in language 'sql'
Date: 2009-02-10 09:54:41
Message-ID: 162867790902100154t4456692s69f42b140659f739@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)ikoffice(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Magnus Hagander 2009-02-10 14:29:23 Re: pg_listener entries deleted under heavy NOTIFY load only on Windows
Previous Message hubert depesz lubaczewski 2009-02-10 09:46:44 Re: Set-returning functions only allowed if written in language 'sql'