doc: \copy can get data values \. and end-of-input confused
authorBruce Momjian <[email protected]>
Fri, 3 Nov 2023 17:57:59 +0000 (13:57 -0400)
committerBruce Momjian <[email protected]>
Fri, 3 Nov 2023 17:57:59 +0000 (13:57 -0400)
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
src/bin/psql/copy.c

index d14f0581e60580b00373be658801c708be9bbfac..32eee145acd03af7f17d0c668498672b25ca3f39 100644 (file)
@@ -1086,6 +1086,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>
 
index e1fee8e0992ec16617d57d4eb4663cb04a54da87..5a9ec297c28f87c6147a116534d5f8fb463f8c31 100644 (file)
@@ -629,6 +629,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.
                     * https://www.postgresql.org/message-id/[email protected]
+                    * https://www.postgresql.org/message-id/[email protected]
                     */
                    if (strcmp(buf, "\\.\n") == 0 ||
                        strcmp(buf, "\\.\r\n") == 0)