]> granicus.if.org Git - postgresql/commitdiff
This patch changes the behavior of PostgreSQL so that if any queries are
authorBruce Momjian <bruce@momjian.us>
Tue, 6 Aug 2002 05:24:04 +0000 (05:24 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 6 Aug 2002 05:24:04 +0000 (05:24 +0000)
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

index 7916f609414584f3735ed913ce69d1550f13e9e7..e430d07c7630dda62a921a14082ae5805f98f474 100644 (file)
@@ -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");
        }
 
        /*