Re: Fixing backslash dot for COPY FROM...CSV

Daniel Verite <daniel@manitou-mail.org>

From: "Daniel Verite" <daniel@manitou-mail.org>
To: "Artur Zakirov" <zaartur@gmail.com>
Cc: Sutou Kouhei <kou@clear-code.com>, tgl@sss.pgh.pa.us, bruce@momjian.us, robertmhaas@gmail.com, pgsql-hackers@postgresql.org
Date: 2024-09-30T19:15:44Z
Lists: pgsql-hackers

Attachments

	Artur Zakirov wrote:

> I've tested the patch and it seems it works as expected.

Thanks for looking at this!

> It seems it isn't necessary to handle "\." within
> "CopyAttributeOutCSV()" (file "src/backend/commands/copyto.c")
> anymore.

It's still useful to produce CSV data that can be safely
reloaded by previous versions.
Until these versions are EOL'ed, I assume we'd better
continue to quote "\."

> Another thing is that the comparison "copystream ==
> pset.cur_cmd_source" happens twice within "handleCopyIn()". TBH it is
> a bit confusing to me what is the real purpose of that check, but one
> of the comparisons looks unnecessary.

Indeed, good catch. The redundant comparison is removed in the
attached v6.


Best regards,
-- 
Daniel Vérité
https://postgresql.verite.pro/
Twitter: @DanielVerite

Commits

  1. Reject a copy EOF marker that has data ahead of it on the same line.

  2. Do not treat \. as an EOF marker in CSV mode for COPY IN.

  3. doc: \copy can get data values \. and end-of-input confused