Re: COPY complaining about unquoted carriage return found in data... in a quoted field

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: COPY complaining about unquoted carriage return found in data... in a quoted field
Date: 2011-05-10 13:59:07
Message-ID: 20110510155907.0f92e3f0@dawn.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 10 May 2011 14:38:23 +0200
Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:

> Hello
>
> COPY doesn't like '\n' too.
>
> Replace '\n' by '\\n'

mmm maybe you were mislead by the "semi-transliterated" hexdump.

There is no "slash" in the record, the actual input was the one
reported in hex. The following line was just to help reading the
hexdump.

09 22 56 | 69 61 20 46 | 61 65 6E 74 | 69 6E 61 2C
20 35 33 0D | 0A 22 09 22 | 35 30 30 31 | 34 22 09

as a quick reference:
0x09 = \t
0x0a = \n
0x0d = \r
0x20 = space
0x22 = "

I thought that

csv
quote as '"'

where there exactly to avoid escaping of delimiters (other than
the quoting character itself) inside fields.

From the docs:
http://www.postgresql.org/docs/8.3/static/sql-copy.html
«If the value contains the delimiter character, the QUOTE character,
the NULL string, a carriage return, or line feed character, then the
whole value is prefixed and suffixed by the QUOTE character, and any
occurrence within the value of a QUOTE character or the ESCAPE
character is preceded by the escape character.»

So up to my understanding once I've "quoted" a field I've to take
care of escaping just the quote and the escape characters and the
field may contain delimiter characters (field separator and record
separator) without escaping.

I was wondering if a) the documentation is wrong b) I didn't write a
correct \COPY command string c) there is a bug d) I can't correctly
interpret the documentation e) I'm more stupid then usual

thanks

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2011-05-10 14:01:42 Re: PGA
Previous Message salah jubeh 2011-05-10 13:53:11 PGA