From fe83e60f10c9ecd0c988fe6cd7919db9811fdff0 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Mon, 4 May 2026 10:07:53 +0800
Subject: [PATCH v2] Adjust pg_stat_get_lock() row estimate and comments

pg_stat_get_lock() returns one row per lock type.  There are currently
12 lock types, but pg_proc.dat still estimates 10 rows, so EXPLAIN shows
a row estimate that does not match the actual result.

Adjust prorows to 12 to match the current number of lock types.

While here, also fix a couple of nearby comments in pgstat_lock.c.

Author: Chao Li <lic@highgo.com>
---
 src/backend/utils/activity/pgstat_lock.c | 4 ++--
 src/include/catalog/pg_proc.dat          | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/backend/utils/activity/pgstat_lock.c b/src/backend/utils/activity/pgstat_lock.c
index aec64f8fb4b..5cf95ef3539 100644
--- a/src/backend/utils/activity/pgstat_lock.c
+++ b/src/backend/utils/activity/pgstat_lock.c
@@ -31,7 +31,7 @@ pgstat_fetch_stat_lock(void)
 }
 
 /*
- * Simpler wrapper of pgstat_lock_flush_cb()
+ * Simple wrapper around pgstat_lock_flush_cb()
  */
 void
 pgstat_lock_flush(bool nowait)
@@ -44,7 +44,7 @@ pgstat_lock_flush(bool nowait)
  *
  * If no stats have been recorded, this function returns false.
  *
- * If nowait is true, this function returns true if the lock could not be
+ * If nowait is true, this function returns true if the stats lock could not be
  * acquired. Otherwise, return false.
  */
 bool
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index be157a5fbe9..138a63073c3 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -6062,7 +6062,7 @@
   prosrc => 'pg_stat_get_io' },
 
 { oid => '6509', descr => 'statistics: per lock type statistics',
-  proname => 'pg_stat_get_lock', prorows => '10', proretset => 't',
+  proname => 'pg_stat_get_lock', prorows => '12', proretset => 't',
   provolatile => 'v', proparallel => 'r', prorettype => 'record',
   proargtypes => '', proallargtypes => '{text,int8,int8,int8,timestamptz}',
   proargmodes => '{o,o,o,o,o}',
-- 
2.50.1 (Apple Git-155)

