Close previously open holes for invalidly encoded data to enter the
authorAndrew Dunstan <andrew@dunslane.net>
Tue, 18 Sep 2007 17:41:17 +0000 (17:41 +0000)
committerAndrew Dunstan <andrew@dunslane.net>
Tue, 18 Sep 2007 17:41:17 +0000 (17:41 +0000)
commit2b1fa869fa54c5c74c8bf81308ffc3283c7c12a8
tree7fecc93edb941149bf8d407790e2cd0135cd630f
parentbf590f537fcdf304d02c9ca082f38c4589416a28
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
doc/src/sgml/func.sgml
src/backend/catalog/pg_conversion.c
src/backend/utils/adt/oracle_compat.c
src/backend/utils/mb/mbutils.c
src/backend/utils/mb/wchar.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h
src/include/mb/pg_wchar.h
src/include/utils/builtins.h