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 1oOWQW-00017S-F4 for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Aug 2022 03:42:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oOWQV-00054c-1u for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Aug 2022 03:42:35 +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 1oOWQU-00054T-P4 for pgsql-hackers@lists.postgresql.org; Thu, 18 Aug 2022 03:42:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oOWQS-0003t8-Mh; Thu, 18 Aug 2022 03:42:33 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 27I3gRYv2230210; Wed, 17 Aug 2022 23:42:28 -0400 From: Tom Lane To: Michael Paquier cc: Peter Smith , Justin Pryzby , PostgreSQL-development , Tomas Vondra , David Rowley Subject: Re: shadow variables - pg15 edition In-reply-to: References: <20220817145434.GC26426@telsasoft.com> Comments: In-reply-to Michael Paquier message dated "Thu, 18 Aug 2022 09:39:02 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2230208.1660794147.1@sss.pgh.pa.us> Date: Wed, 17 Aug 2022 23:42:27 -0400 Message-ID: <2230209.1660794147@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > A lot of the changes proposed here update the code so as the same > variable gets used across more code paths by removing declarations, > but we have two variables defined because both are aimed to be used in > a different context (see AttachPartitionEnsureIndexes() in tablecmds.c > for example). > Wouldn't it be a saner approach in a lot of cases to rename the > shadowed variables (aka the ones getting removed in your patches) and > keep them local to the code paths where we use them? Yeah. I do not think a patch of this sort has any business changing the scopes of variables. That moves it out of "cosmetic cleanup" and into "hm, I wonder if this introduces any bugs". Most hackers are going to decide that they have better ways to spend their time than doing that level of analysis for a very noncritical patch. regards, tom lane