Skip to content

Commit c623e85

Browse files
Reduce scope of heap vacuum per_buffer_data
Move lazy_scan_heap()'s per_buffer_data variable into a tighter scope. In lazy_scan_heap()'s phase I heap vacuuming, the read stream API returns a pointer to the next block number to vacuum. As long as read_stream_next_buffer() returns a valid buffer, per_buffer_data should always be valid. Move per_buffer_data into a tighter scope and make sure it is reset to NULL on each iteration so that we get a core dump instead of bogus data from a previous block if something goes wrong in the read stream API. Suggested-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/626104.1739729538%40sss.pgh.pa.us
1 parent 95ef3d9 commit c623e85

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/access/heap/vacuumlazy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,6 @@ lazy_scan_heap(LVRelState *vacrel)
11921192
BlockNumber rel_pages = vacrel->rel_pages,
11931193
blkno = 0,
11941194
next_fsm_block_to_vacuum = 0;
1195-
void *per_buffer_data = NULL;
11961195
BlockNumber orig_eager_scan_success_limit =
11971196
vacrel->eager_scan_remaining_successes; /* for logging */
11981197
Buffer vmbuffer = InvalidBuffer;
@@ -1231,6 +1230,7 @@ lazy_scan_heap(LVRelState *vacrel)
12311230
Page page;
12321231
uint8 blk_info = 0;
12331232
bool has_lpdead_items;
1233+
void *per_buffer_data = NULL;
12341234
bool vm_page_frozen = false;
12351235
bool got_cleanup_lock = false;
12361236

0 commit comments

Comments
 (0)