From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org |
Subject: | Re: anonymous composite types for Table Functions (aka |
Date: | 2002-08-05 04:00:31 |
Message-ID: | 3D4DF85F.6020109@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
The attached patch disallows the use of coldeflists for functions that
don't return type RECORD. It also catches a core dump condition when a
function returning RECORD had an alias list instead of a coldeflist.
Now both conditions throw an ERROR.
Sample output below:
Tom Lane wrote:
> regression=# select * from foo() as z;
> foo
> ------
> 8800
> 1891
> 3420
> 9850
> ...
>
> (hm, what happened to the alias?)
Actually nothing wrong with this one. The z is the relation alias, not
the column alias. The column alias defaults to the function name for
SRFs returning scalar. If you try:
test=# select myfoo1.* from myfoo1() as z;
ERROR: Relation "myfoo1" does not exist
which is as expected.
>
> regression=# select * from foo() as z(a int);
> foo
> ------
> 8800
> 1891
> 3420
> 9850
> 7164
> ...
>
> (again, what happened to the alias? Column name should be a)
This one now throws an error:
test=# select * from myfoo1() as z(a int);
ERROR: A column definition list is only allowed for functions returning
RECORD
>
> regression=# select * from foo() as z(a int8);
> foo
> ------
> 8800
> 1891
> 3420
> 9850
>
> (definitely not cool)
Same here.
Other change is like so:
test=# create function myfoo2() returns setof record as 'select * from
ct limit 10' language sql;
test=# select * from myfoo2() as z(a);
ERROR: A column definition list is required for functions returning RECORD
test=# select * from myfoo2();
ERROR: A column definition list is required for functions returning RECORD
test=# select * from myfoo2() as (a int, b text, c text, d text, e text);
a | b | c | d | e
----+--------+-------+------+------
1 | group1 | test1 | att1 | val1
2 | group1 | test1 | att2 | val2
3 | group1 | test1 | att3 | val3
4 | group1 | test1 | att4 | val4
5 | group1 | test2 | att1 | val5
6 | group1 | test2 | att2 | val6
7 | group1 | test2 | att3 | val7
8 | group1 | test2 | att4 | val8
9 | group2 | test3 | att1 | val1
10 | group2 | test3 | att2 | val2
(10 rows)
test=# select * from myfoo2() as (a int8, b text, c text, d text, e text);
ERROR: Query-specified return tuple and actual function return tuple do
not match
Please apply if no objections.
Thanks,
Joe
Attachment | Content-Type | Size |
---|---|---|
pseudo-type-alias-fixup.2002.08.04.patch | text/plain | 1.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2002-08-05 04:08:25 | Re: FUNC_MAX_ARGS benchmarks |
Previous Message | Tom Lane | 2002-08-05 03:56:25 | Re: FUNC_MAX_ARGS benchmarks |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-08-05 04:08:33 | Re: anonymous composite types for Table Functions (aka SRFs) |
Previous Message | Tom Lane | 2002-08-05 02:58:47 | Re: anonymous composite types for Table Functions (aka SRFs) |