Re: return setof : alternatives to holder table - Mailing list pgsql-general

From Craig Ringer
Subject Re: return setof : alternatives to holder table
Date
Msg-id 4C67D644.9090609@postnewspapers.com.au
Whole thread Raw
In response to Re: return setof : alternatives to holder table  (Mike Christensen <mike@kitchenpc.com>)
List pgsql-general
On 15/08/2010 6:18 PM, Mike Christensen wrote:

> How about just using OUT parameters?
>
> CREATE FUNCTION FOO(IN _id uuid, OUT col1 text, OUT col2 text)
>     RETURNS SETOF record AS
>     BEGIN
>        select col1, col2 from test where id=_id;
>     END;
>
> Then your output just has to match the signature of the OUT parameters.
>   And you don't need to define anything when you call it.

That works - and in fact is what I often do. For a couple of functions I
have a little query that re-generates the OUT param lists based on the
contents of the INFORMATION_SCHEMA for those tables and dynamically
re-creates the function, too.

It'd be kind of nice to have ALTERing a table propagate that sort of
change to dependent functions so it didn't have to be manually
maintained. Given that it doesn't do that for even views at the
momement, though, it'd a pretty minor thing, and after development slows
down post-release schema don't tend to change that fast anyway.

--
Craig Ringer

pgsql-general by date:

Previous
From: Mike Christensen
Date:
Subject: Re: return setof : alternatives to holder table
Next
From: Sandeep Srinivasa
Date:
Subject: Relationship between ulimit and effective_cache_size, work_mem, shared_buffers, maintenance_work_mem and vacuum