*
* 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"
bool prev_cmd_interactive;
unsigned int prev_lineno;
- bool die_on_error;
+ volatile bool die_on_error = false;
/* Save old settings */
appendPQExpBufferChar(query_buf, '\n');
/* append the line to the query buffer */
appendPQExpBufferStr(query_buf, line + query_start);
+ appendPQExpBufferChar(query_buf, ';');
}
/* execute query */
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);