pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Do not treat \. as an EOF marker in CSV mode for COPY IN.
Date: Mon, 30 Sep 2024 21:57:31 +0000
Message-ID: <E1svOOY-001dEv-QX@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1svOOY-001dEv-QX@gemulon.postgresql.org>
Permalink:  ../E1svOOY-001dEv-QX@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1svOOY-001dEv-QX@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Do not treat \. as an EOF marker in CSV mode for COPY IN.
  In-Reply-To: <E1svOOY-001dEv-QX@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox