Thread: pgsql: Close previously open holes for invalidly encoded data to enter

pgsql: Close previously open holes for invalidly encoded data to enter

From
adunstan@postgresql.org (Andrew Dunstan)
Date:
Log Message:
-----------
Close previously open holes for invalidly encoded data to enter the
database via builtin functions, as recently discussed on -hackers.

chr() now returns a character in the database encoding. For UTF8 encoded databases
the argument is treated as a Unicode code point. For other multi-byte encodings
the argument must designate a strict ascii character, or an error is raised,
as is also the case if the argument is 0.

ascii() is adjusted so that it remains the inverse of chr().

The two argument form of convert() is gone, and the three argument form now
takes a bytea first argument and returns a bytea. To cover this loss three new
functions are introduced:
. convert_from(bytea, name) returns text - converts the first argument from the
  named encoding to the database encoding
. convert_to(text, name) returns bytea - converts the first argument from the
  database encoding to the named encoding
. length(bytea, name) returns int - gives the length of the first argument in
  characters in the named encoding

Modified Files:
--------------
    pgsql/doc/src/sgml:
        func.sgml (r1.395 -> r1.396)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/func.sgml?r1=1.395&r2=1.396)
    pgsql/src/backend/catalog:
        pg_conversion.c (r1.36 -> r1.37)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/catalog/pg_conversion.c?r1=1.36&r2=1.37)
    pgsql/src/backend/utils/adt:
        oracle_compat.c (r1.70 -> r1.71)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/oracle_compat.c?r1=1.70&r2=1.71)
    pgsql/src/backend/utils/mb:
        mbutils.c (r1.63 -> r1.64)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/mb/mbutils.c?r1=1.63&r2=1.64)
        wchar.c (r1.63 -> r1.64)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/mb/wchar.c?r1=1.63&r2=1.64)
    pgsql/src/include/catalog:
        catversion.h (r1.424 -> r1.425)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/catversion.h?r1=1.424&r2=1.425)
        pg_proc.h (r1.469 -> r1.470)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_proc.h?r1=1.469&r2=1.470)
    pgsql/src/include/mb:
        pg_wchar.h (r1.72 -> r1.73)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/mb/pg_wchar.h?r1=1.72&r2=1.73)
    pgsql/src/include/utils:
        builtins.h (r1.302 -> r1.303)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/builtins.h?r1=1.302&r2=1.303)