Skip to content

Commit a6c7681

Browse files
committed
This patch changes the behavior of PostgreSQL so that if any queries are
executed in an implicitely aborted transaction (e.g. after an occur occurs), we return an error (and not just a warning). For example: nconway=# begin; BEGIN nconway=# insert; -- syntax error ERROR: parser: parse error at or near ";" nconway=# select * from a; ERROR: current transaction is aborted, queries ignored until end of transaction block The old behavior was: nconway=# begin; BEGIN nconway=# insert; ERROR: parser: parse error at or near ";" nconway=# select * from a; WARNING: current transaction is aborted, queries ignored until end of transaction block *ABORT STATE* Which can be confusing: if the client isn't paying careful attention, they will conclude that the query has executed (because no error is returned). Neil Conway
1 parent 5df307c commit a6c7681

File tree

1 file changed

+5
-30
lines changed

1 file changed

+5
-30
lines changed

src/backend/tcop/postgres.c

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.279 2002/08/04 23:56:01 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.280 2002/08/06 05:24:04 momjian Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -648,38 +648,13 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
648648
{
649649
TransactionStmt *stmt = (TransactionStmt *) parsetree;
650650

651-
switch (stmt->command)
652-
{
653-
case COMMIT:
654-
case ROLLBACK:
655-
allowit = true;
656-
break;
657-
default:
658-
break;
659-
}
651+
if (stmt->command == COMMIT || stmt->command == ROLLBACK)
652+
allowit = true;
660653
}
661654

662655
if (!allowit)
663-
{
664-
elog(WARNING, "current transaction is aborted, "
656+
elog(ERROR, "current transaction is aborted, "
665657
"queries ignored until end of transaction block");
666-
667-
/*
668-
* We need to emit a command-complete report to the client,
669-
* even though we didn't process the query.
670-
* - cim 6/1/90
671-
*/
672-
commandTag = "*ABORT STATE*";
673-
674-
EndCommand(commandTag, dest);
675-
676-
/*
677-
* We continue in the loop, on the off chance that there
678-
* is a COMMIT or ROLLBACK utility command later in the
679-
* query string.
680-
*/
681-
continue;
682-
}
683658
}
684659

685660
/* Make sure we are in a transaction command */
@@ -1701,7 +1676,7 @@ PostgresMain(int argc, char *argv[], const char *username)
17011676
if (!IsUnderPostmaster)
17021677
{
17031678
puts("\nPOSTGRES backend interactive interface ");
1704-
puts("$Revision: 1.279 $ $Date: 2002/08/04 23:56:01 $\n");
1679+
puts("$Revision: 1.280 $ $Date: 2002/08/06 05:24:04 $\n");
17051680
}
17061681

17071682
/*

0 commit comments

Comments
 (0)