pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix const correctness in pgstat data serialization callbacks
Date: Wed, 17 Dec 2025 22:34:11 +0000
Message-ID: <E1vW05y-001JUb-1f@gemulon.postgresql.org> (raw)

Fix const correctness in pgstat data serialization callbacks

4ba012a8ed9c defined the "header" (pointer to the stats data) of
from_serialized_data() as a const, even though it is fine (and
expected!) for the callback to modify the shared memory entry when
loading the stats at startup.

While on it, this commit updates the callback to_serialized_data() in
the test module test_custom_stats to make the data extracted from the
"header" parameter a const since it should never be modified: the stats
are written to disk and no modifications are expected in the shared
memory entry.

This clarifies the API contract of these new callbacks.

Reported-By: Peter Eisentraut <peter@eisentraut.org>
Author: Michael Paquier <michael@paquier.xyz>
Co-authored-by: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/d87a93b0-19c7-4db6-b9c0-d6827e7b2da1@eisentraut.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/167cb26718e3eae4fef470900b4cd1d434f15649

Modified Files
--------------
src/include/utils/pgstat_internal.h                        | 5 +++--
src/test/modules/test_custom_stats/test_custom_var_stats.c | 6 +++---
2 files changed, 6 insertions(+), 5 deletions(-)



Message-ID: <E1vW05y-001JUb-1f@gemulon.postgresql.org>
Permalink:  ../E1vW05y-001JUb-1f@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vW05y-001JUb-1f@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix const correctness in pgstat data serialization callbacks
  In-Reply-To: <E1vW05y-001JUb-1f@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox