diff options
author | Tom Lane | 2007-02-27 23:48:10 +0000 |
---|---|---|
committer | Tom Lane | 2007-02-27 23:48:10 +0000 |
commit | 234a02b2a888cacc4c09363cc1411ae4eac9bb51 (patch) | |
tree | 4aadb74b5d7bbcfc3cdae9c8703eac168d6108ae /src/include/c.h | |
parent | 0459b591fc90b197ed31923b170c658cc30758d5 (diff) |
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/c.h')
-rw-r--r-- | src/include/c.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/include/c.h b/src/include/c.h index 0774ec7cc1e..73b72a816ad 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/c.h,v 1.218 2007/02/05 04:22:18 tgl Exp $ + * $PostgreSQL: pgsql/src/include/c.h,v 1.219 2007/02/27 23:48:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -399,13 +399,16 @@ typedef struct * NOTE: for TOASTable types, this is an oversimplification, since the value * may be compressed or moved out-of-line. However datatype-specific routines * are mostly content to deal with de-TOASTed values only, and of course - * client-side routines should never see a TOASTed value. See postgres.h for - * details of the TOASTed form. + * client-side routines should never see a TOASTed value. But even in a + * de-TOASTed value, beware of touching vl_len_ directly, as its representation + * is no longer convenient. It's recommended that code always use the VARDATA, + * VARSIZE, and SET_VARSIZE macros instead of relying on direct mentions of + * the struct fields. See postgres.h for details of the TOASTed form. * ---------------- */ struct varlena { - int32 vl_len; + int32 vl_len_; /* Do not touch this field directly! */ char vl_dat[1]; }; @@ -433,7 +436,7 @@ typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */ */ typedef struct { - int32 size; /* these fields must match ArrayType! */ + int32 vl_len_; /* these fields must match ArrayType! */ int ndim; /* always 1 for int2vector */ int32 dataoffset; /* always 0 for int2vector */ Oid elemtype; @@ -444,7 +447,7 @@ typedef struct typedef struct { - int32 size; /* these fields must match ArrayType! */ + int32 vl_len_; /* these fields must match ArrayType! */ int ndim; /* always 1 for oidvector */ int32 dataoffset; /* always 0 for oidvector */ Oid elemtype; |