calling a function that takes a row type and returns a set of rows - Mailing list pgsql-general

From Robert Haas
Subject calling a function that takes a row type and returns a set of rows
Date
Msg-id 603c8f070810101222h2745f90bg712d0745dd68c68f@mail.gmail.com
Whole thread Raw
Responses Re: calling a function that takes a row type and returns a set of rows  ("Pavel Stehule" <pavel.stehule@gmail.com>)
Re: calling a function that takes a row type and returns a set of rows  (Dimitri Fontaine <dfontaine@hi-media.com>)
List pgsql-general
So, say I have something like this - the actual example is something a
bit more useful:

CREATE TABLE foo (a integer, b integer);
INSERT INTO foo VALUES (1, 1);   -- must have some data to generate the failure

CREATE FUNCTION bar (foo) RETURNS SETOF foo AS $$
DECLARE
    f foo;
BEGIN
    f.a := 1;
    RETURN NEXT f;
    f.a := 2;
    RETURN NEXT f;
END
$$ LANGUAGE plpgsql;

I can't find any legal way of calling this function.

SELECT bar(f) FROM foo f;
ERROR:  set-valued function called in context that cannot accept a set

SELECT * FROM foo f, bar(f);
ERROR:  function expression in FROM may not refer to other relations
of same query level

Any help appreciated.

Thanks,

...Robert

pgsql-general by date:

Previous
From: "postgres Emanuel CALVO FRANCO"
Date:
Subject: Re: Opteron vs. Xeon performance differences
Next
From: "Pavel Stehule"
Date:
Subject: Re: calling a function that takes a row type and returns a set of rows