|
3 | 3 | *
|
4 | 4 | * Copyright 2000 by PostgreSQL Global Development Group
|
5 | 5 | *
|
6 |
| - * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.24 2000/03/05 13:30:19 petere Exp $ |
| 6 | + * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.25 2000/03/13 13:46:32 petere Exp $ |
7 | 7 | */
|
8 | 8 | #include"postgres.h"
|
9 | 9 | #include"mainloop.h"
|
@@ -61,7 +61,7 @@ MainLoop(FILE *source)
|
61 | 61 | boolprev_cmd_interactive;
|
62 | 62 |
|
63 | 63 | unsignedintprev_lineno;
|
64 |
| -booldie_on_error; |
| 64 | +volatilebooldie_on_error= false; |
65 | 65 |
|
66 | 66 |
|
67 | 67 | /* Save old settings */
|
@@ -395,6 +395,7 @@ MainLoop(FILE *source)
|
395 | 395 | appendPQExpBufferChar(query_buf,'\n');
|
396 | 396 | /* append the line to the query buffer */
|
397 | 397 | appendPQExpBufferStr(query_buf,line+query_start);
|
| 398 | +appendPQExpBufferChar(query_buf,';'); |
398 | 399 | }
|
399 | 400 |
|
400 | 401 | /* execute query */
|
@@ -515,8 +516,21 @@ MainLoop(FILE *source)
|
515 | 516 | successResult=EXIT_BADCONN;
|
516 | 517 | break;
|
517 | 518 | }
|
518 |
| -}/* while !endofprogram */ |
519 |
| - |
| 519 | +}/* while !endoffile/session */ |
| 520 | + |
| 521 | +/* |
| 522 | + * Process query at the end of file without a semicolon |
| 523 | + */ |
| 524 | +if (query_buf->len>0&& !pset.cur_cmd_interactive) |
| 525 | + { |
| 526 | +success=SendQuery(query_buf->data); |
| 527 | + |
| 528 | +if (!success&&die_on_error) |
| 529 | +successResult=EXIT_USER; |
| 530 | +elseif (pset.db==NULL) |
| 531 | +successResult=EXIT_BADCONN; |
| 532 | + } |
| 533 | + |
520 | 534 | destroyPQExpBuffer(query_buf);
|
521 | 535 | destroyPQExpBuffer(previous_buf);
|
522 | 536 |
|
|