diff options
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r-- | src/backend/utils/adt/arrayfuncs.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/cash.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/char.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/float.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/formatting.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/int.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/int8.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/lztext.c | 188 | ||||
-rw-r--r-- | src/backend/utils/adt/mac.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/nabstime.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/network.c | 12 | ||||
-rw-r--r-- | src/backend/utils/adt/oid.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/oracle_compat.c | 24 | ||||
-rw-r--r-- | src/backend/utils/adt/pg_lzcompress.c | 14 | ||||
-rw-r--r-- | src/backend/utils/adt/regproc.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 10 | ||||
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 8 | ||||
-rw-r--r-- | src/backend/utils/adt/varbit.c | 24 | ||||
-rw-r--r-- | src/backend/utils/adt/varchar.c | 14 | ||||
-rw-r--r-- | src/backend/utils/adt/varlena.c | 10 | ||||
-rw-r--r-- | src/backend/utils/adt/version.c | 4 |
21 files changed, 149 insertions, 213 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index fe96d77f43a..3fc00613042 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.59 2000/06/14 18:17:42 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.60 2000/07/03 23:09:50 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -813,7 +813,7 @@ array_dims(PG_FUNCTION_ARGS) sprintf(p, "[%d:%d]", lb[i], dimv[i] + lb[i] - 1); p += strlen(p); } - VARSIZE(result) = strlen(VARDATA(result)) + VARHDRSZ; + VARATT_SIZEP(result) = strlen(VARDATA(result)) + VARHDRSZ; PG_RETURN_TEXT_P(result); } @@ -1151,7 +1151,7 @@ array_set(ArrayType *array, Int32GetDatum(SEEK_SET))) < 0) return array; v = (struct varlena *) palloc(elmlen + VARHDRSZ); - VARSIZE(v) = elmlen + VARHDRSZ; + VARATT_SIZEP(v) = elmlen + VARHDRSZ; ArrayCastAndSet(dataValue, elmbyval, elmlen, VARDATA(v)); #ifdef LOARRAY if (DatumGetInt32(DirectFunctionCall2(lowrite, diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index 484b8e8f942..09237e52755 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -9,7 +9,7 @@ * workings can be found in the book "Software Solutions in C" by * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.40 2000/06/15 03:32:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.41 2000/07/03 23:09:50 wieck Exp $ */ #include <limits.h> @@ -730,7 +730,7 @@ cash_words_out(Cash *value) /* make a text type for output */ result = (text *) palloc(strlen(buf) + VARHDRSZ); - VARSIZE(result) = strlen(buf) + VARHDRSZ; + VARATT_SIZEP(result) = strlen(buf) + VARHDRSZ; memcpy(VARDATA(result), buf, strlen(buf)); return result; diff --git a/src/backend/utils/adt/char.c b/src/backend/utils/adt/char.c index 04e40406f8b..b2c3080ca3c 100644 --- a/src/backend/utils/adt/char.c +++ b/src/backend/utils/adt/char.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.28 2000/06/05 07:28:51 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.29 2000/07/03 23:09:50 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -162,7 +162,7 @@ char_text(PG_FUNCTION_ARGS) char arg1 = PG_GETARG_CHAR(0); text *result = palloc(VARHDRSZ + 1); - VARSIZE(result) = VARHDRSZ + 1; + VARATT_SIZEP(result) = VARHDRSZ + 1; *(VARDATA(result)) = arg1; PG_RETURN_TEXT_P(result); diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index f8c3a3f1560..f618a10eb8e 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.61 2000/06/14 18:17:42 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.62 2000/07/03 23:09:50 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -953,7 +953,7 @@ float8_text(float64 num) result = palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; memmove(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); @@ -998,7 +998,7 @@ float4_text(float32 num) result = palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; memmove(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 2d1ae16c5eb..cf7d3618426 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * formatting.c * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.17 2000/07/03 16:01:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.18 2000/07/03 23:09:50 wieck Exp $ * * * Portions Copyright (c) 1999-2000, PostgreSQL, Inc @@ -2526,7 +2526,7 @@ timestamp_to_char(PG_FUNCTION_ARGS) result = (text *) palloc(len + 1 + VARHDRSZ); strcpy(VARDATA(result), VARDATA(result_tmp)); - VARSIZE(result) = len + VARHDRSZ; + VARATT_SIZEP(result) = len + VARHDRSZ; pfree(result_tmp); PG_RETURN_TEXT_P(result); @@ -3987,7 +3987,7 @@ do { \ result = (text *) palloc( len + 1 + VARHDRSZ); \ \ strcpy( VARDATA(result), VARDATA(result_tmp)); \ - VARSIZE(result) = len + VARHDRSZ; \ + VARATT_SIZEP(result) = len + VARHDRSZ; \ pfree(result_tmp); \ } while(0) diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index b5f66f11188..7029ca73b89 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.38 2000/06/14 18:17:44 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.39 2000/07/03 23:09:52 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -263,7 +263,7 @@ int2_text(PG_FUNCTION_ARGS) text *result = (text *) palloc(7+VARHDRSZ); /* sign,5 digits, '\0' */ itoa((int) arg1, VARDATA(result)); - VARSIZE(result) = strlen(VARDATA(result)) + VARHDRSZ; + VARATT_SIZEP(result) = strlen(VARDATA(result)) + VARHDRSZ; PG_RETURN_TEXT_P(result); } @@ -294,7 +294,7 @@ int4_text(PG_FUNCTION_ARGS) text *result = (text *) palloc(12+VARHDRSZ); /* sign,10 digits,'\0' */ ltoa(arg1, VARDATA(result)); - VARSIZE(result) = strlen(VARDATA(result)) + VARHDRSZ; + VARATT_SIZEP(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 ea29ffaff55..63c09384612 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 - * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.21 2000/06/14 18:17:44 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.22 2000/07/03 23:09:52 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -581,7 +581,7 @@ int8_text(PG_FUNCTION_ARGS) result = (text *) palloc(VARHDRSZ + len); - VARSIZE(result) = len + VARHDRSZ; + VARATT_SIZEP(result) = len + VARHDRSZ; memcpy(VARDATA(result), s, len); pfree(s); diff --git a/src/backend/utils/adt/lztext.c b/src/backend/utils/adt/lztext.c index 4442d00351f..412445e727f 100644 --- a/src/backend/utils/adt/lztext.c +++ b/src/backend/utils/adt/lztext.c @@ -1,7 +1,7 @@ /* ---------- * lztext.c - * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/lztext.c,v 1.7 2000/05/30 00:49:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/lztext.c,v 1.8 2000/07/03 23:09:52 wieck Exp $ * * Text type with internal LZ compressed representation. Uses the * standard PostgreSQL compression method. @@ -34,8 +34,6 @@ lztextin(char *str) { lztext *result; int32 rawsize; - lztext *tmp; - int tmp_size; /* ---------- * Handle NULL @@ -44,35 +42,11 @@ lztextin(char *str) if (str == NULL) return NULL; - /* ---------- - * Determine input size and maximum output Datum size - * ---------- - */ rawsize = strlen(str); - tmp_size = PGLZ_MAX_OUTPUT(rawsize); - - /* ---------- - * Allocate a temporary result and compress into it - * ---------- - */ - tmp = (lztext *) palloc(tmp_size); - pglz_compress(str, rawsize, tmp, NULL); + result = (lztext *)palloc(VARHDRSZ + rawsize); - /* ---------- - * If we miss less than 25% bytes at the end of the temp value, - * so be it. Therefore we save a palloc()/memcpy()/pfree() - * sequence. - * ---------- - */ - if (tmp_size - tmp->varsize < 256 || - tmp_size - tmp->varsize < tmp_size / 4) - result = tmp; - else - { - result = (lztext *) palloc(tmp->varsize); - memcpy(result, tmp, tmp->varsize); - pfree(tmp); - } + VARATT_SIZEP(result) = VARHDRSZ + rawsize; + memcpy(VARATT_DATA(result), str, rawsize); return result; } @@ -88,6 +62,8 @@ char * lztextout(lztext *lz) { char *result; + void *tmp; + int32 rawsize; /* ---------- * Handle NULL @@ -101,25 +77,15 @@ lztextout(lztext *lz) return result; } - /* ---------- - * Allocate the result string - the required size is remembered - * in the lztext header so we don't need a temporary buffer or - * have to diddle with realloc's. - * ---------- - */ - result = (char *) palloc(PGLZ_RAW_SIZE(lz) + 1); + VARATT_GETPLAIN(lz, tmp); - /* ---------- - * Decompress and add terminating ZERO - * ---------- - */ - pglz_decompress(lz, result); - result[lz->rawsize] = '\0'; + rawsize = VARATT_SIZE(tmp) - VARHDRSZ; + result = (char *)palloc(rawsize + 1); + memcpy(result, VARATT_DATA(tmp), rawsize); + result[rawsize] = '\0'; + + VARATT_FREE(lz, tmp); - /* ---------- - * Return the result - * ---------- - */ return result; } @@ -167,7 +133,13 @@ lztextlen(lztext *lz) * without multibyte support, it's the remembered rawsize * ---------- */ - return PGLZ_RAW_SIZE(lz); + if (!VARATT_IS_EXTENDED(lz)) + return VARATT_SIZE(lz) - VARHDRSZ; + + if (VARATT_IS_EXTERNAL(lz)) + return lz->va_content.va_external.va_rawsize; + + return lz->va_content.va_compressed.va_rawsize; #endif } @@ -189,11 +161,10 @@ lztextoctetlen(lztext *lz) if (lz == NULL) return 0; - /* ---------- - * Return the varsize minus the VARSIZE field itself. - * ---------- - */ - return VARSIZE(lz) - VARHDRSZ; + if (!VARATT_IS_EXTERNAL(lz)) + return VARATT_SIZE(lz) - VARHDRSZ; + + return lz->va_content.va_external.va_extsize; } @@ -208,9 +179,6 @@ text_lztext(text *txt) { lztext *result; int32 rawsize; - lztext *tmp; - int tmp_size; - char *str; /* ---------- * Handle NULL @@ -220,35 +188,13 @@ text_lztext(text *txt) return NULL; /* ---------- - * Determine input size and eventually tuple size + * Copy the entire attribute * ---------- */ rawsize = VARSIZE(txt) - VARHDRSZ; - str = VARDATA(txt); - tmp_size = PGLZ_MAX_OUTPUT(rawsize); - - /* ---------- - * Allocate a temporary result and compress into it - * ---------- - */ - tmp = (lztext *) palloc(tmp_size); - pglz_compress(str, rawsize, tmp, NULL); - - /* ---------- - * If we miss less than 25% bytes at the end of the temp value, - * so be it. Therefore we save a palloc()/memcpy()/pfree() - * sequence. - * ---------- - */ - if (tmp_size - tmp->varsize < 256 || - tmp_size - tmp->varsize < tmp_size / 4) - result = tmp; - else - { - result = (lztext *) palloc(tmp->varsize); - memcpy(result, tmp, tmp->varsize); - pfree(tmp); - } + result = (lztext *)palloc(rawsize + VARHDRSZ); + VARATT_SIZEP(result) = rawsize + VARHDRSZ; + memcpy(VARATT_DATA(result), VARATT_DATA(txt), rawsize); return result; } @@ -264,6 +210,8 @@ text * lztext_text(lztext *lz) { text *result; + lztext *tmp; + int32 rawsize; /* ---------- * Handle NULL @@ -272,19 +220,14 @@ lztext_text(lztext *lz) if (lz == NULL) return NULL; - /* ---------- - * Allocate and initialize the text result - * ---------- - */ - result = (text *) palloc(PGLZ_RAW_SIZE(lz) + VARHDRSZ + 1); - VARSIZE(result) = lz->rawsize + VARHDRSZ; + VARATT_GETPLAIN(lz, tmp); + + rawsize = VARATT_SIZE(tmp) - VARHDRSZ; + result = (text *)palloc(rawsize + VARHDRSZ); + VARATT_SIZEP(result) = rawsize + VARHDRSZ; + memcpy(VARATT_DATA(result), VARATT_DATA(tmp), rawsize); - /* ---------- - * Decompress directly into the text data area. - * ---------- - */ - VARDATA(result)[lz->rawsize] = 0; - pglz_decompress(lz, VARDATA(result)); + VARATT_FREE(lz, tmp); return result; } @@ -322,43 +265,32 @@ lztext_cmp(lztext *lz1, lztext *lz2) #else /* !USE_LOCALE */ - PGLZ_DecompState ds1; - PGLZ_DecompState ds2; - int c1; - int c2; - int32 result = (int32) 0; + int result; + char *p1 = NULL; + char *p2 = NULL; + int size1; + int size2; if (lz1 == NULL || lz2 == NULL) - return (int32) 0; - - pglz_decomp_init(&ds1, lz1); - pglz_decomp_init(&ds2, lz2); - - for (;;) - { - c1 = pglz_decomp_getchar(&ds1); - c2 = pglz_decomp_getchar(&ds2); - - if (c1 == EOF) - { - if (c2 != EOF) - result = (int32) -1; - break; - } - else - { - if (c2 == EOF) - result = (int32) 1; - } - if (c1 != c2) - { - result = (int32) (c1 - c2); - break; - } - } + return 0; - pglz_decomp_end(&ds1); - pglz_decomp_end(&ds2); + VARATT_GETPLAIN(lz1, p1); + VARATT_GETPLAIN(lz2, p2); + + size1 = VARATT_SIZE(p1) - VARHDRSZ; + size2 = VARATT_SIZE(p2) - VARHDRSZ; + result = memcmp(VARATT_DATA(p1), VARATT_DATA(p2), + (size1 < size2) ? size1 : size2); + if (result == 0) + { + if (size1 > size2) + result = 1; + else if (size1 < size2) + result = -1; + } + + VARATT_FREE(lz2, p2); + VARATT_FREE(lz1, p1); return result; diff --git a/src/backend/utils/adt/mac.c b/src/backend/utils/adt/mac.c index 02fc1863b60..9d880a4aa69 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. * - * $Id: mac.c,v 1.14 1999/12/16 01:30:49 momjian Exp $ + * $Id: mac.c,v 1.15 2000/07/03 23:09:52 wieck Exp $ */ @@ -314,14 +314,14 @@ macaddr_manuf(macaddr *addr) { result = palloc(VARHDRSZ + 1); memset(result, 0, VARHDRSZ + 1); - VARSIZE(result) = VARHDRSZ + 1; + VARATT_SIZEP(result) = VARHDRSZ + 1; } else { length = strlen(manuf->name) + 1; result = palloc(length + VARHDRSZ); memset(result, 0, length + VARHDRSZ); - VARSIZE(result) = length + VARHDRSZ; + VARATT_SIZEP(result) = length + VARHDRSZ; memcpy(VARDATA(result), manuf->name, length); } return result; diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index 9a666ebd708..720517c9536 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.70 2000/06/27 18:08:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.71 2000/07/03 23:09:52 wieck Exp $ * * NOTES * @@ -1945,7 +1945,7 @@ timeofday(PG_FUNCTION_ARGS) len = VARHDRSZ + strlen(buf); result = (text *) palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; memcpy(VARDATA(result), buf, strlen(buf)); PG_RETURN_TEXT_P(result); } diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 7e1a9ead666..a5127ece26f 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -3,7 +3,7 @@ * is for IP V4 CIDR notation, but prepared for V6: just * add the necessary bits where the comments indicate. * - * $Id: network.c,v 1.21 2000/04/12 17:15:50 momjian Exp $ + * $Id: network.c,v 1.22 2000/07/03 23:09:52 wieck Exp $ * Jon Postel RIP 16 Oct 1998 */ @@ -61,7 +61,7 @@ network_in(char *src, int type) /* Go for an IPV6 address here, before faulting out: */ elog(ERROR, "could not parse \"%s\"", src); - VARSIZE(dst) = VARHDRSZ + VARATT_SIZEP(dst) = VARHDRSZ + ((char *) &ip_v4addr(dst) - (char *) VARDATA(dst)) + ip_addrsize(dst); ip_bits(dst) = bits; @@ -346,7 +346,7 @@ network_host(inet *ip) if (ret == NULL) elog(ERROR, "unable to allocate memory in network_host()"); - VARSIZE(ret) = len; + VARATT_SIZEP(ret) = len; strcpy(VARDATA(ret), tmp); return (ret); } @@ -396,7 +396,7 @@ network_broadcast(inet *ip) if (ret == NULL) elog(ERROR, "unable to allocate memory in network_broadcast()"); - VARSIZE(ret) = len; + VARATT_SIZEP(ret) = len; strcpy(VARDATA(ret), tmp); return (ret); } @@ -429,7 +429,7 @@ network_network(inet *ip) if (ret == NULL) elog(ERROR, "unable to allocate memory in network_network()"); - VARSIZE(ret) = len; + VARATT_SIZEP(ret) = len; strcpy(VARDATA(ret), tmp); return (ret); } @@ -466,7 +466,7 @@ network_netmask(inet *ip) if (ret == NULL) elog(ERROR, "unable to allocate memory in network_netmask()"); - VARSIZE(ret) = len; + VARATT_SIZEP(ret) = len; strcpy(VARDATA(ret), tmp); return (ret); } diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c index 156237862b1..a51eadfc5ef 100644 --- a/src/backend/utils/adt/oid.c +++ b/src/backend/utils/adt/oid.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.36 2000/06/14 18:17:45 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.37 2000/07/03 23:09:52 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -231,7 +231,7 @@ oid_text(PG_FUNCTION_ARGS) result = (text *) palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(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 4455c04c556..5f0b1fa776a 100644 --- a/src/backend/utils/adt/oracle_compat.c +++ b/src/backend/utils/adt/oracle_compat.c @@ -1,7 +1,7 @@ /* * Edmund Mergl <E.Mergl@bawue.de> * - * $Id: oracle_compat.c,v 1.25 2000/06/13 07:35:07 tgl Exp $ + * $Id: oracle_compat.c,v 1.26 2000/07/03 23:09:52 wieck Exp $ * */ @@ -37,7 +37,7 @@ lower(text *string) return string; ret = (text *) palloc(VARSIZE(string)); - VARSIZE(ret) = VARSIZE(string); + VARATT_SIZEP(ret) = VARSIZE(string); ptr = VARDATA(string); ptr_ret = VARDATA(ret); @@ -75,7 +75,7 @@ upper(text *string) return string; ret = (text *) palloc(VARSIZE(string)); - VARSIZE(ret) = VARSIZE(string); + VARATT_SIZEP(ret) = VARSIZE(string); ptr = VARDATA(string); ptr_ret = VARDATA(ret); @@ -115,7 +115,7 @@ initcap(text *string) return string; ret = (text *) palloc(VARSIZE(string)); - VARSIZE(ret) = VARSIZE(string); + VARATT_SIZEP(ret) = VARSIZE(string); ptr = VARDATA(string); ptr_ret = VARDATA(ret); @@ -169,7 +169,7 @@ lpad(PG_FUNCTION_ARGS) PG_RETURN_TEXT_P(string1); ret = (text *) palloc(VARHDRSZ + len); - VARSIZE(ret) = VARHDRSZ + len; + VARATT_SIZEP(ret) = VARHDRSZ + len; ptr2 = VARDATA(string2); ptr_ret = VARDATA(ret); @@ -224,7 +224,7 @@ rpad(PG_FUNCTION_ARGS) PG_RETURN_TEXT_P(string1); ret = (text *) palloc(VARHDRSZ + len); - VARSIZE(ret) = VARHDRSZ + len; + VARATT_SIZEP(ret) = VARHDRSZ + len; n = VARSIZE(string1) - VARHDRSZ; ptr1 = VARDATA(string1); @@ -316,7 +316,7 @@ btrim(text *string, text *set) ++m; ret = (text *) palloc(VARHDRSZ + m); - VARSIZE(ret) = VARHDRSZ + m; + VARATT_SIZEP(ret) = VARHDRSZ + m; memcpy(VARDATA(ret), ptr, m); return ret; @@ -374,7 +374,7 @@ ltrim(text *string, text *set) ++m; ret = (text *) palloc(VARHDRSZ + m); - VARSIZE(ret) = VARHDRSZ + m; + VARATT_SIZEP(ret) = VARHDRSZ + m; memcpy(VARDATA(ret), ptr, m); @@ -434,7 +434,7 @@ rtrim(text *string, text *set) ++m; ret = (text *) palloc(VARHDRSZ + m); - VARSIZE(ret) = VARHDRSZ + m; + VARATT_SIZEP(ret) = VARHDRSZ + m; #ifdef NOT_USED memcpy(VARDATA(ret), ptr - VARSIZE(ret) + m, m); #endif @@ -528,7 +528,7 @@ translate(text *string, text *from, text *to) } } - VARSIZE(result) = retlen + VARHDRSZ; + VARATT_SIZEP(result) = retlen + VARHDRSZ; /* * There may be some wasted space in the result if deletions occurred, @@ -560,7 +560,7 @@ ichar(PG_FUNCTION_ARGS) text *result; result = (text *) palloc(VARHDRSZ + 1); - VARSIZE(result) = VARHDRSZ + 1; + VARATT_SIZEP(result) = VARHDRSZ + 1; *VARDATA(result) = (char) cvalue; PG_RETURN_TEXT_P(result); @@ -586,7 +586,7 @@ repeat(PG_FUNCTION_ARGS) result = (text *) palloc(tlen); - VARSIZE(result) = tlen; + VARATT_SIZEP(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 f4e6ac5be37..493b4e64465 100644 --- a/src/backend/utils/adt/pg_lzcompress.c +++ b/src/backend/utils/adt/pg_lzcompress.c @@ -1,7 +1,7 @@ /* ---------- * pg_lzcompress.c - * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.5 2000/05/30 00:49:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.6 2000/07/03 23:09:52 wieck Exp $ * * This is an implementation of LZ compression for PostgreSQL. * It uses a simple history table and generates 2-3 byte tags @@ -582,11 +582,15 @@ pglz_compress(char *source, int slen, PGLZ_Header *dest, PGLZ_Strategy *strategy * ---------- */ if (do_compress) - return (dest->varsize = result_size + sizeof(PGLZ_Header)); + { + dest->varsize = result_size + sizeof(PGLZ_Header); + return VARATT_SIZE(dest); + } else { memcpy(((char *) dest) + sizeof(PGLZ_Header), source, slen); - return (dest->varsize = slen + sizeof(PGLZ_Header)); + dest->varsize = slen + sizeof(PGLZ_Header); + return VARATT_SIZE(dest); } } @@ -609,10 +613,10 @@ pglz_decompress(PGLZ_Header *source, char *dest) int32 off; dp = ((unsigned char *) source) + sizeof(PGLZ_Header); - dend = ((unsigned char *) source) + source->varsize; + dend = ((unsigned char *) source) + VARATT_SIZE(source); bp = (unsigned char *) dest; - if (source->varsize == source->rawsize + sizeof(PGLZ_Header)) + if (VARATT_SIZE(source) == source->rawsize + sizeof(PGLZ_Header)) { memcpy(dest, dp, source->rawsize); return source->rawsize; diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index c5fbeadff6a..6660d15f1d6 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.56 2000/06/05 07:28:52 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.57 2000/07/03 23:09:52 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -282,7 +282,7 @@ oidvectortypes(PG_FUNCTION_ARGS) else strcat(VARDATA(result), "- "); } - VARSIZE(result) = strlen(VARDATA(result)) + VARHDRSZ; + VARATT_SIZEP(result) = strlen(VARDATA(result)) + VARHDRSZ; PG_RETURN_TEXT_P(result); } diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 5b2a2ea0163..5bd339a5cc9 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * out of its tuple * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.54 2000/06/13 07:35:08 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.55 2000/07/03 23:09:52 wieck Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -181,7 +181,7 @@ pg_get_ruledef(NameData *rname) if (SPI_finish() != SPI_OK_FINISH) elog(ERROR, "get_ruledef: SPI_finish() failed"); ruledef = SPI_palloc(VARHDRSZ + 1); - VARSIZE(ruledef) = VARHDRSZ + 1; + VARATT_SIZEP(ruledef) = VARHDRSZ + 1; VARDATA(ruledef)[0] = '-'; return ruledef; } @@ -197,7 +197,7 @@ pg_get_ruledef(NameData *rname) make_ruledef(&buf, ruletup, rulettc); len = buf.len + VARHDRSZ; ruledef = SPI_palloc(len); - VARSIZE(ruledef) = len; + VARATT_SIZEP(ruledef) = len; memcpy(VARDATA(ruledef), buf.data, buf.len); pfree(buf.data); @@ -296,7 +296,7 @@ pg_get_viewdef(NameData *rname) } len = buf.len + VARHDRSZ; ruledef = SPI_palloc(len); - VARSIZE(ruledef) = len; + VARATT_SIZEP(ruledef) = len; memcpy(VARDATA(ruledef), buf.data, buf.len); pfree(buf.data); @@ -530,7 +530,7 @@ pg_get_indexdef(PG_FUNCTION_ARGS) */ len = buf.len + VARHDRSZ; indexdef = SPI_palloc(len); - VARSIZE(indexdef) = len; + VARATT_SIZEP(indexdef) = len; memcpy(VARDATA(indexdef), buf.data, buf.len); pfree(buf.data); pfree(keybuf.data); diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 71549bb9256..4b3f498a2af 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.30 2000/06/19 03:54:27 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.31 2000/07/03 23:09:53 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -1375,7 +1375,7 @@ timestamp_text(PG_FUNCTION_ARGS) result = palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; memmove(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); @@ -1430,7 +1430,7 @@ interval_text(PG_FUNCTION_ARGS) result = palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; memmove(VARDATA(result), str, (len - VARHDRSZ)); pfree(str); @@ -2101,7 +2101,7 @@ timestamp_zone(PG_FUNCTION_ARGS) result = palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; memmove(VARDATA(result), buf, (len - VARHDRSZ)); } else diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index 3e4abe828bb..b5d2e18e104 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -4,7 +4,7 @@ * Functions for the built-in type bit() and varying bit(). * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.3 2000/06/15 03:32:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.4 2000/07/03 23:09:53 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -122,7 +122,7 @@ zpbit_in(char *s, int dummy, int32 atttypmod) result = (bits8 *) palloc(len); /* set to 0 so that *r is always initialised and strin is zero-padded */ memset(result, 0, len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; VARBITLEN(result) = atttypmod; /* @@ -353,7 +353,7 @@ varbit_in(char *s, int dummy, int32 atttypmod) result = (bits8 *) palloc(len); /* set to 0 so that *r is always initialised and strin is zero-padded */ memset(result, 0, len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; VARBITLEN(result) = bitlen; /* @@ -561,7 +561,7 @@ bitcat(bits8 *arg1, bits8 *arg2) bytelen = VARBITDATALEN(bitlen1 + bitlen2); result = (bits8 *) palloc(bytelen * sizeof(bits8)); - VARSIZE(result) = bytelen; + VARATT_SIZEP(result) = bytelen; VARBITLEN(result) = bitlen1 + bitlen2; /* Copy the first bitstring in */ memcpy(VARBITS(result), VARBITS(arg1), VARBITBYTES(arg1)); @@ -625,7 +625,7 @@ bitsubstr(bits8 *arg, int32 s, int32 l) len = VARBITDATALEN(0); result = (bits8 *) palloc(len); VARBITLEN(result) = 0; - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; } else { @@ -638,7 +638,7 @@ bitsubstr(bits8 *arg, int32 s, int32 l) len = VARBITDATALEN(rbitlen); result = (bits8 *) palloc(len); VARBITLEN(result) = rbitlen; - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; len -= VARHDRSZ + VARBITHDRSZ; /* Are we copying from a byte boundary? */ if ((s1 - 1) % BITSPERBYTE == 0) @@ -691,7 +691,7 @@ bitand(bits8 *arg1, bits8 *arg2) len = Min(VARSIZE(arg1), VARSIZE(arg2)); result = (bits8 *) palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2)); p1 = (bits8 *) VARBITS(arg1); @@ -725,7 +725,7 @@ bitor(bits8 *arg1, bits8 *arg2) len = Min(VARSIZE(arg1), VARSIZE(arg2)); result = (bits8 *) palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2)); p1 = (bits8 *) VARBITS(arg1); @@ -761,7 +761,7 @@ bitxor(bits8 *arg1, bits8 *arg2) len = Min(VARSIZE(arg1), VARSIZE(arg2)); result = (bits8 *) palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; VARBITLEN(result) = Min(VARBITLEN(arg1), VARBITLEN(arg2)); p1 = (bits8 *) VARBITS(arg1); @@ -792,7 +792,7 @@ bitnot(bits8 *arg) return (bool) 0; result = (bits8 *) palloc(VARSIZE(arg)); - VARSIZE(result) = VARSIZE(arg); + VARATT_SIZEP(result) = VARSIZE(arg); VARBITLEN(result) = VARBITLEN(arg); p = (bits8 *) VARBITS(arg); @@ -828,7 +828,7 @@ bitshiftleft(bits8 *arg, int shft) return bitshiftright(arg, -shft); result = (bits8 *) palloc(VARSIZE(arg)); - VARSIZE(result) = VARSIZE(arg); + VARATT_SIZEP(result) = VARSIZE(arg); VARBITLEN(result) = VARBITLEN(arg); r = (bits8 *) VARBITS(result); @@ -879,7 +879,7 @@ bitshiftright(bits8 *arg, int shft) return bitshiftleft(arg, -shft); result = (bits8 *) palloc(VARSIZE(arg)); - VARSIZE(result) = VARSIZE(arg); + VARATT_SIZEP(result) = VARSIZE(arg); VARBITLEN(result) = VARBITLEN(arg); r = (bits8 *) VARBITS(result); diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 53c6ec41677..6f17cb589ae 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.66 2000/06/19 03:54:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.67 2000/07/03 23:09:53 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -88,7 +88,7 @@ bpcharin(PG_FUNCTION_ARGS) len = atttypmod - VARHDRSZ; result = (BpChar *) palloc(atttypmod); - VARSIZE(result) = atttypmod; + VARATT_SIZEP(result) = atttypmod; r = VARDATA(result); for (i = 0; i < len; i++, r++, s++) { @@ -154,7 +154,7 @@ bpchar(PG_FUNCTION_ARGS) #endif result = (BpChar *) palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; r = VARDATA(result); #ifdef MULTIBYTE @@ -248,7 +248,7 @@ char_bpchar(PG_FUNCTION_ARGS) result = (BpChar *) palloc(VARHDRSZ + 1); - VARSIZE(result) = VARHDRSZ + 1; + VARATT_SIZEP(result) = VARHDRSZ + 1; *(VARDATA(result)) = c; PG_RETURN_BPCHAR_P(result); @@ -317,7 +317,7 @@ name_bpchar(NameData *s) result = (char *) palloc(VARHDRSZ + len); strncpy(VARDATA(result), NameStr(*s), len); - VARSIZE(result) = len + VARHDRSZ; + VARATT_SIZEP(result) = len + VARHDRSZ; return result; } /* name_bpchar() */ @@ -348,7 +348,7 @@ varcharin(PG_FUNCTION_ARGS) len = atttypmod; /* clip the string at max length */ result = (VarChar *) palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; memcpy(VARDATA(result), s, len - VARHDRSZ); #ifdef CYR_RECODE @@ -407,7 +407,7 @@ varchar(PG_FUNCTION_ARGS) #endif result = (VarChar *) palloc(slen); - VARSIZE(result) = slen; + VARATT_SIZEP(result) = slen; memcpy(VARDATA(result), VARDATA(s), len); PG_RETURN_VARCHAR_P(result); diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index fedd29f0c3e..114bcff29a4 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.60 2000/06/14 18:17:45 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.61 2000/07/03 23:09:54 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -157,7 +157,7 @@ textin(char *inputText) len = strlen(inputText) + VARHDRSZ; result = (text *) palloc(len); - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; memmove(VARDATA(result), inputText, len - VARHDRSZ); @@ -288,7 +288,7 @@ textcat(text *t1, text *t2) result = palloc(len); /* Set size of result string... */ - VARSIZE(result) = len; + VARATT_SIZEP(result) = len; /* Fill data field of result string... */ ptr = VARDATA(result); @@ -374,7 +374,7 @@ text_substr(PG_FUNCTION_ARGS) #endif ret = (text *) palloc(VARHDRSZ + n); - VARSIZE(ret) = VARHDRSZ + n; + VARATT_SIZEP(ret) = VARHDRSZ + n; memcpy(VARDATA(ret), VARDATA(string) + m, n); @@ -842,7 +842,7 @@ name_text(NameData *s) result = palloc(VARHDRSZ + len); strncpy(VARDATA(result), NameStr(*s), len); - VARSIZE(result) = len + VARHDRSZ; + VARATT_SIZEP(result) = len + VARHDRSZ; return result; } /* name_text() */ diff --git a/src/backend/utils/adt/version.c b/src/backend/utils/adt/version.c index 4914acc8e35..0cf0b7859e8 100644 --- a/src/backend/utils/adt/version.c +++ b/src/backend/utils/adt/version.c @@ -5,7 +5,7 @@ * * IDENTIFICATION * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/version.c,v 1.10 2000/07/02 15:20:51 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/version.c,v 1.11 2000/07/03 23:09:54 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -22,7 +22,7 @@ version(void) int n = strlen(PG_VERSION_STR) + VARHDRSZ; text *ret = (text *) palloc(n); - VARSIZE(ret) = n; + VARATT_SIZEP(ret) = n; memcpy(VARDATA(ret), PG_VERSION_STR, strlen(PG_VERSION_STR)); return ret; |