Subject: pgsql: Fix pg_stat_get_backend_wait_event() for aux processes

From: Heikki Linnakangas <[email-masked]>
Date: Wed, 11 Feb 2026 17:00:27 +0000

Fix pg_stat_get_backend_wait_event() for aux processes

The pg_stat_activity view shows information for aux processes, but the
pg_stat_get_backend_wait_event() and
pg_stat_get_backend_wait_event_type() functions did not. To fix, call
AuxiliaryPidGetProc(pid) if BackendPidGetProc(pid) returns NULL, like
we do in pg_stat_get_activity().

In version 17 and above, it's a little silly to use those functions
when we already have the ProcNumber at hand, but it was necessary
before v17 because the backend ID was different from ProcNumber. I
have other plans for wait_event_info on master, so it doesn't seem
worth applying a different fix on different versions now.

Reviewed-by: Sami Imseih <[email-masked]>
Reviewed-by: Chao Li <[email-masked]>
Reviewed-by: Kyotaro Horiguchi <[email-masked]>
Discussion: https://www.postgresql.org/message-id/[email-masked]
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/82b495cdd7ec1e7bfcfa497ce2138d3ce5a8fa43

Modified Files
--------------
src/backend/utils/adt/pgstatfuncs.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)