postgresql/src/bin
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
..
initdb Fix new warnings from GCC 7 2017-05-16 08:43:55 -04:00
pg_archivecleanup Fix new warnings from GCC 7 2017-05-16 08:43:55 -04:00
pg_basebackup Fix new warnings from GCC 7 2017-05-16 08:43:55 -04:00
pg_config Translation updates 2017-05-08 10:13:00 -04:00
pg_controldata Translation updates 2017-05-08 10:13:00 -04:00
pg_ctl Translation updates 2017-05-08 10:13:00 -04:00
pg_dump Ignore PQcancel errors properly 2017-05-09 14:58:51 -03:00
pg_resetxlog Fix new warnings from GCC 7 2017-05-16 08:43:55 -04:00
pg_rewind Fix new warnings from GCC 7 2017-05-16 08:43:55 -04:00
pg_test_fsync Avoid depending on non-POSIX behavior of fcntl(2). 2017-04-21 15:55:56 -04:00
pg_test_timing Move pg_test_timing from contrib/ to src/bin/ 2015-04-20 21:30:12 -04:00
pg_upgrade pg_upgrade: Fix for changed pg_ctl default stop mode 2017-01-13 16:20:00 -05:00
pg_xlogdump pg_xlogdump: Remove extra newline in error message 2017-03-08 09:58:51 -05:00
pgbench Fix pgbench's calculation of average latency, when -T is not used. 2016-09-21 13:16:20 +03:00
pgevent Update copyright for 2015 2015-01-06 11:43:47 -05:00
psql Make psql handle EOF during COPY FROM STDIN properly on all platforms. 2017-05-17 12:24:19 -04:00
scripts Ignore PQcancel errors properly 2017-05-09 14:58:51 -03:00
Makefile Move pg_xlogdump from contrib/ to src/bin/ 2015-04-21 19:03:49 -04:00