| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Improve checks and error messages of pgstat_register_kind() |
| Date: | 2026-07-06 01:50:04 |
| Message-ID: | E1wgYTE-001WNL-2F@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Improve checks and error messages of pgstat_register_kind()
pgstat_register_kind() did not validate that required callbacks are
set, which could lead to NULL pointer dereferences when trying to
register a stats kind. This adds a couple of checks:
- Fox fixed-sized kinds, init_shmem_cb, reset_all_cb, and snapshot_cb
are required.
- For variable-sized kinds, flush_pending_cb is called when there is
pending data, pending_size being required.
These issues should be easy to notice for someone developing an
extension that relies on the custom pgstats APIs. No backpatch is done
as it is mainly a life improvement.
Author: Sami Imseih <samimseih(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAA5RZ0uNoe=xT7QsU1K0mMRg-QAwPtupPWZ2J3weM2PjVL2tiA@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/a924407ce0264ccb8fcea0de9c6f0573d24b57a7
Modified Files
--------------
src/backend/utils/activity/pgstat.c | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-07-06 02:38:34 | pgsql: Emit a warning when io_min_workers exceeds io_max_workers |
| Previous Message | Fujii Masao | 2026-07-06 00:49:11 | pgsql: Restore basebackup_progress_done() to preserve ABI |