Do not treat \. as an EOF marker in CSV mode for COPY IN.
Since backslash is (typically) not special in CSV data, we should
not be treating \. as special either. The server historically did
this to keep CSV and TEXT modes more alike and to support V2 protocol;
but V2 protocol is long dead, and the inconsistency with CSV standards
is annoying. Remove that behavior in CopyReadLineText, and make some
minor consequent code simplifications.
On the client side, we need to fix psql so that it does not check
for \. except when reading data from STDIN (that is, the script
source). We must do that regardless of TEXT/CSV mode or there is
no way to end the COPY short of script EOF. Also, be careful
not to send the \. to the server in that case.
This is a small compatibility break in that other applications
beside psql may need similar adjustment. Also, using an older
version of psql with a v18 server may result in misbehavior
during CSV-mode COPY IN.
Daniel Vérité, reviewed by vignesh C, Robert Haas, and myself
Discussion: https://postgr.es/m/ed659f37-a9dd-42a7-82b9-0da562cc4006@manitou-mail.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/7702337489810f645b3501d99215c2b525c5abca
Modified Files
--------------
doc/src/sgml/libpq.sgml | 5 ++-
doc/src/sgml/protocol.sgml | 5 ++-
doc/src/sgml/ref/copy.sgml | 36 +++++++++++-----
doc/src/sgml/ref/psql-ref.sgml | 7 +---
src/backend/commands/copyfromparse.c | 80 +++++++++---------------------------
src/backend/commands/copyto.c | 7 +++-
src/bin/psql/copy.c | 27 ++++++++----
src/test/regress/expected/copy.out | 18 ++++++++
src/test/regress/sql/copy.sql | 12 ++++++
9 files changed, 105 insertions(+), 92 deletions(-)