Re: functions returning sets - Mailing list pgsql-general

From Joe Conway
Subject Re: functions returning sets
Date
Msg-id 3FDF52A1.9040803@joeconway.com
Whole thread Raw
In response to Re: functions returning sets  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Tom Lane wrote:
> Jeff Rogers <jrogers@findlaw.com> writes:
>>I expect this latter to return all the ids, but it seems to only return every
>>other one.
>
> Hmm, this looks like a bug having to do with not resetting state
> correctly for the next invocation of the SRF.  Hard to tell whether
> the bug is in your code or the system's support for SRFs though.
>
> Joe, did you see
> http://archives.postgresql.org/pgsql-general/2003-12/msg00709.php
> ?  I don't have time to look at this right now ...

I've not gotten to the bottom of this, but I can confirm the issue.

The way I would expect this query to be written does work:

regression=# select id from foo where 'a' in (select * from
pgxml_xpath(doc,'/top/node'));
  id
----
  1
  2
  3
(3 rows)

So the problem seems to be related specifically to "SRF returning setof
scalar in targetlist of subselect". Maybe some difference between
ExecMakeFunctionResult and ExecMakeTableFunctionResult? SRFs returning
complex types are not allowed in targetlists, but in this case there is
no restriction because the return type is scalar.

I'll keep digging as time allows.

Joe





pgsql-general by date:

Previous
From: Joe Conway
Date:
Subject: Re: DB with bytea types reload problem
Next
From: Jonathan Bartlett
Date:
Subject: Re: Reload bytea [was Re: Picture with Postgres and Delphi]