Add an explicit caution about how to use pg_do_encoding_conversion with
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 11 Nov 2008 03:01:20 +0000 (03:01 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 11 Nov 2008 03:01:20 +0000 (03:01 +0000)
non-null-terminated input.  Per discussion with ITAGAKI Takahiro.

src/backend/utils/mb/mbutils.c

index e45218a15c2e9db40d98738edfdc8bfdec14ebe9..efe3942fb0547201818dcb88a75f00f18c5d35f6 100644 (file)
@@ -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,