pgsql: Use pgstat_kind_infos to write fixed shared statistics

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use pgstat_kind_infos to write fixed shared statistics
Date: 2024-07-09 01:28:08
Message-ID: E1sQzeK-000vP2-23@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use pgstat_kind_infos to write fixed shared statistics

This is similar to 9004abf6206e, but this time for the write part of the
stats file. The code is changed so as, rather than referring to
individual members of PgStat_Snapshot in an order based on their
PgStat_Kind value, a loop based on pgstat_kind_infos is used to retrieve
the contents to write from the snapshot structure, for a size of
PgStat_KindInfo's shared_data_len.

This requires the addition to PgStat_KindInfo of an offset to track the
location of each fixed-numbered stats in PgStat_Snapshot. This change
is useful to make this area of the code more easily pluggable, and
reduces the knowledge of specific fixed-numbered kinds in pgstat.c.

Reviewed-by: Bertrand Drouvot
Discussion: https://postgr.es/m/Zot5bxoPYdS7yaoy@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b68b29bc8feca0eb340cb857ff1d28d4099c7878

Modified Files
--------------
src/backend/utils/activity/pgstat.c | 56 ++++++++++++-------------------------
src/include/utils/pgstat_internal.h | 6 ++++
2 files changed, 24 insertions(+), 38 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Amit Kapila 2024-07-09 03:45:49 pgsql: To improve the code, move the error check in logical_read_xlog_p
Previous Message David Rowley 2024-07-09 00:48:23 pgsql: Avoid JIT-related test instability in EXPLAIN ANALYZE