Reduce scope of heap vacuum per_buffer_data
authorMelanie Plageman <melanieplageman@gmail.com>
Tue, 18 Feb 2025 14:28:10 +0000 (09:28 -0500)
committerMelanie Plageman <melanieplageman@gmail.com>
Tue, 18 Feb 2025 14:29:10 +0000 (09:29 -0500)
commitc623e8593ec4ee6987f3cd9350ced7caf8526ed2
tree7e0690c9db5d26578fd88485b7f311dea62e0a3b
parent95ef3d902950317650ccea4b9a8bef47936eae35
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
src/backend/access/heap/vacuumlazy.c