Re: Having a plpgsql function return multiple rows that indicate its progress in a cursor like fashion - Mailing list pgsql-general

From Tom Lane
Subject Re: Having a plpgsql function return multiple rows that indicate its progress in a cursor like fashion
Date
Msg-id 29326.1266335120@sss.pgh.pa.us
Whole thread Raw
In response to Re: Having a plpgsql function return multiple rows that indicate its progress in a cursor like fashion  (Peter Geoghegan <peter.geoghegan86@gmail.com>)
Responses Re: Having a plpgsql function return multiple rows that indicate its progress in a cursor like fashion  (Peter Geoghegan <peter.geoghegan86@gmail.com>)
List pgsql-general
Peter Geoghegan <peter.geoghegan86@gmail.com> writes:
> Cursors simply address the problem of "impedance mismatch" (the use of
> that term in this way probably pre-dates ORM, so please don't tell me
> that that term refers exclusively to an ORM problem within an RDBMS
> context). You don't have to fetch the result set all at once where
> that is impractical. However, the entire result set is available on
> the server from the first fetch.

The above statements are not true as far as the cursor mechanism is
concerned (at least not in Postgres).  However, they are true as far as
the result of a plpgsql function returning set is concerned.  The
function runs to completion, dumping RETURN NEXT outputs into a
"tuplestore", and then returns the tuplestore as its result.

It is possible to code set-returning functions in a suspend-and-resume
style, but none of the available PLs do that; you have to get down to
the C level.

            regards, tom lane

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: possible bug with inheritance?
Next
From: manugarciac
Date:
Subject: Check what a transaction did in the past