{
        case T_IdentifySystemCmd:
            cmdtag = "IDENTIFY_SYSTEM";
+           set_ps_display(cmdtag);
            IdentifySystem();
            EndReplicationCommand(cmdtag);
            break;
 
        case T_BaseBackupCmd:
            cmdtag = "BASE_BACKUP";
+           set_ps_display(cmdtag);
            PreventInTransactionBlock(true, cmdtag);
            SendBaseBackup((BaseBackupCmd *) cmd_node);
            EndReplicationCommand(cmdtag);
 
        case T_CreateReplicationSlotCmd:
            cmdtag = "CREATE_REPLICATION_SLOT";
+           set_ps_display(cmdtag);
            CreateReplicationSlot((CreateReplicationSlotCmd *) cmd_node);
            EndReplicationCommand(cmdtag);
            break;
 
        case T_DropReplicationSlotCmd:
            cmdtag = "DROP_REPLICATION_SLOT";
+           set_ps_display(cmdtag);
            DropReplicationSlot((DropReplicationSlotCmd *) cmd_node);
            EndReplicationCommand(cmdtag);
            break;
                StartReplicationCmd *cmd = (StartReplicationCmd *) cmd_node;
 
                cmdtag = "START_REPLICATION";
+               set_ps_display(cmdtag);
                PreventInTransactionBlock(true, cmdtag);
 
                if (cmd->kind == REPLICATION_KIND_PHYSICAL)
 
        case T_TimeLineHistoryCmd:
            cmdtag = "TIMELINE_HISTORY";
+           set_ps_display(cmdtag);
            PreventInTransactionBlock(true, cmdtag);
            SendTimeLineHistory((TimeLineHistoryCmd *) cmd_node);
            EndReplicationCommand(cmdtag);
                VariableShowStmt *n = (VariableShowStmt *) cmd_node;
 
                cmdtag = "SHOW";
+               set_ps_display(cmdtag);
 
                /* syscache access needs a transaction environment */
                StartTransactionCommand();
    MemoryContextSwitchTo(old_context);
    MemoryContextDelete(cmd_context);
 
-   /* Report to pgstat that this process is now idle */
-   pgstat_report_activity(STATE_IDLE, NULL);
+   /*
+    * We need not update ps display or pg_stat_activity, because PostgresMain
+    * will reset those to "idle".  But we must reset debug_query_string to
+    * ensure it doesn't become a dangling pointer.
+    */
    debug_query_string = NULL;
 
    return true;