Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g11KcRl40873 for ; Fri, 1 Feb 2002 15:38:28 -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.4/8.11.4) with ESMTP id g11Karf12634; Fri, 1 Feb 2002 15:36:53 -0500 (EST) To: alla@sergey.com (Alla) cc: pgsql-sql@postgresql.org Subject: Re: What's wrong with this function - "returns setof" In-reply-to: <9275d56e.0201291114.57d7b9a@posting.google.com> References: <9275d56e.0201291114.57d7b9a@posting.google.com> Comments: In-reply-to alla@sergey.com (Alla) message dated "29 Jan 2002 11:14:07 -0800" Date: Fri, 01 Feb 2002 15:36:52 -0500 Message-ID: <12631.1012595812@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200202/27 X-Sequence-Number: 6459 alla@sergey.com (Alla) writes: > select get_field1(results.a), get_field2(results.b) > from (select test_func('aaa') as p) as resutls; > I am getting the following error: > ERROR: No such attribute or function 'get_field1' Well, correct syntax would be select get_field1(results.p), get_field2(results.p) from (select test_func('aaa') as p) as results; but unfortunately that still isn't gonna work. The code supporting functions returning sets is fairly disheveled at the moment, having suffered a lot of bit-rot and no attention since Berkeley days; and even back then there seems to have been some fatal confusion between true functions and "set attribute" functions. Here the parser is mistaking results.p for a "set attribute", which it ain't. We are talking about resurrecting the capability in a more straightforward form, wherein you'd write just select field1, field2 from test_func('foo') as results; ie, the result of a function returning setof would be treated syntactically as a table in its own right; but it's not happening quite yet. regards, tom lane