doc: \copy can get data values \. and end-of-input confused
authorBruce Momjian
Fri, 3 Nov 2023 17:57:59 +0000 (13:57 -0400)
committerBruce Momjian
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 dceb8cdfd432406f299398e71be29b44ea740c17..d0bd119842ff2f2b098409fe1e6679d422d21e55 100644 (file)
@@ -1082,6 +1082,10 @@ testdb=>
         destination, because all data must pass through the client/server
         connection.  For large amounts of data the SQL
         command might be preferable.
+        Also, because of this pass-through method, \copy
+        ... from in CSV mode will erroneously
+        treat a \. data value alone on a line as an
+        end-of-input marker.
         
         
 
index 424a429e1e2b490d8d473a07ff68b0881923a208..23363b038d02edd03a4b0f853c828f7e8b468c32 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 ((linelen == 3 && memcmp(fgresult, "\\.\n", 3) == 0) ||
                            (linelen == 4 && memcmp(fgresult, "\\.\r\n", 4) == 0))