Re: Interesting issue with SFR in PL/pgSQL ...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hans-Jürgen Schönig <postgres(at)cybertec(dot)at>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Interesting issue with SFR in PL/pgSQL ...
Date: 2004-09-18 15:13:18
Message-ID: 4248.1095520398@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=?ISO-8859-1?Q?Hans-J=FCrgen_Sch=F6nig?= <postgres(at)cybertec(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeroen T. Vermeulen 2004-09-18 15:19:01 Re: transaction idle timeout in 7.4.5 and 8.0.0beta2
Previous Message Michael Paesold 2004-09-18 13:04:00 Log line prefix on win32