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
bin9rwOyaxyzo.bin
Description: sql-functions-3.patch.gz
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers