Re: raw output from copy

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
Cc: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>,"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>,"hlinnaka" <hlinnaka(at)iki(dot)fi>,"PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>,"Simon Riggs" <simon(at)2ndquadrant(dot)com>,"Pavel Golub" <pavel(at)microolap(dot)com>,"Craig Ringer" <craig(at)2ndquadrant(dot)com>
Subject: Re: raw output from copy
Date: 2016-04-01 15:42:42
Message-ID: 0b5a9866-be6d-4f23-8364-2948730e5929@mm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Teodor Sigaev 2016-04-01 15:44:03 Re: pgsql: Bloom index contrib module
Previous Message Tom Lane 2016-04-01 15:30:15 Re: OOM in libpq and infinite loop with getCopyStart()