Change the attribute name in pg_stat_replication_slots view.
authorAmit Kapila <akapila@postgresql.org>
Tue, 20 Oct 2020 04:54:36 +0000 (10:24 +0530)
committerAmit Kapila <akapila@postgresql.org>
Tue, 20 Oct 2020 04:54:36 +0000 (10:24 +0530)
Change the attribute 'name' to 'slot_name' in pg_stat_replication_slots
view to make it clear and that way we will be consistent with the other
places like pg_stat_wal_receiver view where we display the same attribute.

In the passing, fix the typo in one of the macros in the related code.

Bump the catversion as we have modified the name in the catalog as well.

Reported-by: Noriyoshi Shinoda
Author: Noriyoshi Shinoda
Reviewed-by: Sawada Masahiko and Amit Kapila
Discussion: https://postgr.es/m/CA+fd4k5_pPAYRTDrO2PbtTOe0eHQpBvuqmCr8ic39uTNmR49Eg@mail.gmail.com

contrib/test_decoding/expected/stats.out
contrib/test_decoding/sql/stats.sql
doc/src/sgml/monitoring.sgml
src/backend/catalog/system_views.sql
src/backend/utils/adt/pgstatfuncs.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/test/regress/expected/rules.out

index bfffd1ac21dfcd0d36b072d6651584cb966bf2f5..dafca965201d0545ff3c4be97a5ebcd534e69b08 100644 (file)
@@ -21,7 +21,7 @@ BEGIN
                 ELSE (spill_txns > 0)
            END
     INTO updated
-    FROM pg_stat_replication_slots WHERE name='regression_slot';
+    FROM pg_stat_replication_slots WHERE slot_name='regression_slot';
 
     exit WHEN updated;
 
@@ -57,8 +57,8 @@ SELECT wait_for_decode_stats(false);
  
 (1 row)
 
-SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
-      name       | spill_txns | spill_count 
+SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
+    slot_name    | spill_txns | spill_count 
 -----------------+------------+-------------
  regression_slot | t          | t
 (1 row)
@@ -76,8 +76,8 @@ SELECT wait_for_decode_stats(true);
  
 (1 row)
 
-SELECT name, spill_txns, spill_count FROM pg_stat_replication_slots;
-      name       | spill_txns | spill_count 
+SELECT slot_name, spill_txns, spill_count FROM pg_stat_replication_slots;
+    slot_name    | spill_txns | spill_count 
 -----------------+------------+-------------
  regression_slot |          0 |           0
 (1 row)
@@ -95,8 +95,8 @@ SELECT wait_for_decode_stats(false);
  
 (1 row)
 
-SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
-      name       | spill_txns | spill_count 
+SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
+    slot_name    | spill_txns | spill_count 
 -----------------+------------+-------------
  regression_slot | t          | t
 (1 row)
index b95adb16fa715857e2e1ed1672359a25ae088705..182df84030d0db28fb3d646b28a37ff31fcf9d76 100644 (file)
@@ -19,7 +19,7 @@ BEGIN
                 ELSE (spill_txns > 0)
            END
     INTO updated
-    FROM pg_stat_replication_slots WHERE name='regression_slot';
+    FROM pg_stat_replication_slots WHERE slot_name='regression_slot';
 
     exit WHEN updated;
 
@@ -47,17 +47,17 @@ SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL,
 -- exact stats count as that can vary if any background transaction (say by
 -- autovacuum) happens in parallel to the main transaction.
 SELECT wait_for_decode_stats(false);
-SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
+SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
 
 -- reset the slot stats, and wait for stats collector to reset
 SELECT pg_stat_reset_replication_slot('regression_slot');
 SELECT wait_for_decode_stats(true);
-SELECT name, spill_txns, spill_count FROM pg_stat_replication_slots;
+SELECT slot_name, spill_txns, spill_count FROM pg_stat_replication_slots;
 
 -- decode and check stats again.
 SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'skip-empty-xacts', '1');
 SELECT wait_for_decode_stats(false);
-SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
+SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
 
 DROP FUNCTION wait_for_decode_stats(bool);
 DROP TABLE stats_test;
index 66566765f0c9117edb1b4ca9fe78d3785ba0de76..f5cf163c8c68f57a52fa883b1a1ba49dbfdc594f 100644 (file)
@@ -2590,7 +2590,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
     <tbody>
      <row>
       <entry role="catalog_table_entry"><para role="column_definition">
-        <structfield>name</structfield> <type>text</type>
+        <structfield>slot_name</structfield> <type>text</type>
        </para>
        <para>
         A unique, cluster-wide identifier for the replication slot
index c29390760fe4b90cae0f9b4ae8c46b9eeb866fd3..85cd147e21bbf9d40ab2eaeef951b0e9596b67a9 100644 (file)
@@ -798,7 +798,7 @@ CREATE VIEW pg_stat_replication AS
 
 CREATE VIEW pg_stat_replication_slots AS
     SELECT
-            s.name,
+            s.slot_name,
             s.spill_txns,
             s.spill_count,
             s.spill_bytes,
index 0d0d2e6d2bb2e42f66083e95a873ad53997f1269..472fa596e1f8ad3a69d11165168c81637b751f33 100644 (file)
@@ -2153,7 +2153,7 @@ pg_stat_get_archiver(PG_FUNCTION_ARGS)
 Datum
 pg_stat_get_replication_slots(PG_FUNCTION_ARGS)
 {
-#define PG_STAT_GET_REPLICATION_SLOT_CLOS 5
+#define PG_STAT_GET_REPLICATION_SLOT_COLS 5
    ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
    TupleDesc   tupdesc;
    Tuplestorestate *tupstore;
@@ -2190,8 +2190,8 @@ pg_stat_get_replication_slots(PG_FUNCTION_ARGS)
    slotstats = pgstat_fetch_replslot(&nstats);
    for (i = 0; i < nstats; i++)
    {
-       Datum       values[PG_STAT_GET_REPLICATION_SLOT_CLOS];
-       bool        nulls[PG_STAT_GET_REPLICATION_SLOT_CLOS];
+       Datum       values[PG_STAT_GET_REPLICATION_SLOT_COLS];
+       bool        nulls[PG_STAT_GET_REPLICATION_SLOT_COLS];
        PgStat_ReplSlotStats *s = &(slotstats[i]);
 
        MemSet(values, 0, sizeof(values));
index 584c61728439f953293369a1021dd14db061e104..f44a09b0c25157069b6f480d4c7505496582fb22 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 202010081
+#define CATALOG_VERSION_NO 202010201
 
 #endif
index 22340baf1c67db088e48c0998bac0347ea50e1ff..bbcac69d48f77373bd5193439a90784004981199 100644 (file)
   prorettype => 'record', proargtypes => '',
   proallargtypes => '{text,int8,int8,int8,timestamptz}',
   proargmodes => '{o,o,o,o,o}',
-  proargnames => '{name,spill_txns,spill_count,spill_bytes,stats_reset}',
+  proargnames => '{slot_name,spill_txns,spill_count,spill_bytes,stats_reset}',
   prosrc => 'pg_stat_get_replication_slots' },
 { oid => '6118', descr => 'statistics: information about subscription',
   proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',
index cf2a9b44082eaa1bab0a595f574681bf39273453..492cdcf74c36abf02b644f1b1501d765b206f3da 100644 (file)
@@ -2018,12 +2018,12 @@ pg_stat_replication| SELECT s.pid,
    FROM ((pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, sslcompression, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid)
      JOIN pg_stat_get_wal_senders() w(pid, state, sent_lsn, write_lsn, flush_lsn, replay_lsn, write_lag, flush_lag, replay_lag, sync_priority, sync_state, reply_time) ON ((s.pid = w.pid)))
      LEFT JOIN pg_authid u ON ((s.usesysid = u.oid)));
-pg_stat_replication_slots| SELECT s.name,
+pg_stat_replication_slots| SELECT s.slot_name,
     s.spill_txns,
     s.spill_count,
     s.spill_bytes,
     s.stats_reset
-   FROM pg_stat_get_replication_slots() s(name, spill_txns, spill_count, spill_bytes, stats_reset);
+   FROM pg_stat_get_replication_slots() s(slot_name, spill_txns, spill_count, spill_bytes, stats_reset);
 pg_stat_slru| SELECT s.name,
     s.blks_zeroed,
     s.blks_hit,