Re: raw output from copy - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: raw output from copy
Date
Msg-id CAKFQuwbJUVYkdbcOZh0zCCU73M_5t+Eix9UHVn-2+baBJ_Uj+A@mail.gmail.com
Whole thread Raw
In response to Re: raw output from copy  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-hackers
On Fri, Apr 1, 2016 at 8:42 AM, Daniel Verite <daniel@manitou-mail.org> wrote:
        Andrew Dunstan wrote:

> If someone can make a good case that this is going to be of
> general use I'll happily go along, but I haven't seen one so far.

About COPY FROM with a raw format, for instance just yesterday
there was this user question on stackoverflow:
http://stackoverflow.com/questions/36317237

which essentially is: how to import contents from a file without any
particular interpretation of any character?

With the patch discussed in this thread, a user can do
\copy table(textcol) from /path/to/file (format raw)

​What is needed to solve this specific use-case is a way to specify "QUOTE NONE" instead of the default for whatever format is being hijacked:

​COPY file_content FROM '/tmp/textfile.txt' WITH (FORMAT csv, QUOTE E'<unprintable character that should never appear in the data>');

becomes

COPY file_content FROM '/tmp/textfile.txt' WITH (FORMAT csv, QUOTE NONE);

​Or maybe: "WITH (FORMAT single_column)"

Though maybe that doesn't extend well to unencoded binary data...which seems like it can be considered a separate problem from reliably importing an entire file into a single row+column in a table.

David J.


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: raw output from copy
Next
From: Robert Haas
Date:
Subject: Re: SSL indicator in psql prompt