Re: WIP patch: convert SQL-language functions to return tuplestores - Mailing list pgsql-hackers

From Tom Lane
Subject Re: WIP patch: convert SQL-language functions to return tuplestores
Date
Msg-id 5036.1225469794@sss.pgh.pa.us
Whole thread Raw
In response to Re: WIP patch: convert SQL-language functions to return tuplestores  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: WIP patch: convert SQL-language functions to return tuplestores
List pgsql-hackers
With the attached patch, SQL functions support returning the results of
INSERT/UPDATE/DELETE RETURNING clauses.  An INSERT/UPDATE/DELETE
statement is always executed to completion before returning (including
firing any related triggers or rules), so we always materialize the
RETURNING output.  When the function result comes from a SELECT, we
continue to use value-per-call mode when being called from
ExecMakeFunctionResult (thus preserving the prior behavior if the
calling query doesn't execute to completion).  When called from
ExecMakeTableFunctionResult, we materialize the output and return the
tuplestore in one call.  This is also the same behavior as before,
since ExecMakeTableFunctionResult would've filled a tuplestore anyway;
but it's noticeably faster because a lot of call/return and executor
entry overhead is eliminated.

This is code-complete but I haven't touched the docs yet.  Barring
objections, I plan to commit when I've finished fixing the docs.

            regards, tom lane


Attachment

pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: Re: Window Functions: patch for CommitFest:Nov.
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Enabling archive_mode without restart