aboutsummaryrefslogtreecommitdiff
path: root/src/include/postgres.h
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/include/postgres.h
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/include/postgres.h')
-rw-r--r--src/include/postgres.h28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/include/postgres.h b/src/include/postgres.h
index 03ffd89f5d7..c06333573e2 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -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))
/* ----------------------------------------------------------------