mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
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
This commit is contained in:
@@ -1135,7 +1135,8 @@ SELECT $1 \parse stmt1
|
||||
|
||||
<para>
|
||||
For <literal>\copy ... from stdin</literal>, data rows are read from the same
|
||||
source that issued the command, continuing until <literal>\.</literal>
|
||||
source that issued the command, continuing until a line containing
|
||||
only <literal>\.</literal>
|
||||
is read or the stream reaches <acronym>EOF</acronym>. This option is useful
|
||||
for populating tables in-line within an SQL script file.
|
||||
For <literal>\copy ... to stdout</literal>, output is sent to the same place
|
||||
@@ -1179,10 +1180,6 @@ SELECT $1 \parse stmt1
|
||||
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>
|
||||
|
||||
|
Reference in New Issue
Block a user