diff options
author | Tom Lane | 2008-11-11 03:01:20 +0000 |
---|---|---|
committer | Tom Lane | 2008-11-11 03:01:20 +0000 |
commit | 3be2448525e9b66205bfcb0ebfeca54137a0cada (patch) | |
tree | 3e1101103f574f72986f4e255a4767e19c6011da /src | |
parent | a4917bef0ead2424bf0c2eeb05dfb681dff33574 (diff) |
Add an explicit caution about how to use pg_do_encoding_conversion with
non-null-terminated input. Per discussion with ITAGAKI Takahiro.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/mb/mbutils.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index 678989a0c0f..6465afa1049 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -4,7 +4,7 @@ * (currently mule internal code (mic) is used) * Tatsuo Ishii * - * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.74 2008/11/10 15:18:40 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.75 2008/11/11 03:01:20 tgl Exp $ */ #include "postgres.h" @@ -221,8 +221,14 @@ pg_get_client_encoding_name(void) * it's taken from pg_catalog schema. If it even is not in the schema, * warn and return src. * + * If conversion occurs, a palloc'd null-terminated string is returned. * In the case of no conversion, src is returned. * + * CAUTION: although the presence of a length argument means that callers + * can pass non-null-terminated strings, care is required because the same + * string will be passed back if no conversion occurs. Such callers *must* + * check whether result == src and handle that case differently. + * * Note: we try to avoid raising error, since that could get us into * infinite recursion when this function is invoked during error message * sending. It should be OK to raise error for overlength strings though, |