diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2000-03-13 13:46:32 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2000-03-13 13:46:32 +0000 |
commit | a1642089bf4d4d85abec6cdde777471e97561657 (patch) | |
tree | 0dae155461a4a1c2bd2ecc0c18af0c805d73a078 | |
parent | e631df3c1beb5609ba9aab1515a3e38f619f43df (diff) | |
download | postgresql-a1642089bf4d4d85abec6cdde777471e97561657.tar.gz postgresql-a1642089bf4d4d85abec6cdde777471e97561657.zip |
Fixed deficiency where an unterminated (no semicolon) command at end of
psql script would be dropped silently.
-rw-r--r-- | src/bin/psql/mainloop.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index 4bd4608e5ce..4f71f3e4105 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.24 2000/03/05 13:30:19 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.25 2000/03/13 13:46:32 petere Exp $ */ #include "postgres.h" #include "mainloop.h" @@ -61,7 +61,7 @@ MainLoop(FILE *source) bool prev_cmd_interactive; unsigned int prev_lineno; - bool die_on_error; + volatile bool die_on_error = false; /* Save old settings */ @@ -395,6 +395,7 @@ MainLoop(FILE *source) appendPQExpBufferChar(query_buf, '\n'); /* append the line to the query buffer */ appendPQExpBufferStr(query_buf, line + query_start); + appendPQExpBufferChar(query_buf, ';'); } /* execute query */ @@ -515,8 +516,21 @@ MainLoop(FILE *source) successResult = EXIT_BADCONN; break; } - } /* while !endofprogram */ - + } /* while !endoffile/session */ + + /* + * Process query at the end of file without a semicolon + */ + if (query_buf->len > 0 && !pset.cur_cmd_interactive) + { + success = SendQuery(query_buf->data); + + if (!success && die_on_error) + successResult = EXIT_USER; + else if (pset.db == NULL) + successResult = EXIT_BADCONN; + } + destroyPQExpBuffer(query_buf); destroyPQExpBuffer(previous_buf); |