postgresql/src/backend
Bruce Momjian d21de3b121 > =================================================================
> User interface proposal for multi-row function targetlist entries
> =================================================================
> 1. Only one targetlist entry may return a set.
> 2. Each targetlist item (other than the set returning one) is
>    repeated for each item in the returned set.
>

Having gotten no objections (actually, no response at all), I can only assume
no one had heartburn with this change. The attached patch covers the first of
the two proposals, i.e. restricting the target list to only one set returning
function.

It compiles cleanly, and passes all regression tests. If there are no
objections, please apply.

Any suggestions on where this should be documented (other than maybe sql-select)?

Thanks,

Joe

p.s. Here's what the previous example now looks like:
CREATE TABLE bar(f1 int, f2 text, f3 int);
INSERT INTO bar VALUES(1, 'Hello', 42);
INSERT INTO bar VALUES(2, 'Happy', 45);

CREATE TABLE foo(a int, b text);
INSERT INTO foo VALUES(42, 'World');
INSERT INTO foo VALUES(42, 'Everyone');
INSERT INTO foo VALUES(45, 'Birthday');
INSERT INTO foo VALUES(45, 'New Year');

CREATE TABLE foo2(a int, b text);
INSERT INTO foo2 VALUES(42, '!!!!');
INSERT INTO foo2 VALUES(42, '????');
INSERT INTO foo2 VALUES(42, '####');
INSERT INTO foo2 VALUES(45, '$$$$');

CREATE OR REPLACE FUNCTION getfoo(int) RETURNS SETOF text AS '
   SELECT b FROM foo WHERE a = $1
' language 'sql';

CREATE OR REPLACE FUNCTION getfoo2(int) RETURNS SETOF text AS '
   SELECT b FROM foo2 WHERE a = $1
' language 'sql';

regression=# SELECT f1, f2, getfoo(f3) AS f4 FROM bar;
  f1 |  f2   |    f4
----+-------+----------
   1 | Hello | World
   1 | Hello | Everyone
   2 | Happy | Birthday
   2 | Happy | New Year
(4 rows)

regression=# SELECT f1, f2, getfoo(f3) AS f4, getfoo2(f3) AS f5 FROM bar;
ERROR:  Only one target list entry may return a set result


Joe Conway
2003-02-13 05:06:35 +00:00
..
access Use stat(2) to probe for existing xlog segments in InstallXLogFileSegment, 2003-01-25 03:06:04 +00:00
bootstrap Revise executor APIs so that all per-query state structure is built in 2002-12-15 16:17:59 +00:00
catalog Create a distinction between Lists of integers and Lists of OIDs, to get 2003-02-09 06:56:28 +00:00
commands Add code to show join rule (for outer and IN joins) in join type name. 2003-02-10 17:06:23 +00:00
executor Create a distinction between Lists of integers and Lists of OIDs, to get 2003-02-09 06:56:28 +00:00
lib Remove bit.c/h routines. Not used anymore. 2003-01-09 01:23:55 +00:00
libpq #ifdef out stuff that shouldn't be compiled when not USE_SSL. 2003-02-03 22:33:51 +00:00
main This patch removes a bunch of superfluous #include directives: if 2002-11-08 20:23:57 +00:00
nodes Get rid of last few vestiges of parsetree dependency on grammar token 2003-02-10 04:44:47 +00:00
optimizer Fix thinko in new logic about pushing down non-nullability constraints: 2003-02-10 17:08:50 +00:00
parser > ================================================================= 2003-02-13 05:06:35 +00:00
po Most of the code follows the American spelling of the word, which is 2002-11-19 17:21:40 +00:00
port This patch removes a bunch of superfluous #include directives: if 2002-11-08 20:23:57 +00:00
postmaster Where available, use utime() or utimes() to update the file mod time 2003-01-25 05:19:47 +00:00
regex Replace regular expression package with Henry Spencer's latest version 2003-02-05 17:41:33 +00:00
rewrite Replace planner's representation of relation sets, per pghackers discussion. 2003-02-08 20:20:55 +00:00
storage Add code to print information about a detected deadlock cycle. The 2003-01-16 21:01:45 +00:00
tcop Get rid of last few vestiges of parsetree dependency on grammar token 2003-02-10 04:44:47 +00:00
utils Create a distinction between Lists of integers and Lists of OIDs, to get 2003-02-09 06:56:28 +00:00
Makefile Move pg_service.conf.sample to /interfaces/libpq. 2003-02-03 14:24:07 +00:00
nls.mk Translation updates 2002-09-14 13:46:24 +00:00