|
4 | 4 | * (currently mule internal code (mic) is used) |
5 | 5 | * Tatsuo Ishii |
6 | 6 | * |
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 $ |
8 | 8 | */ |
9 | 9 | #include"postgres.h" |
10 | 10 |
|
@@ -305,6 +305,10 @@ pg_convert_to(PG_FUNCTION_ARGS) |
305 | 305 | namein,CStringGetDatum(DatabaseEncoding->name)); |
306 | 306 | Datumresult; |
307 | 307 |
|
| 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 | + */ |
308 | 312 | result=DirectFunctionCall3( |
309 | 313 | pg_convert,string,src_encoding_name,dest_encoding_name); |
310 | 314 |
|
@@ -334,6 +338,12 @@ pg_convert_from(PG_FUNCTION_ARGS) |
334 | 338 | /* free memory allocated by namein */ |
335 | 339 | pfree((void*)src_encoding_name); |
336 | 340 |
|
| 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 | + */ |
337 | 347 | PG_RETURN_TEXT_P(result); |
338 | 348 | } |
339 | 349 |
|
|