Skip to content

Commit d30b499

Browse files
Make lazy_vacuum_heap_rel match lazy_scan_heap.
Make lazy_vacuum_heap_rel variable names match those from lazy_scan_heap where that makes sense. Extracted from a larger patch to deal with issues with how vacuumlazy.c sets pages all-frozen. Author: Peter Geoghegan <pg@bowt.ie> Discussion: https://postgr.es/m/CAH2-WznuNGSzF8v6OsgjaC5aYsb3cZ6HW6MLm30X0d65cmSH6A@mail.gmail.com
1 parent 8c233cf commit d30b499

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/backend/access/heap/vacuumlazy.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,8 +2388,8 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
23882388
static void
23892389
lazy_vacuum_heap_rel(LVRelState *vacrel)
23902390
{
2391-
int index;
2392-
BlockNumber vacuumed_pages;
2391+
int index = 0;
2392+
BlockNumber vacuumed_pages = 0;
23932393
Buffer vmbuffer = InvalidBuffer;
23942394
LVSavedErrInfo saved_err_info;
23952395

@@ -2406,42 +2406,34 @@ lazy_vacuum_heap_rel(LVRelState *vacrel)
24062406
VACUUM_ERRCB_PHASE_VACUUM_HEAP,
24072407
InvalidBlockNumber, InvalidOffsetNumber);
24082408

2409-
vacuumed_pages = 0;
2410-
2411-
index = 0;
24122409
while (index < vacrel->dead_items->num_items)
24132410
{
2414-
BlockNumber tblk;
2411+
BlockNumber blkno;
24152412
Buffer buf;
24162413
Page page;
24172414
Size freespace;
24182415

24192416
vacuum_delay_point();
24202417

2421-
tblk = ItemPointerGetBlockNumber(&vacrel->dead_items->items[index]);
2422-
vacrel->blkno = tblk;
2423-
buf = ReadBufferExtended(vacrel->rel, MAIN_FORKNUM, tblk, RBM_NORMAL,
2418+
blkno = ItemPointerGetBlockNumber(&vacrel->dead_items->items[index]);
2419+
vacrel->blkno = blkno;
2420+
buf = ReadBufferExtended(vacrel->rel, MAIN_FORKNUM, blkno, RBM_NORMAL,
24242421
vacrel->bstrategy);
24252422
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
2426-
index = lazy_vacuum_heap_page(vacrel, tblk, buf, index, &vmbuffer);
2423+
index = lazy_vacuum_heap_page(vacrel, blkno, buf, index, &vmbuffer);
24272424

24282425
/* Now that we've vacuumed the page, record its available space */
24292426
page = BufferGetPage(buf);
24302427
freespace = PageGetHeapFreeSpace(page);
24312428

24322429
UnlockReleaseBuffer(buf);
2433-
RecordPageWithFreeSpace(vacrel->rel, tblk, freespace);
2430+
RecordPageWithFreeSpace(vacrel->rel, blkno, freespace);
24342431
vacuumed_pages++;
24352432
}
24362433

2437-
/* Clear the block number information */
24382434
vacrel->blkno = InvalidBlockNumber;
2439-
24402435
if (BufferIsValid(vmbuffer))
2441-
{
24422436
ReleaseBuffer(vmbuffer);
2443-
vmbuffer = InvalidBuffer;
2444-
}
24452437

24462438
/*
24472439
* We set all LP_DEAD items from the first heap pass to LP_UNUSED during

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