From: Melanie Plageman <melanieplageman@gmail.com>
Date: Tue, 16 Dec 2025 15:29:16 +0000 (-0500)
Subject: Fix const qualification in prune_freeze_setup()
X-Git-Url: http://git.postgresql.org/gitweb/static/formdemo.sql?a=commitdiff_plain;h=4877391ce894e5b964a69e94e1750cde9df04a07;p=postgresql.git

Fix const qualification in prune_freeze_setup()

The const qualification of the presult argument to prune_freeze_setup()
is later cast away, so it was not correct. Remove it and add a comment
explaining that presult should not be modified.

Author: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/fb97d0ae-a0bc-411d-8a87-f84e7e146488%40eisentraut.org
---

diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
index ca44225a10e..f99d92725b8 100644
--- a/src/backend/access/heap/pruneheap.c
+++ b/src/backend/access/heap/pruneheap.c
@@ -160,7 +160,7 @@ typedef struct
 static void prune_freeze_setup(PruneFreezeParams *params,
 							   TransactionId *new_relfrozen_xid,
 							   MultiXactId *new_relmin_mxid,
-							   const PruneFreezeResult *presult,
+							   PruneFreezeResult *presult,
 							   PruneState *prstate);
 static void prune_freeze_plan(Oid reloid, Buffer buffer,
 							  PruneState *prstate,
@@ -322,12 +322,15 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
 /*
  * Helper for heap_page_prune_and_freeze() to initialize the PruneState using
  * the provided parameters.
+ *
+ * params, new_relfrozen_xid, new_relmin_mxid, and presult are input
+ * parameters and are not modified by this function. Only prstate is modified.
  */
 static void
 prune_freeze_setup(PruneFreezeParams *params,
 				   TransactionId *new_relfrozen_xid,
 				   MultiXactId *new_relmin_mxid,
-				   const PruneFreezeResult *presult,
+				   PruneFreezeResult *presult,
 				   PruneState *prstate)
 {
 	/* Copy parameters to prstate */
@@ -382,7 +385,7 @@ prune_freeze_setup(PruneFreezeParams *params,
 	prstate->recently_dead_tuples = 0;
 	prstate->hastup = false;
 	prstate->lpdead_items = 0;
-	prstate->deadoffsets = (OffsetNumber *) presult->deadoffsets;
+	prstate->deadoffsets = presult->deadoffsets;
 	prstate->frz_conflict_horizon = InvalidTransactionId;
 
 	/*
