From c118ef37539a1f639b8c5fe27f67f16e7f201fc7 Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Wed, 25 Feb 2026 16:12:42 +0000 Subject: [PATCH v2 1/2] Reduce the scope of the volatile qualifier in vac_truncate_clog() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c66a7d75e652 introduced a new "cast discards ‘volatile’" warning (-Wcast-qual). Instead of making use of unvolatize(), let's remove the warning by reducing the scope of the volatile qualifier (added in 2d2e40e3bef) to only 2 fields. Suggested-by: Peter Eisentraut Author: Bertrand Drouvot Reviewed-by: Nathan Bossart 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 03932f45c8a..7ff24600fcf 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -1869,9 +1869,11 @@ vac_truncate_clog(TransactionId frozenXID, while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - volatile FormData_pg_database *dbform = (Form_pg_database) GETSTRUCT(tuple); - TransactionId datfrozenxid = dbform->datfrozenxid; - TransactionId datminmxid = dbform->datminmxid; + Form_pg_database dbform = (Form_pg_database) GETSTRUCT(tuple); + volatile TransactionId *datfrozenxid_p = &dbform->datfrozenxid; + volatile TransactionId *datminmxid_p = &dbform->datminmxid; + TransactionId datfrozenxid = *datfrozenxid_p; + TransactionId datminmxid = *datminmxid_p; Assert(TransactionIdIsNormal(datfrozenxid)); Assert(MultiXactIdIsValid(datminmxid)); -- 2.34.1