From: Melanie Plageman Date: Thu, 5 Mar 2026 21:22:57 +0000 (-0500) Subject: Add PageGetPruneXid() helper X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68c2dcb9130e8e3bc60676909676be1567c3cd51;p=thirdparty%2Fpostgresql.git Add PageGetPruneXid() helper This is similar to the other page accessors in bufpage.h. It improves readability and avoids long lines. Author: Melanie Plageman Reviewed-by: Chao Li Discussion: https://postgr.es/m/BD8B69E7-26D8-4706-9164-597C6AE57812%40gmail.com --- diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c index 3c5d33834fc..1d61b336193 100644 --- a/src/backend/access/heap/pruneheap.c +++ b/src/backend/access/heap/pruneheap.c @@ -234,7 +234,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer) * determining the appropriate horizon is a waste if there's no prune_xid * (i.e. no updates/deletes left potentially dead tuples around). */ - prune_xid = ((PageHeader) page)->pd_prune_xid; + prune_xid = PageGetPruneXid(page); if (!TransactionIdIsValid(prune_xid)) return; @@ -868,7 +868,7 @@ heap_page_prune_and_freeze(PruneFreezeParams *params, * pd_prune_xid field or the page was marked full, we will update the hint * bit. */ - do_hint_prune = ((PageHeader) prstate.page)->pd_prune_xid != prstate.new_prune_xid || + do_hint_prune = PageGetPruneXid(prstate.page) != prstate.new_prune_xid || PageIsFull(prstate.page); /* diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h index ae3725b3b81..92a6bb9b0c0 100644 --- a/src/include/storage/bufpage.h +++ b/src/include/storage/bufpage.h @@ -441,6 +441,12 @@ PageClearAllVisible(Page page) ((PageHeader) page)->pd_flags &= ~PD_ALL_VISIBLE; } +static inline TransactionId +PageGetPruneXid(const PageData *page) +{ + return ((const PageHeaderData *) page)->pd_prune_xid; +} + /* * These two require "access/transam.h", so left as macros. */