30 Datum leafValue,
bool isNull,
bool recheck,
31 bool recheckDistances,
double *distances);
130 startEntry->
isLeaf =
false;
131 startEntry->
level = 0;
171 for (i = 0; i < so->
nPtrs; i++)
181 for (i = 0; i < so->
nPtrs; i++)
250 haveIsNull = haveNotNull =
false;
276 if (haveIsNull && haveNotNull)
311 "SP-GiST search temporary context",
314 "SP-GiST traversal-value context",
366 ScanKey orderbys,
int norderbys)
372 memmove(scan->
keyData, scankey,
442 Datum leafValue,
bool recheck,
bool recheckDistances,
443 bool isnull,
double *distances)
476 bool recheckDistances;
482 leafValue = (
Datum) 0;
485 recheckDistances =
false;
545 Assert(!recheckDistances);
546 storeRes(so, &leafTuple->
heapPtr, leafValue, isnull,
547 recheck,
false, NULL);
548 *reportedSome =
true;
619 int nNodes = innerTuple->
nNodes;
622 memset(&out, 0,
sizeof(out));
641 for (i = 0; i < nNodes; i++)
647 elog(
ERROR,
"inconsistent inner_consistent results for allTheSame inner tuple");
662 for (i = 0; i < out.
nNodes; i++)
668 Assert(nodeN >= 0 && nodeN < nNodes);
713 bool isnull,
bool isroot,
751 spgLeafTest(so, item, leafTuple, isnull, reportedSome, storeRes);
768 bool reportedSome =
false;
770 while (scanWholeIndex || !reportedSome)
826 &reportedSome, storeRes);
836 &reportedSome, storeRes);
857 elog(
ERROR,
"unexpected SPGiST tuple state: %d",
879 Datum leafValue,
bool isnull,
bool recheck,
bool recheckDistances,
882 Assert(!recheckDistances && !distances);
906 Datum leafValue,
bool isnull,
bool recheck,
bool recheckDistances,
907 double *nonNullDistances)
931 distances[
i].
value = nonNullDistances[offset];
965 elog(
ERROR,
"SP-GiST only supports forward scan direction");
992 for (i = 0; i < so->
nPtrs; i++)
1002 for (i = 0; i < so->
nPtrs; i++)
#define ItemPointerIsValid(pointer)
Datum * spgExtractNodeLabels(SpGistState *state, SpGistInnerTuple innerTuple)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
static void TestForOldSnapshot(Snapshot snapshot, Relation relation, Page page)
SpGistInnerTupleData * SpGistInnerTuple
#define SpGistPageIsLeaf(page)
static float8 get_float8_infinity(void)
SpGistCache * spgGetCache(Relation index)
#define SPGIST_LEAF_CONSISTENT_PROC
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
IndexOrderByDistance * distances[MaxIndexTuplesPerPage]
struct ScanKeyData * orderByData
static int pairingheap_SpGistSearchItem_cmp(const pairingheap_node *a, const pairingheap_node *b, void *arg)
bool recheckDistances[MaxIndexTuplesPerPage]
#define RelationGetDescr(relation)
ItemPointerData heapPtrs[MaxIndexTuplesPerPage]
#define PointerGetDatum(X)
#define SGITITERATE(x, i, nt)
void tbm_add_tuples(TIDBitmap *tbm, const ItemPointer tids, int ntids, bool recheck)
struct TupleDescData * xs_hitupdesc
SpGistTypeDesc attLeafType
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define pairingheap_is_empty(h)
static SpGistSearchItem * spgGetNextQueueItem(SpGistScanOpaque so)
void spgrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
pairingheap * pairingheap_allocate(pairingheap_comparator compare, void *arg)
struct SnapshotData * xs_snapshot
void MemoryContextReset(MemoryContext context)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
#define SPGIST_ROOT_BLKNO
void spgendscan(IndexScanDesc scan)
#define PageGetMaxOffsetNumber(page)
HeapTuple reconTups[MaxIndexTuplesPerPage]
bool spgcanreturn(Relation index, int attno)
Oid get_func_rettype(Oid funcid)
void pfree(void *pointer)
void UnlockReleaseBuffer(Buffer buffer)
MemoryContext traversalMemoryContext
#define ALLOCSET_DEFAULT_SIZES
void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo, MemoryContext destcxt)
#define SizeOfSpGistSearchItem(n_distances)
static OffsetNumber spgTestLeafTuple(SpGistScanOpaque so, SpGistSearchItem *item, Page page, OffsetNumber offset, bool isnull, bool isroot, bool *reportedSome, storeRes_func storeRes)
ItemPointerData xs_heaptid
#define SPGIST_NULL_BLKNO
static SpGistSearchItem * spgAllocSearchItem(SpGistScanOpaque so, bool isnull, double *distances)
bool recheck[MaxIndexTuplesPerPage]
#define FirstOffsetNumber
static void spgPrepareScanKeys(IndexScanDesc scan)
#define SPGIST_METAPAGE_BLKNO
void initSpGistState(SpGistState *state, Relation index)
SpGistDeadTupleData * SpGistDeadTuple
int64 spggetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
static SpGistSearchItem * spgMakeInnerItem(SpGistScanOpaque so, SpGistSearchItem *parentItem, SpGistNodeTuple tuple, spgInnerConsistentOut *out, int i, bool isnull, double *distances)
MemoryContext CurrentMemoryContext
static void spgAddStartItem(SpGistScanOpaque so, bool isnull)
#define BufferGetPage(buffer)
Datum datumCopy(Datum value, bool typByVal, int typLen)
static void spgAddSearchItemToQueue(SpGistScanOpaque so, SpGistSearchItem *item)
#define PageGetItemId(page, offsetNumber)
int * nonNullOrderByOffsets
void(* storeRes_func)(SpGistScanOpaque so, ItemPointer heapPtr, Datum leafValue, bool isNull, bool recheck, bool recheckDistances, double *distances)
void * palloc0(Size size)
void index_store_float8_orderby_distances(IndexScanDesc scan, Oid *orderByTypes, IndexOrderByDistance *distances, bool recheckOrderBy)
void LockBuffer(Buffer buffer, int mode)
SpGistScanOpaqueData * SpGistScanOpaque
static void spgInnerTest(SpGistScanOpaque so, SpGistSearchItem *item, SpGistInnerTuple innerTuple, bool isnull)
static void storeGettuple(SpGistScanOpaque so, ItemPointer heapPtr, Datum leafValue, bool isnull, bool recheck, bool recheckDistances, double *nonNullDistances)
#define InvalidOffsetNumber
double distances[FLEXIBLE_ARRAY_MEMBER]
#define SpGistPageStoresNulls(page)
static void spgWalk(Relation index, SpGistScanOpaque so, bool scanWholeIndex, storeRes_func storeRes, Snapshot snapshot)
FmgrInfo leafConsistentFn
FmgrInfo innerConsistentFn
#define Assert(condition)
static void spgInitInnerConsistentIn(spgInnerConsistentIn *in, SpGistScanOpaque so, SpGistSearchItem *item, SpGistInnerTuple innerTuple)
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
#define SpGistBlockIsRoot(blkno)
Datum * reconstructedValues
#define ItemPointerGetOffsetNumber(pointer)
static void resetSpGistScanOpaque(SpGistScanOpaque so)
#define DatumGetPointer(X)
struct ScanKeyData * keyData
MemoryContext traversalCxt
BlockNumber BufferGetBlockNumber(Buffer buffer)
#define MaxIndexTuplesPerPage
bool spggettuple(IndexScanDesc scan, ScanDirection dir)
#define BUFFER_LOCK_SHARE
pairingheap_node * pairingheap_remove_first(pairingheap *heap)
#define SPGIST_INNER_CONSISTENT_PROC
static bool spgLeafTest(SpGistScanOpaque so, SpGistSearchItem *item, SpGistLeafTuple leafTuple, bool isnull, bool *reportedSome, storeRes_func storeRes)
IndexScanDesc RelationGetIndexScan(Relation indexRelation, int nkeys, int norderbys)
SpGistSpecialOffsetNumbers
IndexScanDesc spgbeginscan(Relation rel, int keysz, int orderbysz)
#define CHECK_FOR_INTERRUPTS()
void pairingheap_add(pairingheap *heap, pairingheap_node *node)
static void storeBitmap(SpGistScanOpaque so, ItemPointer heapPtr, Datum leafValue, bool isnull, bool recheck, bool recheckDistances, double *distances)
#define ItemPointerGetBlockNumber(pointer)
SpGistLeafTupleData * SpGistLeafTuple
int numberOfNonNullOrderBys
#define PageGetItem(page, itemId)
#define ItemPointerSet(pointer, blockNumber, offNum)
static void spgFreeSearchItem(SpGistScanOpaque so, SpGistSearchItem *item)
static SpGistSearchItem * spgNewHeapItem(SpGistScanOpaque so, int level, ItemPointer heapPtr, Datum leafValue, bool recheck, bool recheckDistances, bool isnull, double *distances)