Re: Proposed ProcessUtility() API additions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Proposed ProcessUtility() API additions
Date
Msg-id 3298.1173332942@sss.pgh.pa.us
Whole thread Raw
In response to Re: Proposed ProcessUtility() API additions  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-hackers
Gregory Stark <stark@enterprisedb.com> writes:
> "Tom Lane" <tgl@sss.pgh.pa.us> writes:
>> 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.

> I'm not exactly following. How does the exec_simple_query or
> exec_execute_message tell you whether you're in a transaction?

Read PreventTransactionChain and friends.  We can tell from state info
provided by xact.c whether we're inside a BEGIN block.  The problem
stems from cases like
SELECT myfunc()

where myfunc() tries to execute one of the verboten commands, via SPI or
some similar mechanism.  If we allowed that, then the function could try
to execute more commands within the same top-level transaction, which is
exactly what we don't want to allow.  If the command is being issued
directly by exec_simple_query or exec_execute_message, and it's not
inside a BEGIN block, then there's no way for an additional command to
be issued before commit.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Greg Smith
Date:
Subject: Re: Log levels for checkpoint/bgwriter monitoring
Next
From: Jim Nasby
Date:
Subject: Re: Auto creation of Partitions