31 Datum leafValue,
bool isNull,
33 bool recheckDistances,
double *distances);
65 if (isnan(
sa->distances[
i]))
138 startEntry->
isLeaf =
false;
139 startEntry->
level = 0;
259 haveIsNull = haveNotNull =
false;
285 if (haveIsNull && haveNotNull)
320 "SP-GiST search temporary context",
323 "SP-GiST traversal-value context",
381 ScanKey orderbys,
int norderbys)
462 Datum leafValue,
bool recheck,
bool recheckDistances,
463 bool isnull,
double *distances)
522 bool recheckDistances;
528 leafValue = (
Datum) 0;
531 recheckDistances =
false;
592 Assert(!recheckDistances);
593 storeRes(so, &leafTuple->
heapPtr, leafValue, isnull,
594 leafTuple, recheck,
false, NULL);
595 *reportedSome =
true;
670 int nNodes = innerTuple->
nNodes;
673 memset(&out, 0,
sizeof(out));
692 for (
i = 0;
i < nNodes;
i++)
698 elog(
ERROR,
"inconsistent inner_consistent results for allTheSame inner tuple");
719 Assert(nodeN >= 0 && nodeN < nNodes);
764 bool isnull,
bool isroot,
802 spgLeafTest(so, item, leafTuple, isnull, reportedSome, storeRes);
819 bool reportedSome =
false;
821 while (scanWholeIndex || !reportedSome)
877 &reportedSome, storeRes);
887 &reportedSome, storeRes);
908 elog(
ERROR,
"unexpected SPGiST tuple state: %d",
930 Datum leafValue,
bool isnull,
932 bool recheckDistances,
double *distances)
934 Assert(!recheckDistances && !distances);
958 Datum leafValue,
bool isnull,
960 bool recheckDistances,
double *nonNullDistances)
984 distances[
i].
value = nonNullDistances[offset];
1011 leafDatums, leafIsnulls, isnull);
1029 elog(
ERROR,
"SP-GiST only supports forward scan direction");
BlockNumber BufferGetBlockNumber(Buffer buffer)
void UnlockReleaseBuffer(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
#define BUFFER_LOCK_SHARE
static Page BufferGetPage(Buffer buffer)
static Item PageGetItem(Page page, ItemId itemId)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
#define Assert(condition)
Datum datumCopy(Datum value, bool typByVal, int typLen)
static float8 get_float8_infinity(void)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo, MemoryContext destcxt)
IndexScanDesc RelationGetIndexScan(Relation indexRelation, int nkeys, int norderbys)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
void index_store_float8_orderby_distances(IndexScanDesc scan, Oid *orderByTypes, IndexOrderByDistance *distances, bool recheckOrderBy)
if(TABLE==NULL||TABLE_index==NULL)
static void ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
static bool ItemPointerIsValid(const ItemPointerData *pointer)
#define MaxIndexTuplesPerPage
Oid get_func_rettype(Oid funcid)
void MemoryContextReset(MemoryContext context)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define CHECK_FOR_INTERRUPTS()
#define InvalidOffsetNumber
#define FirstOffsetNumber
void pairingheap_add(pairingheap *heap, pairingheap_node *node)
pairingheap * pairingheap_allocate(pairingheap_comparator compare, void *arg)
pairingheap_node * pairingheap_remove_first(pairingheap *heap)
#define pairingheap_is_empty(h)
#define pgstat_count_index_scan(rel)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
MemoryContextSwitchTo(old_ctx)
#define RelationGetDescr(relation)
#define SPGIST_LEAF_CONSISTENT_PROC
#define SPGIST_INNER_CONSISTENT_PROC
#define SPGIST_NULL_BLKNO
SpGistDeadTupleData * SpGistDeadTuple
SpGistInnerTupleData * SpGistInnerTuple
#define SpGistPageStoresNulls(page)
#define SGLT_GET_NEXTOFFSET(spgLeafTuple)
#define SizeOfSpGistSearchItem(n_distances)
#define SGITITERATE(x, i, nt)
SpGistScanOpaqueData * SpGistScanOpaque
#define SpGistPageIsLeaf(page)
#define SPGIST_METAPAGE_BLKNO
#define SpGistBlockIsRoot(blkno)
struct SpGistLeafTupleData * SpGistLeafTuple
#define SPGIST_ROOT_BLKNO
IndexScanDesc spgbeginscan(Relation rel, int keysz, int orderbysz)
static int pairingheap_SpGistSearchItem_cmp(const pairingheap_node *a, const pairingheap_node *b, void *arg)
bool spgcanreturn(Relation index, int attno)
bool spggettuple(IndexScanDesc scan, ScanDirection dir)
static void spgInitInnerConsistentIn(spgInnerConsistentIn *in, SpGistScanOpaque so, SpGistSearchItem *item, SpGistInnerTuple innerTuple)
static void spgWalk(Relation index, SpGistScanOpaque so, bool scanWholeIndex, storeRes_func storeRes)
void spgendscan(IndexScanDesc scan)
static SpGistSearchItem * spgGetNextQueueItem(SpGistScanOpaque so)
static OffsetNumber spgTestLeafTuple(SpGistScanOpaque so, SpGistSearchItem *item, Page page, OffsetNumber offset, bool isnull, bool isroot, bool *reportedSome, storeRes_func storeRes)
static bool spgLeafTest(SpGistScanOpaque so, SpGistSearchItem *item, SpGistLeafTuple leafTuple, bool isnull, bool *reportedSome, storeRes_func storeRes)
static void spgAddStartItem(SpGistScanOpaque so, bool isnull)
static void spgFreeSearchItem(SpGistScanOpaque so, SpGistSearchItem *item)
static SpGistSearchItem * spgNewHeapItem(SpGistScanOpaque so, int level, SpGistLeafTuple leafTuple, Datum leafValue, bool recheck, bool recheckDistances, bool isnull, double *distances)
SpGistSpecialOffsetNumbers
@ SpGistErrorOffsetNumber
@ SpGistBreakOffsetNumber
@ SpGistRedirectOffsetNumber
static void resetSpGistScanOpaque(SpGistScanOpaque so)
static SpGistSearchItem * spgMakeInnerItem(SpGistScanOpaque so, SpGistSearchItem *parentItem, SpGistNodeTuple tuple, spgInnerConsistentOut *out, int i, bool isnull, double *distances)
static void storeGettuple(SpGistScanOpaque so, ItemPointer heapPtr, Datum leafValue, bool isnull, SpGistLeafTuple leafTuple, bool recheck, bool recheckDistances, double *nonNullDistances)
static void storeBitmap(SpGistScanOpaque so, ItemPointer heapPtr, Datum leafValue, bool isnull, SpGistLeafTuple leafTuple, bool recheck, bool recheckDistances, double *distances)
void spgrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
int64 spggetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
static void spgPrepareScanKeys(IndexScanDesc scan)
static void spgAddSearchItemToQueue(SpGistScanOpaque so, SpGistSearchItem *item)
static SpGistSearchItem * spgAllocSearchItem(SpGistScanOpaque so, bool isnull, double *distances)
void(* storeRes_func)(SpGistScanOpaque so, ItemPointer heapPtr, Datum leafValue, bool isNull, SpGistLeafTuple leafTuple, bool recheck, bool recheckDistances, double *distances)
static void spgInnerTest(SpGistScanOpaque so, SpGistSearchItem *item, SpGistInnerTuple innerTuple, bool isnull)
Datum * spgExtractNodeLabels(SpGistState *state, SpGistInnerTuple innerTuple)
void initSpGistState(SpGistState *state, Relation index)
TupleDesc getSpGistTupleDesc(Relation index, SpGistTypeDesc *keyType)
SpGistCache * spgGetCache(Relation index)
void spgDeformLeafTuple(SpGistLeafTuple tup, TupleDesc tupleDescriptor, Datum *datums, bool *isnulls, bool keyColumnIsNull)
struct ScanKeyData * keyData
struct ScanKeyData * orderByData
struct TupleDescData * xs_hitupdesc
ItemPointerData xs_heaptid
HeapTuple reconTups[MaxIndexTuplesPerPage]
ItemPointerData heapPtrs[MaxIndexTuplesPerPage]
MemoryContext traversalCxt
int * nonNullOrderByOffsets
int numberOfNonNullOrderBys
bool recheckDistances[MaxIndexTuplesPerPage]
FmgrInfo leafConsistentFn
IndexOrderByDistance * distances[MaxIndexTuplesPerPage]
bool recheck[MaxIndexTuplesPerPage]
FmgrInfo innerConsistentFn
SpGistLeafTuple leafTuple
double distances[FLEXIBLE_ARRAY_MEMBER]
SpGistTypeDesc attLeafType
MemoryContext traversalMemoryContext
Datum * reconstructedValues
void tbm_add_tuples(TIDBitmap *tbm, const ItemPointer tids, int ntids, bool recheck)
void FreeTupleDesc(TupleDesc tupdesc)