Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitffcf654

Browse files
committed
Fix systable_recheck_tuple() for MVCC scan snapshots.
Since this function assumed non-MVCC snapshots, it broke when commit568d413 switched its one caller fromSnapshotNow scans to MVCC-snapshot scans.Reviewed by Robert Haas, Tom Lane and Andres Freund.
1 parentb560ec1 commitffcf654

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

‎src/backend/access/index/genam.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ systable_getnext(SysScanDesc sysscan)
361361
/*
362362
* systable_recheck_tuple --- recheck visibility of most-recently-fetched tuple
363363
*
364+
* In particular, determine if this tuple would be visible to a catalog scan
365+
* that started now. We don't handle the case of a non-MVCC scan snapshot,
366+
* because no caller needs that yet.
367+
*
364368
* This is useful to test whether an object was deleted while we waited to
365369
* acquire lock on it.
366370
*
@@ -370,30 +374,38 @@ systable_getnext(SysScanDesc sysscan)
370374
bool
371375
systable_recheck_tuple(SysScanDescsysscan,HeapTupletup)
372376
{
377+
Snapshotfreshsnap;
373378
boolresult;
374379

380+
/*
381+
* Trust that LockBuffer() and HeapTupleSatisfiesMVCC() do not themselves
382+
* acquire snapshots, so we need not register the snapshot. Those
383+
* facilities are too low-level to have any business scanning tables.
384+
*/
385+
freshsnap=GetCatalogSnapshot(RelationGetRelid(sysscan->heap_rel));
386+
375387
if (sysscan->irel)
376388
{
377389
IndexScanDescscan=sysscan->iscan;
378390

391+
Assert(IsMVCCSnapshot(scan->xs_snapshot));
379392
Assert(tup==&scan->xs_ctup);
380393
Assert(BufferIsValid(scan->xs_cbuf));
381394
/* must hold a buffer lock to call HeapTupleSatisfiesVisibility */
382395
LockBuffer(scan->xs_cbuf,BUFFER_LOCK_SHARE);
383-
result=HeapTupleSatisfiesVisibility(tup,scan->xs_snapshot,
384-
scan->xs_cbuf);
396+
result=HeapTupleSatisfiesVisibility(tup,freshsnap,scan->xs_cbuf);
385397
LockBuffer(scan->xs_cbuf,BUFFER_LOCK_UNLOCK);
386398
}
387399
else
388400
{
389401
HeapScanDescscan=sysscan->scan;
390402

403+
Assert(IsMVCCSnapshot(scan->rs_snapshot));
391404
Assert(tup==&scan->rs_ctup);
392405
Assert(BufferIsValid(scan->rs_cbuf));
393406
/* must hold a buffer lock to call HeapTupleSatisfiesVisibility */
394407
LockBuffer(scan->rs_cbuf,BUFFER_LOCK_SHARE);
395-
result=HeapTupleSatisfiesVisibility(tup,scan->rs_snapshot,
396-
scan->rs_cbuf);
408+
result=HeapTupleSatisfiesVisibility(tup,freshsnap,scan->rs_cbuf);
397409
LockBuffer(scan->rs_cbuf,BUFFER_LOCK_UNLOCK);
398410
}
399411
returnresult;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp