Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit183e8b9

Browse files
committed
While fixing plperl and pltcl, I realized plpgsql wasn't doing
subtransactions quite right either: the ReleaseCurrentSubTransactioncall should occur inside the PG_TRY, so that the proper path is takenif an error occurs during subtransaction commit. This assumes thatAbortSubTransaction can cope with the state left behind ifCommitSubTransaction fails partway through, but we were alreadyrequiring that.
1 parent32c97fd commit183e8b9

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

‎src/pl/plpgsql/src/pl_exec.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language
44
*
55
* IDENTIFICATION
6-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.121 2004/11/16 18:10:14 tgl Exp $
6+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.122 2004/11/21 22:27:34 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -898,7 +898,6 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
898898
*/
899899
MemoryContextoldcontext=CurrentMemoryContext;
900900
ResourceOwneroldowner=CurrentResourceOwner;
901-
volatileboolcaught= false;
902901

903902
BeginInternalSubTransaction(NULL);
904903
/* Want to run statements inside function's memory context */
@@ -907,6 +906,17 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
907906
PG_TRY();
908907
{
909908
rc=exec_stmts(estate,block->body);
909+
910+
/* Commit the inner transaction, return to outer xact context */
911+
ReleaseCurrentSubTransaction();
912+
MemoryContextSwitchTo(oldcontext);
913+
CurrentResourceOwner=oldowner;
914+
915+
/*
916+
* AtEOSubXact_SPI() should not have popped any SPI context,
917+
* but just in case it did, make sure we remain connected.
918+
*/
919+
SPI_restore_connection();
910920
}
911921
PG_CATCH();
912922
{
@@ -949,22 +959,8 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
949959
ReThrowError(edata);
950960
else
951961
FreeErrorData(edata);
952-
caught= true;
953962
}
954963
PG_END_TRY();
955-
956-
/* Commit the inner transaction, return to outer xact context */
957-
if (!caught)
958-
{
959-
ReleaseCurrentSubTransaction();
960-
MemoryContextSwitchTo(oldcontext);
961-
CurrentResourceOwner=oldowner;
962-
/*
963-
* AtEOSubXact_SPI() should not have popped any SPI context,
964-
* but just in case it did, make sure we remain connected.
965-
*/
966-
SPI_restore_connection();
967-
}
968964
}
969965
else
970966
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp