Re: [Proposal] Adding callback support for custom statistics kinds
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Sami Imseih <samimseih@gmail.com>, Chao Li <li.evan.chao@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-17T08:11:19Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix const correctness in pgstat data serialization callbacks
- 167cb26718e3 19 (unreleased) landed
-
test_custom_stats: Add tests with read/write of auxiliary data
- 481783e69f14 19 (unreleased) landed
-
Allow cumulative statistics to read/write auxiliary data from/to disk
- 4ba012a8ed9c 19 (unreleased) landed
-
test_custom_stats: Test module for custom cumulative statistics
- 31280d96a648 19 (unreleased) landed
-
injection_points: Remove portions related to custom pgstats
- d52c24b0f808 19 (unreleased) landed
-
Rename routines for write/read of pgstats file
- ed823da12891 19 (unreleased) landed
Attachments
- custom-stats-const.patch (text/x-diff) patch
On Wed, Dec 17, 2025 at 08:03:36AM +0100, Peter Eisentraut wrote: > So it seems to me that either the callbacks API needs some adjustments, or > this particular implementation of the callback function is incorrect. Hmm, you are right that this is not aligned. This can be improved with one change for each callback: - It is OK with from_serialized_data() to manipulate the header data, because we want to fill a portion of the shmem data with extra data read from disk (the module wants to add a reference to a DSA stored in the shmem entry, read from the second file). So we should discard the const marker from the callback definition. - The const usage is OK for to_serialized_data(): it is better to encourage a policy where the header data cannot be manipulated. So the const needs to be kept in the definition, but I also think that we should change the module implementation so as the cast to PgStatShared_CustomVarEntry is a const. These changes result in the attached. Sami, what do you think? -- Michael