Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita164208

Browse files
committed
Fixed deficiency where an unterminated (no semicolon) command at end of
psql script would be dropped silently.
1 parente631df3 commita164208

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

‎src/bin/psql/mainloop.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
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 $
77
*/
88
#include"postgres.h"
99
#include"mainloop.h"
@@ -61,7 +61,7 @@ MainLoop(FILE *source)
6161
boolprev_cmd_interactive;
6262

6363
unsignedintprev_lineno;
64-
booldie_on_error;
64+
volatilebooldie_on_error= false;
6565

6666

6767
/* Save old settings */
@@ -395,6 +395,7 @@ MainLoop(FILE *source)
395395
appendPQExpBufferChar(query_buf,'\n');
396396
/* append the line to the query buffer */
397397
appendPQExpBufferStr(query_buf,line+query_start);
398+
appendPQExpBufferChar(query_buf,';');
398399
}
399400

400401
/* execute query */
@@ -515,8 +516,21 @@ MainLoop(FILE *source)
515516
successResult=EXIT_BADCONN;
516517
break;
517518
}
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+
520534
destroyPQExpBuffer(query_buf);
521535
destroyPQExpBuffer(previous_buf);
522536

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp