diff options
author | Bruce Momjian <bruce@momjian.us> | 2010-03-09 01:10:23 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2010-03-09 01:10:23 +0000 |
commit | b5cf5dfc3d590529e7ca000ab8f5494b0d9874e6 (patch) | |
tree | 9eba4e1b38cb6c8c7a44811cd75fcbc7a9e9b7b1 /src | |
parent | 2bf64bc275a9c173dbecae60e7ceaf3327f96db0 (diff) | |
download | postgresql-b5cf5dfc3d590529e7ca000ab8f5494b0d9874e6.tar.gz postgresql-b5cf5dfc3d590529e7ca000ab8f5494b0d9874e6.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.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 7c815b8f977..098c31a4729 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.206 2009/06/11 14:49:07 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.206.2.1 2010/03/09 01:10:23 momjian Exp $ */ #include "postgres_fe.h" #include "command.h" @@ -1688,10 +1688,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; |