Skip to content

Commit e5cca62

Browse files
committed
Add support for pg_stat_reset_slru without argument
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 23c8c0c. Bump catalog version. Author: Bharath Rupireddy Reviewed-by: Atsushi Torikoshi Discussion: https://postgr.es/m/CALj2ACW1VizYg01EeH_cA-7qA+4NzWVAoZ5Lw9_XYO1RRHAZbA@mail.gmail.com
1 parent a70f2a5 commit e5cca62

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

doc/src/sgml/monitoring.sgml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4781,14 +4781,15 @@ description | Waiting for a newly initialized WAL file to reach durable storage
47814781
<indexterm>
47824782
<primary>pg_stat_reset_slru</primary>
47834783
</indexterm>
4784-
<function>pg_stat_reset_slru</function> ( <type>text</type> )
4784+
<function>pg_stat_reset_slru</function> ( [ <parameter>target</parameter> <type>text</type> <literal>DEFAULT</literal> <literal>NULL</literal> ] )
47854785
<returnvalue>void</returnvalue>
47864786
</para>
47874787
<para>
47884788
Resets statistics to zero for a single SLRU cache, or for all SLRUs in
4789-
the cluster. If the argument is NULL, all counters shown in
4789+
the cluster. If <parameter>target</parameter> is
4790+
<literal>NULL</literal> or is not specified, all the counters shown in
47904791
the <structname>pg_stat_slru</structname> view for all SLRU caches are
4791-
reset. The argument can be one of
4792+
reset. The argument can be one of
47924793
<literal>CommitTs</literal>,
47934794
<literal>MultiXactMember</literal>,
47944795
<literal>MultiXactOffset</literal>,

src/backend/catalog/system_functions.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,13 @@ LANGUAGE INTERNAL
628628
CALLED ON NULL INPUT VOLATILE PARALLEL SAFE
629629
AS 'pg_stat_reset_shared';
630630

631+
CREATE OR REPLACE FUNCTION
632+
pg_stat_reset_slru(target text DEFAULT NULL)
633+
RETURNS void
634+
LANGUAGE INTERNAL
635+
CALLED ON NULL INPUT VOLATILE PARALLEL SAFE
636+
AS 'pg_stat_reset_slru';
637+
631638
--
632639
-- The default permissions for functions mean that anyone can execute them.
633640
-- A number of functions shouldn't be executable by just anyone, but rather

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/* yyyymmddN */
60-
#define CATALOG_VERSION_NO 202311121
60+
#define CATALOG_VERSION_NO 202311141
6161

6262
#endif

src/include/catalog/pg_proc.dat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5897,7 +5897,8 @@
58975897
{ oid => '2307',
58985898
descr => 'statistics: reset collected statistics for a single SLRU',
58995899
proname => 'pg_stat_reset_slru', proisstrict => 'f', provolatile => 'v',
5900-
prorettype => 'void', proargtypes => 'text', prosrc => 'pg_stat_reset_slru' },
5900+
prorettype => 'void', proargtypes => 'text', proargnames => '{target}',
5901+
prosrc => 'pg_stat_reset_slru' },
59015902
{ oid => '6170',
59025903
descr => 'statistics: reset collected statistics for a single replication slot',
59035904
proname => 'pg_stat_reset_replication_slot', proisstrict => 'f',

src/test/regress/expected/stats.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru W
882882

883883
SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'CommitTs' \gset
884884
-- Test that multiple SLRUs are reset when no specific SLRU provided to reset function
885-
SELECT pg_stat_reset_slru(NULL);
885+
SELECT pg_stat_reset_slru();
886886
pg_stat_reset_slru
887887
--------------------
888888

src/test/regress/sql/stats.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru W
454454
SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'CommitTs' \gset
455455

456456
-- Test that multiple SLRUs are reset when no specific SLRU provided to reset function
457-
SELECT pg_stat_reset_slru(NULL);
457+
SELECT pg_stat_reset_slru();
458458
SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'CommitTs';
459459
SELECT stats_reset > :'slru_notify_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'Notify';
460460

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy