diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2007-09-18 17:41:17 +0000 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2007-09-18 17:41:17 +0000 |
commit | 55613bf9cd7d6071e43e68ac14bc0243a1027507 (patch) | |
tree | 9b151f94d94e7dc3aa5988c03867d3f6f6b562ba /src/backend/catalog/pg_conversion.c | |
parent | 8544110042ddf8be29e177e37f53516686a06da2 (diff) | |
download | postgresql-55613bf9cd7d6071e43e68ac14bc0243a1027507.tar.gz |
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
Diffstat (limited to 'src/backend/catalog/pg_conversion.c')
-rw-r--r-- | src/backend/catalog/pg_conversion.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/catalog/pg_conversion.c b/src/backend/catalog/pg_conversion.c index 262d9f41fb..7146d0b4f5 100644 --- a/src/backend/catalog/pg_conversion.c +++ b/src/backend/catalog/pg_conversion.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_conversion.c,v 1.36 2007/02/27 23:48:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_conversion.c,v 1.37 2007/09/18 17:41:17 adunstan Exp $ * *------------------------------------------------------------------------- */ @@ -282,7 +282,10 @@ FindConversion(const char *conname, Oid connamespace) * CONVERT <left paren> <character value expression> * USING <form-of-use conversion name> <right paren> * - * TEXT convert_using(TEXT string, TEXT conversion_name) + * BYTEA convert_using(TEXT string, TEXT conversion_name) + * + * bytea is returned so we don't give a value that is + * not valid in the database encoding. */ Datum pg_convert_using(PG_FUNCTION_ARGS) @@ -344,5 +347,5 @@ pg_convert_using(PG_FUNCTION_ARGS) pfree(result); pfree(str); - PG_RETURN_TEXT_P(retval); + PG_RETURN_BYTEA_P(retval); } |