]> granicus.if.org Git - postgresql/commit
Fix COPY FROM for null marker strings that correspond to invalid encoding.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 26 Mar 2012 03:17:22 +0000 (23:17 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 26 Mar 2012 03:17:22 +0000 (23:17 -0400)
commite8476f46fc847060250c92ec9b310559293087fc
treeb1287139787799f8de1090a2f1b4e7b7c799c0d8
parentc7cea267de3ca05b29a57b9d113b95ef3793c8d8
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.
src/backend/commands/copy.c
src/test/regress/expected/copy2.out
src/test/regress/sql/copy2.sql