From: Jeff Davis <pgsql@j-davis.com>
To: pgsql-bugs@postgresql.org
Subject: possible bug in COPY ... FROM ... NULL '\0'
Date: Sun, 25 Mar 2012 16:55:09 -0700
Message-ID: <1332719709.8251.47.camel@jdavis> (raw)
The documentation says:
"The specified null string is sent by COPY TO without adding any
backslashes; conversely, COPY FROM matches the input against the null
string before removing backslashes."
-- http://www.postgresql.org/docs/devel/static/sql-copy.html
Those seem inconsistent with the following behavior:
postgres=# copy foo to '/tmp/a.copy' null '\0';
COPY 2
postgres=# copy foo from '/tmp/a.copy' null '\0';
ERROR: invalid byte sequence for encoding "UTF8": 0x00
CONTEXT: COPY foo, line 2: "\0"
$ cat /tmp/a.copy
1
\0
COPY TO seems to follow the documentation, inserting the null string
without modification into the output file. COPY FROM seems to de-escape
the input before trying to match it against the null string, leading to
the invalid byte sequence.
standard_conforming_strings is on.
Regards,
Jeff Davis
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: pgsql@j-davis.com
Subject: Re: possible bug in COPY ... FROM ... NULL '\0'
In-Reply-To: <1332719709.8251.47.camel@jdavis>
References: <1332719709.8251.47.camel@jdavis>
* 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