Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TOjcD-0007Ps-Vt for pgsql-bugs@postgresql.org; Thu, 18 Oct 2012 06:29:58 +0000 Received: from mahout.postgresql.org ([98.129.198.123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TOjc7-0002vb-15 for pgsql-bugs@postgresql.org; Thu, 18 Oct 2012 06:29:57 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TOjc5-0007nu-Lx for pgsql-bugs@postgresql.org; Thu, 18 Oct 2012 06:29:50 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1TOjc5-0001lZ-5m for pgsql-bugs@postgresql.org; Thu, 18 Oct 2012 06:29:49 +0000 Date: Thu, 18 Oct 2012 06:29:49 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #7611: \copy (and COPY?) incorrectly parses nul character for windows-1252 To: pgsql-bugs@postgresql.org From: sams.james+postgres@gmail.com X-Pg-Spam-Score: -1.4 (-) X-Archive-Number: 201210/181 X-Sequence-Number: 34481 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.