diff options
Diffstat (limited to 'src/backend/utils/adt')
35 files changed, 201 insertions, 200 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index c9f9a07f230..0865c7f0d60 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.137 2007/01/05 22:19:39 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.138 2007/02/27 23:48:07 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -353,7 +353,7 @@ allocacl(int n) elog(ERROR, "invalid size: %d", n); size = ACL_N_SIZE(n); new_acl = (Acl *) palloc0(size); - new_acl->size = size; + SET_VARSIZE(new_acl, size); new_acl->ndim = 1; new_acl->dataoffset = 0; /* we never put in any nulls */ new_acl->elemtype = ACLITEMOID; @@ -716,8 +716,9 @@ aclupdate(const Acl *old_acl, const AclItem *mod_aip, memmove(new_aip + dst, new_aip + dst + 1, (num - dst - 1) * sizeof(AclItem)); + /* Adjust array size to be 'num - 1' items */ ARR_DIMS(new_acl)[0] = num - 1; - ARR_SIZE(new_acl) -= sizeof(AclItem); + SET_VARSIZE(new_acl, ACL_N_SIZE(num - 1)); } /* @@ -830,7 +831,7 @@ aclnewowner(const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId) } /* Adjust array size to be 'dst' items */ ARR_DIMS(new_acl)[0] = dst; - ARR_SIZE(new_acl) = ACL_N_SIZE(dst); + SET_VARSIZE(new_acl, ACL_N_SIZE(dst)); } return new_acl; diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c index 1dad5210156..0745f1e1d2a 100644 --- a/src/backend/utils/adt/array_userfuncs.c +++ b/src/backend/utils/adt/array_userfuncs.c @@ -6,7 +6,7 @@ * Copyright (c) 2003-2007, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.21 2007/01/05 22:19:39 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.22 2007/02/27 23:48:07 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -376,7 +376,7 @@ array_cat(PG_FUNCTION_ARGS) nbytes = ndatabytes + ARR_OVERHEAD_NONULLS(ndims); } result = (ArrayType *) palloc(nbytes); - result->size = nbytes; + SET_VARSIZE(result, nbytes); result->ndim = ndims; result->dataoffset = dataoffset; result->elemtype = element_type; diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 525d94e1ecd..43acdffcaf0 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.136 2007/01/05 22:19:39 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.137 2007/02/27 23:48:07 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -324,7 +324,7 @@ array_in(PG_FUNCTION_ARGS) nbytes += ARR_OVERHEAD_NONULLS(ndim); } retval = (ArrayType *) palloc(nbytes); - retval->size = nbytes; + SET_VARSIZE(retval, nbytes); retval->ndim = ndim; retval->dataoffset = dataoffset; retval->elemtype = element_type; @@ -1279,7 +1279,7 @@ array_recv(PG_FUNCTION_ARGS) nbytes += ARR_OVERHEAD_NONULLS(ndim); } retval = (ArrayType *) palloc(nbytes); - retval->size = nbytes; + SET_VARSIZE(retval, nbytes); retval->ndim = ndim; retval->dataoffset = dataoffset; retval->elemtype = element_type; @@ -1573,7 +1573,7 @@ array_dims(PG_FUNCTION_ARGS) sprintf(p, "[%d:%d]", lb[i], dimv[i] + lb[i] - 1); p += strlen(p); } - VARATT_SIZEP(result) = strlen(VARDATA(result)) + VARHDRSZ; + SET_VARSIZE(result, strlen(VARDATA(result)) + VARHDRSZ); PG_RETURN_TEXT_P(result); } @@ -1879,7 +1879,7 @@ array_get_slice(ArrayType *array, } newarray = (ArrayType *) palloc(bytes); - newarray->size = bytes; + SET_VARSIZE(newarray, bytes); newarray->ndim = ndim; newarray->dataoffset = dataoffset; newarray->elemtype = elemtype; @@ -2132,7 +2132,7 @@ array_set(ArrayType *array, * OK, create the new array and fill in header/dimensions */ newarray = (ArrayType *) palloc(newsize); - newarray->size = newsize; + SET_VARSIZE(newarray, newsize); newarray->ndim = ndim; newarray->dataoffset = newhasnulls ? overheadlen : 0; newarray->elemtype = ARR_ELEMTYPE(array); @@ -2458,7 +2458,7 @@ array_set_slice(ArrayType *array, newsize = overheadlen + olddatasize - olditemsize + newitemsize; newarray = (ArrayType *) palloc(newsize); - newarray->size = newsize; + SET_VARSIZE(newarray, newsize); newarray->ndim = ndim; newarray->dataoffset = newhasnulls ? overheadlen : 0; newarray->elemtype = ARR_ELEMTYPE(array); @@ -2717,7 +2717,7 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType, nbytes += ARR_OVERHEAD_NONULLS(ndim); } result = (ArrayType *) palloc(nbytes); - result->size = nbytes; + SET_VARSIZE(result, nbytes); result->ndim = ndim; result->dataoffset = dataoffset; result->elemtype = retType; @@ -2853,7 +2853,7 @@ construct_md_array(Datum *elems, nbytes += ARR_OVERHEAD_NONULLS(ndims); } result = (ArrayType *) palloc(nbytes); - result->size = nbytes; + SET_VARSIZE(result, nbytes); result->ndim = ndims; result->dataoffset = dataoffset; result->elemtype = elmtype; @@ -2877,7 +2877,7 @@ construct_empty_array(Oid elmtype) ArrayType *result; result = (ArrayType *) palloc(sizeof(ArrayType)); - result->size = sizeof(ArrayType); + SET_VARSIZE(result, sizeof(ArrayType)); result->ndim = 0; result->dataoffset = 0; result->elemtype = elmtype; diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index d04f3d38c22..06dc4fec8c0 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -13,7 +13,7 @@ * this version handles 64 bit numbers and so can hold values up to * $92,233,720,368,547,758.07. * - * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.69 2007/01/03 01:19:50 darcy Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.70 2007/02/27 23:48:07 tgl Exp $ */ #include "postgres.h" @@ -860,7 +860,7 @@ cash_words(PG_FUNCTION_ARGS) /* make a text type for output */ result = (text *) palloc(strlen(buf) + VARHDRSZ); - VARATT_SIZEP(result) = strlen(buf) + VARHDRSZ; + SET_VARSIZE(result, strlen(buf) + VARHDRSZ); memcpy(VARDATA(result), buf, strlen(buf)); PG_RETURN_TEXT_P(result); diff --git a/src/backend/utils/adt/char.c b/src/backend/utils/adt/char.c index 2ed8172c4ee..489c4673a4e 100644 --- a/src/backend/utils/adt/char.c +++ b/src/backend/utils/adt/char.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/char.c,v 1.46 2007/01/05 22:19:40 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/char.c,v 1.47 2007/02/27 23:48:07 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -203,11 +203,11 @@ char_text(PG_FUNCTION_ARGS) */ if (arg1 != '\0') { - VARATT_SIZEP(result) = VARHDRSZ + 1; + SET_VARSIZE(result, VARHDRSZ + 1); *(VARDATA(result)) = arg1; } else - VARATT_SIZEP(result) = VARHDRSZ; + SET_VARSIZE(result, VARHDRSZ); PG_RETURN_TEXT_P(result); } diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index c3a6415634b..bdda749bed0 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.128 2007/02/16 03:39:44 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.129 2007/02/27 23:48:07 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -891,8 +891,8 @@ date_text(PG_FUNCTION_ARGS) result = palloc(len); - VARATT_SIZEP(result) = len; - memmove(VARDATA(result), str, (len - VARHDRSZ)); + SET_VARSIZE(result, len); + memcpy(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); @@ -1634,8 +1634,8 @@ time_text(PG_FUNCTION_ARGS) result = palloc(len); - VARATT_SIZEP(result) = len; - memmove(VARDATA(result), str, (len - VARHDRSZ)); + SET_VARSIZE(result, len); + memcpy(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); @@ -2420,8 +2420,8 @@ timetz_text(PG_FUNCTION_ARGS) result = palloc(len); - VARATT_SIZEP(result) = len; - memmove(VARDATA(result), str, (len - VARHDRSZ)); + SET_VARSIZE(result, len); + memcpy(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c index 40963bc2b99..21e7cc55412 100644 --- a/src/backend/utils/adt/datum.c +++ b/src/backend/utils/adt/datum.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/datum.c,v 1.33 2007/01/05 22:19:40 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datum.c,v 1.34 2007/02/27 23:48:07 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -79,7 +79,7 @@ datumGetSize(Datum value, bool typByVal, int typLen) (errcode(ERRCODE_DATA_EXCEPTION), errmsg("invalid Datum pointer"))); - size = (Size) VARATT_SIZE(s); + size = (Size) VARSIZE(s); } else if (typLen == -2) { diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index dcb84a7d249..6df746c38eb 100644 --- a/src/backend/utils/adt/dbsize.c +++ b/src/backend/utils/adt/dbsize.c @@ -5,7 +5,7 @@ * Copyright (c) 2002-2007, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.10 2007/01/05 22:19:40 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.11 2007/02/27 23:48:07 tgl Exp $ * */ @@ -396,7 +396,7 @@ pg_size_pretty(PG_FUNCTION_ARGS) } } - VARATT_SIZEP(result) = strlen(VARDATA(result)) + VARHDRSZ; + SET_VARSIZE(result, strlen(VARDATA(result)) + VARHDRSZ); PG_RETURN_TEXT_P(result); } diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c index c092e7ec3a3..3d753e9a6cf 100644 --- a/src/backend/utils/adt/encode.c +++ b/src/backend/utils/adt/encode.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/encode.c,v 1.18 2007/01/05 22:19:40 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/encode.c,v 1.19 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -63,7 +63,7 @@ binary_encode(PG_FUNCTION_ARGS) if (res > resultlen) elog(FATAL, "overflow - encode estimate too small"); - VARATT_SIZEP(result) = VARHDRSZ + res; + SET_VARSIZE(result, VARHDRSZ + res); PG_RETURN_TEXT_P(result); } @@ -99,7 +99,7 @@ binary_decode(PG_FUNCTION_ARGS) if (res > resultlen) elog(FATAL, "overflow - decode estimate too small"); - VARATT_SIZEP(result) = VARHDRSZ + res; + SET_VARSIZE(result, VARHDRSZ + res); PG_RETURN_BYTEA_P(result); } diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index a123d106fac..f2c22937564 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.148 2007/01/20 21:47:10 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.149 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1214,7 +1214,7 @@ float8_text(PG_FUNCTION_ARGS) result = (text *) palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); memcpy(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); @@ -1265,7 +1265,7 @@ float4_text(PG_FUNCTION_ARGS) result = (text *) palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); memcpy(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 344bf7db087..6095a1f4fdc 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * formatting.c * - * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.128 2007/02/17 03:11:32 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.129 2007/02/27 23:48:08 tgl Exp $ * * * Portions Copyright (c) 1999-2007, PostgreSQL Global Development Group @@ -2991,7 +2991,7 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt, bool is_interval) reslen = strlen(result); res = (text *) palloc(reslen + VARHDRSZ); memcpy(VARDATA(res), result, reslen); - VARATT_SIZEP(res) = reslen + VARHDRSZ; + SET_VARSIZE(res, reslen + VARHDRSZ); pfree(result); return res; @@ -4829,10 +4829,10 @@ do { \ } \ \ result_tmp = result; \ - result = (text *) palloc( len + 1 + VARHDRSZ); \ + result = (text *) palloc(len + VARHDRSZ); \ \ - strcpy( VARDATA(result), VARDATA(result_tmp)); \ - VARATT_SIZEP(result) = len + VARHDRSZ; \ + memcpy(VARDATA(result), VARDATA(result_tmp), len); \ + SET_VARSIZE(result, len + VARHDRSZ); \ pfree(result_tmp); \ } while(0) diff --git a/src/backend/utils/adt/genfile.c b/src/backend/utils/adt/genfile.c index af277875c56..e95c04876ca 100644 --- a/src/backend/utils/adt/genfile.c +++ b/src/backend/utils/adt/genfile.c @@ -9,7 +9,7 @@ * Author: Andreas Pflug <pgadmin@pse-consulting.de> * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.15 2007/02/01 19:10:28 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.16 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -135,7 +135,7 @@ pg_read_file(PG_FUNCTION_ARGS) (errcode_for_file_access(), errmsg("could not read file \"%s\": %m", filename))); - VARATT_SIZEP(buf) = nbytes + VARHDRSZ; + SET_VARSIZE(buf, nbytes + VARHDRSZ); FreeFile(file); pfree(filename); @@ -261,7 +261,7 @@ pg_ls_dir(PG_FUNCTION_ARGS) continue; result = palloc(len + VARHDRSZ); - VARATT_SIZEP(result) = len + VARHDRSZ; + SET_VARSIZE(result, len + VARHDRSZ); memcpy(VARDATA(result), de->d_name, len); SRF_RETURN_NEXT(funcctx, PointerGetDatum(result)); diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index 61217fc94c1..3360c07afc1 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.94 2007/01/05 22:19:40 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.95 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1415,7 +1415,7 @@ path_in(PG_FUNCTION_ARGS) size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * npts; path = (PATH *) palloc(size); - path->size = size; + SET_VARSIZE(path, size); path->npts = npts; if ((!path_decode(TRUE, npts, s, &isopen, &s, &(path->p[0]))) @@ -1464,7 +1464,7 @@ path_recv(PG_FUNCTION_ARGS) size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * npts; path = (PATH *) palloc(size); - path->size = size; + SET_VARSIZE(path, size); path->npts = npts; path->closed = (closed ? 1 : 0); @@ -3440,7 +3440,7 @@ poly_in(PG_FUNCTION_ARGS) size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts; poly = (POLYGON *) palloc0(size); /* zero any holes */ - poly->size = size; + SET_VARSIZE(poly, size); poly->npts = npts; if ((!path_decode(FALSE, npts, str, &isopen, &s, &(poly->p[0]))) @@ -3492,7 +3492,7 @@ poly_recv(PG_FUNCTION_ARGS) size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts; poly = (POLYGON *) palloc0(size); /* zero any holes */ - poly->size = size; + SET_VARSIZE(poly, size); poly->npts = npts; for (i = 0; i < npts; i++) @@ -4079,7 +4079,7 @@ path_add(PG_FUNCTION_ARGS) result = (PATH *) palloc(size); - result->size = size; + SET_VARSIZE(result, size); result->npts = (p1->npts + p2->npts); result->closed = p1->closed; @@ -4207,7 +4207,7 @@ path_poly(PG_FUNCTION_ARGS) size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * path->npts; poly = (POLYGON *) palloc(size); - poly->size = size; + SET_VARSIZE(poly, size); poly->npts = path->npts; for (i = 0; i < path->npts; i++) @@ -4282,7 +4282,7 @@ box_poly(PG_FUNCTION_ARGS) size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * 4; poly = (POLYGON *) palloc(size); - poly->size = size; + SET_VARSIZE(poly, size); poly->npts = 4; poly->p[0].x = box->low.x; @@ -4312,7 +4312,7 @@ poly_path(PG_FUNCTION_ARGS) size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * poly->npts; path = (PATH *) palloc(size); - path->size = size; + SET_VARSIZE(path, size); path->npts = poly->npts; path->closed = TRUE; @@ -4995,7 +4995,7 @@ circle_poly(PG_FUNCTION_ARGS) errmsg("too many points requested"))); poly = (POLYGON *) palloc0(size); /* zero any holes */ - poly->size = size; + SET_VARSIZE(poly, size); poly->npts = npts; anglestep = (2.0 * M_PI) / npts; diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index fce3bb89fba..d6d59022077 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.78 2007/02/01 19:10:28 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.79 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -124,7 +124,7 @@ buildint2vector(const int2 *int2s, int n) * Attach standard array header. For historical reasons, we set the index * lower bound to 0 not 1. */ - result->size = Int2VectorSize(n); + SET_VARSIZE(result, Int2VectorSize(n)); result->ndim = 1; result->dataoffset = 0; /* never any nulls */ result->elemtype = INT2OID; @@ -162,7 +162,7 @@ int2vectorin(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("int2vector has too many elements"))); - result->size = Int2VectorSize(n); + SET_VARSIZE(result, Int2VectorSize(n)); result->ndim = 1; result->dataoffset = 0; /* never any nulls */ result->elemtype = INT2OID; @@ -350,7 +350,7 @@ int2_text(PG_FUNCTION_ARGS) text *result = (text *) palloc(7 + VARHDRSZ); /* sign,5 digits, '\0' */ pg_itoa(arg1, VARDATA(result)); - VARATT_SIZEP(result) = strlen(VARDATA(result)) + VARHDRSZ; + SET_VARSIZE(result, strlen(VARDATA(result)) + VARHDRSZ); PG_RETURN_TEXT_P(result); } @@ -381,7 +381,7 @@ int4_text(PG_FUNCTION_ARGS) text *result = (text *) palloc(12 + VARHDRSZ); /* sign,10 digits,'\0' */ pg_ltoa(arg1, VARDATA(result)); - VARATT_SIZEP(result) = strlen(VARDATA(result)) + VARHDRSZ; + SET_VARSIZE(result, strlen(VARDATA(result)) + VARHDRSZ); PG_RETURN_TEXT_P(result); } diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 7f0d1df93cc..25672b680fc 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.64 2007/02/01 19:10:28 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.65 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1171,7 +1171,7 @@ int8_text(PG_FUNCTION_ARGS) result = (text *) palloc(VARHDRSZ + len); - VARATT_SIZEP(result) = len + VARHDRSZ; + SET_VARSIZE(result, VARHDRSZ + len); memcpy(VARDATA(result), s, len); pfree(s); diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c index 3455432220f..46f223b38ff 100644 --- a/src/backend/utils/adt/like.c +++ b/src/backend/utils/adt/like.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/like.c,v 1.67 2007/01/05 22:19:41 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/like.c,v 1.68 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -532,7 +532,7 @@ like_escape_bytea(PG_FUNCTION_ARGS) } } - VARATT_SIZEP(result) = r - ((char *) result); + SET_VARSIZE(result, r - ((char *) result)); PG_RETURN_BYTEA_P(result); } diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c index 69f73c1dc36..22e2705fb36 100644 --- a/src/backend/utils/adt/like_match.c +++ b/src/backend/utils/adt/like_match.c @@ -19,7 +19,7 @@ * Copyright (c) 1996-2007, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.14 2007/01/05 22:19:41 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.15 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -332,7 +332,7 @@ do_like_escape(text *pat, text *esc) } } - VARATT_SIZEP(result) = r - ((char *) result); + SET_VARSIZE(result, r - ((char *) result)); return result; } diff --git a/src/backend/utils/adt/mac.c b/src/backend/utils/adt/mac.c index 0c9bff2b8fe..fa13abe4618 100644 --- a/src/backend/utils/adt/mac.c +++ b/src/backend/utils/adt/mac.c @@ -1,7 +1,7 @@ /* * PostgreSQL type definitions for MAC addresses. * - * $PostgreSQL: pgsql/src/backend/utils/adt/mac.c,v 1.36 2006/01/11 08:43:12 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/mac.c,v 1.37 2007/02/27 23:48:08 tgl Exp $ */ #include "postgres.h" @@ -163,8 +163,8 @@ macaddr_text(PG_FUNCTION_ARGS) result = palloc(len); - VARATT_SIZEP(result) = len; - memmove(VARDATA(result), str, (len - VARHDRSZ)); + SET_VARSIZE(result, len); + memcpy(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index dfab102fa76..3ec098a39f3 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.149 2007/01/05 22:19:41 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.150 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1596,7 +1596,7 @@ timeofday(PG_FUNCTION_ARGS) len = VARHDRSZ + strlen(buf); result = (text *) palloc(len); - VARATT_SIZEP(result) = len; - memcpy(VARDATA(result), buf, strlen(buf)); + SET_VARSIZE(result, len); + memcpy(VARDATA(result), buf, len - VARHDRSZ); PG_RETURN_TEXT_P(result); } diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 29ba260b45a..88fa427450f 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -1,7 +1,7 @@ /* * PostgreSQL type definitions for the INET and CIDR types. * - * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.67 2007/01/02 22:21:08 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.68 2007/02/27 23:48:08 tgl Exp $ * * Jon Postel RIP 16 Oct 1998 */ @@ -105,9 +105,9 @@ network_in(char *src, bool is_cidr) errdetail("Value has bits set to right of mask."))); } - VARATT_SIZEP(dst) = VARHDRSZ + + SET_VARSIZE(dst, VARHDRSZ + ((char *) ip_addr(dst) - (char *) VARDATA(dst)) + - ip_addrsize(dst); + ip_addrsize(dst)); ip_bits(dst) = bits; return dst; @@ -220,9 +220,9 @@ network_recv(StringInfo buf, bool is_cidr) /* translator: %s is inet or cidr */ errmsg("invalid length in external \"%s\" value", is_cidr ? "cidr" : "inet"))); - VARATT_SIZEP(addr) = VARHDRSZ + + SET_VARSIZE(addr, VARHDRSZ + ((char *) ip_addr(addr) - (char *) VARDATA(addr)) + - ip_addrsize(addr); + ip_addrsize(addr)); addrptr = (char *) ip_addr(addr); for (i = 0; i < nb; i++) @@ -638,7 +638,7 @@ network_host(PG_FUNCTION_ARGS) /* Return string as a text datum */ len = strlen(tmp); ret = (text *) palloc(len + VARHDRSZ); - VARATT_SIZEP(ret) = len + VARHDRSZ; + SET_VARSIZE(ret, len + VARHDRSZ); memcpy(VARDATA(ret), tmp, len); PG_RETURN_TEXT_P(ret); } @@ -667,7 +667,7 @@ network_show(PG_FUNCTION_ARGS) /* Return string as a text datum */ len = strlen(tmp); ret = (text *) palloc(len + VARHDRSZ); - VARATT_SIZEP(ret) = len + VARHDRSZ; + SET_VARSIZE(ret, len + VARHDRSZ); memcpy(VARDATA(ret), tmp, len); PG_RETURN_TEXT_P(ret); } @@ -692,7 +692,7 @@ inet_abbrev(PG_FUNCTION_ARGS) /* Return string as a text datum */ len = strlen(tmp); ret = (text *) palloc(len + VARHDRSZ); - VARATT_SIZEP(ret) = len + VARHDRSZ; + SET_VARSIZE(ret, len + VARHDRSZ); memcpy(VARDATA(ret), tmp, len); PG_RETURN_TEXT_P(ret); } @@ -717,7 +717,7 @@ cidr_abbrev(PG_FUNCTION_ARGS) /* Return string as a text datum */ len = strlen(tmp); ret = (text *) palloc(len + VARHDRSZ); - VARATT_SIZEP(ret) = len + VARHDRSZ; + SET_VARSIZE(ret, len + VARHDRSZ); memcpy(VARDATA(ret), tmp, len); PG_RETURN_TEXT_P(ret); } @@ -793,9 +793,9 @@ network_broadcast(PG_FUNCTION_ARGS) ip_family(dst) = ip_family(ip); ip_bits(dst) = ip_bits(ip); - VARATT_SIZEP(dst) = VARHDRSZ + + SET_VARSIZE(dst, VARHDRSZ + ((char *) ip_addr(dst) - (char *) VARDATA(dst)) + - ip_addrsize(dst); + ip_addrsize(dst)); PG_RETURN_INET_P(dst); } @@ -838,9 +838,9 @@ network_network(PG_FUNCTION_ARGS) ip_family(dst) = ip_family(ip); ip_bits(dst) = ip_bits(ip); - VARATT_SIZEP(dst) = VARHDRSZ + + SET_VARSIZE(dst, VARHDRSZ + ((char *) ip_addr(dst) - (char *) VARDATA(dst)) + - ip_addrsize(dst); + ip_addrsize(dst)); PG_RETURN_INET_P(dst); } @@ -881,9 +881,9 @@ network_netmask(PG_FUNCTION_ARGS) ip_family(dst) = ip_family(ip); ip_bits(dst) = ip_maxbits(ip); - VARATT_SIZEP(dst) = VARHDRSZ + + SET_VARSIZE(dst, VARHDRSZ + ((char *) ip_addr(dst) - (char *) VARDATA(dst)) + - ip_addrsize(dst); + ip_addrsize(dst)); PG_RETURN_INET_P(dst); } @@ -930,9 +930,9 @@ network_hostmask(PG_FUNCTION_ARGS) ip_family(dst) = ip_family(ip); ip_bits(dst) = ip_maxbits(ip); - VARATT_SIZEP(dst) = VARHDRSZ + + SET_VARSIZE(dst, VARHDRSZ + ((char *) ip_addr(dst) - (char *) VARDATA(dst)) + - ip_addrsize(dst); + ip_addrsize(dst)); PG_RETURN_INET_P(dst); } @@ -1272,9 +1272,9 @@ inetnot(PG_FUNCTION_ARGS) ip_bits(dst) = ip_bits(ip); ip_family(dst) = ip_family(ip); - VARATT_SIZEP(dst) = VARHDRSZ + + SET_VARSIZE(dst, VARHDRSZ + ((char *) ip_addr(dst) - (char *) VARDATA(dst)) + - ip_addrsize(dst); + ip_addrsize(dst)); PG_RETURN_INET_P(dst); } @@ -1306,9 +1306,9 @@ inetand(PG_FUNCTION_ARGS) ip_bits(dst) = Max(ip_bits(ip), ip_bits(ip2)); ip_family(dst) = ip_family(ip); - VARATT_SIZEP(dst) = VARHDRSZ + + SET_VARSIZE(dst, VARHDRSZ + ((char *) ip_addr(dst) - (char *) VARDATA(dst)) + - ip_addrsize(dst); + ip_addrsize(dst)); PG_RETURN_INET_P(dst); } @@ -1340,9 +1340,9 @@ inetor(PG_FUNCTION_ARGS) ip_bits(dst) = Max(ip_bits(ip), ip_bits(ip2)); ip_family(dst) = ip_family(ip); - VARATT_SIZEP(dst) = VARHDRSZ + + SET_VARSIZE(dst, VARHDRSZ + ((char *) ip_addr(dst) - (char *) VARDATA(dst)) + - ip_addrsize(dst); + ip_addrsize(dst)); PG_RETURN_INET_P(dst); } @@ -1394,9 +1394,9 @@ internal_inetpl(inet *ip, int64 addend) ip_bits(dst) = ip_bits(ip); ip_family(dst) = ip_family(ip); - VARATT_SIZEP(dst) = VARHDRSZ + + SET_VARSIZE(dst, VARHDRSZ + ((char *) ip_addr(dst) - (char *) VARDATA(dst)) + - ip_addrsize(dst); + ip_addrsize(dst)); return dst; } diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 19fc4d45055..f173f30211c 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -14,7 +14,7 @@ * Copyright (c) 1998-2007, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.100 2007/02/17 00:55:57 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.101 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -230,7 +230,7 @@ static void dump_var(const char *str, NumericVar *var); #define NUMERIC_DIGITS(num) ((NumericDigit *)(num)->n_data) #define NUMERIC_NDIGITS(num) \ - (((num)->varlen - NUMERIC_HDRSZ) / sizeof(NumericDigit)) + ((VARSIZE(num) - NUMERIC_HDRSZ) / sizeof(NumericDigit)) static void alloc_var(NumericVar *var, int ndigits); static void free_var(NumericVar *var); @@ -494,8 +494,8 @@ numeric(PG_FUNCTION_ARGS) */ if (typmod < (int32) (VARHDRSZ)) { - new = (Numeric) palloc(num->varlen); - memcpy(new, num, num->varlen); + new = (Numeric) palloc(VARSIZE(num)); + memcpy(new, num, VARSIZE(num)); PG_RETURN_NUMERIC(new); } @@ -515,8 +515,8 @@ numeric(PG_FUNCTION_ARGS) ddigits = (num->n_weight + 1) * DEC_DIGITS; if (ddigits <= maxdigits && scale >= NUMERIC_DSCALE(num)) { - new = (Numeric) palloc(num->varlen); - memcpy(new, num, num->varlen); + new = (Numeric) palloc(VARSIZE(num)); + memcpy(new, num, VARSIZE(num)); new->n_sign_dscale = NUMERIC_SIGN(new) | ((uint16) scale & NUMERIC_DSCALE_MASK); PG_RETURN_NUMERIC(new); @@ -621,8 +621,8 @@ numeric_abs(PG_FUNCTION_ARGS) /* * Do it the easy way directly on the packed format */ - res = (Numeric) palloc(num->varlen); - memcpy(res, num, num->varlen); + res = (Numeric) palloc(VARSIZE(num)); + memcpy(res, num, VARSIZE(num)); res->n_sign_dscale = NUMERIC_POS | NUMERIC_DSCALE(num); @@ -645,15 +645,15 @@ numeric_uminus(PG_FUNCTION_ARGS) /* * Do it the easy way directly on the packed format */ - res = (Numeric) palloc(num->varlen); - memcpy(res, num, num->varlen); + res = (Numeric) palloc(VARSIZE(num)); + memcpy(res, num, VARSIZE(num)); /* * The packed format is known to be totally zero digit trimmed always. So * we can identify a ZERO by the fact that there are no digits at all. Do * nothing to a zero. */ - if (num->varlen != NUMERIC_HDRSZ) + if (VARSIZE(num) != NUMERIC_HDRSZ) { /* Else, flip the sign */ if (NUMERIC_SIGN(num) == NUMERIC_POS) @@ -672,8 +672,8 @@ numeric_uplus(PG_FUNCTION_ARGS) Numeric num = PG_GETARG_NUMERIC(0); Numeric res; - res = (Numeric) palloc(num->varlen); - memcpy(res, num, num->varlen); + res = (Numeric) palloc(VARSIZE(num)); + memcpy(res, num, VARSIZE(num)); PG_RETURN_NUMERIC(res); } @@ -703,7 +703,7 @@ numeric_sign(PG_FUNCTION_ARGS) * The packed format is known to be totally zero digit trimmed always. So * we can identify a ZERO by the fact that there are no digits at all. */ - if (num->varlen == NUMERIC_HDRSZ) + if (VARSIZE(num) == NUMERIC_HDRSZ) set_var_from_var(&const_zero, &result); else { @@ -2105,7 +2105,7 @@ numeric_text(PG_FUNCTION_ARGS) result = (text *) palloc(VARHDRSZ + len); - VARATT_SIZEP(result) = len + VARHDRSZ; + SET_VARSIZE(result, VARHDRSZ + len); memcpy(VARDATA(result), s, len); pfree(s); @@ -2301,7 +2301,7 @@ numeric_avg(PG_FUNCTION_ARGS) /* SQL92 defines AVG of no values to be NULL */ /* N is zero iff no digits (cf. numeric_uminus) */ - if (N->varlen == NUMERIC_HDRSZ) + if (VARSIZE(N) == NUMERIC_HDRSZ) PG_RETURN_NULL(); PG_RETURN_DATUM(DirectFunctionCall2(numeric_div, @@ -3232,7 +3232,7 @@ make_result(NumericVar *var) { result = (Numeric) palloc(NUMERIC_HDRSZ); - result->varlen = NUMERIC_HDRSZ; + SET_VARSIZE(result, NUMERIC_HDRSZ); result->n_weight = 0; result->n_sign_dscale = NUMERIC_NAN; @@ -3263,7 +3263,7 @@ make_result(NumericVar *var) /* Build the result */ len = NUMERIC_HDRSZ + n * sizeof(NumericDigit); result = (Numeric) palloc(len); - result->varlen = len; + SET_VARSIZE(result, len); result->n_weight = weight; result->n_sign_dscale = sign | (var->dscale & NUMERIC_DSCALE_MASK); diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c index 42a44eed758..8a9f971a227 100644 --- a/src/backend/utils/adt/oid.c +++ b/src/backend/utils/adt/oid.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.70 2007/01/05 22:19:41 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.71 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -174,7 +174,7 @@ buildoidvector(const Oid *oids, int n) * Attach standard array header. For historical reasons, we set the index * lower bound to 0 not 1. */ - result->size = OidVectorSize(n); + SET_VARSIZE(result, OidVectorSize(n)); result->ndim = 1; result->dataoffset = 0; /* never any nulls */ result->elemtype = OIDOID; @@ -211,7 +211,7 @@ oidvectorin(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("oidvector has too many elements"))); - result->size = OidVectorSize(n); + SET_VARSIZE(result, OidVectorSize(n)); result->ndim = 1; result->dataoffset = 0; /* never any nulls */ result->elemtype = OIDOID; @@ -434,7 +434,7 @@ oid_text(PG_FUNCTION_ARGS) result = (text *) palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); memcpy(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c index 6da6b30cca3..9fcd5ae747a 100644 --- a/src/backend/utils/adt/oracle_compat.c +++ b/src/backend/utils/adt/oracle_compat.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.69 2007/02/08 18:19:33 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.70 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -144,7 +144,7 @@ wcstotext(const wchar_t *str, int ncodes) Assert(nbytes <= (size_t) (ncodes * MB_CUR_MAX)); - VARATT_SIZEP(result) = nbytes + VARHDRSZ; + SET_VARSIZE(result, nbytes + VARHDRSZ); return result; } @@ -229,7 +229,7 @@ win32_utf8_wcstotext(const wchar_t *str) errmsg("UTF-16 to UTF-8 translation failed: %lu", GetLastError()))); - VARATT_SIZEP(result) = nbytes + VARHDRSZ - 1; /* -1 to ignore null */ + SET_VARSIZE(result, nbytes + VARHDRSZ - 1); /* -1 to ignore null */ return result; } @@ -278,7 +278,7 @@ wstring_upper(char *str) in_text = palloc(nbytes + VARHDRSZ); memcpy(VARDATA(in_text), str, nbytes); - VARATT_SIZEP(in_text) = nbytes + VARHDRSZ; + SET_VARSIZE(in_text, nbytes + VARHDRSZ); workspace = texttowcs(in_text); @@ -312,7 +312,7 @@ wstring_lower(char *str) in_text = palloc(nbytes + VARHDRSZ); memcpy(VARDATA(in_text), str, nbytes); - VARATT_SIZEP(in_text) = nbytes + VARHDRSZ; + SET_VARSIZE(in_text, nbytes + VARHDRSZ); workspace = texttowcs(in_text); @@ -639,7 +639,7 @@ lpad(PG_FUNCTION_ARGS) ptr1 += mlen; } - VARATT_SIZEP(ret) = ptr_ret - (char *) ret; + SET_VARSIZE(ret, ptr_ret - (char *) ret); PG_RETURN_TEXT_P(ret); } @@ -735,7 +735,7 @@ rpad(PG_FUNCTION_ARGS) ptr2 = VARDATA(string2); } - VARATT_SIZEP(ret) = ptr_ret - (char *) ret; + SET_VARSIZE(ret, ptr_ret - (char *) ret); PG_RETURN_TEXT_P(ret); } @@ -944,7 +944,7 @@ dotrim(const char *string, int stringlen, /* Return selected portion of string */ result = (text *) palloc(VARHDRSZ + stringlen); - VARATT_SIZEP(result) = VARHDRSZ + stringlen; + SET_VARSIZE(result, VARHDRSZ + stringlen); memcpy(VARDATA(result), string, stringlen); return result; @@ -1017,7 +1017,7 @@ byteatrim(PG_FUNCTION_ARGS) } ret = (bytea *) palloc(VARHDRSZ + m); - VARATT_SIZEP(ret) = VARHDRSZ + m; + SET_VARSIZE(ret, VARHDRSZ + m); memcpy(VARDATA(ret), ptr, m); PG_RETURN_BYTEA_P(ret); @@ -1223,7 +1223,7 @@ translate(PG_FUNCTION_ARGS) m -= source_len; } - VARATT_SIZEP(result) = retlen + VARHDRSZ; + SET_VARSIZE(result, retlen + VARHDRSZ); /* * There may be some wasted space in the result if deletions occurred, but @@ -1275,13 +1275,13 @@ ascii(PG_FUNCTION_ARGS) ********************************************************************/ Datum -chr (PG_FUNCTION_ARGS) +chr(PG_FUNCTION_ARGS) { int32 cvalue = PG_GETARG_INT32(0); text *result; result = (text *) palloc(VARHDRSZ + 1); - VARATT_SIZEP(result) = VARHDRSZ + 1; + SET_VARSIZE(result, VARHDRSZ + 1); *VARDATA(result) = (char) cvalue; PG_RETURN_TEXT_P(result); @@ -1332,7 +1332,7 @@ repeat(PG_FUNCTION_ARGS) result = (text *) palloc(tlen); - VARATT_SIZEP(result) = tlen; + SET_VARSIZE(result, tlen); cp = VARDATA(result); for (i = 0; i < count; i++) { diff --git a/src/backend/utils/adt/pg_lzcompress.c b/src/backend/utils/adt/pg_lzcompress.c index 918f7bad7ff..c756e5707a5 100644 --- a/src/backend/utils/adt/pg_lzcompress.c +++ b/src/backend/utils/adt/pg_lzcompress.c @@ -45,7 +45,7 @@ * PGLZ_Header is defined as * * typedef struct PGLZ_Header { - * int32 varsize; + * int32 vl_len_; * int32 rawsize; * } * @@ -54,7 +54,7 @@ * The data representation is easiest explained by describing * the process of decompression. * - * If varsize == rawsize + sizeof(PGLZ_Header), then the data + * If VARSIZE(x) == rawsize + sizeof(PGLZ_Header), then the data * is stored uncompressed as plain bytes. Thus, the decompressor * simply copies rawsize bytes from the location after the * header to the destination. @@ -166,7 +166,7 @@ * * Copyright (c) 1999-2007, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.24 2007/01/20 01:08:42 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.25 2007/02/27 23:48:08 tgl Exp $ * ---------- */ #include "postgres.h" @@ -618,7 +618,7 @@ pglz_compress(const char *source, int32 slen, PGLZ_Header *dest, /* * Success - need only fill in the actual length of the compressed datum. */ - dest->varsize = result_size + sizeof(PGLZ_Header); + SET_VARSIZE(dest, result_size + sizeof(PGLZ_Header)); return true; } @@ -643,7 +643,7 @@ pglz_decompress(const PGLZ_Header *source, char *dest) int32 destsize; dp = ((const unsigned char *) source) + sizeof(PGLZ_Header); - dend = ((const unsigned char *) source) + VARATT_SIZE(source); + dend = ((const unsigned char *) source) + VARSIZE(source); bp = (unsigned char *) dest; while (dp < dend) diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index d011fff76f8..50624d6e728 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.38 2007/02/07 23:11:29 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.39 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -398,7 +398,7 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS) len = strlen(activity); result = palloc(VARHDRSZ + len); - VARATT_SIZEP(result) = VARHDRSZ + len; + SET_VARSIZE(result, VARHDRSZ + len); memcpy(VARDATA(result), activity, len); PG_RETURN_TEXT_P(result); diff --git a/src/backend/utils/adt/quote.c b/src/backend/utils/adt/quote.c index 3cc7f03007a..31fbf57aaf8 100644 --- a/src/backend/utils/adt/quote.c +++ b/src/backend/utils/adt/quote.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/quote.c,v 1.21 2007/01/05 22:19:41 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/quote.c,v 1.22 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,7 @@ quote_ident(PG_FUNCTION_ARGS) len = strlen(qstr); result = (text *) palloc(len + VARHDRSZ); - VARATT_SIZEP(result) = len + VARHDRSZ; + SET_VARSIZE(result, len + VARHDRSZ); memcpy(VARDATA(result), qstr, len); PG_RETURN_TEXT_P(result); @@ -92,7 +92,7 @@ quote_literal(PG_FUNCTION_ARGS) } *cp2++ = '\''; - VARATT_SIZEP(result) = cp2 - ((char *) result); + SET_VARSIZE(result, cp2 - ((char *) result)); PG_RETURN_TEXT_P(result); } diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index 48a70820a30..6a7a5fcc13b 100644 --- a/src/backend/utils/adt/regexp.c +++ b/src/backend/utils/adt/regexp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.68 2007/01/05 22:19:41 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.69 2007/02/27 23:48:08 tgl Exp $ * * Alistair Crooks added the code for the regex caching * agc - cached the regular expressions used - there's a good chance @@ -620,7 +620,7 @@ similar_escape(PG_FUNCTION_ARGS) *r++ = ')'; *r++ = '$'; - VARATT_SIZEP(result) = r - ((char *) result); + SET_VARSIZE(result, r - ((char *) result)); PG_RETURN_TEXT_P(result); } diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 765b3c65c30..f17061738a4 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.251 2007/02/23 21:59:44 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.252 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -5298,7 +5298,7 @@ string_to_text(char *str) tlen = slen + VARHDRSZ; result = (text *) palloc(tlen); - VARATT_SIZEP(result) = tlen; + SET_VARSIZE(result, tlen); memcpy(VARDATA(result), str, slen); pfree(str); diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index f25a8d8f70d..1588ac405a2 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.227 2007/02/22 22:00:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.228 2007/02/27 23:48:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -4731,7 +4731,7 @@ string_to_bytea_const(const char *str, size_t str_len) Datum conval; memcpy(VARDATA(bstr), str, str_len); - VARATT_SIZEP(bstr) = VARHDRSZ + str_len; + SET_VARSIZE(bstr, VARHDRSZ + str_len); conval = PointerGetDatum(bstr); return makeConst(BYTEAOID, -1, conval, false, false); diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index a842c1b02cf..e9d1efe3ed1 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.173 2007/02/19 17:41:39 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.174 2007/02/27 23:48:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3199,8 +3199,8 @@ timestamp_text(PG_FUNCTION_ARGS) result = palloc(len); - VARATT_SIZEP(result) = len; - memmove(VARDATA(result), str, len - VARHDRSZ); + SET_VARSIZE(result, len); + memcpy(VARDATA(result), str, len - VARHDRSZ); pfree(str); @@ -3260,8 +3260,8 @@ timestamptz_text(PG_FUNCTION_ARGS) result = palloc(len); - VARATT_SIZEP(result) = len; - memmove(VARDATA(result), str, len - VARHDRSZ); + SET_VARSIZE(result, len); + memcpy(VARDATA(result), str, len - VARHDRSZ); pfree(str); @@ -3320,8 +3320,8 @@ interval_text(PG_FUNCTION_ARGS) result = palloc(len); - VARATT_SIZEP(result) = len; - memmove(VARDATA(result), str, len - VARHDRSZ); + SET_VARSIZE(result, len); + memcpy(VARDATA(result), str, len - VARHDRSZ); pfree(str); diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index 5b5c4aa5a57..a9eef1e0e7d 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varbit.c,v 1.52 2007/01/05 22:19:42 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varbit.c,v 1.53 2007/02/27 23:48:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -160,7 +160,7 @@ bit_in(PG_FUNCTION_ARGS) len = VARBITTOTALLEN(atttypmod); /* set to 0 so that *r is always initialised and string is zero-padded */ result = (VarBit *) palloc0(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); VARBITLEN(result) = atttypmod; r = VARBITS(result); @@ -299,7 +299,7 @@ bit_recv(PG_FUNCTION_ARGS) len = VARBITTOTALLEN(bitlen); result = (VarBit *) palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); VARBITLEN(result) = bitlen; pq_copymsgbytes(buf, (char *) VARBITS(result), VARBITBYTES(result)); @@ -356,7 +356,7 @@ bit(PG_FUNCTION_ARGS) rlen = VARBITTOTALLEN(len); /* set to 0 so that string is zero-padded */ result = (VarBit *) palloc0(rlen); - VARATT_SIZEP(result) = rlen; + SET_VARSIZE(result, rlen); VARBITLEN(result) = len; memcpy(VARBITS(result), VARBITS(arg), @@ -458,7 +458,7 @@ varbit_in(PG_FUNCTION_ARGS) len = VARBITTOTALLEN(bitlen); /* set to 0 so that *r is always initialised and string is zero-padded */ result = (VarBit *) palloc0(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); VARBITLEN(result) = Min(bitlen, atttypmod); r = VARBITS(result); @@ -595,7 +595,7 @@ varbit_recv(PG_FUNCTION_ARGS) len = VARBITTOTALLEN(bitlen); result = (VarBit *) palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); VARBITLEN(result) = bitlen; pq_copymsgbytes(buf, (char *) VARBITS(result), VARBITBYTES(result)); @@ -656,7 +656,7 @@ varbit(PG_FUNCTION_ARGS) rlen = VARBITTOTALLEN(len); result = (VarBit *) palloc(rlen); - VARATT_SIZEP(result) = rlen; + SET_VARSIZE(result, rlen); VARBITLEN(result) = len; memcpy(VARBITS(result), VARBITS(arg), VARBITBYTES(result)); @@ -884,7 +884,7 @@ bitcat(PG_FUNCTION_ARGS) bytelen = VARBITTOTALLEN(bitlen1 + bitlen2); result = (VarBit *) palloc(bytelen); - VARATT_SIZEP(result) = bytelen; + SET_VARSIZE(result, bytelen); VARBITLEN(result) = bitlen1 + bitlen2; /* Copy the first bitstring in */ @@ -951,7 +951,7 @@ bitsubstr(PG_FUNCTION_ARGS) /* Need to return a zero-length bitstring */ len = VARBITTOTALLEN(0); result = (VarBit *) palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); VARBITLEN(result) = 0; } else @@ -963,7 +963,7 @@ bitsubstr(PG_FUNCTION_ARGS) rbitlen = e1 - s1; len = VARBITTOTALLEN(rbitlen); result = (VarBit *) palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); VARBITLEN(result) = rbitlen; len -= VARHDRSZ + VARBITHDRSZ; /* Are we copying from a byte boundary? */ @@ -1044,7 +1044,7 @@ bitand(PG_FUNCTION_ARGS) len = VARSIZE(arg1); result = (VarBit *) palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); VARBITLEN(result) = bitlen1; p1 = VARBITS(arg1); @@ -1084,7 +1084,7 @@ bitor(PG_FUNCTION_ARGS) errmsg("cannot OR bit strings of different sizes"))); len = VARSIZE(arg1); result = (VarBit *) palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); VARBITLEN(result) = bitlen1; p1 = VARBITS(arg1); @@ -1131,7 +1131,7 @@ bitxor(PG_FUNCTION_ARGS) len = VARSIZE(arg1); result = (VarBit *) palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); VARBITLEN(result) = bitlen1; p1 = VARBITS(arg1); @@ -1164,7 +1164,7 @@ bitnot(PG_FUNCTION_ARGS) bits8 mask; result = (VarBit *) palloc(VARSIZE(arg)); - VARATT_SIZEP(result) = VARSIZE(arg); + SET_VARSIZE(result, VARSIZE(arg)); VARBITLEN(result) = VARBITLEN(arg); p = VARBITS(arg); @@ -1205,7 +1205,7 @@ bitshiftleft(PG_FUNCTION_ARGS) Int32GetDatum(-shft))); result = (VarBit *) palloc(VARSIZE(arg)); - VARATT_SIZEP(result) = VARSIZE(arg); + SET_VARSIZE(result, VARSIZE(arg)); VARBITLEN(result) = VARBITLEN(arg); r = VARBITS(result); @@ -1264,7 +1264,7 @@ bitshiftright(PG_FUNCTION_ARGS) Int32GetDatum(-shft))); result = (VarBit *) palloc(VARSIZE(arg)); - VARATT_SIZEP(result) = VARSIZE(arg); + SET_VARSIZE(result, VARSIZE(arg)); VARBITLEN(result) = VARBITLEN(arg); r = VARBITS(result); @@ -1324,7 +1324,7 @@ bitfromint4(PG_FUNCTION_ARGS) rlen = VARBITTOTALLEN(typmod); result = (VarBit *) palloc(rlen); - VARATT_SIZEP(result) = rlen; + SET_VARSIZE(result, rlen); VARBITLEN(result) = typmod; r = VARBITS(result); @@ -1399,7 +1399,7 @@ bitfromint8(PG_FUNCTION_ARGS) rlen = VARBITTOTALLEN(typmod); result = (VarBit *) palloc(rlen); - VARATT_SIZEP(result) = rlen; + SET_VARSIZE(result, rlen); VARBITLEN(result) = typmod; r = VARBITS(result); diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 8bc6ed5e6a1..371a8a605d6 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.121 2007/01/05 22:19:42 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.122 2007/02/27 23:48:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -169,7 +169,7 @@ bpchar_input(const char *s, size_t len, int32 atttypmod) } result = (BpChar *) palloc(maxlen + VARHDRSZ); - VARATT_SIZEP(result) = maxlen + VARHDRSZ; + SET_VARSIZE(result, maxlen + VARHDRSZ); r = VARDATA(result); memcpy(r, s, len); @@ -328,7 +328,7 @@ bpchar(PG_FUNCTION_ARGS) s = VARDATA(source); result = palloc(maxlen); - VARATT_SIZEP(result) = maxlen; + SET_VARSIZE(result, maxlen); r = VARDATA(result); memcpy(r, s, len - VARHDRSZ); @@ -352,7 +352,7 @@ char_bpchar(PG_FUNCTION_ARGS) result = (BpChar *) palloc(VARHDRSZ + 1); - VARATT_SIZEP(result) = VARHDRSZ + 1; + SET_VARSIZE(result, VARHDRSZ + 1); *(VARDATA(result)) = c; PG_RETURN_BPCHAR_P(result); @@ -409,7 +409,7 @@ name_bpchar(PG_FUNCTION_ARGS) len = strlen(NameStr(*s)); result = (BpChar *) palloc(VARHDRSZ + len); memcpy(VARDATA(result), NameStr(*s), len); - VARATT_SIZEP(result) = len + VARHDRSZ; + SET_VARSIZE(result, VARHDRSZ + len); PG_RETURN_BPCHAR_P(result); } @@ -477,7 +477,7 @@ varchar_input(const char *s, size_t len, int32 atttypmod) } result = (VarChar *) palloc(len + VARHDRSZ); - VARATT_SIZEP(result) = len + VARHDRSZ; + SET_VARSIZE(result, len + VARHDRSZ); memcpy(VARDATA(result), s, len); return result; @@ -601,7 +601,7 @@ varchar(PG_FUNCTION_ARGS) len = maxmblen + VARHDRSZ; result = palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); memcpy(VARDATA(result), VARDATA(source), len - VARHDRSZ); PG_RETURN_VARCHAR_P(result); diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 1992db9bdfa..51130efd79b 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.154 2007/01/05 22:19:42 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.155 2007/02/27 23:48:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -124,7 +124,7 @@ byteain(PG_FUNCTION_ARGS) byte += VARHDRSZ; result = (bytea *) palloc(byte); - VARATT_SIZEP(result) = byte; /* set varlena length */ + SET_VARSIZE(result, byte); tp = inputText; rp = VARDATA(result); @@ -233,7 +233,7 @@ bytearecv(PG_FUNCTION_ARGS) nbytes = buf->len - buf->cursor; result = (bytea *) palloc(nbytes + VARHDRSZ); - VARATT_SIZEP(result) = nbytes + VARHDRSZ; + SET_VARSIZE(result, nbytes + VARHDRSZ); pq_copymsgbytes(buf, VARDATA(result), nbytes); PG_RETURN_BYTEA_P(result); } @@ -264,7 +264,7 @@ textin(PG_FUNCTION_ARGS) len = strlen(inputText); result = (text *) palloc(len + VARHDRSZ); - VARATT_SIZEP(result) = len + VARHDRSZ; + SET_VARSIZE(result, len + VARHDRSZ); memcpy(VARDATA(result), inputText, len); @@ -303,7 +303,7 @@ textrecv(PG_FUNCTION_ARGS) str = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes); result = (text *) palloc(nbytes + VARHDRSZ); - VARATT_SIZEP(result) = nbytes + VARHDRSZ; + SET_VARSIZE(result, nbytes + VARHDRSZ); memcpy(VARDATA(result), str, nbytes); pfree(str); PG_RETURN_TEXT_P(result); @@ -466,7 +466,7 @@ textcat(PG_FUNCTION_ARGS) result = (text *) palloc(len); /* Set size of result string... */ - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); /* Fill data field of result string... */ ptr = VARDATA(result); @@ -737,7 +737,7 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) p += pg_mblen(p); ret = (text *) palloc(VARHDRSZ + (p - s)); - VARATT_SIZEP(ret) = VARHDRSZ + (p - s); + SET_VARSIZE(ret, VARHDRSZ + (p - s)); memcpy(VARDATA(ret), s, (p - s)); if (slice != (text *) DatumGetPointer(str)) @@ -1409,7 +1409,7 @@ byteacat(PG_FUNCTION_ARGS) result = (bytea *) palloc(len); /* Set size of result string... */ - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); /* Fill data field of result string... */ ptr = VARDATA(result); @@ -1761,7 +1761,7 @@ name_text(PG_FUNCTION_ARGS) #endif result = palloc(VARHDRSZ + len); - VARATT_SIZEP(result) = VARHDRSZ + len; + SET_VARSIZE(result, VARHDRSZ + len); memcpy(VARDATA(result), NameStr(*s), len); PG_RETURN_TEXT_P(result); @@ -2593,7 +2593,7 @@ text_to_array(PG_FUNCTION_ARGS) /* must build a temp text datum to pass to accumArrayResult */ result_text = (text *) palloc(VARHDRSZ + chunk_len); - VARATT_SIZEP(result_text) = VARHDRSZ + chunk_len; + SET_VARSIZE(result_text, VARHDRSZ + chunk_len); memcpy(VARDATA(result_text), start_ptr, chunk_len); /* stash away this field */ diff --git a/src/backend/utils/adt/version.c b/src/backend/utils/adt/version.c index 19d75db513e..7afbcd43581 100644 --- a/src/backend/utils/adt/version.c +++ b/src/backend/utils/adt/version.c @@ -7,7 +7,7 @@ * * IDENTIFICATION * - * $PostgreSQL: pgsql/src/backend/utils/adt/version.c,v 1.14 2007/01/20 01:08:42 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/version.c,v 1.15 2007/02/27 23:48:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ pgsql_version(PG_FUNCTION_ARGS) int n = strlen(PG_VERSION_STR); text *ret = (text *) palloc(n + VARHDRSZ); - VARATT_SIZEP(ret) = n + VARHDRSZ; + SET_VARSIZE(ret, n + VARHDRSZ); memcpy(VARDATA(ret), PG_VERSION_STR, n); PG_RETURN_TEXT_P(ret); diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index f814d7f543e..c12522cfe45 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.31 2007/02/16 18:37:43 petere Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.32 2007/02/27 23:48:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -128,7 +128,7 @@ xml_in(PG_FUNCTION_ARGS) len = strlen(s); vardata = palloc(len + VARHDRSZ); - VARATT_SIZEP(vardata) = len + VARHDRSZ; + SET_VARSIZE(vardata, len + VARHDRSZ); memcpy(VARDATA(vardata), s, len); /* @@ -225,7 +225,7 @@ xml_recv(PG_FUNCTION_ARGS) str = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes); result = palloc(nbytes + VARHDRSZ); - VARATT_SIZEP(result) = nbytes + VARHDRSZ; + SET_VARSIZE(result, nbytes + VARHDRSZ); memcpy(VARDATA(result), str, nbytes); parse_xml_decl((xmlChar *) str, NULL, NULL, &encoding, NULL); @@ -251,7 +251,7 @@ xml_recv(PG_FUNCTION_ARGS) nbytes = strlen(newstr); result = palloc(nbytes + VARHDRSZ); - VARATT_SIZEP(result) = nbytes + VARHDRSZ; + SET_VARSIZE(result, nbytes + VARHDRSZ); memcpy(VARDATA(result), newstr, nbytes); } @@ -293,7 +293,7 @@ stringinfo_to_xmltype(StringInfo buf) len = buf->len + VARHDRSZ; result = palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); memcpy(VARDATA(result), buf->data, buf->len); return result; @@ -308,7 +308,7 @@ cstring_to_xmltype(const char *string) len = strlen(string) + VARHDRSZ; result = palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); memcpy(VARDATA(result), string, len - VARHDRSZ); return result; @@ -324,7 +324,7 @@ xmlBuffer_to_xmltype(xmlBufferPtr buf) len = xmlBufferLength(buf) + VARHDRSZ; result = palloc(len); - VARATT_SIZEP(result) = len; + SET_VARSIZE(result, len); memcpy(VARDATA(result), xmlBufferContent(buf), len - VARHDRSZ); return result; |