aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1997-03-12 20:41:14 +0000
committerMarc G. Fournier <scrappy@hub.org>1997-03-12 20:41:14 +0000
commit51844146e504931f0cfa1048e0ea3bbc4e8ea619 (patch)
tree7169e3b7ba7f0022e8949c162c9bf345e390cecc /src
parent336eb7056d87b8cc341a955341318968e836918f (diff)
downloadpostgresql-51844146e504931f0cfa1048e0ea3bbc4e8ea619.tar.gz
postgresql-51844146e504931f0cfa1048e0ea3bbc4e8ea619.zip
From: Dan McGuirk <mcguirk@indirect.com>
Subject: [HACKERS] abort failed transaction patch This patch allows you to end a transaction that has failed on an error using the 'ABORT' statement without generating another error message. (By default you get an error unless you use 'END' to terminate the transaction, which has already been aborted anyway.)
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/xact.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index e58502ccaa8..3cb49b8e27d 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.6 1996/11/27 07:14:51 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.7 1997/03/12 20:41:14 scrappy Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@@ -30,6 +30,7 @@
* default state. In case 2, there may be more commands coming
* our way which are part of the same transaction block and we have
* to ignore these commands until we see an END transaction.
+ * (or an ABORT! --djm)
*
* Internal aborts are now handled by AbortTransactionBlock(), just as
* they always have been, and user aborts are now handled by
@@ -1265,7 +1266,7 @@ AbortTransactionBlock(void)
* state after the upcoming CommitTransactionCommand().
* ----------------
*/
- elog(NOTICE, "AbortTransactionBlock and not inprogress state");
+ elog(NOTICE, "AbortTransactionBlock and not in in-progress state");
AbortTransaction();
s->blockState = TBLOCK_ENDABORT;
}
@@ -1285,7 +1286,17 @@ UserAbortTransactionBlock()
*/
if (s->state == TRANS_DISABLED)
return;
-
+
+ /*
+ * if the transaction has already been automatically aborted with an error,
+ * and the user subsequently types 'abort', allow it. (the behavior is
+ * the same as if they had typed 'end'.)
+ */
+ if (s->blockState == TBLOCK_ABORT) {
+ s->blockState = TBLOCK_ENDABORT;
+ return;
+ }
+
if (s->blockState == TBLOCK_INPROGRESS) {
/* ----------------
* here we were inside a transaction block and we
@@ -1320,7 +1331,7 @@ UserAbortTransactionBlock()
* state after the upcoming CommitTransactionCommand().
* ----------------
*/
- elog(NOTICE, "UserAbortTransactionBlock and not inprogress state");
+ elog(NOTICE, "UserAbortTransactionBlock and not in in-progress state");
AbortTransaction();
s->blockState = TBLOCK_ENDABORT;
}