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

Commit5184414

Browse files
committed
From: Dan McGuirk <mcguirk@indirect.com>
Subject: [HACKERS] abort failed transaction patchThis patch allows you to end a transaction that has failed on an errorusing the 'ABORT' statement without generating another error message.(By default you get an error unless you use 'END' to terminate thetransaction, which has already been aborted anyway.)
1 parent336eb70 commit5184414

File tree

1 file changed

+15
-4
lines changed
  • src/backend/access/transam

1 file changed

+15
-4
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.6 1996/11/27 07:14:51 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.7 1997/03/12 20:41:14 scrappy Exp $
1111
*
1212
* NOTES
1313
*Transaction aborts can now occur two ways:
@@ -30,6 +30,7 @@
3030
*default state. In case 2, there may be more commands coming
3131
*our way which are part of the same transaction block and we have
3232
*to ignore these commands until we see an END transaction.
33+
* (or an ABORT! --djm)
3334
*
3435
*Internal aborts are now handled by AbortTransactionBlock(), just as
3536
*they always have been, and user aborts are now handled by
@@ -1265,7 +1266,7 @@ AbortTransactionBlock(void)
12651266
* state after the upcoming CommitTransactionCommand().
12661267
* ----------------
12671268
*/
1268-
elog(NOTICE,"AbortTransactionBlock and notinprogress state");
1269+
elog(NOTICE,"AbortTransactionBlock and notin in-progress state");
12691270
AbortTransaction();
12701271
s->blockState=TBLOCK_ENDABORT;
12711272
}
@@ -1285,7 +1286,17 @@ UserAbortTransactionBlock()
12851286
*/
12861287
if (s->state==TRANS_DISABLED)
12871288
return;
1288-
1289+
1290+
/*
1291+
* if the transaction has already been automatically aborted with an error,
1292+
* and the user subsequently types 'abort', allow it. (the behavior is
1293+
* the same as if they had typed 'end'.)
1294+
*/
1295+
if (s->blockState==TBLOCK_ABORT) {
1296+
s->blockState=TBLOCK_ENDABORT;
1297+
return;
1298+
}
1299+
12891300
if (s->blockState==TBLOCK_INPROGRESS) {
12901301
/* ----------------
12911302
* here we were inside a transaction block and we
@@ -1320,7 +1331,7 @@ UserAbortTransactionBlock()
13201331
* state after the upcoming CommitTransactionCommand().
13211332
* ----------------
13221333
*/
1323-
elog(NOTICE,"UserAbortTransactionBlock and notinprogress state");
1334+
elog(NOTICE,"UserAbortTransactionBlock and notin in-progress state");
13241335
AbortTransaction();
13251336
s->blockState=TBLOCK_ENDABORT;
13261337
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp