diff --git a/contrib/pg_visibility/pg_visibility.c b/contrib/pg_visibility/pg_visibility.c index d79ef35006..d0c73eaeb0 100644 --- a/contrib/pg_visibility/pg_visibility.c +++ b/contrib/pg_visibility/pg_visibility.c @@ -769,6 +769,7 @@ collect_corrupt_items(Oid relid, bool all_visible, bool all_frozen) OffsetNumber offnum, maxoff; BlockNumber blkno; + HeapTupleData tuple; /* Make sure we are interruptible. */ CHECK_FOR_INTERRUPTS(); @@ -793,12 +794,15 @@ collect_corrupt_items(Oid relid, bool all_visible, bool all_frozen) continue; } + /* block and tableOid is the same for all tuples, set it once outside the loop */ + ItemPointerSetBlockNumber(&tuple.t_self, blkno); + tuple.t_tableOid = relid; + /* Iterate over each tuple on the page. */ for (offnum = FirstOffsetNumber; offnum <= maxoff; offnum = OffsetNumberNext(offnum)) { - HeapTupleData tuple; ItemId itemid; itemid = PageGetItemId(page, offnum); @@ -807,19 +811,18 @@ collect_corrupt_items(Oid relid, bool all_visible, bool all_frozen) if (!ItemIdIsUsed(itemid) || ItemIdIsRedirected(itemid)) continue; + ItemPointerSetOffsetNumber(&tuple.t_self, offnum); + /* Dead line pointers are neither all-visible nor frozen. */ if (ItemIdIsDead(itemid)) { - ItemPointerSet(&(tuple.t_self), blkno, offnum); record_corrupt_item(items, &tuple.t_self); continue; } /* Initialize a HeapTupleData structure for checks below. */ - ItemPointerSet(&(tuple.t_self), blkno, offnum); tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid); tuple.t_len = ItemIdGetLength(itemid); - tuple.t_tableOid = relid; /* * If we're checking whether the page is all-visible, we expect