pgsql: Remove unnecessary volatile qualifiers.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove unnecessary volatile qualifiers.
Date: 2026-07-07 15:58:02
Message-ID: E1wh8BN-0001DZ-2v@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Remove unnecessary volatile qualifiers.

This commit cleans up volatile qualifiers that fit the below
criteria:

* Accesses to shared memory protected by a spinlock or LWLock.
Before commit 0709b7ee72, callers had to use volatile when
accessing spinlock-protected shared memory. Since spinlock
acquire/release became compiler barriers, and because LWLocks
provide the same guarantee, that is no longer necessary. These
either predate that change or were cargo-culted from code that did.

* Pointers used only to find the address of a member. The volatile
qualifier only affects accesses made by dereferencing the pointer,
so it is unnecessary there.

* Accesses to struct members that are marked volatile in the struct
definition. There's no need to mark these pointers volatile,
either.

* Leftovers from removed PG_TRY blocks. These were marked volatile
to protect a value that is modified inside a PG_TRY block, but the
PG_TRY has since been removed.

Reviewed-by: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Discussion: https://postgr.es/m/akQ5eJR1tCCXme8e%40nathan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b34fd845e03aea7401d3bf403c87e171d10f7709

Modified Files
--------------
src/backend/access/transam/clog.c | 7 +++----
src/backend/catalog/index.c | 2 +-
src/backend/commands/async.c | 4 ++--
src/backend/replication/syncrep.c | 19 ++++++++-----------
src/backend/storage/ipc/procsignal.c | 8 ++++----
src/backend/storage/ipc/shm_toc.c | 31 ++++++++++++++-----------------
src/backend/storage/lmgr/lock.c | 2 +-
src/backend/storage/lmgr/proc.c | 3 +--
src/test/modules/test_shm_mq/setup.c | 4 ++--
src/test/modules/test_shm_mq/worker.c | 2 +-
10 files changed, 37 insertions(+), 45 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-07-07 16:53:12 pgsql: Fix pg_dump ACL minimization for PROPERTY GRAPH.
Previous Message Heikki Linnakangas 2026-07-07 15:56:47 pgsql: libpq: Drain all pending bytes from SSL/GSS during pqReadData()