Skip to content

Commit 03d51b7

Browse files
author
Amit Kapila
committed
Change the attribute name in pg_stat_replication_slots view.
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
1 parent 8e5793a commit 03d51b7

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

contrib/test_decoding/expected/stats.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ BEGIN
2121
ELSE (spill_txns > 0)
2222
END
2323
INTO updated
24-
FROM pg_stat_replication_slots WHERE name='regression_slot';
24+
FROM pg_stat_replication_slots WHERE slot_name='regression_slot';
2525

2626
exit WHEN updated;
2727

@@ -57,8 +57,8 @@ SELECT wait_for_decode_stats(false);
5757

5858
(1 row)
5959

60-
SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
61-
name | spill_txns | spill_count
60+
SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
61+
slot_name | spill_txns | spill_count
6262
-----------------+------------+-------------
6363
regression_slot | t | t
6464
(1 row)
@@ -76,8 +76,8 @@ SELECT wait_for_decode_stats(true);
7676

7777
(1 row)
7878

79-
SELECT name, spill_txns, spill_count FROM pg_stat_replication_slots;
80-
name | spill_txns | spill_count
79+
SELECT slot_name, spill_txns, spill_count FROM pg_stat_replication_slots;
80+
slot_name | spill_txns | spill_count
8181
-----------------+------------+-------------
8282
regression_slot | 0 | 0
8383
(1 row)
@@ -95,8 +95,8 @@ SELECT wait_for_decode_stats(false);
9595

9696
(1 row)
9797

98-
SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
99-
name | spill_txns | spill_count
98+
SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
99+
slot_name | spill_txns | spill_count
100100
-----------------+------------+-------------
101101
regression_slot | t | t
102102
(1 row)

contrib/test_decoding/sql/stats.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ BEGIN
1919
ELSE (spill_txns > 0)
2020
END
2121
INTO updated
22-
FROM pg_stat_replication_slots WHERE name='regression_slot';
22+
FROM pg_stat_replication_slots WHERE slot_name='regression_slot';
2323

2424
exit WHEN updated;
2525

@@ -47,17 +47,17 @@ SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL,
4747
-- exact stats count as that can vary if any background transaction (say by
4848
-- autovacuum) happens in parallel to the main transaction.
4949
SELECT wait_for_decode_stats(false);
50-
SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
50+
SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
5151

5252
-- reset the slot stats, and wait for stats collector to reset
5353
SELECT pg_stat_reset_replication_slot('regression_slot');
5454
SELECT wait_for_decode_stats(true);
55-
SELECT name, spill_txns, spill_count FROM pg_stat_replication_slots;
55+
SELECT slot_name, spill_txns, spill_count FROM pg_stat_replication_slots;
5656

5757
-- decode and check stats again.
5858
SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'skip-empty-xacts', '1');
5959
SELECT wait_for_decode_stats(false);
60-
SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
60+
SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
6161

6262
DROP FUNCTION wait_for_decode_stats(bool);
6363
DROP TABLE stats_test;

doc/src/sgml/monitoring.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2590,7 +2590,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
25902590
<tbody>
25912591
<row>
25922592
<entry role="catalog_table_entry"><para role="column_definition">
2593-
<structfield>name</structfield> <type>text</type>
2593+
<structfield>slot_name</structfield> <type>text</type>
25942594
</para>
25952595
<para>
25962596
A unique, cluster-wide identifier for the replication slot

src/backend/catalog/system_views.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ CREATE VIEW pg_stat_replication AS
798798

799799
CREATE VIEW pg_stat_replication_slots AS
800800
SELECT
801-
s.name,
801+
s.slot_name,
802802
s.spill_txns,
803803
s.spill_count,
804804
s.spill_bytes,

src/backend/utils/adt/pgstatfuncs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,7 +2153,7 @@ pg_stat_get_archiver(PG_FUNCTION_ARGS)
21532153
Datum
21542154
pg_stat_get_replication_slots(PG_FUNCTION_ARGS)
21552155
{
2156-
#define PG_STAT_GET_REPLICATION_SLOT_CLOS 5
2156+
#define PG_STAT_GET_REPLICATION_SLOT_COLS 5
21572157
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
21582158
TupleDesc tupdesc;
21592159
Tuplestorestate *tupstore;
@@ -2190,8 +2190,8 @@ pg_stat_get_replication_slots(PG_FUNCTION_ARGS)
21902190
slotstats = pgstat_fetch_replslot(&nstats);
21912191
for (i = 0; i < nstats; i++)
21922192
{
2193-
Datum values[PG_STAT_GET_REPLICATION_SLOT_CLOS];
2194-
bool nulls[PG_STAT_GET_REPLICATION_SLOT_CLOS];
2193+
Datum values[PG_STAT_GET_REPLICATION_SLOT_COLS];
2194+
bool nulls[PG_STAT_GET_REPLICATION_SLOT_COLS];
21952195
PgStat_ReplSlotStats *s = &(slotstats[i]);
21962196

21972197
MemSet(values, 0, sizeof(values));

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 202010081
56+
#define CATALOG_VERSION_NO 202010201
5757

5858
#endif

src/include/catalog/pg_proc.dat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5263,7 +5263,7 @@
52635263
prorettype => 'record', proargtypes => '',
52645264
proallargtypes => '{text,int8,int8,int8,timestamptz}',
52655265
proargmodes => '{o,o,o,o,o}',
5266-
proargnames => '{name,spill_txns,spill_count,spill_bytes,stats_reset}',
5266+
proargnames => '{slot_name,spill_txns,spill_count,spill_bytes,stats_reset}',
52675267
prosrc => 'pg_stat_get_replication_slots' },
52685268
{ oid => '6118', descr => 'statistics: information about subscription',
52695269
proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',

src/test/regress/expected/rules.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,12 +2018,12 @@ pg_stat_replication| SELECT s.pid,
20182018
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)
20192019
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)))
20202020
LEFT JOIN pg_authid u ON ((s.usesysid = u.oid)));
2021-
pg_stat_replication_slots| SELECT s.name,
2021+
pg_stat_replication_slots| SELECT s.slot_name,
20222022
s.spill_txns,
20232023
s.spill_count,
20242024
s.spill_bytes,
20252025
s.stats_reset
2026-
FROM pg_stat_get_replication_slots() s(name, spill_txns, spill_count, spill_bytes, stats_reset);
2026+
FROM pg_stat_get_replication_slots() s(slot_name, spill_txns, spill_count, spill_bytes, stats_reset);
20272027
pg_stat_slru| SELECT s.name,
20282028
s.blks_zeroed,
20292029
s.blks_hit,

0 commit comments

Comments
 (0)