While working on the "Combine Prune and Freeze records emitted by
vacuum" patch [1], I wished we would have an easier way to test pruning.
There's a lot of logic with following HOT chains etc., and it's very
hard to construct all those scenarios just by INSERT/UPDATE/DELETE
commands. In principle though, pruning should be very amenable for good
test coverage. The input is one heap page and some parameters, the
output is one heap page and a few other fields that are already packaged
neatly in the PruneFreezeResult struct.
Back then, I started to work on a little tool for that to verify the
correctness of pruning refactoring, but I never got around to polish it
or write proper repeatable tests with it. I did use it for some ad hoc
testing, though.
I don't know when I'll find the time to polish it, so here is the very
rough work-in-progress version I've got now.
One thing I used this for was to test that we still handle
HEAP_MOVED_IN/OFF correctly. Yes, it still works. But what surprised me
is that when a HEAP_MOVED_IN tuple is frozen, we replace xvac with
FrozenTransactondId, and leave the HEAP_MOVED_IN flag in place. I
assumed that we would clear the HEAP_MOVED_IN flag instead.
[1]
https://www.postgresql.org/message-id/CAAKRu_azf-zH%3DDgVbquZ3tFWjMY1w5pO8m-TXJaMdri8z3933g%40mail.gmail.com
--
Heikki Linnakangas
Neon (https://neon.tech)