@@ -73,21 +73,38 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
73
73
#define IndexTupleHasVarwidths (itup ) ((((IndexTuple) (itup))->t_info & INDEX_VAR_MASK))
74
74
75
75
76
+ /* routines in indextuple.c */
77
+ extern IndexTuple index_form_tuple (TupleDesc tupleDescriptor ,
78
+ Datum * values , bool * isnull );
79
+ extern IndexTuple index_form_tuple_context (TupleDesc tupleDescriptor ,
80
+ Datum * values , bool * isnull ,
81
+ MemoryContext context );
82
+ extern Datum nocache_index_getattr (IndexTuple tup , int attnum ,
83
+ TupleDesc tupleDesc );
84
+ extern void index_deform_tuple (IndexTuple tup , TupleDesc tupleDescriptor ,
85
+ Datum * values , bool * isnull );
86
+ extern void index_deform_tuple_internal (TupleDesc tupleDescriptor ,
87
+ Datum * values , bool * isnull ,
88
+ char * tp , bits8 * bp , int hasnulls );
89
+ extern IndexTuple CopyIndexTuple (IndexTuple source );
90
+ extern IndexTuple index_truncate_tuple (TupleDesc sourceDescriptor ,
91
+ IndexTuple source , int leavenatts );
92
+
93
+
76
94
/*
77
95
* Takes an infomask as argument (primarily because this needs to be usable
78
96
* at index_form_tuple time so enough space is allocated).
79
97
*/
80
- #define IndexInfoFindDataOffset (t_info ) \
81
- ( \
82
- (!((t_info) & INDEX_NULL_MASK)) ? \
83
- ( \
84
- (Size)MAXALIGN(sizeof(IndexTupleData)) \
85
- ) \
86
- : \
87
- ( \
88
- (Size)MAXALIGN(sizeof(IndexTupleData) + sizeof(IndexAttributeBitMapData)) \
89
- ) \
90
- )
98
+ static inline Size
99
+ IndexInfoFindDataOffset (unsigned short t_info )
100
+ {
101
+ if (!(t_info & INDEX_NULL_MASK ))
102
+ return MAXALIGN (sizeof (IndexTupleData ));
103
+ else
104
+ return MAXALIGN (sizeof (IndexTupleData ) + sizeof (IndexAttributeBitMapData ));
105
+ }
106
+
107
+ #ifndef FRONTEND
91
108
92
109
/* ----------------
93
110
* index_getattr
@@ -97,34 +114,38 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
97
114
*
98
115
* ----------------
99
116
*/
100
- #define index_getattr (tup , attnum , tupleDesc , isnull ) \
101
- ( \
102
- AssertMacro(PointerIsValid(isnull) && (attnum) > 0), \
103
- *(isnull) = false, \
104
- !IndexTupleHasNulls(tup) ? \
105
- ( \
106
- TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
107
- ( \
108
- fetchatt(TupleDescAttr((tupleDesc), (attnum)-1), \
109
- (char *) (tup) + IndexInfoFindDataOffset((tup)->t_info) \
110
- + TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff) \
111
- ) \
112
- : \
113
- nocache_index_getattr((tup), (attnum), (tupleDesc)) \
114
- ) \
115
- : \
116
- ( \
117
- (att_isnull((attnum)-1, (bits8 *)(tup) + sizeof(IndexTupleData))) ? \
118
- ( \
119
- *(isnull) = true, \
120
- (Datum)NULL \
121
- ) \
122
- : \
123
- ( \
124
- nocache_index_getattr((tup), (attnum), (tupleDesc)) \
125
- ) \
126
- ) \
127
- )
117
+ static inline Datum
118
+ index_getattr (IndexTuple tup , int attnum , TupleDesc tupleDesc , bool * isnull )
119
+ {
120
+ Assert (PointerIsValid (isnull ));
121
+ Assert (attnum > 0 );
122
+
123
+ * isnull = false;
124
+
125
+ if (!IndexTupleHasNulls (tup ))
126
+ {
127
+ if (TupleDescAttr (tupleDesc , attnum - 1 )-> attcacheoff >= 0 )
128
+ {
129
+ return fetchatt (TupleDescAttr (tupleDesc , attnum - 1 ),
130
+ (char * ) tup + IndexInfoFindDataOffset (tup -> t_info )
131
+ + TupleDescAttr (tupleDesc , attnum - 1 )-> attcacheoff );
132
+ }
133
+ else
134
+ return nocache_index_getattr (tup , attnum , tupleDesc );
135
+ }
136
+ else
137
+ {
138
+ if (att_isnull (attnum - 1 , (bits8 * ) tup + sizeof (IndexTupleData )))
139
+ {
140
+ * isnull = true;
141
+ return (Datum ) NULL ;
142
+ }
143
+ else
144
+ return nocache_index_getattr (tup , attnum , tupleDesc );
145
+ }
146
+ }
147
+
148
+ #endif
128
149
129
150
/*
130
151
* MaxIndexTuplesPerPage is an upper bound on the number of tuples that can
@@ -146,22 +167,4 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
146
167
((int) ((BLCKSZ - SizeOfPageHeaderData) / \
147
168
(MAXALIGN(sizeof(IndexTupleData) + 1) + sizeof(ItemIdData))))
148
169
149
-
150
- /* routines in indextuple.c */
151
- extern IndexTuple index_form_tuple (TupleDesc tupleDescriptor ,
152
- Datum * values , bool * isnull );
153
- extern IndexTuple index_form_tuple_context (TupleDesc tupleDescriptor ,
154
- Datum * values , bool * isnull ,
155
- MemoryContext context );
156
- extern Datum nocache_index_getattr (IndexTuple tup , int attnum ,
157
- TupleDesc tupleDesc );
158
- extern void index_deform_tuple (IndexTuple tup , TupleDesc tupleDescriptor ,
159
- Datum * values , bool * isnull );
160
- extern void index_deform_tuple_internal (TupleDesc tupleDescriptor ,
161
- Datum * values , bool * isnull ,
162
- char * tp , bits8 * bp , int hasnulls );
163
- extern IndexTuple CopyIndexTuple (IndexTuple source );
164
- extern IndexTuple index_truncate_tuple (TupleDesc sourceDescriptor ,
165
- IndexTuple source , int leavenatts );
166
-
167
170
#endif /* ITUP_H */
0 commit comments