pgsql: Improve checks and error messages of pgstat_register_kind() - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Improve checks and error messages of pgstat_register_kind()
Date
Msg-id E1wgYTE-001WNL-2F@gemulon.postgresql.org
Whole thread
List 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@gmail.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(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix psql's pager selection for wrapped expanded output.
Next
From: Michael Paquier
Date:
Subject: pgsql: Emit a warning when io_min_workers exceeds io_max_workers