Re: add validations for required callbacks during pgstat_register_kind()

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: add validations for required callbacks during pgstat_register_kind()
Date: 2026-07-06 01:54:47
Message-ID: aksK5z3jYIdImtoD@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 03, 2026 at 11:04:56AM -0500, Sami Imseih wrote:
> v2-0002 also makes the errmsg consistent and includes kind names
> (except for when a name is not provided)
> and kind IDs across all the messages.

Thanks. Merged 0001 and 0002 together, tweaked two small things
(s_p_l replaced by a %s, and an underscore removed), and applied the
result on HEAD. Consistency is nice.

> hmm, I think it's better to have a clear assertion log ( when built
> with asserts ),
> than a segfault. Also, it's self-documenting. It is also consistent with
> snapshot_cb. I think we should keep it, but I separated that into a v2-0003,
> Perhaps you will change your mind.

The locations of snapshot_cb are a bit smarter than this proposal:
- The assertion at the beginning of snapshot_fixed() is
unconditionally taken and makes sure that the callback is set.
- The assertion in pgstat_build_snapshot() make sure that no callback
is set if we have a non-fixed kind.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-07-06 02:41:06 Re: [PATCH] Warn when io_min_workers exceeds io_max_workers
Previous Message Noah Misch 2026-07-06 01:26:42 wait_event_type for WAIT FOR LSN