Convert macros to static inline functions (itup.h)
Reviewed-by: Amul Sul <sulamul@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/5b558da8-99fb-0a99-83dd-f72f05388517%40enterprisedb.com
This commit is contained in:
parent
2cbc3c17a5
commit
14a8bd9827
@ -73,21 +73,38 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
|
|||||||
#define IndexTupleHasVarwidths(itup) ((((IndexTuple) (itup))->t_info & INDEX_VAR_MASK))
|
#define IndexTupleHasVarwidths(itup) ((((IndexTuple) (itup))->t_info & INDEX_VAR_MASK))
|
||||||
|
|
||||||
|
|
||||||
|
/* routines in indextuple.c */
|
||||||
|
extern IndexTuple index_form_tuple(TupleDesc tupleDescriptor,
|
||||||
|
Datum *values, bool *isnull);
|
||||||
|
extern IndexTuple index_form_tuple_context(TupleDesc tupleDescriptor,
|
||||||
|
Datum *values, bool *isnull,
|
||||||
|
MemoryContext context);
|
||||||
|
extern Datum nocache_index_getattr(IndexTuple tup, int attnum,
|
||||||
|
TupleDesc tupleDesc);
|
||||||
|
extern void index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor,
|
||||||
|
Datum *values, bool *isnull);
|
||||||
|
extern void index_deform_tuple_internal(TupleDesc tupleDescriptor,
|
||||||
|
Datum *values, bool *isnull,
|
||||||
|
char *tp, bits8 *bp, int hasnulls);
|
||||||
|
extern IndexTuple CopyIndexTuple(IndexTuple source);
|
||||||
|
extern IndexTuple index_truncate_tuple(TupleDesc sourceDescriptor,
|
||||||
|
IndexTuple source, int leavenatts);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Takes an infomask as argument (primarily because this needs to be usable
|
* Takes an infomask as argument (primarily because this needs to be usable
|
||||||
* at index_form_tuple time so enough space is allocated).
|
* at index_form_tuple time so enough space is allocated).
|
||||||
*/
|
*/
|
||||||
#define IndexInfoFindDataOffset(t_info) \
|
static inline Size
|
||||||
( \
|
IndexInfoFindDataOffset(unsigned short t_info)
|
||||||
(!((t_info) & INDEX_NULL_MASK)) ? \
|
{
|
||||||
( \
|
if (!(t_info & INDEX_NULL_MASK))
|
||||||
(Size)MAXALIGN(sizeof(IndexTupleData)) \
|
return MAXALIGN(sizeof(IndexTupleData));
|
||||||
) \
|
else
|
||||||
: \
|
return MAXALIGN(sizeof(IndexTupleData) + sizeof(IndexAttributeBitMapData));
|
||||||
( \
|
}
|
||||||
(Size)MAXALIGN(sizeof(IndexTupleData) + sizeof(IndexAttributeBitMapData)) \
|
|
||||||
) \
|
#ifndef FRONTEND
|
||||||
)
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* index_getattr
|
* index_getattr
|
||||||
@ -97,34 +114,38 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
|
|||||||
*
|
*
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
#define index_getattr(tup, attnum, tupleDesc, isnull) \
|
static inline Datum
|
||||||
( \
|
index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
|
||||||
AssertMacro(PointerIsValid(isnull) && (attnum) > 0), \
|
{
|
||||||
*(isnull) = false, \
|
Assert(PointerIsValid(isnull));
|
||||||
!IndexTupleHasNulls(tup) ? \
|
Assert(attnum > 0);
|
||||||
( \
|
|
||||||
TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
|
*isnull = false;
|
||||||
( \
|
|
||||||
fetchatt(TupleDescAttr((tupleDesc), (attnum)-1), \
|
if (!IndexTupleHasNulls(tup))
|
||||||
(char *) (tup) + IndexInfoFindDataOffset((tup)->t_info) \
|
{
|
||||||
+ TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff) \
|
if (TupleDescAttr(tupleDesc, attnum - 1)->attcacheoff >= 0)
|
||||||
) \
|
{
|
||||||
: \
|
return fetchatt(TupleDescAttr(tupleDesc, attnum - 1),
|
||||||
nocache_index_getattr((tup), (attnum), (tupleDesc)) \
|
(char *) tup + IndexInfoFindDataOffset(tup->t_info)
|
||||||
) \
|
+ TupleDescAttr(tupleDesc, attnum - 1)->attcacheoff);
|
||||||
: \
|
}
|
||||||
( \
|
else
|
||||||
(att_isnull((attnum)-1, (bits8 *)(tup) + sizeof(IndexTupleData))) ? \
|
return nocache_index_getattr(tup, attnum, tupleDesc);
|
||||||
( \
|
}
|
||||||
*(isnull) = true, \
|
else
|
||||||
(Datum)NULL \
|
{
|
||||||
) \
|
if (att_isnull(attnum - 1, (bits8 *) tup + sizeof(IndexTupleData)))
|
||||||
: \
|
{
|
||||||
( \
|
*isnull = true;
|
||||||
nocache_index_getattr((tup), (attnum), (tupleDesc)) \
|
return (Datum) NULL;
|
||||||
) \
|
}
|
||||||
) \
|
else
|
||||||
)
|
return nocache_index_getattr(tup, attnum, tupleDesc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MaxIndexTuplesPerPage is an upper bound on the number of tuples that can
|
* MaxIndexTuplesPerPage is an upper bound on the number of tuples that can
|
||||||
@ -146,22 +167,4 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
|
|||||||
((int) ((BLCKSZ - SizeOfPageHeaderData) / \
|
((int) ((BLCKSZ - SizeOfPageHeaderData) / \
|
||||||
(MAXALIGN(sizeof(IndexTupleData) + 1) + sizeof(ItemIdData))))
|
(MAXALIGN(sizeof(IndexTupleData) + 1) + sizeof(ItemIdData))))
|
||||||
|
|
||||||
|
|
||||||
/* routines in indextuple.c */
|
|
||||||
extern IndexTuple index_form_tuple(TupleDesc tupleDescriptor,
|
|
||||||
Datum *values, bool *isnull);
|
|
||||||
extern IndexTuple index_form_tuple_context(TupleDesc tupleDescriptor,
|
|
||||||
Datum *values, bool *isnull,
|
|
||||||
MemoryContext context);
|
|
||||||
extern Datum nocache_index_getattr(IndexTuple tup, int attnum,
|
|
||||||
TupleDesc tupleDesc);
|
|
||||||
extern void index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor,
|
|
||||||
Datum *values, bool *isnull);
|
|
||||||
extern void index_deform_tuple_internal(TupleDesc tupleDescriptor,
|
|
||||||
Datum *values, bool *isnull,
|
|
||||||
char *tp, bits8 *bp, int hasnulls);
|
|
||||||
extern IndexTuple CopyIndexTuple(IndexTuple source);
|
|
||||||
extern IndexTuple index_truncate_tuple(TupleDesc sourceDescriptor,
|
|
||||||
IndexTuple source, int leavenatts);
|
|
||||||
|
|
||||||
#endif /* ITUP_H */
|
#endif /* ITUP_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user