]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Add PageGetPruneXid() helper
authorMelanie Plageman <melanieplageman@gmail.com>
Thu, 5 Mar 2026 21:22:57 +0000 (16:22 -0500)
committerMelanie Plageman <melanieplageman@gmail.com>
Thu, 5 Mar 2026 21:22:57 +0000 (16:22 -0500)
This is similar to the other page accessors in bufpage.h. It improves
readability and avoids long lines.

Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/BD8B69E7-26D8-4706-9164-597C6AE57812%40gmail.com

src/backend/access/heap/pruneheap.c
src/include/storage/bufpage.h

index 3c5d33834fcdc68a4a2573f552bfd045be7e4448..1d61b336193f0449fdd9509b83a2a36ce6f69539 100644 (file)
@@ -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);
 
        /*
index ae3725b3b81bbb948072077ff9f8b7dbf26a79f9..92a6bb9b0c0f42c4b02751ea9ca777b2a762f07f 100644 (file)
@@ -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.
  */