*/
MemoryContext oldcontext = CurrentMemoryContext;
ResourceOwner oldowner = CurrentResourceOwner;
- volatile bool caught = false;
BeginInternalSubTransaction(NULL);
/* Want to run statements inside function's memory context */
PG_TRY();
{
rc = exec_stmts(estate, block->body);
+
+ /* Commit the inner transaction, return to outer xact context */
+ ReleaseCurrentSubTransaction();
+ MemoryContextSwitchTo(oldcontext);
+ CurrentResourceOwner = oldowner;
+
+ /*
+ * AtEOSubXact_SPI() should not have popped any SPI context,
+ * but just in case it did, make sure we remain connected.
+ */
+ SPI_restore_connection();
}
PG_CATCH();
{
ReThrowError(edata);
else
FreeErrorData(edata);
- caught = true;
}
PG_END_TRY();
-
- /* Commit the inner transaction, return to outer xact context */
- if (!caught)
- {
- ReleaseCurrentSubTransaction();
- MemoryContextSwitchTo(oldcontext);
- CurrentResourceOwner = oldowner;
- /*
- * AtEOSubXact_SPI() should not have popped any SPI context,
- * but just in case it did, make sure we remain connected.
- */
- SPI_restore_connection();
- }
}
else
{