Skip to content

Commit 42d3125

Browse files
committed
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
1 parent d391f6d commit 42d3125

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

doc/src/sgml/ref/psql-ref.sgml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,10 @@ INSERT INTO tbl1 VALUES ($1, $2) \bind 'first value' 'second value' \g
11191119
destination, because all data must pass through the client/server
11201120
connection. For large amounts of data the <acronym>SQL</acronym>
11211121
command might be preferable.
1122+
Also, because of this pass-through method, <literal>\copy
1123+
... from</literal> in <acronym>CSV</acronym> mode will erroneously
1124+
treat a <literal>\.</literal> data value alone on a line as an
1125+
end-of-input marker.
11221126
</para>
11231127
</tip>
11241128

src/bin/psql/copy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary, PGresult **res)
627627
* This code erroneously assumes '\.' on a line alone
628628
* inside a quoted CSV string terminates the \copy.
629629
* https://www.postgresql.org/message-id/E1TdNVQ-0001ju-GO@wrigleys.postgresql.org
630+
*
631+
* https://www.postgresql.org/message-id/bfcd57e4-8f23-4c3e-a5db-2571d09208e2@beta.fastmail.com
630632
*/
631633
if ((linelen == 3 && memcmp(fgresult, "\\.\n", 3) == 0) ||
632634
(linelen == 4 && memcmp(fgresult, "\\.\r\n", 4) == 0))

0 commit comments

Comments
 (0)