Re: proposal: table functions and plpgsql - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: proposal: table functions and plpgsql
Date
Msg-id b42b73150805211031mc717455p4714b433fe7c8e7@mail.gmail.com
Whole thread Raw
In response to Re: proposal: table functions and plpgsql  (Hannu Krosing <hannu@krosing.net>)
Responses Re: proposal: table functions and plpgsql  (Hannu Krosing <hannu@krosing.net>)
Re: proposal: table functions and plpgsql  ("Pavel Stehule" <pavel.stehule@gmail.com>)
List pgsql-hackers
On Wed, May 21, 2008 at 1:28 PM, Hannu Krosing <hannu@krosing.net> wrote:
>> In my proposal I don't create any default variables. Result type is
>> only virtual - I don't need write it to system directory. I thing it's
>> better than using some specific predeclared type as RESULTTYPE OR
>> RESULTSET.
>
> How is this different from using OUT params and RETURNS SETOF RECORD ?

*) you reference output variables via rowtype (r.var vs. var)
*) seems cleaner to separate in/out variables so add/drop function are
symmetric.

Also,
What about:

CREATE OR REPLACE FUNCTION foo(m integer)
RETURNS TABLE (a integer, b integer) AS $$ -- DECLARE r foo; -- make alias of r to foo optional
BEGINFOR i IN 1..m LOOP    foo.a := i; foo.b := i + 1;
[...]

or
RETURNS TABLE r(a integer, b integer) AS $$

merlin


pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: proposal: table functions and plpgsql
Next
From: Tom Lane
Date:
Subject: May Commitfest is done!