Re: return query/composite types - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: return query/composite types
Date
Msg-id [email protected]
Whole thread Raw
In response to Re: return query/composite types  (Merlin Moncure <[email protected]>)
List pgsql-hackers
On Fri, Feb 20, 2009 at 3:25 PM, Merlin Moncure <[email protected]> wrote:
> On Fri, Feb 20, 2009 at 3:00 PM, Tom Lane <[email protected]> wrote:
>> Merlin Moncure <[email protected]> writes:
>>> create table foo(a int, b int);
>>> postgres=# create function rfoo() returns setof foo as $$ begin return
>>> query select foo from foo; end; $$ language plpgsql;
>>
>> Use "select * from ..." instead.
>
> Yeah...I was thinking maybe that shouldn't be required:
> 1. it's illogical and conflicts with regular non 'returns query'
> semantics (declare foo, assign, return)
> 2. if 'foo' is result of set returning function (like unnest), you
> need to make extra subquery to prevent that function from executing
> lots of extra times.
> e.g.
> select unnest(foo) from <something> will unnest the set six times if

er,
select (unnest(foo)).* from <something> will unnest the set six times if                                ^^^


pgsql-hackers by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: return query/composite types
Next
From: Tom Lane
Date:
Subject: Re: return query/composite types