Re: first cut at PL/PgSQL table functions - Mailing list pgsql-patches

From Joe Conway
Subject Re: first cut at PL/PgSQL table functions
Date
Msg-id 3D626A8F.4040303@joeconway.com
Whole thread Raw
In response to first cut at PL/PgSQL table functions  (Neil Conway <neilc@samurai.com>)
List pgsql-patches
Jan Wieck wrote:
> A PL/pgSQL function might (in the future) want to return a refcursor on
> one call, but use RETURN ... AND RESUME on another. So this has to be
> done for every SET.

How? They are going to be two different datatypes.


> My original idea was to make a tuplestore part of the cursor (Portal
> structure). This way the tuplestore access would be hidden behind the
> fetching and the caller doesn't have to care what the function really
> returns. Also it'd avoid the memory context problem, because the
> tuplestore would be part of the Portal memory context and go away when
> the cursor is closed.

I don't understand your concern. In the current implementation, table
functions really have very little to do with portals. That was why
pretty early on (7 May) Tom asked me to "s/portal/function/ throughout
the patch".

In any case, what Neil has proposed does hide the tuplestore behind the
fetching. The user only declares the tuple return type like they would
have to anyway. If you're referring to the functionmode being added to
the grammar, I think Tom has talked us out of that already ;-)

Joe


pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: first cut at PL/PgSQL table functions
Next
From: Tom Lane
Date:
Subject: Re: Correct regression tests