pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: alla@sergey.com
Cc: pgsql-sql@postgresql.org
Subject: Re: What's wrong with this function - "returns setof"
Date: Fri, 01 Feb 2002 15:36:52 -0500
Message-ID: <12631.1012595812@sss.pgh.pa.us> (raw)
In-Reply-To: <9275d56e.0201291114.57d7b9a@posting.google.com>
References: <9275d56e.0201291114.57d7b9a@posting.google.com>

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



Message-ID: <12631.1012595812@sss.pgh.pa.us>
Permalink:  ../12631.1012595812@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12631.1012595812@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, alla@sergey.com
  Subject: Re: What's wrong with this function - "returns setof"
  In-Reply-To: <12631.1012595812@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox