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)
387 memmove(scan->
keyData, scankey,
464 Datum leafValue,
bool recheck,
bool recheckDistances,
465 bool isnull,
double *distances)
524 bool recheckDistances;
530 leafValue = (
Datum) 0;
533 recheckDistances =
false;
594 Assert(!recheckDistances);
595 storeRes(so, &leafTuple->
heapPtr, leafValue, isnull,
596 leafTuple, recheck,
false, NULL);
597 *reportedSome =
true;
672 int nNodes = innerTuple->
nNodes;
675 memset(&out, 0,
sizeof(out));
694 for (
i = 0;
i < nNodes;
i++)
700 elog(
ERROR,
"inconsistent inner_consistent results for allTheSame inner tuple");
721 Assert(nodeN >= 0 && nodeN < nNodes);
766 bool isnull,
bool isroot,
804 spgLeafTest(so, item, leafTuple, isnull, reportedSome, storeRes);
821 bool reportedSome =
false;
823 while (scanWholeIndex || !reportedSome)
880 &reportedSome, storeRes);
890 &reportedSome, storeRes);
911 elog(
ERROR,
"unexpected SPGiST tuple state: %d",
933 Datum leafValue,
bool isnull,
935 bool recheckDistances,
double *distances)
937 Assert(!recheckDistances && !distances);
961 Datum leafValue,
bool isnull,
963 bool recheckDistances,
double *nonNullDistances)
987 distances[
i].
value = nonNullDistances[offset];
1014 leafDatums, leafIsnulls, isnull);
1032 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 void TestForOldSnapshot(Snapshot snapshot, Relation relation, Page page)
static Item PageGetItem(Page page, ItemId itemId)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
Datum datumCopy(Datum value, bool typByVal, int typLen)
elog(ERROR, "%s: %s", p2, msg)
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, Datum *values, 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
Assert(fmt[strlen(fmt) - 1] !='\n')
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)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define pgstat_count_index_scan(rel)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
#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)
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)
SpGistSpecialOffsetNumbers
@ SpGistErrorOffsetNumber
@ SpGistBreakOffsetNumber
@ SpGistRedirectOffsetNumber
static void resetSpGistScanOpaque(SpGistScanOpaque so)
static SpGistSearchItem * spgNewHeapItem(SpGistScanOpaque so, int level, SpGistLeafTuple leafTuple, Datum leafValue, bool recheck, bool recheckDistances, bool isnull, double *distances)
static void spgWalk(Relation index, SpGistScanOpaque so, bool scanWholeIndex, storeRes_func storeRes, Snapshot snapshot)
static void storeGettuple(SpGistScanOpaque so, ItemPointer heapPtr, Datum leafValue, bool isnull, SpGistLeafTuple leafTuple, bool recheck, bool recheckDistances, double *nonNullDistances)
static SpGistSearchItem * spgMakeInnerItem(SpGistScanOpaque so, SpGistSearchItem *parentItem, SpGistNodeTuple tuple, spgInnerConsistentOut *out, int i, bool isnull, double *distances)
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)
void spgDeformLeafTuple(SpGistLeafTuple tup, TupleDesc tupleDescriptor, Datum *datums, bool *isnulls, bool keyColumnIsNull)
SpGistCache * spgGetCache(Relation index)
struct ScanKeyData * keyData
struct ScanKeyData * orderByData
struct TupleDescData * xs_hitupdesc
ItemPointerData xs_heaptid
struct SnapshotData * xs_snapshot
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)