postgresql/src/bin/psql
Tom Lane 49dfbb53cb Make psql handle EOF during COPY FROM STDIN properly on all platforms.
When stdin is a terminal, it's possible to end a COPY FROM STDIN with
a keyboard EOF signal (typically control-D), and then keep on issuing
SQL commands.  One would expect another COPY FROM STDIN to work as well,
but on some platforms it did not.  This turns out to be because we were
not resetting the stream's feof() flag, and BSD-ish versions of fread()
and fgets() won't attempt to read more data if that's set.

The misbehavior is observed on BSDen (including macOS), but not Linux,
Windows, or SysV-ish Unixen, which makes this a portability bug not
just a missing feature.

Add a clearerr() call to fix the behavior, and improve the prompt that's
issued when copying from a TTY to mention that EOF signals work.

It's been like this forever, so back-patch to all supported branches.

Thomas Munro

Discussion: https://postgr.es/m/CAEepm=0MCGfYf=JAMiYhO6JPtv9-3ZfBo8fcGeCZ8oMzaw+Z+Q@mail.gmail.com
2017-05-17 12:24:19 -04:00
..
po Translation updates 2017-05-08 10:13:00 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
command.c Fix assorted places in psql to print version numbers >= 10 in new style. 2016-08-16 15:58:30 -04:00
command.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
common.c Fix typos in comments. 2017-02-06 11:34:18 +02:00
common.h Clean up some psql issues around handling of the query output file. 2015-12-03 14:29:29 -05:00
copy.c Make psql handle EOF during COPY FROM STDIN properly on all platforms. 2017-05-17 12:24:19 -04:00
copy.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
create_help.pl Update copyright for 2015 2015-01-06 11:43:47 -05:00
describe.c psql: Add missing translation markers 2017-05-10 10:15:53 -04:00
describe.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
help.c Update line count totals for psql help displays. 2016-08-18 16:04:35 -04:00
help.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
input.c Guard against empty buffer in gets_fromFile()'s check for a newline. 2016-07-28 18:57:39 -04:00
input.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
large_obj.c Fix behavior of printTable() and friends with externally-invoked pager. 2015-12-02 18:20:34 -05:00
large_obj.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
mainloop.c Fix documentation of psql's ECHO all mode. 2015-01-31 18:35:13 -05:00
mainloop.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
Makefile Update copyright for 2015 2015-01-06 11:43:47 -05:00
mbprint.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
mbprint.h Fix indentation of \d footers for non-ASCII cases. 2012-03-07 19:25:59 -05:00
nls.mk Translation updates 2016-01-04 08:18:48 -05:00
print.c Restore psql's SIGPIPE setting if popen() fails. 2016-12-07 12:39:24 -05:00
print.h Get rid of scribbling on a const variable in psql's print.c. 2016-03-12 18:16:38 -05:00
prompt.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
prompt.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
psqlrc.sample Improve FILES section of psql reference page. 2014-01-14 19:27:57 -05:00
psqlscan.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
psqlscan.l Sort out paired double quotes in \connect, \password and \crosstabview. 2016-08-08 10:07:50 -04:00
settings.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
startup.c Introduce a psql "\connect -reuse-previous=on|off" option. 2016-08-08 10:07:50 -04:00
stringutils.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
stringutils.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
tab-complete.c Fix tab completion in psql for ALTER DEFAULT PRIVILEGES 2016-12-23 21:01:40 -05:00
tab-complete.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
variables.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
variables.h Update copyright for 2015 2015-01-06 11:43:47 -05:00