*/
Assert(state->readonly && state->rootdescend);
exists = false;
- stack = _bt_search(state->rel, NULL, key, &lbuf, BT_READ, NULL);
+ stack = _bt_search(state->rel, NULL, key, &lbuf, BT_READ);
if (BufferIsValid(lbuf))
{
MemoryContext oldcxt = CurrentMemoryContext;
bool autosummarize = BrinGetAutoSummarize(idxRel);
- revmap = brinRevmapInitialize(idxRel, &pagesPerRange, NULL);
+ revmap = brinRevmapInitialize(idxRel, &pagesPerRange);
/*
* origHeapBlk is the block number where the insertion occurred. heapBlk
lastPageTuple =
brinGetTupleForHeapBlock(revmap, lastPageRange, &buf, &off,
- NULL, BUFFER_LOCK_SHARE, NULL);
+ NULL, BUFFER_LOCK_SHARE);
if (!lastPageTuple)
{
bool recorded;
}
brtup = brinGetTupleForHeapBlock(revmap, heapBlk, &buf, &off,
- NULL, BUFFER_LOCK_SHARE, NULL);
+ NULL, BUFFER_LOCK_SHARE);
/* if range is unsummarized, there's nothing to do */
if (!brtup)
scan = RelationGetIndexScan(r, nkeys, norderbys);
opaque = palloc_object(BrinOpaque);
- opaque->bo_rmAccess = brinRevmapInitialize(r, &opaque->bo_pagesPerRange,
- scan->xs_snapshot);
+ opaque->bo_rmAccess = brinRevmapInitialize(r, &opaque->bo_pagesPerRange);
opaque->bo_bdesc = brin_build_desc(r);
scan->opaque = opaque;
MemoryContextResetAndDeleteChildren(perRangeCxt);
tup = brinGetTupleForHeapBlock(opaque->bo_rmAccess, heapBlk, &buf,
- &off, &size, BUFFER_LOCK_SHARE,
- scan->xs_snapshot);
+ &off, &size, BUFFER_LOCK_SHARE);
if (tup)
{
gottuple = true;
/*
* Initialize our state, including the deformed tuple state.
*/
- revmap = brinRevmapInitialize(index, &pagesPerRange, NULL);
+ revmap = brinRevmapInitialize(index, &pagesPerRange);
state = initialize_brin_buildstate(index, revmap, pagesPerRange);
/*
* the same.)
*/
phtup = brinGetTupleForHeapBlock(state->bs_rmAccess, heapBlk, &phbuf,
- &offset, &phsz, BUFFER_LOCK_SHARE,
- NULL);
+ &offset, &phsz, BUFFER_LOCK_SHARE);
/* the placeholder tuple must exist */
if (phtup == NULL)
elog(ERROR, "missing placeholder tuple");
Buffer buf;
BlockNumber startBlk;
- revmap = brinRevmapInitialize(index, &pagesPerRange, NULL);
+ revmap = brinRevmapInitialize(index, &pagesPerRange);
/* determine range of pages to process */
heapNumBlocks = RelationGetNumberOfBlocks(heapRel);
CHECK_FOR_INTERRUPTS();
tup = brinGetTupleForHeapBlock(revmap, startBlk, &buf, &off, NULL,
- BUFFER_LOCK_SHARE, NULL);
+ BUFFER_LOCK_SHARE);
if (tup == NULL)
{
/* no revmap entry for this heap range. Summarize it. */
* brinRevmapTerminate when caller is done with it.
*/
BrinRevmap *
-brinRevmapInitialize(Relation idxrel, BlockNumber *pagesPerRange,
- Snapshot snapshot)
+brinRevmapInitialize(Relation idxrel, BlockNumber *pagesPerRange)
{
BrinRevmap *revmap;
Buffer meta;
*/
BrinTuple *
brinGetTupleForHeapBlock(BrinRevmap *revmap, BlockNumber heapBlk,
- Buffer *buf, OffsetNumber *off, Size *size, int mode,
- Snapshot snapshot)
+ Buffer *buf, OffsetNumber *off, Size *size, int mode)
{
Relation idxRel = revmap->rm_irel;
BlockNumber mapBlk;
OffsetNumber regOffset;
ItemId lp;
- revmap = brinRevmapInitialize(idxrel, &pagesPerRange, NULL);
+ revmap = brinRevmapInitialize(idxrel, &pagesPerRange);
revmapBlk = revmap_get_blkno(revmap, heapBlk);
if (!BlockNumberIsValid(revmapBlk))
*
* Initialize an appropriate TOAST snapshot. We must use an MVCC snapshot
* to initialize the TOAST snapshot; since we don't know which one to use,
- * just use the oldest one. This is safe: at worst, we will get a "snapshot
- * too old" error that might have been avoided otherwise.
+ * just use the oldest one.
*/
void
init_toast_snapshot(Snapshot toast_snapshot)
*/
GinBtreeStack *
ginFindLeafPage(GinBtree btree, bool searchMode,
- bool rootConflictCheck, Snapshot snapshot)
+ bool rootConflictCheck)
{
GinBtreeStack *stack;
{
/* search for the leaf page where the first item should go to */
btree.itemptr = insertdata.items[insertdata.curitem];
- stack = ginFindLeafPage(&btree, false, true, NULL);
+ stack = ginFindLeafPage(&btree, false, true);
ginInsertValue(&btree, stack, &insertdata, buildStats);
}
* Starts a new scan on a posting tree.
*/
GinBtreeStack *
-ginScanBeginPostingTree(GinBtree btree, Relation index, BlockNumber rootBlkno,
- Snapshot snapshot)
+ginScanBeginPostingTree(GinBtree btree, Relation index, BlockNumber rootBlkno)
{
GinBtreeStack *stack;
btree->fullScan = true;
- stack = ginFindLeafPage(btree, true, false, snapshot);
+ stack = ginFindLeafPage(btree, true, false);
return stack;
}
*/
static void
scanPostingTree(Relation index, GinScanEntry scanEntry,
- BlockNumber rootPostingTree, Snapshot snapshot)
+ BlockNumber rootPostingTree)
{
GinBtreeData btree;
GinBtreeStack *stack;
Page page;
/* Descend to the leftmost leaf page */
- stack = ginScanBeginPostingTree(&btree, index, rootPostingTree, snapshot);
+ stack = ginScanBeginPostingTree(&btree, index, rootPostingTree);
buffer = stack->buffer;
IncrBufferRefCount(buffer); /* prevent unpin in freeGinBtreeStack */
PredicateLockPage(btree->index, rootPostingTree, snapshot);
/* Collect all the TIDs in this entry's posting tree */
- scanPostingTree(btree->index, scanEntry, rootPostingTree,
- snapshot);
+ scanPostingTree(btree->index, scanEntry, rootPostingTree);
/*
* We lock again the entry page and while it was unlocked insert
ginPrepareEntryScan(&btreeEntry, entry->attnum,
entry->queryKey, entry->queryCategory,
ginstate);
- stackEntry = ginFindLeafPage(&btreeEntry, true, false, snapshot);
+ stackEntry = ginFindLeafPage(&btreeEntry, true, false);
page = BufferGetPage(stackEntry->buffer);
/* ginFindLeafPage() will have already checked snapshot age. */
needUnlock = false;
stack = ginScanBeginPostingTree(&entry->btree, ginstate->index,
- rootPostingTree, snapshot);
+ rootPostingTree);
entry->buffer = stack->buffer;
/*
*/
static void
entryLoadMoreItems(GinState *ginstate, GinScanEntry entry,
- ItemPointerData advancePast, Snapshot snapshot)
+ ItemPointerData advancePast)
{
Page page;
int i;
OffsetNumberNext(GinItemPointerGetOffsetNumber(&advancePast)));
}
entry->btree.fullScan = false;
- stack = ginFindLeafPage(&entry->btree, true, false, snapshot);
+ stack = ginFindLeafPage(&entry->btree, true, false);
/* we don't need the stack, just the buffer. */
entry->buffer = stack->buffer;
*/
static void
entryGetItem(GinState *ginstate, GinScanEntry entry,
- ItemPointerData advancePast, Snapshot snapshot)
+ ItemPointerData advancePast)
{
Assert(!entry->isFinished);
/* If we've processed the current batch, load more items */
while (entry->offset >= entry->nlist)
{
- entryLoadMoreItems(ginstate, entry, advancePast, snapshot);
+ entryLoadMoreItems(ginstate, entry, advancePast);
if (entry->isFinished)
{
*/
static void
keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
- ItemPointerData advancePast, Snapshot snapshot)
+ ItemPointerData advancePast)
{
ItemPointerData minItem;
ItemPointerData curPageLossy;
*/
if (ginCompareItemPointers(&entry->curItem, &advancePast) <= 0)
{
- entryGetItem(ginstate, entry, advancePast, snapshot);
+ entryGetItem(ginstate, entry, advancePast);
if (entry->isFinished)
continue;
}
if (ginCompareItemPointers(&entry->curItem, &advancePast) <= 0)
{
- entryGetItem(ginstate, entry, advancePast, snapshot);
+ entryGetItem(ginstate, entry, advancePast);
if (entry->isFinished)
continue;
}
}
/* Fetch the next item for this key that is > advancePast. */
- keyGetItem(&so->ginstate, so->tempCtx, key, advancePast,
- scan->xs_snapshot);
+ keyGetItem(&so->ginstate, so->tempCtx, key, advancePast);
if (key->isFinished)
return false;
ginPrepareEntryScan(&btree, attnum, key, category, ginstate);
btree.isBuild = (buildStats != NULL);
- stack = ginFindLeafPage(&btree, false, false, NULL);
+ stack = ginFindLeafPage(&btree, false, false);
page = BufferGetPage(stack->buffer);
if (btree.findItem(&btree, stack))
* in effect in any case. lazy_scan_prune makes the optimistic assumption
* that any LP_DEAD items it encounters will always be LP_UNUSED by the time
* we're called.
- *
- * Also don't attempt it if we are doing early pruning/vacuuming, because a
- * scan which cannot find a truncated heap page cannot determine that the
- * snapshot is too old to read that page.
*/
static bool
should_attempt_truncation(LVRelState *vacrel)
/* Cannot use optimization -- descend tree, return proper descent stack */
return _bt_search(rel, heaprel, insertstate->itup_key, &insertstate->buf,
- BT_WRITE, NULL);
+ BT_WRITE);
}
/*
BlockNumberIsValid(RelationGetTargetBlock(rel))));
/* Find the leftmost page at the next level up */
- pbuf = _bt_get_endpoint(rel, opaque->btpo_level + 1, false, NULL);
+ pbuf = _bt_get_endpoint(rel, opaque->btpo_level + 1, false);
/* Set up a phony stack entry pointing there */
stack = &fakestack;
stack->bts_blkno = BufferGetBlockNumber(pbuf);
itup_key = _bt_mkscankey(rel, targetkey);
/* find the leftmost leaf page with matching pivot/high key */
itup_key->pivotsearch = true;
- stack = _bt_search(rel, NULL, itup_key, &sleafbuf, BT_READ,
- NULL);
+ stack = _bt_search(rel, NULL, itup_key, &sleafbuf, BT_READ);
/* won't need a second lock or pin on leafbuf */
_bt_relbuf(rel, sleafbuf);
static bool _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno, ScanDirection dir);
static bool _bt_parallel_readpage(IndexScanDesc scan, BlockNumber blkno,
ScanDirection dir);
-static Buffer _bt_walk_left(Relation rel, Buffer buf, Snapshot snapshot);
+static Buffer _bt_walk_left(Relation rel, Buffer buf);
static bool _bt_endpoint(IndexScanDesc scan, ScanDirection dir);
static inline void _bt_initialize_more_data(BTScanOpaque so, ScanDirection dir);
* which is locked and pinned. No locks are held on the parent pages,
* however!
*
- * If the snapshot parameter is not NULL, "old snapshot" checking will take
- * place during the descent through the tree. This is not needed when
- * positioning for an insert or delete, so NULL is used for those cases.
- *
* The returned buffer is locked according to access parameter. Additionally,
* access = BT_WRITE will allow an empty root page to be created and returned.
* When access = BT_READ, an empty index will result in *bufP being set to
*/
BTStack
_bt_search(Relation rel, Relation heaprel, BTScanInsert key, Buffer *bufP,
- int access, Snapshot snapshot)
+ int access)
{
BTStack stack_in = NULL;
int page_access = BT_READ;
* opportunity to finish splits of internal pages too.
*/
*bufP = _bt_moveright(rel, heaprel, key, *bufP, (access == BT_WRITE),
- stack_in, page_access, snapshot);
+ stack_in, page_access);
/* if this is a leaf page, we're done */
page = BufferGetPage(*bufP);
* but before we acquired a write lock. If it has, we may need to
* move right to its new sibling. Do that.
*/
- *bufP = _bt_moveright(rel, heaprel, key, *bufP, true, stack_in, BT_WRITE,
- snapshot);
+ *bufP = _bt_moveright(rel, heaprel, key, *bufP, true, stack_in, BT_WRITE);
}
return stack_in;
* On entry, we have the buffer pinned and a lock of the type specified by
* 'access'. If we move right, we release the buffer and lock and acquire
* the same on the right sibling. Return value is the buffer we stop at.
- *
- * If the snapshot parameter is not NULL, "old snapshot" checking will take
- * place during the descent through the tree. This is not needed when
- * positioning for an insert or delete, so NULL is used for those cases.
*/
Buffer
_bt_moveright(Relation rel,
Buffer buf,
bool forupdate,
BTStack stack,
- int access,
- Snapshot snapshot)
+ int access)
{
Page page;
BTPageOpaque opaque;
* Use the manufactured insertion scan key to descend the tree and
* position ourselves on the target leaf page.
*/
- stack = _bt_search(rel, NULL, &inskey, &buf, BT_READ, scan->xs_snapshot);
+ stack = _bt_search(rel, NULL, &inskey, &buf, BT_READ);
/* don't need to keep the stack around... */
_bt_freestack(stack);
if (IsolationIsSerializable())
{
PredicateLockRelation(rel, scan->xs_snapshot);
- stack = _bt_search(rel, NULL, &inskey, &buf, BT_READ,
- scan->xs_snapshot);
+ stack = _bt_search(rel, NULL, &inskey, &buf, BT_READ);
_bt_freestack(stack);
}
}
/* Step to next physical page */
- so->currPos.buf = _bt_walk_left(rel, so->currPos.buf,
- scan->xs_snapshot);
+ so->currPos.buf = _bt_walk_left(rel, so->currPos.buf);
/* if we're physically at end of index, return failure */
if (so->currPos.buf == InvalidBuffer)
* again if it's important.
*/
static Buffer
-_bt_walk_left(Relation rel, Buffer buf, Snapshot snapshot)
+_bt_walk_left(Relation rel, Buffer buf)
{
Page page;
BTPageOpaque opaque;
* The returned buffer is pinned and read-locked.
*/
Buffer
-_bt_get_endpoint(Relation rel, uint32 level, bool rightmost,
- Snapshot snapshot)
+_bt_get_endpoint(Relation rel, uint32 level, bool rightmost)
{
Buffer buf;
Page page;
* version of _bt_search(). We don't maintain a stack since we know we
* won't need it.
*/
- buf = _bt_get_endpoint(rel, 0, ScanDirectionIsBackward(dir), scan->xs_snapshot);
+ buf = _bt_get_endpoint(rel, 0, ScanDirectionIsBackward(dir));
if (!BufferIsValid(buf))
{
*/
static void
spgWalk(Relation index, SpGistScanOpaque so, bool scanWholeIndex,
- storeRes_func storeRes, Snapshot snapshot)
+ storeRes_func storeRes)
{
Buffer buffer = InvalidBuffer;
bool reportedSome = false;
so->tbm = tbm;
so->ntids = 0;
- spgWalk(scan->indexRelation, so, true, storeBitmap, scan->xs_snapshot);
+ spgWalk(scan->indexRelation, so, true, storeBitmap);
return so->ntids;
}
}
so->iPtr = so->nPtrs = 0;
- spgWalk(scan->indexRelation, so, false, storeGettuple,
- scan->xs_snapshot);
+ spgWalk(scan->indexRelation, so, false, storeGettuple);
if (so->nPtrs == 0)
break; /* must have completed scan */
typedef struct BrinRevmap BrinRevmap;
extern BrinRevmap *brinRevmapInitialize(Relation idxrel,
- BlockNumber *pagesPerRange, Snapshot snapshot);
+ BlockNumber *pagesPerRange);
extern void brinRevmapTerminate(BrinRevmap *revmap);
extern void brinRevmapExtend(BrinRevmap *revmap,
BlockNumber heapBlk, ItemPointerData tid);
extern BrinTuple *brinGetTupleForHeapBlock(BrinRevmap *revmap,
BlockNumber heapBlk, Buffer *buf, OffsetNumber *off,
- Size *size, int mode, Snapshot snapshot);
+ Size *size, int mode);
extern bool brinRevmapDesummarizeRange(Relation idxrel, BlockNumber heapBlk);
#endif /* BRIN_REVMAP_H */
*/
extern GinBtreeStack *ginFindLeafPage(GinBtree btree, bool searchMode,
- bool rootConflictCheck, Snapshot snapshot);
+ bool rootConflictCheck);
extern Buffer ginStepRight(Buffer buffer, Relation index, int lockmode);
extern void freeGinBtreeStack(GinBtreeStack *stack);
extern void ginInsertValue(GinBtree btree, GinBtreeStack *stack,
extern void ginInsertItemPointers(Relation index, BlockNumber rootBlkno,
ItemPointerData *items, uint32 nitem,
GinStatsData *buildStats);
-extern GinBtreeStack *ginScanBeginPostingTree(GinBtree btree, Relation index, BlockNumber rootBlkno, Snapshot snapshot);
+extern GinBtreeStack *ginScanBeginPostingTree(GinBtree btree, Relation index, BlockNumber rootBlkno);
extern void ginDataFillRoot(GinBtree btree, Page root, BlockNumber lblkno, Page lpage, BlockNumber rblkno, Page rpage);
/*
* prototypes for functions in nbtsearch.c
*/
extern BTStack _bt_search(Relation rel, Relation heaprel, BTScanInsert key,
- Buffer *bufP, int access, Snapshot snapshot);
+ Buffer *bufP, int access);
extern Buffer _bt_moveright(Relation rel, Relation heaprel, BTScanInsert key,
Buffer buf, bool forupdate, BTStack stack,
- int access, Snapshot snapshot);
+ int access);
extern OffsetNumber _bt_binsrch_insert(Relation rel, BTInsertState insertstate);
extern int32 _bt_compare(Relation rel, BTScanInsert key, Page page, OffsetNumber offnum);
extern bool _bt_first(IndexScanDesc scan, ScanDirection dir);
extern bool _bt_next(IndexScanDesc scan, ScanDirection dir);
-extern Buffer _bt_get_endpoint(Relation rel, uint32 level, bool rightmost,
- Snapshot snapshot);
+extern Buffer _bt_get_endpoint(Relation rel, uint32 level, bool rightmost);
/*
* prototypes for functions in nbtutils.c