aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/varbit.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-02-27 23:48:10 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-02-27 23:48:10 +0000
commit234a02b2a888cacc4c09363cc1411ae4eac9bb51 (patch)
tree4aadb74b5d7bbcfc3cdae9c8703eac168d6108ae /src/backend/utils/adt/varbit.c
parent0459b591fc90b197ed31923b170c658cc30758d5 (diff)
downloadpostgresql-234a02b2a888cacc4c09363cc1411ae4eac9bb51.tar.gz
postgresql-234a02b2a888cacc4c09363cc1411ae4eac9bb51.zip
Replace direct assignments to VARATT_SIZEP(x) with SET_VARSIZE(x, len).
Get rid of VARATT_SIZE and VARATT_DATA, which were simply redundant with VARSIZE and VARDATA, and as a consequence almost no code was using the longer names. Rename the length fields of struct varlena and various derived structures to catch anyplace that was accessing them directly; and clean up various places so caught. In itself this patch doesn't change any behavior at all, but it is necessary infrastructure if we hope to play any games with the representation of varlena headers. Greg Stark and Tom Lane
Diffstat (limited to 'src/backend/utils/adt/varbit.c')
-rw-r--r--src/backend/utils/adt/varbit.c36
1 files changed, 18 insertions, 18 deletions
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);