summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2010-03-09 01:10:05 +0000
committerBruce Momjian2010-03-09 01:10:05 +0000
commit93d23c459e00b4f8c33f553400ba62f480ecd441 (patch)
treea61673dded32d55df7853d322cba519b47e5941d
parente51710d1e2d1ec8def47aac6b39997355c1ae8bb (diff)
Return proper exit code (3) from psql when ON_ERROR_STOP=on and
--single-transaction are both used and the failure happens in commit, e.g. failed deferred trigger. Also properly free BEGIN/COMMIT result structures from --single-transaction. Per report from Dominic Bevacqua
-rw-r--r--src/bin/psql/command.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 3e6f1bc58f0..8680b3696ce 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.186 2008/01/01 19:45:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.186.2.1 2010/03/09 01:10:05 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@@ -1496,10 +1496,28 @@ process_file(char *filename, bool single_txn)
pset.inputfile = filename;
if (single_txn)
- res = PSQLexec("BEGIN", false);
+ {
+ if ((res = PSQLexec("BEGIN", false)) == NULL)
+ {
+ if (pset.on_error_stop)
+ return EXIT_USER;
+ }
+ else
+ PQclear(res);
+ }
+
result = MainLoop(fd);
+
if (single_txn)
- res = PSQLexec("COMMIT", false);
+ {
+ if ((res = PSQLexec("COMMIT", false)) == NULL)
+ {
+ if (pset.on_error_stop)
+ return EXIT_USER;
+ }
+ else
+ PQclear(res);
+ }
fclose(fd);
pset.inputfile = oldfilename;