From 2af207662215f2382ae0ce61a4f78c67c7ff6afc Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Date: Wed, 25 Feb 2026 16:37:12 +0000
Subject: [PATCH v2 2/2] Reduce the scope of the volatile qualifier in
 vac_update_datfrozenxid()

Commit xxx reduced the scope of the volatile qualifier in vac_truncate_clog().
Let's do the same for vac_update_datfrozenxid(), since the intent of f65ab862e3b
was to prevent the same kind of race condition that 2d2e40e3bef was fixing.

Suggested-by: Peter Eisentraut <peter@eisentraut.org>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/aZ3a%2BV82uSfEjDmD%40ip-10-97-1-34.eu-west-3.compute.internal
---
 src/backend/commands/vacuum.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
 100.0% src/backend/commands/

diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ff24600fcf..b9840637783 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -1665,9 +1665,11 @@ vac_update_datfrozenxid(void)
 
 	while ((classTup = systable_getnext(scan)) != NULL)
 	{
-		volatile FormData_pg_class *classForm = (Form_pg_class) GETSTRUCT(classTup);
-		TransactionId relfrozenxid = classForm->relfrozenxid;
-		TransactionId relminmxid = classForm->relminmxid;
+		Form_pg_class classForm = (Form_pg_class) GETSTRUCT(classTup);
+		volatile TransactionId *relfrozenxid_p = &classForm->relfrozenxid;
+		volatile TransactionId *relminmxid_p = &classForm->relminmxid;
+		TransactionId relfrozenxid = *relfrozenxid_p;
+		TransactionId relminmxid = *relminmxid_p;
 
 		/*
 		 * Only consider relations able to hold unfrozen XIDs (anything else
-- 
2.34.1

