postgres/src
Tom Lane 07477130e2 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
..
backend Fix new warnings from GCC 7 2017-05-15 13:31:35 -04:00
bin Make psql handle EOF during COPY FROM STDIN properly on all platforms. 2017-05-17 12:24:19 -04:00
include Stamp 9.2.21. 2017-05-08 17:22:52 -04:00
interfaces Stamp 9.2.21. 2017-05-08 17:22:52 -04:00
makefiles Don't use deprecated dllwrap on Cygwin. 2014-02-01 16:13:46 -05:00
pl Translation updates 2017-05-08 10:20:30 -04:00
port Stamp 9.2.21. 2017-05-08 17:22:52 -04:00
template AIX: Test the -qlonglong option before use. 2015-07-17 03:02:18 -04:00
test Match pg_user_mappings limits to information_schema.user_mapping_options. 2017-05-08 07:24:28 -07:00
timezone Fix new warnings from GCC 7 2017-05-15 13:31:35 -04:00
tools Add libxml2 include path for MSVC builds 2017-05-12 10:24:36 -04:00
tutorial Remove tabs after spaces in C comments 2014-05-06 11:26:27 -04:00
.gitignore
bcc32.mak
DEVELOPERS
Makefile
Makefile.global.in Document usage of COPT environment variable for adjusting configure flags. 2017-02-17 16:11:03 -05:00
Makefile.shlib Fix typos in comments. 2017-02-06 11:34:32 +02:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00
win32.mak