Re: functions are returns columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: "Michele Petrazzo - Unipex srl" <michele(dot)petrazzo(at)unipex(dot)it>, "Pgsql-Sql" <pgsql-sql(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: functions are returns columns
Date: 2007-11-10 23:14:50
Message-ID: 21435.1194736490@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>> Not quite --- it's just "returns setof record".

> I did test my example before posting it:

> postgres=# postgres=# CREATE or replace FUNCTION getfoo (IN int, OUT int, OUT int) returns setof record(int,int)AS $$
> SELECT 1,2 union all select 2,3;
> $$ LANGUAGE SQL;

Interesting --- if you try it in anything older than 8.3, it will fail.

What is happening here is that the "(int,int)" is being taken as a
typmod (per Teodor's work to allow typmods for all data types), and
apparently in this path we never check to see if it's a *valid* typmod.

Now typmods are always discarded from function argument and result
types, but it seems like we'd better validate that they're legal for the
datatype anyway. Otherwise there will be confusion of just this sort.

Comments, objections?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Trevor Talbot 2007-11-10 23:17:13 Re: 8.2.3: Server crashes on Windows using Eclipse/Junit
Previous Message Gregory Stark 2007-11-10 21:04:06 Re: functions are returns columns

Browse pgsql-sql by date

  From Date Subject
Next Message chester c young 2007-11-11 00:23:42 general question on optimizer
Previous Message Gregory Stark 2007-11-10 21:04:06 Re: functions are returns columns