From a6c768199734b28e1d32f2088211a0d5350dd5e2 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 6 Aug 2002 05:24:04 +0000 Subject: 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 --- src/backend/tcop/postgres.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 7916f609414..e430d07c763 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.279 2002/08/04 23:56:01 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.280 2002/08/06 05:24:04 momjian Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -648,38 +648,13 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */ { TransactionStmt *stmt = (TransactionStmt *) parsetree; - switch (stmt->command) - { - case COMMIT: - case ROLLBACK: - allowit = true; - break; - default: - break; - } + if (stmt->command == COMMIT || stmt->command == ROLLBACK) + allowit = true; } if (!allowit) - { - elog(WARNING, "current transaction is aborted, " + elog(ERROR, "current transaction is aborted, " "queries ignored until end of transaction block"); - - /* - * We need to emit a command-complete report to the client, - * even though we didn't process the query. - * - cim 6/1/90 - */ - commandTag = "*ABORT STATE*"; - - EndCommand(commandTag, dest); - - /* - * We continue in the loop, on the off chance that there - * is a COMMIT or ROLLBACK utility command later in the - * query string. - */ - continue; - } } /* Make sure we are in a transaction command */ @@ -1701,7 +1676,7 @@ PostgresMain(int argc, char *argv[], const char *username) if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.279 $ $Date: 2002/08/04 23:56:01 $\n"); + puts("$Revision: 1.280 $ $Date: 2002/08/06 05:24:04 $\n"); } /* -- cgit v1.2.3