Skip to content

Commit e351f85

Browse files
committed
Push lpp variable closer to usage in heapgetpage()
Author: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/CAAKRu_YSOnhKsDyFcqJsKtBSrd32DP-jjXmv7hL0BPD-z0TGXQ@mail.gmail.com
1 parent 72e0ff2 commit e351f85

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

src/backend/access/heap/heapam.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ heapgetpage(TableScanDesc sscan, BlockNumber block)
383383
int lines;
384384
int ntup;
385385
OffsetNumber lineoff;
386-
ItemId lpp;
387386
bool all_visible;
388387

389388
Assert(block < scan->rs_nblocks);
@@ -452,31 +451,30 @@ heapgetpage(TableScanDesc sscan, BlockNumber block)
452451
*/
453452
all_visible = PageIsAllVisible(page) && !snapshot->takenDuringRecovery;
454453

455-
for (lineoff = FirstOffsetNumber, lpp = PageGetItemId(page, lineoff);
456-
lineoff <= lines;
457-
lineoff++, lpp++)
454+
for (lineoff = FirstOffsetNumber; lineoff <= lines; lineoff++)
458455
{
459-
if (ItemIdIsNormal(lpp))
460-
{
461-
HeapTupleData loctup;
462-
bool valid;
456+
ItemId lpp = PageGetItemId(page, lineoff);
457+
HeapTupleData loctup;
458+
bool valid;
463459

464-
loctup.t_tableOid = RelationGetRelid(scan->rs_base.rs_rd);
465-
loctup.t_data = (HeapTupleHeader) PageGetItem(page, lpp);
466-
loctup.t_len = ItemIdGetLength(lpp);
467-
ItemPointerSet(&(loctup.t_self), block, lineoff);
460+
if (!ItemIdIsNormal(lpp))
461+
continue;
468462

469-
if (all_visible)
470-
valid = true;
471-
else
472-
valid = HeapTupleSatisfiesVisibility(&loctup, snapshot, buffer);
463+
loctup.t_tableOid = RelationGetRelid(scan->rs_base.rs_rd);
464+
loctup.t_data = (HeapTupleHeader) PageGetItem(page, lpp);
465+
loctup.t_len = ItemIdGetLength(lpp);
466+
ItemPointerSet(&(loctup.t_self), block, lineoff);
473467

474-
HeapCheckForSerializableConflictOut(valid, scan->rs_base.rs_rd,
475-
&loctup, buffer, snapshot);
468+
if (all_visible)
469+
valid = true;
470+
else
471+
valid = HeapTupleSatisfiesVisibility(&loctup, snapshot, buffer);
476472

477-
if (valid)
478-
scan->rs_vistuples[ntup++] = lineoff;
479-
}
473+
HeapCheckForSerializableConflictOut(valid, scan->rs_base.rs_rd,
474+
&loctup, buffer, snapshot);
475+
476+
if (valid)
477+
scan->rs_vistuples[ntup++] = lineoff;
480478
}
481479

482480
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);

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