diff options
author | Peter Geoghegan <pg@bowt.ie> | 2023-01-11 18:45:32 -0800 |
---|---|---|
committer | Peter Geoghegan <pg@bowt.ie> | 2023-01-11 18:45:32 -0800 |
commit | d30b499997caa77805c112b3e0524d2bca8f3e48 (patch) | |
tree | fa49de1fd731d1b5cc711516fa8442a84a3fc833 /src/backend/access/heap | |
parent | 8c233cf86b6d77989a1a6bea96f9b2e31a9b6c7a (diff) | |
download | postgresql-d30b499997caa77805c112b3e0524d2bca8f3e48.tar.gz |
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
Diffstat (limited to 'src/backend/access/heap')
-rw-r--r-- | src/backend/access/heap/vacuumlazy.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 731e77676c..3694515167 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -2388,8 +2388,8 @@ lazy_vacuum_all_indexes(LVRelState *vacrel) static void lazy_vacuum_heap_rel(LVRelState *vacrel) { - int index; - BlockNumber vacuumed_pages; + int index = 0; + BlockNumber vacuumed_pages = 0; Buffer vmbuffer = InvalidBuffer; LVSavedErrInfo saved_err_info; @@ -2406,42 +2406,34 @@ lazy_vacuum_heap_rel(LVRelState *vacrel) VACUUM_ERRCB_PHASE_VACUUM_HEAP, InvalidBlockNumber, InvalidOffsetNumber); - vacuumed_pages = 0; - - index = 0; while (index < vacrel->dead_items->num_items) { - BlockNumber tblk; + BlockNumber blkno; Buffer buf; Page page; Size freespace; vacuum_delay_point(); - tblk = ItemPointerGetBlockNumber(&vacrel->dead_items->items[index]); - vacrel->blkno = tblk; - buf = ReadBufferExtended(vacrel->rel, MAIN_FORKNUM, tblk, RBM_NORMAL, + blkno = ItemPointerGetBlockNumber(&vacrel->dead_items->items[index]); + vacrel->blkno = blkno; + buf = ReadBufferExtended(vacrel->rel, MAIN_FORKNUM, blkno, RBM_NORMAL, vacrel->bstrategy); LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); - index = lazy_vacuum_heap_page(vacrel, tblk, buf, index, &vmbuffer); + index = lazy_vacuum_heap_page(vacrel, blkno, buf, index, &vmbuffer); /* Now that we've vacuumed the page, record its available space */ page = BufferGetPage(buf); freespace = PageGetHeapFreeSpace(page); UnlockReleaseBuffer(buf); - RecordPageWithFreeSpace(vacrel->rel, tblk, freespace); + RecordPageWithFreeSpace(vacrel->rel, blkno, freespace); vacuumed_pages++; } - /* Clear the block number information */ vacrel->blkno = InvalidBlockNumber; - if (BufferIsValid(vmbuffer)) - { ReleaseBuffer(vmbuffer); - vmbuffer = InvalidBuffer; - } /* * We set all LP_DEAD items from the first heap pass to LP_UNUSED during |