mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
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
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user