Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIfhC-0006aO-PW for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Sep 2020 22:14:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kIfhB-0002vs-HC for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Sep 2020 22:14:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIfhB-0002vl-4o for pgsql-hackers@lists.postgresql.org; Wed, 16 Sep 2020 22:14:33 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kIfh4-0001us-B3 for pgsql-hackers@lists.postgresql.org; Wed, 16 Sep 2020 22:14:31 +0000 Received: by mail-qk1-x742.google.com with SMTP id o16so152776qkj.10 for ; Wed, 16 Sep 2020 15:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=LcBZp47Eq8QN+Ct+KsBxruHbILeOnlVo9m6dJKJSmJg=; b=TrDNKBK/F8Q0fVAGl7SM71te/mQo9wKT/KEfrayfNSFzxF5tragAlzpkRh7jHCrf3M yvrJ8XQn0EGxK5DJTHg4d5rd+WzwlA0V01dzJfud1XGnYeHS2O/LmYMf6yho9QgHWRKR tgAZdw5f1Iq90W6pt59MIcP0NLSwsjbLP5UovyO76IZD30IjeQytXXu8D7MzGRiWIDEh uJE7Dln/dmtB4rUPEqq56Kpd+cpHC3whwst2ap+WQ8NHcU4ZhwtLq6kEZ1+Zi0pFZZbd JT5artzoTo6hyB+TFJCk81YtX63xvvc/bmwhbcdPvj2fy9thUYexgI67GElZcLjUp+d6 fwqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=LcBZp47Eq8QN+Ct+KsBxruHbILeOnlVo9m6dJKJSmJg=; b=FClkPOwoTX4pD01o9zV+4dqKRAz0k+LERDHN3FUoa7fEOJYGTCsC5u9NCLqHG8SMTV ciD3rDj4L3QHmg5jm4s4mKOwpHKOFp/6aJyBS/AcJsrx0RVMSFnEYvVOUjxINaPoc+8I 6GGYwYzGjt9FhLQcoX6ysVcoZbyxit8qxP6DIV6+vra39PHCZIrzPv7oD3qVr1PEff3I rlA66IlGTXRoKYwNLAmOeyFycJgxHLmPuFZQ/ZPJPKsCDp5AoTvYl57LNXOxF+uX9y1O Xgk1qq6ZATT15nYkkB5PE2UB++Mbridhgv2ApobYNY/zUyrJd9Q/gcmG2TOcBdkm+nUb BAkQ== X-Gm-Message-State: AOAM530f1YIrKUrxUZlMblz2gyDPF7WQveOa60YdMJ0+j3H0Yd4BUWOf jSq6YtFKjgPle7AcBLPUBgRKv57ENtAset08IA5XZMT0KNuoyawXre4B3amtTFqzFNPuzHX30vu GFGTWClDMvDaOKER8kh0msbcgw11Hqo39pKX/zvP52IqTBN2p/jlDE6exSzITKO/Op5coiOWc1D f5VrmHkZak4YxUXgd/ X-Google-Smtp-Source: ABdhPJxpuab2st1kJ42/0VYWLz4ohP6Ttnk5hZ2Z0HOzucnTrZ08RYY2IFrmkIjYOyY8/J+pzKwrjw== X-Received: by 2002:a37:a64a:: with SMTP id p71mr26002093qke.389.1600294465130; Wed, 16 Sep 2020 15:14:25 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id f3sm19549822qtg.71.2020.09.16.15.14.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 15:14:24 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id C5C0A2A1565; Wed, 16 Sep 2020 19:14:22 -0300 (-03) Date: Wed, 16 Sep 2020 19:14:22 -0300 From: Alvaro Herrera To: Tom Lane Cc: Michael Paquier , pgsql-hackers@lists.postgresql.org Subject: Re: Gripes about walsender command processing Message-ID: <20200916221422.GA24095@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1633417.1600274669@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Sep-16, Tom Lane wrote: > This looks moderately reasonable to me. However, with the process > title reporting I want to add, we're going to end up with a switch > that looks like > > case T_IdentifySystemCmd: > + set_ps_display("IDENTIFY_SYSTEM"); > IdentifySystem(); > + EndReplicationCommand("IDENTIFY_SYSTEM"); > break; > > case T_BaseBackupCmd: > + set_ps_display("BASE_BACKUP"); > PreventInTransactionBlock(true, "BASE_BACKUP"); > SendBaseBackup((BaseBackupCmd *) cmd_node); > + EndReplicationCommand("BASE_BACKUP"); > break; > > which is starting to look a bit repetitive and copy-pasteo-prone. Agreed. > I don't see an easy way to improve on it though. The only obvious > alternative would be to put another switch before the main one that > just fills a "const char *cmdtag" variable, but that seems ugly. The alternative of doing the assignment in each case of the same switch does not look too terrible: 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); break; -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services