diff options
| author | Bruce Momjian <bruce@momjian.us> | 2002-07-20 05:16:59 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 2002-07-20 05:16:59 +0000 |
| commit | b0f5086e4133d1d8ec092799952dda65ebd717c8 (patch) | |
| tree | 0f717342af7cce7896d40fdb34ccc572e435d499 /src/include/access/htup.h | |
| parent | 38dd3ae7d032eecc6ddadcbd402d90f6ac38f6a3 (diff) | |
| download | postgresql-b0f5086e4133d1d8ec092799952dda65ebd717c8.tar.gz | |
oid is needed, it is added at the end of the struct (after the null
bitmap, if present).
Per Tom Lane's suggestion the information whether a tuple has an oid
or not is carried in the tuple descriptor. For debugging reasons
tdhasoid is of type char, not bool. There are predefined values for
WITHOID, WITHOUTOID and UNDEFOID.
This patch has been generated against a cvs snapshot from last week
and I don't expect it to apply cleanly to current sources. While I
post it here for public review, I'm working on a new version against a
current snapshot. (There's been heavy activity recently; hope to
catch up some day ...)
This is a long patch; if it is too hard to swallow, I can provide it
in smaller pieces:
Part 1: Accessor macros
Part 2: tdhasoid in TupDesc
Part 3: Regression test
Part 4: Parameter withoid to heap_addheader
Part 5: Eliminate t_oid from HeapTupleHeader
Part 2 is the most hairy part because of changes in the executor and
even in the parser; the other parts are straightforward.
Up to part 4 the patched postmaster stays binary compatible to
databases created with an unpatched version. Part 5 is small (100
lines) and finally breaks compatibility.
Manfred Koizar
Diffstat (limited to 'src/include/access/htup.h')
| -rw-r--r-- | src/include/access/htup.h | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/include/access/htup.h b/src/include/access/htup.h index 87f1727f9e..5da1c3608e 100644 --- a/src/include/access/htup.h +++ b/src/include/access/htup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: htup.h,v 1.56 2002/07/08 01:52:23 momjian Exp $ + * $Id: htup.h,v 1.57 2002/07/20 05:16:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,8 +70,6 @@ */ typedef struct HeapTupleHeaderData { - Oid t_oid; /* OID of this tuple -- 4 bytes */ - TransactionId t_xmin; /* Xmin -- 4 bytes each */ TransactionId t_cid; /* Cmin, Cmax, Xvac */ TransactionId t_xmax; /* Xmax, Cmax */ @@ -84,7 +82,7 @@ typedef struct HeapTupleHeaderData uint8 t_hoff; /* sizeof header incl. bitmap, padding */ - /* ^ - 27 bytes - ^ */ + /* ^ - 23 bytes - ^ */ bits8 t_bits[1]; /* bitmap of NULLs -- VARIABLE LENGTH */ @@ -123,10 +121,42 @@ typedef HeapTupleHeaderData *HeapTupleHeader; #define HEAP_XACT_MASK 0xFFF0 /* visibility-related bits */ +/* paranoid checking */ + +#ifdef DEBUG_TUPLE_ACCESS + +#define HeapTupleHeaderExpectedLen(tup, withoid) \ + MAXALIGN(offsetof(HeapTupleHeaderData, t_bits) + \ + (((tup)->t_infomask & HEAP_HASNULL) \ + ? BITMAPLEN((tup)->t_natts) : 0) + \ + ((withoid) ? sizeof(Oid) : 0) \ + ) + +#define AssertHeapTupleHeaderHoffIsValid(tup, withoid) \ + AssertMacro((tup)->t_hoff == HeapTupleHeaderExpectedLen(tup, withoid)) + +#else + +#define AssertHeapTupleHeaderHoffIsValid(tup, withoid) ((void)true) + +#endif /* DEBUG_TUPLE_ACCESS */ /* HeapTupleHeader accessor macros */ +#define HeapTupleHeaderGetOid(tup) \ +( \ + AssertHeapTupleHeaderHoffIsValid(tup, true), \ + *((Oid *)((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) \ +) + +#define HeapTupleHeaderSetOid(tup, oid) \ +( \ + AssertHeapTupleHeaderHoffIsValid(tup, true), \ + *((Oid *)((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) = (oid) \ +) + + #define HeapTupleHeaderGetXmin(tup) \ ( \ (tup)->t_xmin \ @@ -406,4 +436,10 @@ typedef HeapTupleData *HeapTuple; #define HeapTupleHasExtended(tuple) \ ((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASEXTENDED) != 0) +#define HeapTupleGetOid(tuple) \ + HeapTupleHeaderGetOid(((HeapTuple)(tuple))->t_data) + +#define HeapTupleSetOid(tuple, oid) \ + HeapTupleHeaderSetOid(((HeapTuple)(tuple))->t_data, (oid)) + #endif /* HTUP_H */ |
