140 stack_in, page_access);
181 stack_in = new_stack;
250 Assert(!forupdate || heaprel != NULL);
269 cmpval =
key->nextkey ? 0 : 1;
314 elog(
ERROR,
"fell off the end of index \"%s\"",
386 cmpval =
key->nextkey ? 0 : 1;
396 if (result >= cmpval)
498 low = insertstate->
low;
536 if (result >= cmpval)
561 (
errcode(ERRCODE_INDEX_CORRUPTED),
562 errmsg_internal(
"table tid from new index tuple (%u,%u) cannot find insert offset between offsets %u and %u of block %u in index \"%s\"",
583 insertstate->
low = low;
641 mid = low + ((high - low) / 2);
725 ncmpkey =
Min(ntupatts,
key->keysz);
728 scankey =
key->scankeys;
729 for (
int i = 1;
i <= ncmpkey;
i++)
787 if (
key->keysz > ntupatts)
796 if (
key->scantid == NULL)
821 if (!
key->backward &&
key->keysz == ntupatts && heapTid == NULL &&
1056 if (chosen == NULL && impliesNN != NULL &&
1062 chosen = ¬nullkeys[keysz];
1083 startKeys[keysz++] = chosen;
1092 strat_total = strat;
1104 cur->sk_attno != curattr + 1)
1110 curattr =
cur->sk_attno;
1122 switch (
cur->sk_strategy)
1180 for (
i = 0;
i < keysz;
i++)
1205 memcpy(inskey.scankeys +
i, subkey,
sizeof(
ScanKeyData));
1223 bool used_all_subkeys =
false;
1237 memcpy(inskey.scankeys + keysz, subkey,
1242 used_all_subkeys =
true;
1246 if (!used_all_subkeys)
1248 switch (strat_total)
1302 elog(
ERROR,
"missing support function %d(%u,%u) for attribute %d of index \"%s\"",
1325 inskey.anynullkeys =
false;
1326 inskey.scantid = NULL;
1327 inskey.keysz = keysz;
1328 switch (strat_total)
1332 inskey.nextkey =
false;
1333 inskey.backward =
true;
1338 inskey.nextkey =
true;
1339 inskey.backward =
true;
1353 inskey.nextkey =
true;
1354 inskey.backward =
true;
1361 inskey.nextkey =
false;
1362 inskey.backward =
false;
1371 inskey.nextkey =
false;
1372 inskey.backward =
false;
1380 inskey.nextkey =
true;
1381 inskey.backward =
false;
1386 elog(
ERROR,
"unrecognized strat_total: %d", (
int) strat_total);
1589 pstate.prev_scan_page = opaque->btpo_next;
1603 pstate.minoff = minoff;
1604 pstate.maxoff = maxoff;
1605 pstate.finaltup = NULL;
1609 pstate.continuescan =
true;
1610 pstate.prechecked =
false;
1611 pstate.firstmatch =
false;
1612 pstate.rechecks = 0;
1613 pstate.targetdistance = 0;
1684 if (!firstPage && !so->
scanBehind && minoff < maxoff)
1694 pstate.prechecked = pstate.continuescan;
1695 pstate.continuescan =
true;
1711 offnum =
Max(offnum, minoff);
1713 while (offnum <= maxoff)
1732 pstate.offnum = offnum;
1742 Assert(!passes_quals && pstate.continuescan);
1743 Assert(offnum < pstate.skip);
1745 offnum = pstate.skip;
1753 pstate.firstmatch =
true;
1784 if (!pstate.continuescan)
1808 pstate.prechecked =
false;
1812 if (!pstate.continuescan)
1823 if (arrayKeys && minoff <= maxoff && !
P_LEFTMOST(opaque))
1833 offnum =
Min(offnum, maxoff);
1835 while (offnum >= minoff)
1861 tuple_alive =
false;
1869 pstate.offnum = offnum;
1879 Assert(!passes_quals && pstate.continuescan);
1880 Assert(offnum > pstate.skip);
1882 offnum = pstate.skip;
1887 if (passes_quals && tuple_alive)
1890 pstate.firstmatch =
true;
1927 if (!pstate.continuescan)
1937 if (!pstate.continuescan ||
P_LEFTMOST(opaque))
1999 memcpy(base, itup, itupsz);
2237 blkno = opaque->btpo_next;
2458 elog(
ERROR,
"fell off the end of index \"%s\"",
2481 elog(
ERROR,
"could not find left sibling of block %u in index \"%s\"",
2537 elog(
ERROR,
"fell off the end of index \"%s\"",
2549 (
errcode(ERRCODE_INDEX_CORRUPTED),
2628 elog(
ERROR,
"invalid scan direction: %d", (
int) dir);
#define InvalidBlockNumber
void IncrBufferRefCount(Buffer buffer)
BlockNumber BufferGetBlockNumber(Buffer buffer)
void ReleaseBuffer(Buffer buffer)
XLogRecPtr BufferGetLSNAtomic(Buffer buffer)
static Page BufferGetPage(Buffer buffer)
static bool BufferIsValid(Buffer bufnum)
static Item PageGetItem(Page page, ItemId itemId)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
#define RegProcedureIsValid(p)
#define INVERT_COMPARE_RESULT(var)
#define Assert(condition)
static void PGresult * res
int errmsg_internal(const char *fmt,...)
int errcode(int sqlerrcode)
#define ereport(elevel,...)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
if(TABLE==NULL||TABLE_index==NULL)
#define ItemIdIsDead(itemId)
int32 ItemPointerCompare(ItemPointer arg1, ItemPointer arg2)
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
IndexTupleData * IndexTuple
#define IndexTupleSize(itup)
static Datum index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
#define CHECK_FOR_INTERRUPTS()
void _bt_finish_split(Relation rel, Relation heaprel, Buffer lbuf, BTStack stack)
Buffer _bt_relandgetbuf(Relation rel, Buffer obuf, BlockNumber blkno, int access)
void _bt_relbuf(Relation rel, Buffer buf)
Buffer _bt_gettrueroot(Relation rel)
void _bt_metaversion(Relation rel, bool *heapkeyspace, bool *allequalimage)
Buffer _bt_getbuf(Relation rel, BlockNumber blkno, int access)
void _bt_unlockbuf(Relation rel, Buffer buf)
void _bt_lockbuf(Relation rel, Buffer buf, int access)
Buffer _bt_getroot(Relation rel, Relation heaprel, int access)
void _bt_parallel_release(IndexScanDesc scan, BlockNumber scan_page)
void _bt_parallel_done(IndexScanDesc scan)
bool _bt_parallel_seize(IndexScanDesc scan, BlockNumber *pageno, bool first)
#define BTScanPosIsPinned(scanpos)
static uint16 BTreeTupleGetNPosting(IndexTuple posting)
static bool BTreeTupleIsPivot(IndexTuple itup)
#define P_LEFTMOST(opaque)
#define BTPageGetOpaque(page)
#define P_ISDELETED(opaque)
#define MaxTIDsPerBTreePage
#define BTScanPosIsValid(scanpos)
#define P_FIRSTDATAKEY(opaque)
static uint32 BTreeTupleGetPostingOffset(IndexTuple posting)
#define P_RIGHTMOST(opaque)
#define SK_BT_NULLS_FIRST
#define P_INCOMPLETE_SPLIT(opaque)
static ItemPointer BTreeTupleGetPostingN(IndexTuple posting, int n)
static BlockNumber BTreeTupleGetDownLink(IndexTuple pivot)
static ItemPointer BTreeTupleGetMaxHeapTID(IndexTuple itup)
static bool BTreeTupleIsPosting(IndexTuple itup)
#define BTScanPosInvalidate(scanpos)
#define BTScanPosUnpinIfPinned(scanpos)
static ItemPointer BTreeTupleGetHeapTID(IndexTuple itup)
#define BTreeTupleGetNAtts(itup, rel)
BTScanOpaqueData * BTScanOpaque
Buffer _bt_get_endpoint(Relation rel, uint32 level, bool rightmost)
static bool _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno, ScanDirection dir)
static Buffer _bt_moveright(Relation rel, Relation heaprel, BTScanInsert key, Buffer buf, bool forupdate, BTStack stack, int access)
static int _bt_binsrch_posting(BTScanInsert key, Page page, OffsetNumber offnum)
bool _bt_first(IndexScanDesc scan, ScanDirection dir)
static void _bt_saveitem(BTScanOpaque so, int itemIndex, OffsetNumber offnum, IndexTuple itup)
static bool _bt_parallel_readpage(IndexScanDesc scan, BlockNumber blkno, ScanDirection dir)
static int _bt_setuppostingitems(BTScanOpaque so, int itemIndex, OffsetNumber offnum, ItemPointer heapTid, IndexTuple itup)
static Buffer _bt_walk_left(Relation rel, Buffer buf)
static void _bt_drop_lock_and_maybe_pin(IndexScanDesc scan, BTScanPos sp)
static OffsetNumber _bt_binsrch(Relation rel, BTScanInsert key, Buffer buf)
static bool _bt_endpoint(IndexScanDesc scan, ScanDirection dir)
static bool _bt_steppage(IndexScanDesc scan, ScanDirection dir)
static void _bt_savepostingitem(BTScanOpaque so, int itemIndex, OffsetNumber offnum, ItemPointer heapTid, int tupleOffset)
BTStack _bt_search(Relation rel, Relation heaprel, BTScanInsert key, Buffer *bufP, int access)
OffsetNumber _bt_binsrch_insert(Relation rel, BTInsertState insertstate)
bool _bt_next(IndexScanDesc scan, ScanDirection dir)
static bool _bt_readpage(IndexScanDesc scan, ScanDirection dir, OffsetNumber offnum, bool firstPage)
int32 _bt_compare(Relation rel, BTScanInsert key, Page page, OffsetNumber offnum)
static void _bt_initialize_more_data(BTScanOpaque so, ScanDirection dir)
bool _bt_checkkeys(IndexScanDesc scan, BTReadPageState *pstate, bool arrayKeys, IndexTuple tuple, int tupnatts)
void _bt_freestack(BTStack stack)
void _bt_killitems(IndexScanDesc scan)
bool _bt_check_natts(Relation rel, bool heapkeyspace, Page page, OffsetNumber offnum)
void _bt_start_array_keys(IndexScanDesc scan, ScanDirection dir)
void _bt_preprocess_keys(IndexScanDesc scan)
#define InvalidOffsetNumber
#define OffsetNumberIsValid(offsetNumber)
#define OffsetNumberNext(offsetNumber)
#define OffsetNumberPrev(offsetNumber)
#define pgstat_count_index_scan(rel)
static Pointer DatumGetPointer(Datum X)
static int32 DatumGetInt32(Datum X)
void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
void PredicateLockRelation(Relation relation, Snapshot snapshot)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define RelationNeedsWAL(relation)
#define IndexRelationGetNumberOfAttributes(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
void ScanKeyEntryInitialize(ScanKey entry, int flags, AttrNumber attributeNumber, StrategyNumber strategy, Oid subtype, Oid collation, RegProcedure procedure, Datum argument)
void ScanKeyEntryInitializeWithInfo(ScanKey entry, int flags, AttrNumber attributeNumber, StrategyNumber strategy, Oid subtype, Oid collation, FmgrInfo *finfo, Datum argument)
#define ScanDirectionIsForward(direction)
#define ScanDirectionIsBackward(direction)
#define IsMVCCSnapshot(snapshot)
#define BTGreaterStrategyNumber
#define BTLessStrategyNumber
#define BTEqualStrategyNumber
#define BTLessEqualStrategyNumber
#define BTGreaterEqualStrategyNumber
BTScanPosItem items[MaxTIDsPerBTreePage]
LocationIndex tupleOffset
struct BTStackData * bts_parent
struct ParallelIndexScanDescData * parallel_scan
bool ignore_killed_tuples
ItemPointerData xs_heaptid
struct SnapshotData * xs_snapshot
StrategyNumber sk_strategy
#define IsolationIsSerializable()