aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2010-03-09 01:09:54 +0000
committerBruce Momjian <bruce@momjian.us>2010-03-09 01:09:54 +0000
commitd70d4114618c5586e7b642f079eb0f9adfd172c0 (patch)
tree711a282084ec997933b65cfcbfffa3fe9c582308 /src
parent452419a6f000d06198e955e74e54fb8cac4fede9 (diff)
downloadpostgresql-d70d4114618c5586e7b642f079eb0f9adfd172c0.tar.gz
postgresql-d70d4114618c5586e7b642f079eb0f9adfd172c0.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 12895a1c7f6..014884a7b25 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.174 2006/10/06 17:14:00 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.174.2.1 2010/03/09 01:09:54 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@@ -1390,10 +1390,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;