Обсуждение: Re: [GENERAL] Good Delimiter for copy command

Поиск
Список
Период
Сортировка

Re: [GENERAL] Good Delimiter for copy command

От
David Fetter
Дата:
On Tue, Feb 17, 2009 at 05:17:40PM +0100, Marco Colombo wrote:
> Tom Lane wrote:
> > Andrew Gould <andrewlylegould@gmail.com> writes:
> >> To the list:  Does pg_dump escape characters that are the same as the
> >> delimiter?
> >
> > Yes.  The OP has not actually explained why he needs to pick a
> > nondefault delimiter, unless maybe it is that he wants to feed the
> > dump to some program that is too dumb to deal with escaping.
> >
> >             regards, tom lane
> >
>
> Which makes me wonder, does copy accept UTF-8 input?

Yes, but...

> Is it possibile to use some unicode character which is unlikely to
> appear in the data set as delimiter? Something like U+FFFC.

No.  The delimiter needs to be one byte long at the moment.  The error
message you're getting probably needs an update.  Bug?

> $ psql -c "\copy test from '2.txt' delimiter ●"
> ERROR:  COPY delimiter must be a single character
> \copy: ERROR:  COPY delimiter must be a single character

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Re: [GENERAL] Good Delimiter for copy command

От
Tom Lane
Дата:
David Fetter <david@fetter.org> writes:
> On Tue, Feb 17, 2009 at 05:17:40PM +0100, Marco Colombo wrote:
>> Is it possibile to use some unicode character which is unlikely to
>> appear in the data set as delimiter? Something like U+FFFC.

> No.  The delimiter needs to be one byte long at the moment.  The error
> message you're getting probably needs an update.  Bug?

>> $ psql -c "\copy test from '2.txt' delimiter ●"
>> ERROR:  COPY delimiter must be a single character
>> \copy: ERROR:  COPY delimiter must be a single character

In 8.3 and CVS HEAD these messages are phrased as "must be a single
ASCII character" which I suppose is someone's attempt at improving the
situation; but IMHO this has replaced an imprecision with a lie.  It
works fine with non-ASCII characters, if you're working in a single-byte
encoding (eg LATIN-n).

I think it should say "must be a single one-byte character" and not try
to talk down to the reader.

            regards, tom lane