From c81685d93b05ceea6da04bd1f93dbc661dbeb991 Mon Sep 17 00:00:00 2001 From: Osumi Takamichi Date: Thu, 18 Nov 2021 11:43:46 +0000 Subject: [PATCH v13 1/3] Rename existing columns of pg_stat_subscription_workers --- doc/src/sgml/monitoring.sgml | 24 ++++++++++++------------ src/backend/catalog/system_views.sql | 10 +++++----- src/backend/utils/adt/pgstatfuncs.c | 20 ++++++++++---------- src/include/catalog/pg_proc.dat | 2 +- src/test/regress/expected/rules.out | 12 ++++++------ src/test/subscription/t/026_error_report.pl | 8 ++++---- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index daf9fe8..5b10d18 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -3103,31 +3103,31 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i - relid oid + last_error_relid oid OID of the relation that the worker was processing when the - error occurred + last error occurred - command text + last_error_command text - Name of command being applied when the error occurred. This field - is always NULL if the error was reported during the initial data - copy. + Name of the last command being applied when the error occurred. + This field is always NULL if the error was reported during the + initial data copy. - xid xid + last_error_xid xid - Transaction ID of the publisher node being applied when the error + Transaction ID of the publisher node being applied when the last error occurred. This field is always NULL if the error was reported during the initial data copy. @@ -3135,19 +3135,19 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i - error_count uint8 + last_error_count uint8 - Number of consecutive times the error occurred + Number of consecutive times the last error occurred - error_message text + last_error_message text - The error message + The last error message diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index cb2f77c..ecf1a0b 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -1267,11 +1267,11 @@ CREATE VIEW pg_stat_subscription_workers AS w.subid, s.subname, w.subrelid, - w.relid, - w.command, - w.xid, - w.error_count, - w.error_message, + w.last_error_relid, + w.last_error_command, + w.last_error_xid, + w.last_error_count, + w.last_error_message, w.first_error_time, w.last_error_time FROM (SELECT diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index b19729d..a34c0b6 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -2441,15 +2441,15 @@ pg_stat_get_subscription_worker(PG_FUNCTION_ARGS) OIDOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 2, "subrelid", OIDOID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 3, "relid", + TupleDescInitEntry(tupdesc, (AttrNumber) 3, "last_error_relid", OIDOID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 4, "command", + TupleDescInitEntry(tupdesc, (AttrNumber) 4, "last_error_command", TEXTOID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 5, "xid", + TupleDescInitEntry(tupdesc, (AttrNumber) 5, "last_error_xid", XIDOID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 6, "error_count", + TupleDescInitEntry(tupdesc, (AttrNumber) 6, "last_error_count", INT8OID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 7, "error_message", + TupleDescInitEntry(tupdesc, (AttrNumber) 7, "last_error_message", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 8, "first_error_time", TIMESTAMPTZOID, -1, 0); @@ -2471,28 +2471,28 @@ pg_stat_get_subscription_worker(PG_FUNCTION_ARGS) else nulls[i++] = true; - /* relid */ + /* last_error_relid */ if (OidIsValid(wentry->relid)) values[i++] = ObjectIdGetDatum(wentry->relid); else nulls[i++] = true; - /* command */ + /* last_error_command */ if (wentry->command != 0) values[i++] = CStringGetTextDatum(logicalrep_message_type(wentry->command)); else nulls[i++] = true; - /* xid */ + /* last_error_xid */ if (TransactionIdIsValid(wentry->xid)) values[i++] = TransactionIdGetDatum(wentry->xid); else nulls[i++] = true; - /* error_count */ + /* last_error_count */ values[i++] = Int64GetDatum(wentry->error_count); - /* error_message */ + /* last_error_message */ values[i++] = CStringGetTextDatum(wentry->error_message); /* first_error_time */ diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 50e1c7b..25f685f 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -5391,7 +5391,7 @@ prorettype => 'record', proargtypes => 'oid oid', proallargtypes => '{oid,oid,oid,oid,oid,text,xid,int8,text,timestamptz,timestamptz}', proargmodes => '{i,i,o,o,o,o,o,o,o,o,o}', - proargnames => '{subid,subrelid,subid,subrelid,relid,command,xid,error_count,error_message,first_error_time,last_error_time}', + proargnames => '{subid,subrelid,subid,subrelid,last_error_relid,last_error_command,last_error_xid,last_error_count,last_error_message,first_error_time,last_error_time}', prosrc => 'pg_stat_get_subscription_worker' }, { oid => '6118', descr => 'statistics: information about subscription', proname => 'pg_stat_get_subscription', prorows => '10', proisstrict => 'f', diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index cb6da2c..d60c5a5 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -2097,11 +2097,11 @@ pg_stat_subscription| SELECT su.oid AS subid, pg_stat_subscription_workers| SELECT w.subid, s.subname, w.subrelid, - w.relid, - w.command, - w.xid, - w.error_count, - w.error_message, + w.last_error_relid, + w.last_error_command, + w.last_error_xid, + w.last_error_count, + w.last_error_message, w.first_error_time, w.last_error_time FROM ( SELECT pg_subscription.oid AS subid, @@ -2112,7 +2112,7 @@ pg_stat_subscription_workers| SELECT w.subid, pg_subscription_rel.srrelid AS relid FROM pg_subscription_rel WHERE (pg_subscription_rel.srsubstate <> 'r'::"char")) sr, - (LATERAL pg_stat_get_subscription_worker(sr.subid, sr.relid) w(subid, subrelid, relid, command, xid, error_count, error_message, first_error_time, last_error_time) + (LATERAL pg_stat_get_subscription_worker(sr.subid, sr.relid) w(subid, subrelid, last_error_relid, last_error_command, last_error_xid, last_error_count, last_error_message, first_error_time, last_error_time) JOIN pg_subscription s ON ((w.subid = s.oid))); pg_stat_sys_indexes| SELECT pg_stat_all_indexes.relid, pg_stat_all_indexes.indexrelid, diff --git a/src/test/subscription/t/026_error_report.pl b/src/test/subscription/t/026_error_report.pl index 1227654..ca30ab2 100644 --- a/src/test/subscription/t/026_error_report.pl +++ b/src/test/subscription/t/026_error_report.pl @@ -15,8 +15,8 @@ sub test_subscription_error my $check_sql = qq[ SELECT count(1) > 0 FROM pg_stat_subscription_workers -WHERE relid = '$relname'::regclass]; - $check_sql .= " AND xid = '$xid'::xid;" if $xid ne ''; +WHERE last_error_relid = '$relname'::regclass]; + $check_sql .= " AND last_error_xid = '$xid'::xid;" if $xid ne ''; # Wait for the error statistics to be updated. $node->poll_query_until( @@ -26,9 +26,9 @@ WHERE relid = '$relname'::regclass]; my $result = $node->safe_psql( 'postgres', qq[ -SELECT subname, command, relid::regclass, error_count > 0 +SELECT subname, last_error_command, last_error_relid::regclass, last_error_count > 0 FROM pg_stat_subscription_workers -WHERE relid = '$relname'::regclass; +WHERE last_error_relid = '$relname'::regclass; ]); is($result, $expected_error, $msg); } -- 2.2.0