pgsql: Plug some more holes in encoding conversion. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Plug some more holes in encoding conversion.
Date
Msg-id E1WHfZh-0000sp-Jb@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Plug some more holes in encoding conversion.

Various places assume that pg_do_encoding_conversion() and
pg_server_to_any() will ensure encoding validity of their results;
but they failed to do so in the case that the source encoding is SQL_ASCII
while the destination is not.  We cannot perform any actual "conversion"
in that scenario, but we should still validate the string according to the
destination encoding.  Per bug #9210 from Digoal Zhou.

Arguably this is a back-patchable bug fix, but on the other hand adding
more enforcing of encoding checks might break existing applications that
were being sloppy.  On balance there doesn't seem to be much enthusiasm
for a back-patch, so fix in HEAD only.

While at it, remove some apparently-no-longer-needed provisions for
letting pg_do_encoding_conversion() "work" outside a transaction ---
if you consider it "working" to silently fail to do the requested
conversion.

Also, make a few cosmetic improvements in mbutils.c, notably removing
some Asserts that are certainly dead code since the variables they
assert aren't null are never null, even at process start.  (I think
this wasn't true at one time, but it is now.)

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/49c817eab78c6f0ce8c3bf46766b73d6cf3190b7

Modified Files
--------------
src/backend/utils/mb/mbutils.c |  205 +++++++++++++++++++++++-----------------
1 file changed, 117 insertions(+), 88 deletions(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: configure.in: Use dnl in place of # where appropriate
Next
From: Tom Lane
Date:
Subject: pgsql: Prefer pg_any_to_server/pg_server_to_any over pg_do_encoding_con