mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +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:
@ -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;
|
||||
|
Reference in New Issue
Block a user