Re: Interesting issue with SFR in PL/pgSQL ... - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Interesting issue with SFR in PL/pgSQL ...
Date
Msg-id 4248.1095520398@sss.pgh.pa.us
Whole thread Raw
In response to Interesting issue with SFR in PL/pgSQL ...  (Hans-Jürgen Schönig <postgres@cybertec.at>)
List pgsql-hackers
Hans-Jürgen Schönig <postgres@cybertec.at> writes:
> CREATE OR REPLACE FUNCTION xy(int4) RETURNS SETOF RECORD AS '
> ...
>                  RETURN v_rec;
> ...
> ' LANGUAGE 'plpgsql';

> ERROR:  RETURN cannot have a parameter in function returning set; use 
> RETURN NEXT at or near "v_rec" at character 324

You were never supposed to do that, although prior releases did not
check for the mistake.  See
http://www.postgresql.org/docs/7.4/static/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING

: When a PL/pgSQL function is declared to return SETOF sometype, the
: procedure to follow is slightly different. In that case, the individual
: items to return are specified in RETURN NEXT commands, and then a final
: RETURN command with no argument is used to indicate that the function
: has finished executing.

> ERROR:  function xy(integer) does not exist
> HINT:  No function matches the given name and argument types. You may 
> need to add explicit type casts.

8.0 not only detects the error, but does so during CREATE FUNCTION
(because it's treated as a syntax error).
        regards, tom lane


pgsql-hackers by date:

Previous
From: Gary Doades
Date:
Subject: Re: libpq and prepared statements progress for 8.0
Next
From: "Jeroen T. Vermeulen"
Date:
Subject: Re: transaction idle timeout in 7.4.5 and 8.0.0beta2