"Tom Lane" <tgl@sss.pgh.pa.us> writes:
> * is_top_level: TRUE if command is being driven directly from
> exec_simple_query or exec_execute_message, else FALSE (this would
> need to be passed through PortalRun, so it gets this parameter added
> too).
...
> The point of adding is_top_level is to provide a simpler, more reliable
> means for PreventTransactionChain and related functions to detect
> whether a function is trying to invoke a non-transaction-block-safe
> command. Currently we rely on an ugly test involving seeing if the
> statement node is in the QueryContext, but that's always been a kluge,
> and I'm not sure that it works 100% even today. I'd like to get rid
> of the QueryContext global altogether.
I'm not exactly following. How does the exec_simple_query or
exec_execute_message tell you whether you're in a transaction?
Can't you exec_simple_query("BEGIN;") and then exec_simple_query a second
query in the same transaction?
-- Gregory Stark EnterpriseDB http://www.enterprisedb.com