set returning function - Mailing list pgsql-bugs

From Dennis Bjorklund
Subject set returning function
Date
Msg-id Pine.LNX.4.44.0505091208380.7072-100000@zigo.dhs.org
Whole thread Raw
Responses Re: set returning function  (Kris Jurka <books@ejurka.com>)
Re: set returning function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
An issue came up on irc. How come that this work:

  SELECT generate_series(0,1);

but

  SELECT foo(0,1);

does not, where foo is my own set returning function, like this example:

CREATE FUNCTION foo(a int, b int)
        RETURNS setof int
             AS 'BEGIN RETURN NEXT a;
                       RETURN NEXT b;
                       RETURN;
                 END'
       LANGUAGE plpgsql;

As far as I can tell the generate_series() example is not supposed to
work either.

Kris Jurka showed me another example that do work in the same way as
generate_series:

CREATE FUNCTION bar(int, int)
        RETURNS setof int
             AS 'SELECT $1 UNION ALL SELECT $2;'
       LANGUAGE sql;

So it seems that it's not just the type that decide how the function can
be used, it's also the language the function is defined in.

Bug?

--
/Dennis Björklund

pgsql-bugs by date:

Previous
From: "Dave Page"
Date:
Subject: Re: BUG #1654: can't run SQL commands
Next
From: Kris Jurka
Date:
Subject: Re: set returning function