Skip site navigation (1) Skip section navigation (2)

pgsql: Fix COPY FROM for null marker strings that correspond toinvalid

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix COPY FROM for null marker strings that correspond toinvalid
Date: 2012-03-26 03:18:08
Message-ID: E1SC0Rc-00026h-VH@gemulon.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Fix COPY FROM for null marker strings that correspond to invalid encoding.

The COPY documentation says "COPY FROM matches the input against the null
string before removing backslashes".  It is therefore reasonable to presume
that null markers like E'\\0' will work ... and they did, until someone put
the tests in the wrong order during microoptimization-driven rewrites.
Since then, we've been failing if the null marker is something that would
de-escape to an invalidly-encoded string.  Since null markers generally
need to be something that can't appear in the data, this represents a
nontrivial loss of functionality; surprising nobody noticed it earlier.

Per report from Jeff Davis.  Backpatch to 8.4 where this got broken.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/9f0a01707607e476ac3a89854777cdba76e0ff37

Modified Files
--------------
src/backend/commands/copy.c         |   45 ++++++++++++++++++++++------------
src/test/regress/expected/copy2.out |   16 ++++++++++++
src/test/regress/sql/copy2.sql      |   15 +++++++++++
3 files changed, 60 insertions(+), 16 deletions(-)

pgsql-committers by date

Next:From: Tom LaneDate: 2012-03-26 03:18:09
Subject: pgsql: Fix COPY FROM for null marker strings that correspond toinvalid
Previous:From: Tom LaneDate: 2012-03-26 01:47:30
Subject: pgsql: Replace empty locale name with implied value in CREATEDATABASE

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group