]> granicus.if.org Git - postgresql/commit
Fix encode(...bytea..., 'escape') so that it converts all high-bit-set byte
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 26 Feb 2008 02:54:08 +0000 (02:54 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 26 Feb 2008 02:54:08 +0000 (02:54 +0000)
commitfd15dba543247eb1ce879d22632b9fdb4c230831
tree0473586a70e4c7527f3444b59799407573bd7cf0
parentbc93919be787ac33fb5c35ae1cfdc1bfa54e2c5c
Fix encode(...bytea..., 'escape') so that it converts all high-bit-set byte
values into \nnn octal escape sequences.  When the database encoding is
multibyte this is *necessary* to avoid generating invalidly encoded text.
Even in a single-byte encoding, the old behavior seems very hazardous ---
consider for example what happens if the text is transferred to another
database with a different encoding.  Decoding would then yield some other
bytea value than what was encoded, which is surely undesirable.  Per gripe
from Hernan Gonzalez.

Backpatch to 8.3, but not further.  This is a bit of a judgment call, but I
make it on these grounds: pre-8.3 we don't really have much encoding safety
anyway because of the convert() function family, and we would also have much
higher risk of breaking existing apps that may not be expecting this behavior.
8.3 is still new enough that we can probably get away with making this change
in the function's behavior.
src/backend/utils/adt/encode.c