Skip to content

Commit a1b14ae

Browse files
committed
Add comments re text <-> bytea internal equivalence in convert routines.
1 parent 82467e4 commit a1b14ae

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/backend/utils/mb/mbutils.c

Lines changed: 11 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.65 2007/09/24 14:59:37 adunstan Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.66 2007/09/24 16:38:24 adunstan Exp $
88
*/
99
#include "postgres.h"
1010

@@ -305,6 +305,10 @@ pg_convert_to(PG_FUNCTION_ARGS)
305305
namein, CStringGetDatum(DatabaseEncoding->name));
306306
Datum result;
307307

308+
/* pg_convert expects a bytea as its first argument. We're passing it
309+
* a text argument here, relying on the fact that they are both in fact
310+
* varlena types, and thus structurally identical.
311+
*/
308312
result = DirectFunctionCall3(
309313
pg_convert, string, src_encoding_name, dest_encoding_name);
310314

@@ -334,6 +338,12 @@ pg_convert_from(PG_FUNCTION_ARGS)
334338
/* free memory allocated by namein */
335339
pfree((void *) src_encoding_name);
336340

341+
/* pg_convert returns a bytea, which we in turn return as text, relying
342+
* on the fact that they are both in fact varlena types, and thus
343+
* structurally identical. Although not all bytea values are valid text,
344+
* in this case it will be because we've told pg_convert to return one
345+
* that is valid as text in the current database encoding.
346+
*/
337347
PG_RETURN_TEXT_P(result);
338348
}
339349

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