From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal: array utility functions phase 1 |
Date: | 2002-12-11 22:27:55 |
Message-ID: | 3DF7BBEB.8010301@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
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?
Joe
Attachment | Content-Type | Size |
---|---|---|
tablefunc-setof-input.1.patch | text/plain | 16.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-12-11 22:29:07 | SCO Openserver supported in 7.3.1 |
Previous Message | Bruce Momjian | 2002-12-11 22:16:05 | Re: pg_hba.conf parse error gives wrong line number |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-12-11 22:45:47 | Re: [BUGS] Bug #718: request for improvement of /? to show |
Previous Message | Neil Conway | 2002-12-11 21:14:37 | libpq doc improvement |