Re: Proposed ProcessUtility() API additions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Proposed ProcessUtility() API additions
Date: 2007-03-08 05:49:02
Message-ID: 3298.1173332942@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-03-08 06:12:22 Re: PostgreSQL - 'SKYLINE OF' clause added!
Previous Message Jim Nasby 2007-03-08 04:33:57 Re: Trivial HugeTLB Benchmark