Skip to content

Commit 3be2448

Browse files
committed
Add an explicit caution about how to use pg_do_encoding_conversion with
non-null-terminated input. Per discussion with ITAGAKI Takahiro.
1 parent a4917be commit 3be2448

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/backend/utils/mb/mbutils.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* (currently mule internal code (mic) is used)
55
* Tatsuo Ishii
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.74 2008/11/10 15:18:40 tgl Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.75 2008/11/11 03:01:20 tgl Exp $
88
*/
99
#include "postgres.h"
1010

@@ -221,8 +221,14 @@ pg_get_client_encoding_name(void)
221221
* it's taken from pg_catalog schema. If it even is not in the schema,
222222
* warn and return src.
223223
*
224+
* If conversion occurs, a palloc'd null-terminated string is returned.
224225
* In the case of no conversion, src is returned.
225226
*
227+
* CAUTION: although the presence of a length argument means that callers
228+
* can pass non-null-terminated strings, care is required because the same
229+
* string will be passed back if no conversion occurs. Such callers *must*
230+
* check whether result == src and handle that case differently.
231+
*
226232
* Note: we try to avoid raising error, since that could get us into
227233
* infinite recursion when this function is invoked during error message
228234
* sending. It should be OK to raise error for overlength strings though,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy