Skip site navigation (1) Skip section navigation (2)

RETURNS TABLE returns NULL set when called by another RETURNS TABLE

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: RETURNS TABLE returns NULL set when called by another RETURNS TABLE
Date: 2010-02-24 01:48:29
Message-ID: 4B84856D.4080604@agliodbs.com (view raw or flat)
Thread:
Lists: pgsql-bugs
Pavel, all:

Apparently if you use one returns table function to call a 2nd returns
table function, it returns a recordset which consists entirely of nulls.

Here's the test case:

create table srf_data ( id serial, cat int, val text );
insert into srf_data ( cat, val ) values
( 1, 'josh' ),
( 1, 'selena' ),
( 2, 'bruce' ),
( 2, 'josh' ),
( 3, 'robert' );

create or replace  function srf1 ( this_cat int )
returns table (
        id1 int,
        val1 text )
language sql as $f$
select id, val from srf_data where cat = $1;
$f$;

create or replace function srf2 ( )
returns table (
        id1 int,
        val1 text )
language plpgsql as $f$
begin
return query
select id1, val1 from srf1(1);
return;
end;
$f$;

select * from srf2();

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2010-02-24 03:34:38
Subject: Re: RETURNS TABLE returns NULL set when called by another RETURNS TABLE
Previous:From: Tim BunceDate: 2010-02-23 22:54:45
Subject: Re: New PL/Perl failure with Safe 2.2x due to recursion (8.x & 9.0)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group