aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2010-03-08 23:03:00 +0000
committerBruce Momjian <bruce@momjian.us>2010-03-08 23:03:00 +0000
commitb989662bf14ba9c6b0e6b2d2171890a935f9bfcc (patch)
tree7d185c1ed64efd51a53f45f30d037dd628a9d8d8 /src
parentaa8eed317257fd9d37e37aad669a8e8074c8b27e (diff)
downloadpostgresql-b989662bf14ba9c6b0e6b2d2171890a935f9bfcc.tar.gz
postgresql-b989662bf14ba9c6b0e6b2d2171890a935f9bfcc.zip
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
Diffstat (limited to 'src')
-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 e9476c4f3fc..d26c86bf863 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.216 2010/02/26 02:01:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.217 2010/03/08 23:03:00 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@@ -1731,10 +1731,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;