Re: Savepoints and SPI

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Thomas Hallgren <thhal(at)mailblocks(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Filip Hrbek <filip(dot)hrbek(at)plz(dot)comstar(dot)cz>
Subject: Re: Savepoints and SPI
Date: 2005-03-16 20:12:06
Message-ID: 20050316201206.GA7907@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 16, 2005 at 07:35:57PM +0100, Thomas Hallgren wrote:
> I have some test code that utilize SPI and does the following:
>
> 1. SPI_connect
> 2. set a savepoint (using BeginInternalSubTransaction)
> 3. execute a statement that contains a syntax error (within PG_TRY/PG_CATCH)
> 4. rollback to the savepoint (RollbackAndReleaseCurrentSubTransaction)
> 5. execute some other statement.
>
> it errors out in step 5 with SPI_ERROR_UNCONNECTED. It seems that step
> 3, when it encounters an error, automatically executes a SPI_finish. Is
> that the desired behavior?

I'd expect the code to close an SPI connection that is opened inside the
savepoint, but if you open it before setting the savepoint then it
should remain open.

--
Alvaro Herrera (<alvherre[(at)]dcc(dot)uchile(dot)cl>)
"Endurecerse, pero jamás perder la ternura" (E. Guevara)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-03-16 21:28:07 Re: [PATCHES] [pgsql-hackers-win32] snprintf causes regression
Previous Message Thomas Hallgren 2005-03-16 18:35:57 Savepoints and SPI