From 45173ae24e308061c008f77996f3edbebe0e4dc2 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 4 May 2008 16:42:41 +0000 Subject: Use new cstring/text conversion functions in some additional places. These changes assume that the varchar and xml data types are represented the same as text. (I did not, however, accept the portions of the proposed patch that wanted to assume bytea is the same as text --- tgl.) Brendan Jurd --- src/backend/utils/adt/varchar.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/backend/utils/adt/varchar.c') diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 49ce0ef4d69..ad48f564c5b 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.127 2008/03/25 22:42:44 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.128 2008/05/04 16:42:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -566,7 +566,6 @@ varchar(PG_FUNCTION_ARGS) VarChar *source = PG_GETARG_VARCHAR_PP(0); int32 typmod = PG_GETARG_INT32(1); bool isExplicit = PG_GETARG_BOOL(2); - VarChar *result; int32 len, maxlen; size_t maxmblen; @@ -596,11 +595,8 @@ varchar(PG_FUNCTION_ARGS) maxlen))); } - result = palloc(maxmblen + VARHDRSZ); - SET_VARSIZE(result, maxmblen + VARHDRSZ); - memcpy(VARDATA(result), s_data, maxmblen); - - PG_RETURN_VARCHAR_P(result); + PG_RETURN_VARCHAR_P((VarChar *) cstring_to_text_with_len(s_data, + maxmblen)); } Datum -- cgit v1.2.3