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

From Daniel Verite
Subject Re: raw output from copy
Date
Msg-id 0b5a9866-be6d-4f23-8364-2948730e5929@mm
Whole thread Raw
In response to Re: raw output from copy  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: raw output from copy
Re: raw output from copy
List pgsql-hackers
    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)
or the equivalent COPY.
If it's a binary column, that works just the same.

Without this, it's not obvious at all how this result can be
achieved without resorting to external preprocessing,
and assuming the availability of such preprocessing tools
in the environment. Notwithstanding the fact that the
solution proposed on SO (doubling backslashes with sed)
doesn't even work if the file contains tabs, as they would be
interpreted as field separators, even if the copy target has only
one column. You can change the delimiter with COPY but AFAIK
you can't tell that there is none.

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: OOM in libpq and infinite loop with getCopyStart()
Next
From: Alexander Ostrow
Date:
Subject: syntax sugar for conditional check