Re: [Proposal] Adding callback support for custom statistics kinds
Sami Imseih <samimseih@gmail.com>
From: Sami Imseih <samimseih@gmail.com>
To: Chao Li <li.evan.chao@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-04T23:00:10Z
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
> If we push down the responsibility into the extension code, then all extensions > that want to enjoy the callbacks have to handle the same complexities of dealing > with stat files, which sounds big duplicate efforts. Thanks for the input! Yes, this is a trade-off between putting responsibility on the extension vs core. The initial thought I had was exactly like yours, but it will be easier to get something pushed if we make the core changes as minimal as possible. If there are enough complaints in the future, this can be revisited. Particularly if there is a common patterns for file cleanup, this could be turned into a core utility. > That looks like a good direction to me. The only differences I can > see with the stats module in injection_points for variable-sized stats > is that this new module does not check pgstat_drop_entry() and > pgstat_fetch_entry() when working on a custom stats kind. If we had > SQL interfaces calling these two, we could just remove > injection_stats.c entirely, moving everything to this new test module. > I should have invented a new module from the start, perhaps, but well, > that was good enough to check the basic APIs when working on the > custom APIs. Removing this duplication would be my own business with > your module in the tree, no need for you to worry about that. That > would also remove the tweak you have used regarding the duplicated > kind ID. I plan on addressing the other comments. However, as discussed off-list, I do think moving the custom kind tests from injection points to the new test module is a prerequisite. I rather not have us push a new test module that is doing duplicate work as the injection stats tests. I worked on this refactoring today and plan to have a patch ready for review by tomorrow. -- Sami Imseih Amazon Web Services (AWS)