pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: sams.james+postgres@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #7611: \copy (and COPY?) incorrectly parses nul character for windows-1252
Date: Thu, 18 Oct 2012 06:29:49 +0000
Message-ID: <E1TOjc5-0001lZ-5m@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      7611
Logged by:          James
Email address:      sams.james+postgres@gmail.com
PostgreSQL version: 9.1.6
Operating system:   Ubuntu Linux 12.04
Description:        

I have a file with several nul characters in it. The file itself appears to
be encoded as windows-1252, though I am not 100% certain of that. I do know
that other software (e.g. Python) can decode the data as windows-1252
without issue. Postgres's \copy, however, chokes on the nul byte:

ERROR:  unterminated CSV quoted field
CONTEXT:  COPY promo_nonactive_load_fake, line 239900

Note that the error is wrong, the field is quoted but postgres seems to jump
forward in the file when it encounters the nul bytes.

Further, the line number is wrong. That is the length of the file (in
lines), not the line on which the error occurs, which is several hundred
lines before this.

Deleting the nul byte characters allowed copy to proceed normally. I
experienced similar issues with psycopg2 and copy_expert using COPY FROM
STDIN and this file.





view thread (2+ messages)  latest in thread

Message-ID: <E1TOjc5-0001lZ-5m@wrigleys.postgresql.org>
Permalink:  ../E1TOjc5-0001lZ-5m@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1TOjc5-0001lZ-5m@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: sams.james+postgres@gmail.com
  Subject: Re: BUG #7611: \copy (and COPY?) incorrectly parses nul character for windows-1252
  In-Reply-To: <E1TOjc5-0001lZ-5m@wrigleys.postgresql.org>
  References: <E1TOjc5-0001lZ-5m@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox