From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | [Fwd: SETOF input parameters (was Re: [HACKERS] proposal: array utility functions phase 1)] |
Date: | 2002-12-19 00:20:31 |
Message-ID: | 3E0110CF.8090408@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
Joe Conway wrote:
> Tom Lane wrote:
>
>> It seems like somehow we need a level of FROM/WHERE producing some base
>> rows, and then a set of table function calls to apply to each of the
>> base rows, and then another level of WHERE to filter the results of the
>> function calls (in particular to provide join conditions to identify
>> which rows to match up in the function outputs). I don't see any way to
>> do this without inventing new SELECT clauses out of whole cloth
>> ... unless SQL99's WITH clause helps, but I don't think it does ...
>
>
> Well, maybe this is a start. It allows a table function's input
> parameter to be declared with setof. The changes involved primarily:
>
> 1) a big loop in ExecMakeTableFunctionResult so that functions with set
> returning arguments get called for each row of the argument,
> and
> 2) aways initializing the tuplestore in ExecMakeTableFunctionResult and
> passing that to the function, even when SFRM_Materialize mode is used.
>
> The result looks like:
>
> create table foot(f1 text, f2 text);
> insert into foot values('a','b');
> insert into foot values('c','d');
> insert into foot values('e','f');
>
> create or replace function test2() returns setof foot as 'select * from
> foot order by 1 asc' language 'sql';
> create or replace function test(setof foot) returns foot as 'select
> $1.f1, $1.f2' language 'sql';
>
> regression=# select * from test(test2());
> f1 | f2
> ----+----
> a | b
> c | d
> e | f
> (3 rows)
>
> I know it doesn't solve all the issues discussed, but is it a step
> forward? Suggestions?
>
Patch updated (again) to apply cleanly against cvs. Compiles clean and passes
all regression tests. Any feedback? If not, please apply.
Thanks,
Joe
Attachment | Content-Type | Size |
---|---|---|
tablefunc-setof-input.3.patch | text/plain | 16.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2002-12-19 01:00:19 | user defined settings (aka user defined guc variables) |
Previous Message | Tom Lane | 2002-12-19 00:20:12 | Re: 7.3.1 documentation updates |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-12-19 01:07:52 | Re: [Fwd: SETOF input parameters (was Re: [HACKERS] proposal: array utility functions phase 1)] |
Previous Message | Bruce Momjian | 2002-12-18 20:40:28 | Re: MVCC doc improvements |