Savepoints and SPI

From: Thomas Hallgren <thhal(at)mailblocks(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Cc: Filip Hrbek <filip(dot)hrbek(at)plz(dot)comstar(dot)cz>
Subject: Savepoints and SPI
Date: 2005-03-16 18:35:57
Message-ID: 42387C8D.8050103@mailblocks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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?

Should I assume that _all_ errors will act this way, i.e. should I
assume that if I end up in a PG_CATCH() that my SPI has been
disconnected always?

Regards,
Thomas Hallgren

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2005-03-16 20:12:06 Re: Savepoints and SPI
Previous Message Andrew Dunstan 2005-03-16 16:23:08 Re: contrib/pg_buffercache