Re: WIP patch: convert SQL-language functions to return tuplestores

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>, pgsql-hackers(at)postgresql(dot)org, "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>, "Gregory Stark" <stark(at)enterprisedb(dot)com>, "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Martijn van Oosterhout" <kleptog(at)svana(dot)org>
Subject: Re: WIP patch: convert SQL-language functions to return tuplestores
Date: 2008-10-31 16:16:34
Message-ID: 5036.1225469794@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
sql-functions-3.patch.gz application/octet-stream 14.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2008-10-31 16:17:23 Re: Enabling archive_mode without restart
Previous Message David Fetter 2008-10-31 16:10:05 Re: Window Functions: patch for CommitFest:Nov.