Add support for pg_stat_reset_slru without argument
authorMichael Paquier <[email protected]>
Tue, 14 Nov 2023 00:50:52 +0000 (09:50 +0900)
committerMichael Paquier <[email protected]>
Tue, 14 Nov 2023 00:50:52 +0000 (09:50 +0900)
pg_stat_reset_slru currently requires an input argument, either:
- NULL to reset the SLRU counters of everything.
- A specific value to reset a single SLRU cache.

This commit adds support for a new pattern: pg_stat_reset_slru without
any argument works the same way as pg_stat_reset_slru(NULL), relying on
a DEFAULT in the function definition to handle this case.  This makes
the function more consistent with 23c8c0c8f472.

Bump catalog version.

Author: Bharath Rupireddy
Reviewed-by: Atsushi Torikoshi
Discussion: https://postgr.es/m/CALj2ACW1VizYg01EeH_cA-7qA+4NzWVAoZ5Lw9_XYO1RRHAZbA@mail.gmail.com

doc/src/sgml/monitoring.sgml
src/backend/catalog/system_functions.sql
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/test/regress/expected/stats.out
src/test/regress/sql/stats.sql

index b8495b649891f95c5f35145505f5e8fabb1908c3..6b237d41cb42c227a689fd3e6848c02a34e61eb6 100644 (file)
@@ -4781,14 +4781,15 @@ description | Waiting for a newly initialized WAL file to reach durable storage
         <indexterm>
          <primary>pg_stat_reset_slru</primary>
         </indexterm>
-        <function>pg_stat_reset_slru</function> ( <type>text</type> )
+        <function>pg_stat_reset_slru</function> ( [ <parameter>target</parameter> <type>text</type> <literal>DEFAULT</literal> <literal>NULL</literal> ] )
         <returnvalue>void</returnvalue>
        </para>
        <para>
         Resets statistics to zero for a single SLRU cache, or for all SLRUs in
-        the cluster.  If the argument is NULL, all counters shown in
+        the cluster. If <parameter>target</parameter> is
+        <literal>NULL</literal> or is not specified, all the counters shown in
         the <structname>pg_stat_slru</structname> view for all SLRU caches are
-        reset.  The argument can be one of
+        reset. The argument can be one of
         <literal>CommitTs</literal>,
         <literal>MultiXactMember</literal>,
         <literal>MultiXactOffset</literal>,
index 8079f1cd7ff8270268fd360155bb0652eb879262..4206752881d8a84c6538c21e9c94bc95093fd4e6 100644 (file)
@@ -628,6 +628,13 @@ LANGUAGE INTERNAL
 CALLED ON NULL INPUT VOLATILE PARALLEL SAFE
 AS 'pg_stat_reset_shared';
 
+CREATE OR REPLACE FUNCTION
+  pg_stat_reset_slru(target text DEFAULT NULL)
+RETURNS void
+LANGUAGE INTERNAL
+CALLED ON NULL INPUT VOLATILE PARALLEL SAFE
+AS 'pg_stat_reset_slru';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
index ff1f392557874630d8d06af8e4f9afb6b95c55ba..f2af8eb0dc2345b9fecfb6966840c68f0c678be8 100644 (file)
@@ -57,6 +57,6 @@
  */
 
 /*                                                     yyyymmddN */
-#define CATALOG_VERSION_NO     202311121
+#define CATALOG_VERSION_NO     202311141
 
 #endif
index bd0b8873d358e8b46b5741a743d8f62df14c77a6..ee351bb76214a2aa57108a46e31e19ea2fb8eb57 100644 (file)
 { oid => '2307',
   descr => 'statistics: reset collected statistics for a single SLRU',
   proname => 'pg_stat_reset_slru', proisstrict => 'f', provolatile => 'v',
-  prorettype => 'void', proargtypes => 'text', prosrc => 'pg_stat_reset_slru' },
+  prorettype => 'void', proargtypes => 'text', proargnames => '{target}',
+  prosrc => 'pg_stat_reset_slru' },
 { oid => '6170',
   descr => 'statistics: reset collected statistics for a single replication slot',
   proname => 'pg_stat_reset_replication_slot', proisstrict => 'f',
index 0694de736a0d1cc2a4848ebe6b3c92e494706eba..6ed3584a763dc71ac29c498d4953f69e820ed041 100644 (file)
@@ -882,7 +882,7 @@ SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru W
 
 SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'CommitTs' \gset
 -- Test that multiple SLRUs are reset when no specific SLRU provided to reset function
-SELECT pg_stat_reset_slru(NULL);
+SELECT pg_stat_reset_slru();
  pg_stat_reset_slru 
 --------------------
  
index 13db45d4dc419d4ca873d641df24167e6ddbe04a..fd8afeeae510a95b4e91ef539021fe96c9f1914f 100644 (file)
@@ -454,7 +454,7 @@ SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru W
 SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'CommitTs' \gset
 
 -- Test that multiple SLRUs are reset when no specific SLRU provided to reset function
-SELECT pg_stat_reset_slru(NULL);
+SELECT pg_stat_reset_slru();
 SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'CommitTs';
 SELECT stats_reset > :'slru_notify_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'Notify';