1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-11 10:01:57 +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:
Tom Lane
2007-02-27 23:48:10 +00:00
parent 0459b591fc
commit 234a02b2a8
87 changed files with 483 additions and 498 deletions

View File

@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1995, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/postgres.h,v 1.76 2007/01/05 22:19:50 momjian Exp $
* $PostgreSQL: pgsql/src/include/postgres.h,v 1.77 2007/02/27 23:48:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -56,12 +56,13 @@
/* ----------------
* struct varattrib is the header of a varlena object that may have been
* TOASTed.
* TOASTed. Generally, only the code closely associated with TOAST logic
* should mess directly with struct varattrib or use the VARATT_FOO macros.
* ----------------
*/
typedef struct varattrib
{
int32 va_header; /* External/compressed storage */
int32 va_header_; /* External/compressed storage */
/* flags and item size */
union
{
@ -88,20 +89,21 @@ typedef struct varattrib
#define VARATT_MASK_FLAGS 0xc0000000
#define VARATT_MASK_SIZE 0x3fffffff
#define VARATT_SIZEP(_PTR) (((varattrib *)(_PTR))->va_header)
#define VARATT_SIZE(PTR) (VARATT_SIZEP(PTR) & VARATT_MASK_SIZE)
#define VARATT_DATA(PTR) (((varattrib *)(PTR))->va_content.va_data)
#define VARATT_CDATA(PTR) (((varattrib *)(PTR))->va_content.va_compressed.va_data)
#define VARSIZE(__PTR) VARATT_SIZE(__PTR)
#define VARDATA(__PTR) VARATT_DATA(__PTR)
#define VARATT_SIZEP_DEPRECATED(PTR) (((varattrib *) (PTR))->va_header_)
#define VARATT_IS_EXTENDED(PTR) \
((VARATT_SIZEP(PTR) & VARATT_MASK_FLAGS) != 0)
((VARATT_SIZEP_DEPRECATED(PTR) & VARATT_MASK_FLAGS) != 0)
#define VARATT_IS_EXTERNAL(PTR) \
((VARATT_SIZEP(PTR) & VARATT_FLAG_EXTERNAL) != 0)
((VARATT_SIZEP_DEPRECATED(PTR) & VARATT_FLAG_EXTERNAL) != 0)
#define VARATT_IS_COMPRESSED(PTR) \
((VARATT_SIZEP(PTR) & VARATT_FLAG_COMPRESSED) != 0)
((VARATT_SIZEP_DEPRECATED(PTR) & VARATT_FLAG_COMPRESSED) != 0)
/* These macros are the ones for non-TOAST code to use */
#define VARSIZE(PTR) (VARATT_SIZEP_DEPRECATED(PTR) & VARATT_MASK_SIZE)
#define VARDATA(PTR) (((varattrib *) (PTR))->va_content.va_data)
#define SET_VARSIZE(PTR,SIZE) (VARATT_SIZEP_DEPRECATED(PTR) = (SIZE))
/* ----------------------------------------------------------------