pgsql: Refactor pg_stat_get_lock() to use a helper function

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Refactor pg_stat_get_lock() to use a helper function
Date: 2026-06-30 07:30:19
Message-ID: E1weSvD-000kgV-2B@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Refactor pg_stat_get_lock() to use a helper function

This commit extracts the tuple-building logic from pg_stat_get_lock()
into a new static helper pg_stat_lock_build_tuples(). This is in
preparation for a follow-up patch, to add support for backend-level lock
stats, which will reuse the same helper.

This change follows the pattern established by pg_stat_io_build_tuples()
for IO stats and pg_stat_wal_build_tuple() for WAL stats.

Author: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Reviewed-by: Tatsuya Kawata <kawatatatsuya0913(at)gmail(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Reviewed-by: Tristan Partin <tristan(at)partin(dot)io>
Reviewed-by: Rui Zhao <zhaorui126(at)gmail(dot)com>
Discussion: https://postgr.es/m/aiAzEY+cMQb/W8yu(at)bdtpg

Branch
------
master

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

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

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-06-30 08:07:25 pgsql: Add backend-level lock statistics
Previous Message Michael Paquier 2026-06-30 07:17:51 pgsql: Use placeholders and not GUC names in error message (autovacuum)