[COMMITTERS] pgsql: Make psql handle EOF during COPY FROM STDIN properly on allplat - Mailing list pgsql-committers

From Tom Lane
Subject [COMMITTERS] pgsql: Make psql handle EOF during COPY FROM STDIN properly on allplat
Date
Msg-id E1dB1kb-0007SN-Gd@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9485516ea2bf3b3ff36020bec03cbb752d8a204c

Modified Files
--------------
src/bin/psql/copy.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)


pgsql-committers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [COMMITTERS] pgsql: Tag refs/tags/REL_10_BETA1 was created
Next
From: Peter Eisentraut
Date:
Subject: [COMMITTERS] pgsql: Add more tests for CREATE SUBSCRIPTION