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

From Daniel Migowski
Subject Set-returning functions only allowed if written in language 'sql'
Date
Msg-id 4990C472.7020700@ikoffice.de
Whole thread Raw
Responses Re: Set-returning functions only allowed if written in language 'sql'  (hubert depesz lubaczewski <depesz@depesz.com>)
Re: Set-returning functions only allowed if written in language 'sql'  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-bugs
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

pgsql-bugs by date:

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