Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f1CLHCx64336 for ; Mon, 12 Feb 2001 16:17:13 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id f1CLH5921882; Mon, 12 Feb 2001 16:17:05 -0500 (EST) To: "K. Ari Krupnikov" cc: pgsql-sql@postgresql.org Subject: Re: ORDER BY in SQL functions In-reply-to: <3A84965D.44806521@iln.net> References: <3A84965D.44806521@iln.net> Comments: In-reply-to "K. Ari Krupnikov" message dated "Fri, 09 Feb 2001 20:16:13 -0500" Date: Mon, 12 Feb 2001 16:17:05 -0500 Message-ID: <21879.982012625@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200102/233 X-Sequence-Number: 1424 "K. Ari Krupnikov" writes: > CREATE FUNCTION foo (INT) > RETURNS SETOF INT AS ' > SELECT id > FROM table > WHERE some_colunm > $1 > ORDER BY some_other_colunm > ' LANGUAGE 'sql'; > ERROR: function declared to return int4 returns multiple values in > final retrieve This is a bug in the SQL-function support --- the check for correct return type gets confused by the extra hidden column used for the ORDER BY. It'll work if you ORDER BY the column you're returning, not that that helps you much. It's fixed in 7.1. regards, tom lane