Re: BUG #7611: \copy (and COPY?) incorrectly parses nul character for windows-1252

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: sams(dot)james+postgres(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #7611: \copy (and COPY?) incorrectly parses nul character for windows-1252
Date: 2012-10-18 17:57:04
Message-ID: 1601.1350583024@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

sams(dot)james+postgres(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Dave Vitek 2012-10-18 19:05:26 Re: Fwd: race in pg_ctl start -w
Previous Message Fujii Masao 2012-10-18 16:48:31 Re: BUG #7534: walreceiver takes long time to detect n/w breakdown