diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 34d83dc702..13a4b2b515 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -383,7 +383,6 @@ heapgetpage(TableScanDesc sscan, BlockNumber block) int lines; int ntup; OffsetNumber lineoff; - ItemId lpp; bool all_visible; Assert(block < scan->rs_nblocks); @@ -452,31 +451,30 @@ heapgetpage(TableScanDesc sscan, BlockNumber block) */ all_visible = PageIsAllVisible(page) && !snapshot->takenDuringRecovery; - for (lineoff = FirstOffsetNumber, lpp = PageGetItemId(page, lineoff); - lineoff <= lines; - lineoff++, lpp++) + for (lineoff = FirstOffsetNumber; lineoff <= lines; lineoff++) { - if (ItemIdIsNormal(lpp)) - { - HeapTupleData loctup; - bool valid; + ItemId lpp = PageGetItemId(page, lineoff); + HeapTupleData loctup; + bool valid; - loctup.t_tableOid = RelationGetRelid(scan->rs_base.rs_rd); - loctup.t_data = (HeapTupleHeader) PageGetItem(page, lpp); - loctup.t_len = ItemIdGetLength(lpp); - ItemPointerSet(&(loctup.t_self), block, lineoff); + if (!ItemIdIsNormal(lpp)) + continue; - if (all_visible) - valid = true; - else - valid = HeapTupleSatisfiesVisibility(&loctup, snapshot, buffer); + loctup.t_tableOid = RelationGetRelid(scan->rs_base.rs_rd); + loctup.t_data = (HeapTupleHeader) PageGetItem(page, lpp); + loctup.t_len = ItemIdGetLength(lpp); + ItemPointerSet(&(loctup.t_self), block, lineoff); - HeapCheckForSerializableConflictOut(valid, scan->rs_base.rs_rd, - &loctup, buffer, snapshot); + if (all_visible) + valid = true; + else + valid = HeapTupleSatisfiesVisibility(&loctup, snapshot, buffer); - if (valid) - scan->rs_vistuples[ntup++] = lineoff; - } + HeapCheckForSerializableConflictOut(valid, scan->rs_base.rs_rd, + &loctup, buffer, snapshot); + + if (valid) + scan->rs_vistuples[ntup++] = lineoff; } LockBuffer(buffer, BUFFER_LOCK_UNLOCK);