Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id AAF029F9F6C for ; Sat, 10 Nov 2007 19:14:55 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 81564-01 for ; Sat, 10 Nov 2007 19:14:46 -0400 (AST) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 6EF329F9989 for ; Sat, 10 Nov 2007 19:14:51 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id lAANEoeo021436; Sat, 10 Nov 2007 18:14:50 -0500 (EST) To: Gregory Stark cc: "Michele Petrazzo - Unipex srl" , "Pgsql-Sql" , pgsql-hackers@postgresql.org Subject: Re: functions are returns columns In-reply-to: <874pftdd89.fsf@oxford.xeocode.com> References: <4734B921.5050704@unipex.it> <162867790711091235i7e77abcch27731d91285949b6@mail.gmail.com> <4735EC6F.5050908@unipex.it> <878x55dhau.fsf@oxford.xeocode.com> <19335.1194723995@sss.pgh.pa.us> <874pftdd89.fsf@oxford.xeocode.com> Comments: In-reply-to Gregory Stark message dated "Sat, 10 Nov 2007 21:04:06 +0000" Date: Sat, 10 Nov 2007 18:14:50 -0500 Message-ID: <21435.1194736490@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/42 X-Sequence-Number: 29570 Gregory Stark writes: > "Tom Lane" 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