Add comments re text <-> bytea internal equivalence in convert routines.
This commit is contained in:
parent
82467e4e70
commit
a1b14ae1dd
@ -4,7 +4,7 @@
|
|||||||
* (currently mule internal code (mic) is used)
|
* (currently mule internal code (mic) is used)
|
||||||
* Tatsuo Ishii
|
* Tatsuo Ishii
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.65 2007/09/24 14:59:37 adunstan Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.66 2007/09/24 16:38:24 adunstan Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
@ -305,6 +305,10 @@ pg_convert_to(PG_FUNCTION_ARGS)
|
|||||||
namein, CStringGetDatum(DatabaseEncoding->name));
|
namein, CStringGetDatum(DatabaseEncoding->name));
|
||||||
Datum result;
|
Datum result;
|
||||||
|
|
||||||
|
/* pg_convert expects a bytea as its first argument. We're passing it
|
||||||
|
* a text argument here, relying on the fact that they are both in fact
|
||||||
|
* varlena types, and thus structurally identical.
|
||||||
|
*/
|
||||||
result = DirectFunctionCall3(
|
result = DirectFunctionCall3(
|
||||||
pg_convert, string, src_encoding_name, dest_encoding_name);
|
pg_convert, string, src_encoding_name, dest_encoding_name);
|
||||||
|
|
||||||
@ -334,6 +338,12 @@ pg_convert_from(PG_FUNCTION_ARGS)
|
|||||||
/* free memory allocated by namein */
|
/* free memory allocated by namein */
|
||||||
pfree((void *) src_encoding_name);
|
pfree((void *) src_encoding_name);
|
||||||
|
|
||||||
|
/* pg_convert returns a bytea, which we in turn return as text, relying
|
||||||
|
* on the fact that they are both in fact varlena types, and thus
|
||||||
|
* structurally identical. Although not all bytea values are valid text,
|
||||||
|
* in this case it will be because we've told pg_convert to return one
|
||||||
|
* that is valid as text in the current database encoding.
|
||||||
|
*/
|
||||||
PG_RETURN_TEXT_P(result);
|
PG_RETURN_TEXT_P(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user