summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/psql/command.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index e6d703abe74..fe37be66f2a 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -1987,7 +1987,10 @@ process_file(char *filename, bool single_txn)
if ((res = PSQLexec("BEGIN", false)) == NULL)
{
if (pset.on_error_stop)
- return EXIT_USER;
+ {
+ result = EXIT_USER;
+ goto error;
+ }
}
else
PQclear(res);
@@ -2000,13 +2003,19 @@ process_file(char *filename, bool single_txn)
if ((res = PSQLexec("COMMIT", false)) == NULL)
{
if (pset.on_error_stop)
- return EXIT_USER;
+ {
+ result = EXIT_USER;
+ goto error;
+ }
}
else
PQclear(res);
}
- fclose(fd);
+error:
+ if (fd != stdin)
+ fclose(fd);
+
pset.inputfile = oldfilename;
return result;
}