77 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88 * Portions Copyright (c) 1994, Regents of the University of California
99 *
10- * $PostgreSQL: pgsql/src/include/access/itup.h,v 1.42 2005/03/21 01:24:04 tgl Exp $
10+ * $PostgreSQL: pgsql/src/include/access/itup.h,v 1.43 2005/03/27 18:38:27 tgl Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
1414#ifndef ITUP_H
1515#define ITUP_H
1616
17- #include "access/ibit.h"
1817#include "access/tupdesc.h"
1918#include "access/tupmacs.h"
2019#include "storage/itemptr.h"
2120
2221
22+ /*
23+ * Index tuple header structure
24+ *
25+ * All index tuples start with IndexTupleData. If the HasNulls bit is set,
26+ * this is followed by an IndexAttributeBitMapData. The index attribute
27+ * values follow, beginning at a MAXALIGN boundary.
28+ *
29+ * Note that the space allocated for the bitmap does not vary with the number
30+ * of attributes; that is because we don't have room to store the number of
31+ * attributes in the header. Given the MAXALIGN constraint there's no space
32+ * savings to be had anyway, for usual values of INDEX_MAX_KEYS.
33+ */
34+
2335typedef struct IndexTupleData
2436{
2537 ItemPointerData t_tid ; /* reference TID to heap tuple */
@@ -36,44 +48,40 @@ typedef struct IndexTupleData
3648
3749 unsigned short t_info ; /* various info about tuple */
3850
39- /*
40- * please make sure sizeof(IndexTupleData) is MAXALIGN'ed. See
41- * IndexInfoFindDataOffset() for the reason.
42- */
43-
4451} IndexTupleData ; /* MORE DATA FOLLOWS AT END OF STRUCT */
4552
4653typedef IndexTupleData * IndexTuple ;
4754
55+ typedef struct IndexAttributeBitMapData
56+ {
57+ bits8 bits [(INDEX_MAX_KEYS + 8 - 1 ) / 8 ];
58+ } IndexAttributeBitMapData ;
59+
60+ typedef IndexAttributeBitMapData * IndexAttributeBitMap ;
4861
49- /* ----------------
50- * externs
51- * ----------------
62+ /*
63+ * t_info manipulation macros
5264 */
53-
5465#define INDEX_SIZE_MASK 0x1FFF
55- #define INDEX_NULL_MASK 0x8000
66+ /* bit 0x2000 is not used at present */
5667#define INDEX_VAR_MASK 0x4000
57- /* bit 0x2000 is not used */
68+ #define INDEX_NULL_MASK 0x8000
5869
5970#define IndexTupleSize (itup ) ((Size) (((IndexTuple) (itup))->t_info & INDEX_SIZE_MASK))
6071#define IndexTupleDSize (itup ) ((Size) ((itup).t_info & INDEX_SIZE_MASK))
6172#define IndexTupleHasNulls (itup ) ((((IndexTuple) (itup))->t_info & INDEX_NULL_MASK))
6273#define IndexTupleHasVarwidths (itup ) ((((IndexTuple) (itup))->t_info & INDEX_VAR_MASK))
6374
64- #define IndexTupleHasMinHeader (itup ) (!IndexTupleHasNulls(itup))
6575
6676/*
6777 * Takes an infomask as argument (primarily because this needs to be usable
6878 * at index_form_tuple time so enough space is allocated).
69- *
70- * Change me if adding an attribute to IndexTuples!!!!!!!!!!!
7179 */
7280#define IndexInfoFindDataOffset (t_info ) \
7381( \
74- (!((unsigned short)( t_info) & INDEX_NULL_MASK)) ? \
82+ (!((t_info) & INDEX_NULL_MASK)) ? \
7583 ( \
76- (Size)sizeof(IndexTupleData) \
84+ (Size)MAXALIGN( sizeof(IndexTupleData) ) \
7785 ) \
7886 : \
7987 ( \
@@ -85,7 +93,7 @@ typedef IndexTupleData *IndexTuple;
8593 * index_getattr
8694 *
8795 * This gets called many times, so we macro the cacheable and NULL
88- * lookups, and call noncachegetattr () for the rest.
96+ * lookups, and call nocache_index_getattr () for the rest.
8997 *
9098 * ----------------
9199 */
@@ -98,21 +106,15 @@ typedef IndexTupleData *IndexTuple;
98106 (tupleDesc)->attrs[(attnum)-1]->attcacheoff >= 0 ? \
99107 ( \
100108 fetchatt((tupleDesc)->attrs[(attnum)-1], \
101- (char *) (tup) + \
102- ( \
103- IndexTupleHasMinHeader(tup) ? \
104- sizeof (*(tup)) \
105- : \
106- IndexInfoFindDataOffset((tup)->t_info) \
107- ) \
109+ (char *) (tup) + IndexInfoFindDataOffset((tup)->t_info) \
108110 + (tupleDesc)->attrs[(attnum)-1]->attcacheoff) \
109111 ) \
110112 : \
111113 nocache_index_getattr((tup), (attnum), (tupleDesc), (isnull)) \
112114 ) \
113115 : \
114116 ( \
115- (att_isnull((attnum)-1, (char *)(tup) + sizeof(*(tup) ))) ? \
117+ (att_isnull((attnum)-1, (char *)(tup) + sizeof(IndexTupleData ))) ? \
116118 ( \
117119 *(isnull) = true, \
118120 (Datum)NULL \
0 commit comments