Skip to content

Commit 9f06025

Browse files
committed
Remove some more "snapshot too old" vestiges.
Commit f691f5b removed the logic, but left behind some now-useless Snapshot arguments to various AM-internal functions, and missed a couple of comments. Reported-by: Peter Geoghegan <pg@bowt.ie> Discussion: https://postgr.es/m/CAH2-Wznj9qSNXZ1P1uWTUD_FeaTezbUazb416EPwi4Qr_jR_6A%40mail.gmail.com
1 parent e722846 commit 9f06025

File tree

16 files changed

+56
-85
lines changed

16 files changed

+56
-85
lines changed

contrib/amcheck/verify_nbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,7 @@ bt_rootdescend(BtreeCheckState *state, IndexTuple itup)
26942694
*/
26952695
Assert(state->readonly && state->rootdescend);
26962696
exists = false;
2697-
stack = _bt_search(state->rel, NULL, key, &lbuf, BT_READ, NULL);
2697+
stack = _bt_search(state->rel, NULL, key, &lbuf, BT_READ);
26982698

26992699
if (BufferIsValid(lbuf))
27002700
{

src/backend/access/brin/brin.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ brininsert(Relation idxRel, Datum *values, bool *nulls,
169169
MemoryContext oldcxt = CurrentMemoryContext;
170170
bool autosummarize = BrinGetAutoSummarize(idxRel);
171171

172-
revmap = brinRevmapInitialize(idxRel, &pagesPerRange, NULL);
172+
revmap = brinRevmapInitialize(idxRel, &pagesPerRange);
173173

174174
/*
175175
* origHeapBlk is the block number where the insertion occurred. heapBlk
@@ -202,7 +202,7 @@ brininsert(Relation idxRel, Datum *values, bool *nulls,
202202

203203
lastPageTuple =
204204
brinGetTupleForHeapBlock(revmap, lastPageRange, &buf, &off,
205-
NULL, BUFFER_LOCK_SHARE, NULL);
205+
NULL, BUFFER_LOCK_SHARE);
206206
if (!lastPageTuple)
207207
{
208208
bool recorded;
@@ -222,7 +222,7 @@ brininsert(Relation idxRel, Datum *values, bool *nulls,
222222
}
223223

224224
brtup = brinGetTupleForHeapBlock(revmap, heapBlk, &buf, &off,
225-
NULL, BUFFER_LOCK_SHARE, NULL);
225+
NULL, BUFFER_LOCK_SHARE);
226226

227227
/* if range is unsummarized, there's nothing to do */
228228
if (!brtup)
@@ -332,8 +332,7 @@ brinbeginscan(Relation r, int nkeys, int norderbys)
332332
scan = RelationGetIndexScan(r, nkeys, norderbys);
333333

334334
opaque = palloc_object(BrinOpaque);
335-
opaque->bo_rmAccess = brinRevmapInitialize(r, &opaque->bo_pagesPerRange,
336-
scan->xs_snapshot);
335+
opaque->bo_rmAccess = brinRevmapInitialize(r, &opaque->bo_pagesPerRange);
337336
opaque->bo_bdesc = brin_build_desc(r);
338337
scan->opaque = opaque;
339338

@@ -537,8 +536,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
537536
MemoryContextResetAndDeleteChildren(perRangeCxt);
538537

539538
tup = brinGetTupleForHeapBlock(opaque->bo_rmAccess, heapBlk, &buf,
540-
&off, &size, BUFFER_LOCK_SHARE,
541-
scan->xs_snapshot);
539+
&off, &size, BUFFER_LOCK_SHARE);
542540
if (tup)
543541
{
544542
gottuple = true;
@@ -880,7 +878,7 @@ brinbuild(Relation heap, Relation index, IndexInfo *indexInfo)
880878
/*
881879
* Initialize our state, including the deformed tuple state.
882880
*/
883-
revmap = brinRevmapInitialize(index, &pagesPerRange, NULL);
881+
revmap = brinRevmapInitialize(index, &pagesPerRange);
884882
state = initialize_brin_buildstate(index, revmap, pagesPerRange);
885883

886884
/*
@@ -1458,8 +1456,7 @@ summarize_range(IndexInfo *indexInfo, BrinBuildState *state, Relation heapRel,
14581456
* the same.)
14591457
*/
14601458
phtup = brinGetTupleForHeapBlock(state->bs_rmAccess, heapBlk, &phbuf,
1461-
&offset, &phsz, BUFFER_LOCK_SHARE,
1462-
NULL);
1459+
&offset, &phsz, BUFFER_LOCK_SHARE);
14631460
/* the placeholder tuple must exist */
14641461
if (phtup == NULL)
14651462
elog(ERROR, "missing placeholder tuple");
@@ -1496,7 +1493,7 @@ brinsummarize(Relation index, Relation heapRel, BlockNumber pageRange,
14961493
Buffer buf;
14971494
BlockNumber startBlk;
14981495

1499-
revmap = brinRevmapInitialize(index, &pagesPerRange, NULL);
1496+
revmap = brinRevmapInitialize(index, &pagesPerRange);
15001497

15011498
/* determine range of pages to process */
15021499
heapNumBlocks = RelationGetNumberOfBlocks(heapRel);
@@ -1537,7 +1534,7 @@ brinsummarize(Relation index, Relation heapRel, BlockNumber pageRange,
15371534
CHECK_FOR_INTERRUPTS();
15381535

15391536
tup = brinGetTupleForHeapBlock(revmap, startBlk, &buf, &off, NULL,
1540-
BUFFER_LOCK_SHARE, NULL);
1537+
BUFFER_LOCK_SHARE);
15411538
if (tup == NULL)
15421539
{
15431540
/* no revmap entry for this heap range. Summarize it. */

src/backend/access/brin/brin_revmap.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ static void revmap_physical_extend(BrinRevmap *revmap);
6868
* brinRevmapTerminate when caller is done with it.
6969
*/
7070
BrinRevmap *
71-
brinRevmapInitialize(Relation idxrel, BlockNumber *pagesPerRange,
72-
Snapshot snapshot)
71+
brinRevmapInitialize(Relation idxrel, BlockNumber *pagesPerRange)
7372
{
7473
BrinRevmap *revmap;
7574
Buffer meta;
@@ -194,8 +193,7 @@ brinSetHeapBlockItemptr(Buffer buf, BlockNumber pagesPerRange,
194193
*/
195194
BrinTuple *
196195
brinGetTupleForHeapBlock(BrinRevmap *revmap, BlockNumber heapBlk,
197-
Buffer *buf, OffsetNumber *off, Size *size, int mode,
198-
Snapshot snapshot)
196+
Buffer *buf, OffsetNumber *off, Size *size, int mode)
199197
{
200198
Relation idxRel = revmap->rm_irel;
201199
BlockNumber mapBlk;
@@ -339,7 +337,7 @@ brinRevmapDesummarizeRange(Relation idxrel, BlockNumber heapBlk)
339337
OffsetNumber regOffset;
340338
ItemId lp;
341339

342-
revmap = brinRevmapInitialize(idxrel, &pagesPerRange, NULL);
340+
revmap = brinRevmapInitialize(idxrel, &pagesPerRange);
343341

344342
revmapBlk = revmap_get_blkno(revmap, heapBlk);
345343
if (!BlockNumberIsValid(revmapBlk))

src/backend/access/common/toast_internals.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,7 @@ toast_close_indexes(Relation *toastidxs, int num_indexes, LOCKMODE lock)
636636
*
637637
* Initialize an appropriate TOAST snapshot. We must use an MVCC snapshot
638638
* to initialize the TOAST snapshot; since we don't know which one to use,
639-
* just use the oldest one. This is safe: at worst, we will get a "snapshot
640-
* too old" error that might have been avoided otherwise.
639+
* just use the oldest one.
641640
*/
642641
void
643642
init_toast_snapshot(Snapshot toast_snapshot)

src/backend/access/gin/ginbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ginTraverseLock(Buffer buffer, bool searchMode)
7878
*/
7979
GinBtreeStack *
8080
ginFindLeafPage(GinBtree btree, bool searchMode,
81-
bool rootConflictCheck, Snapshot snapshot)
81+
bool rootConflictCheck)
8282
{
8383
GinBtreeStack *stack;
8484

src/backend/access/gin/gindatapage.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,7 +1917,7 @@ ginInsertItemPointers(Relation index, BlockNumber rootBlkno,
19171917
{
19181918
/* search for the leaf page where the first item should go to */
19191919
btree.itemptr = insertdata.items[insertdata.curitem];
1920-
stack = ginFindLeafPage(&btree, false, true, NULL);
1920+
stack = ginFindLeafPage(&btree, false, true);
19211921

19221922
ginInsertValue(&btree, stack, &insertdata, buildStats);
19231923
}
@@ -1927,16 +1927,15 @@ ginInsertItemPointers(Relation index, BlockNumber rootBlkno,
19271927
* Starts a new scan on a posting tree.
19281928
*/
19291929
GinBtreeStack *
1930-
ginScanBeginPostingTree(GinBtree btree, Relation index, BlockNumber rootBlkno,
1931-
Snapshot snapshot)
1930+
ginScanBeginPostingTree(GinBtree btree, Relation index, BlockNumber rootBlkno)
19321931
{
19331932
GinBtreeStack *stack;
19341933

19351934
ginPrepareDataScan(btree, index, rootBlkno);
19361935

19371936
btree->fullScan = true;
19381937

1939-
stack = ginFindLeafPage(btree, true, false, snapshot);
1938+
stack = ginFindLeafPage(btree, true, false);
19401939

19411940
return stack;
19421941
}

src/backend/access/gin/ginget.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ moveRightIfItNeeded(GinBtreeData *btree, GinBtreeStack *stack, Snapshot snapshot
6767
*/
6868
static void
6969
scanPostingTree(Relation index, GinScanEntry scanEntry,
70-
BlockNumber rootPostingTree, Snapshot snapshot)
70+
BlockNumber rootPostingTree)
7171
{
7272
GinBtreeData btree;
7373
GinBtreeStack *stack;
7474
Buffer buffer;
7575
Page page;
7676

7777
/* Descend to the leftmost leaf page */
78-
stack = ginScanBeginPostingTree(&btree, index, rootPostingTree, snapshot);
78+
stack = ginScanBeginPostingTree(&btree, index, rootPostingTree);
7979
buffer = stack->buffer;
8080

8181
IncrBufferRefCount(buffer); /* prevent unpin in freeGinBtreeStack */
@@ -244,8 +244,7 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack,
244244
PredicateLockPage(btree->index, rootPostingTree, snapshot);
245245

246246
/* Collect all the TIDs in this entry's posting tree */
247-
scanPostingTree(btree->index, scanEntry, rootPostingTree,
248-
snapshot);
247+
scanPostingTree(btree->index, scanEntry, rootPostingTree);
249248

250249
/*
251250
* We lock again the entry page and while it was unlocked insert
@@ -344,7 +343,7 @@ startScanEntry(GinState *ginstate, GinScanEntry entry, Snapshot snapshot)
344343
ginPrepareEntryScan(&btreeEntry, entry->attnum,
345344
entry->queryKey, entry->queryCategory,
346345
ginstate);
347-
stackEntry = ginFindLeafPage(&btreeEntry, true, false, snapshot);
346+
stackEntry = ginFindLeafPage(&btreeEntry, true, false);
348347
page = BufferGetPage(stackEntry->buffer);
349348

350349
/* ginFindLeafPage() will have already checked snapshot age. */
@@ -419,7 +418,7 @@ startScanEntry(GinState *ginstate, GinScanEntry entry, Snapshot snapshot)
419418
needUnlock = false;
420419

421420
stack = ginScanBeginPostingTree(&entry->btree, ginstate->index,
422-
rootPostingTree, snapshot);
421+
rootPostingTree);
423422
entry->buffer = stack->buffer;
424423

425424
/*
@@ -652,7 +651,7 @@ startScan(IndexScanDesc scan)
652651
*/
653652
static void
654653
entryLoadMoreItems(GinState *ginstate, GinScanEntry entry,
655-
ItemPointerData advancePast, Snapshot snapshot)
654+
ItemPointerData advancePast)
656655
{
657656
Page page;
658657
int i;
@@ -697,7 +696,7 @@ entryLoadMoreItems(GinState *ginstate, GinScanEntry entry,
697696
OffsetNumberNext(GinItemPointerGetOffsetNumber(&advancePast)));
698697
}
699698
entry->btree.fullScan = false;
700-
stack = ginFindLeafPage(&entry->btree, true, false, snapshot);
699+
stack = ginFindLeafPage(&entry->btree, true, false);
701700

702701
/* we don't need the stack, just the buffer. */
703702
entry->buffer = stack->buffer;
@@ -807,7 +806,7 @@ entryLoadMoreItems(GinState *ginstate, GinScanEntry entry,
807806
*/
808807
static void
809808
entryGetItem(GinState *ginstate, GinScanEntry entry,
810-
ItemPointerData advancePast, Snapshot snapshot)
809+
ItemPointerData advancePast)
811810
{
812811
Assert(!entry->isFinished);
813812

@@ -938,7 +937,7 @@ entryGetItem(GinState *ginstate, GinScanEntry entry,
938937
/* If we've processed the current batch, load more items */
939938
while (entry->offset >= entry->nlist)
940939
{
941-
entryLoadMoreItems(ginstate, entry, advancePast, snapshot);
940+
entryLoadMoreItems(ginstate, entry, advancePast);
942941

943942
if (entry->isFinished)
944943
{
@@ -989,7 +988,7 @@ entryGetItem(GinState *ginstate, GinScanEntry entry,
989988
*/
990989
static void
991990
keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
992-
ItemPointerData advancePast, Snapshot snapshot)
991+
ItemPointerData advancePast)
993992
{
994993
ItemPointerData minItem;
995994
ItemPointerData curPageLossy;
@@ -1036,7 +1035,7 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
10361035
*/
10371036
if (ginCompareItemPointers(&entry->curItem, &advancePast) <= 0)
10381037
{
1039-
entryGetItem(ginstate, entry, advancePast, snapshot);
1038+
entryGetItem(ginstate, entry, advancePast);
10401039
if (entry->isFinished)
10411040
continue;
10421041
}
@@ -1111,7 +1110,7 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
11111110

11121111
if (ginCompareItemPointers(&entry->curItem, &advancePast) <= 0)
11131112
{
1114-
entryGetItem(ginstate, entry, advancePast, snapshot);
1113+
entryGetItem(ginstate, entry, advancePast);
11151114
if (entry->isFinished)
11161115
continue;
11171116
}
@@ -1334,8 +1333,7 @@ scanGetItem(IndexScanDesc scan, ItemPointerData advancePast,
13341333
}
13351334

13361335
/* Fetch the next item for this key that is > advancePast. */
1337-
keyGetItem(&so->ginstate, so->tempCtx, key, advancePast,
1338-
scan->xs_snapshot);
1336+
keyGetItem(&so->ginstate, so->tempCtx, key, advancePast);
13391337

13401338
if (key->isFinished)
13411339
return false;

src/backend/access/gin/gininsert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ ginEntryInsert(GinState *ginstate,
192192
ginPrepareEntryScan(&btree, attnum, key, category, ginstate);
193193
btree.isBuild = (buildStats != NULL);
194194

195-
stack = ginFindLeafPage(&btree, false, false, NULL);
195+
stack = ginFindLeafPage(&btree, false, false);
196196
page = BufferGetPage(stack->buffer);
197197

198198
if (btree.findItem(&btree, stack))

src/backend/access/heap/vacuumlazy.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,10 +2865,6 @@ lazy_cleanup_one_index(Relation indrel, IndexBulkDeleteResult *istat,
28652865
* in effect in any case. lazy_scan_prune makes the optimistic assumption
28662866
* that any LP_DEAD items it encounters will always be LP_UNUSED by the time
28672867
* we're called.
2868-
*
2869-
* Also don't attempt it if we are doing early pruning/vacuuming, because a
2870-
* scan which cannot find a truncated heap page cannot determine that the
2871-
* snapshot is too old to read that page.
28722868
*/
28732869
static bool
28742870
should_attempt_truncation(LVRelState *vacrel)

src/backend/access/nbtree/nbtinsert.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ _bt_search_insert(Relation rel, Relation heaprel, BTInsertState insertstate)
378378

379379
/* Cannot use optimization -- descend tree, return proper descent stack */
380380
return _bt_search(rel, heaprel, insertstate->itup_key, &insertstate->buf,
381-
BT_WRITE, NULL);
381+
BT_WRITE);
382382
}
383383

384384
/*
@@ -2165,7 +2165,7 @@ _bt_insert_parent(Relation rel,
21652165
BlockNumberIsValid(RelationGetTargetBlock(rel))));
21662166

21672167
/* Find the leftmost page at the next level up */
2168-
pbuf = _bt_get_endpoint(rel, opaque->btpo_level + 1, false, NULL);
2168+
pbuf = _bt_get_endpoint(rel, opaque->btpo_level + 1, false);
21692169
/* Set up a phony stack entry pointing there */
21702170
stack = &fakestack;
21712171
stack->bts_blkno = BufferGetBlockNumber(pbuf);

src/backend/access/nbtree/nbtpage.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,8 +1962,7 @@ _bt_pagedel(Relation rel, Buffer leafbuf, BTVacState *vstate)
19621962
itup_key = _bt_mkscankey(rel, targetkey);
19631963
/* find the leftmost leaf page with matching pivot/high key */
19641964
itup_key->pivotsearch = true;
1965-
stack = _bt_search(rel, NULL, itup_key, &sleafbuf, BT_READ,
1966-
NULL);
1965+
stack = _bt_search(rel, NULL, itup_key, &sleafbuf, BT_READ);
19671966
/* won't need a second lock or pin on leafbuf */
19681967
_bt_relbuf(rel, sleafbuf);
19691968

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy