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

Commit3f9ef2b

Browse files
committed
Properly recognize and announce input errors.
1 parent492ae18 commit3f9ef2b

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

‎src/bin/psql/input.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.62 2007/01/05 22:19:49 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.63 2007/11/28 09:17:46 petere Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -147,7 +147,7 @@ pg_send_history(PQExpBuffer history_buf)
147147
* gets_fromFile
148148
*
149149
* Gets a line of noninteractive input from a file (which could be stdin).
150-
* The result is a malloc'd string.
150+
* The result is a malloc'd string, or NULL on EOF or input error.
151151
*
152152
* Caller *must* have set up sigint_interrupt_jmp before calling.
153153
*
@@ -179,9 +179,16 @@ gets_fromFile(FILE *source)
179179
/* Disable SIGINT again */
180180
sigint_interrupt_enabled= false;
181181

182-
/* EOF? */
182+
/* EOF or error? */
183183
if (result==NULL)
184+
{
185+
if (ferror(source))
186+
{
187+
psql_error("could not read from input file: %s\n",strerror(errno));
188+
returnNULL;
189+
}
184190
break;
191+
}
185192

186193
appendPQExpBufferStr(buffer,line);
187194

‎src/bin/psql/mainloop.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.85 2007/01/05 22:19:49 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.86 2007/11/28 09:17:46 petere Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"mainloop.h"
@@ -129,7 +129,11 @@ MainLoop(FILE *source)
129129
line=gets_interactive(get_prompt(prompt_status));
130130
}
131131
else
132+
{
132133
line=gets_fromFile(source);
134+
if (!line&&ferror(source))
135+
successResult=EXIT_FAILURE;
136+
}
133137

134138
/*
135139
* query_buf holds query already accumulated. line is the malloc'd

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp