mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Add worker type to pg_stat_subscription.
Thanks to commit 2a8b40e368, the logical replication worker type is
easily determined.  The worker type could already be deduced via
other columns such as leader_pid and relid, but that is unnecessary
complexity for users.
Bumps catversion.
Author: Peter Smith
Reviewed-by: Michael Paquier, Maxim Orlov, Amit Kapila
Discussion: https://postgr.es/m/CAHut%2BPtmbSMfErSk0S7xxVdZJ9XVE3xVLhqBTmT91kf57BeKDQ%40mail.gmail.com
			
			
This commit is contained in:
		@@ -949,6 +949,7 @@ CREATE VIEW pg_stat_subscription AS
 | 
			
		||||
    SELECT
 | 
			
		||||
            su.oid AS subid,
 | 
			
		||||
            su.subname,
 | 
			
		||||
            st.worker_type,
 | 
			
		||||
            st.pid,
 | 
			
		||||
            st.leader_pid,
 | 
			
		||||
            st.relid,
 | 
			
		||||
 
 | 
			
		||||
@@ -1278,7 +1278,7 @@ GetLeaderApplyWorkerPid(pid_t pid)
 | 
			
		||||
Datum
 | 
			
		||||
pg_stat_get_subscription(PG_FUNCTION_ARGS)
 | 
			
		||||
{
 | 
			
		||||
#define PG_STAT_GET_SUBSCRIPTION_COLS	9
 | 
			
		||||
#define PG_STAT_GET_SUBSCRIPTION_COLS	10
 | 
			
		||||
	Oid			subid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
 | 
			
		||||
	int			i;
 | 
			
		||||
	ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
 | 
			
		||||
@@ -1339,6 +1339,22 @@ pg_stat_get_subscription(PG_FUNCTION_ARGS)
 | 
			
		||||
		else
 | 
			
		||||
			values[8] = TimestampTzGetDatum(worker.reply_time);
 | 
			
		||||
 | 
			
		||||
		switch (worker.type)
 | 
			
		||||
		{
 | 
			
		||||
			case WORKERTYPE_APPLY:
 | 
			
		||||
				values[9] = CStringGetTextDatum("apply");
 | 
			
		||||
				break;
 | 
			
		||||
			case WORKERTYPE_PARALLEL_APPLY:
 | 
			
		||||
				values[9] = CStringGetTextDatum("parallel apply");
 | 
			
		||||
				break;
 | 
			
		||||
			case WORKERTYPE_TABLESYNC:
 | 
			
		||||
				values[9] = CStringGetTextDatum("table synchronization");
 | 
			
		||||
				break;
 | 
			
		||||
			case WORKERTYPE_UNKNOWN:
 | 
			
		||||
				/* Should never happen. */
 | 
			
		||||
				elog(ERROR, "unknown worker type");
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc,
 | 
			
		||||
							 values, nulls);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user