pgsql: Introduce macros for WAL block reference IDs of some heap record

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Introduce macros for WAL block reference IDs of some heap record
Date: 2026-07-15 21:38:05
Message-ID: E1wk7Ir-000M42-03@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Introduce macros for WAL block reference IDs of some heap record types

When registering a buffer with the WAL machinery, the caller assigns it a
block reference ID, and replay must read each block back by that same ID.
Today these IDs are bare integers assigned by convention (0, 1, 2, ...),
which is easy to follow when a record registers a single block, or when the
blocks are handled during replay in their registration order.

An upcoming bug fix registers up to two visibility map blocks in addition
to the heap block(s) when clearing the VM, and these are not handled during
replay in a straightforward 1:1, in-registration-order fashion. Relying on
bare integers for the block IDs in that case is error-prone.

Introduce macros naming the block reference IDs for the heap record types
that the upcoming commit extends to register visibility map blocks, so the
registration and replay sites refer to the same block by a meaningful name.

Author: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Reviewed-by: Robert Haas <robertmhaas(at)gmail(dot)com>
Discussion: https://postgr.es/m/66mqpfyti3qhfttcsv6r2lbvqqd32rrmpn6i47ovrsnvguts46%40gou54xc>
Backpatch through: 17

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d0fb1da21bbcc7bdf13632cd080628757cd008e3

Modified Files
--------------
src/backend/access/heap/heapam.c | 43 ++++++++++++++++-----------
src/backend/access/heap/heapam_xlog.c | 56 ++++++++++++++++++++++-------------
src/include/access/heapam_xlog.h | 28 +++++++++++++-----
3 files changed, 82 insertions(+), 45 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Melanie Plageman 2026-07-15 21:44:24 pgsql: Introduce macros for WAL block reference IDs of some heap record
Previous Message Melanie Plageman 2026-07-15 21:32:49 pgsql: Test that VM clear registers VM buffers