postgres.git / summary / log / commit / refs

commit    930bc76bec1021c9ab8c8cb41cc08d598c2e26d8
Author:   Bruce Momjian <bruce@momjian.us>
Date:     Fri Nov 03 17:57:58 2023 +0000
First released in: 17.0, 11.22, 12.17, 13.13, 14.10, 15.5, 16.1

    doc: \copy can get data values \. and end-of-input confused
    
    Reported-by: Svante Richter
    
    Discussion: https://postgr.es/m/fcd57e4-8f23-4c3e-a5db-2571d09208e2@beta.fastmail.com
    
    Backpatch-through: 11


doc/src/sgml/ref/psql-ref.sgml | 4 ++++ src/bin/psql/copy.c | 1 + 2 files changed, 5 insertions(+) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index fa58f71e15f..1d69295a1a4 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -1060,6 +1060,10 @@ testdb=&gt; destination, because all data must pass through the client/server connection. For large amounts of data the <acronym>SQL</acronym> command might be preferable. + Also, because of this pass-through method, <literal>\copy + ... from</literal> in <acronym>CSV</acronym> mode will erroneously + treat a <literal>\.</literal> data value alone on a line as an + end-of-input marker. </para> </tip> diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c index 20a744509b6..7254f093fb3 100644 --- a/src/bin/psql/copy.c +++ b/src/bin/psql/copy.c @@ -633,6 +633,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary, PGresult **res) * This code erroneously assumes '\.' on a line alone * inside a quoted CSV string terminates the \copy. * http://www.postgresql.org/message-id/E1TdNVQ-0001ju-GO@wrigleys.postgresql.org + * https://www.postgresql.org/message-id/bfcd57e4-8f23-4c3e-a5db-2571d09208e2@beta.fastmail.com */ if (strcmp(buf, "\\.\n") == 0 || strcmp(buf, "\\.\r\n") == 0) [parent: 54af107cb119]