Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1b14ae

Browse files
committed
Add comments re text <-> bytea internal equivalence in convert routines.
1 parent82467e4 commita1b14ae

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/2414:59:37 adunstan Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.66 2007/09/2416: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
Datumresult;
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)

[8]ページ先頭

©2009-2025 Movatter.jp