pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: sams.james+postgres@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #7611: \copy (and COPY?) incorrectly parses nul character for windows-1252
Date: Thu, 18 Oct 2012 13:57:04 -0400
Message-ID: <1601.1350583024@sss.pgh.pa.us> (raw)
In-Reply-To: <E1TOjc5-0001lZ-5m@wrigleys.postgresql.org>
References: <E1TOjc5-0001lZ-5m@wrigleys.postgresql.org>

sams.james+postgres@gmail.com writes:
> 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

Postgres doesn't support nul characters in data, so the best you could
hope for here is an error message anyway.  It looks to me like the
immediate cause of this is that \copy reads the file with fgets()
which will effectively ignore the rest of the line after a nul byte.
But there are probably more issues downstream.

			regards, tom lane




view thread (2+ messages)

Message-ID: <1601.1350583024@sss.pgh.pa.us>
Permalink:  ../1601.1350583024@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1601.1350583024@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, sams.james+postgres@gmail.com
  Subject: Re: BUG #7611: \copy (and COPY?) incorrectly parses nul character for windows-1252
  In-Reply-To: <1601.1350583024@sss.pgh.pa.us>
  References: <E1TOjc5-0001lZ-5m@wrigleys.postgresql.org> <1601.1350583024@sss.pgh.pa.us>

* 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