Re: backslash-dot quoting in COPY CSV

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Daniel Verite <daniel(at)manitou-mail(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: backslash-dot quoting in COPY CSV
Date: 2019-01-27 13:10:36
Message-ID: 20190127131036.GC4672@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jan 24, 2019 at 10:09:30PM -0500, Bruce Momjian wrote:
> This seems like a bug to me. Looking at the code, psql issues the
> prompts for STDIN, but when it sees \. alone on a line, it has no idea
> you are in a quoted CSV string, so it thinks the copy is done and sends
> the result to the server. I can't see an easy way to fix this. I guess
> we could document it.

In src/bin/psql/copy.c, handleCopyIn():

/*
* This code erroneously assumes '\.' on a line alone
* inside a quoted CSV string terminates the \copy.
* http://www.postgresql.org/message-id/E1TdNVQ-0001ju-GO@wrigleys.postgresql.org
*/
if (strcmp(buf, "\\.\n") == 0 ||
strcmp(buf, "\\.\r\n") == 0)
{
copydone = true;
break;
}

This story pops up from time to time..
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Gierth 2019-01-27 13:22:57 Re: Early WIP/PoC for inlining CTEs
Previous Message Michael Paquier 2019-01-27 12:58:57 Re: pg_basebackup, walreceiver and wal_sender_timeout