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 1oQqvv-0000i9-E2 for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Aug 2022 14:00:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oQqvt-0004uA-HT for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Aug 2022 14:00:37 +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 1oQqvt-0004u1-5r for pgsql-hackers@lists.postgresql.org; Wed, 24 Aug 2022 14:00:37 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oQqvl-0000om-Ul for pgsql-hackers@postgresql.org; Wed, 24 Aug 2022 14:00:35 +0000 Received: by mail-qt1-x82f.google.com with SMTP id a4so12749486qto.10 for ; Wed, 24 Aug 2022 07:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc; bh=D4/37p0JueK0QSOHtEqH8Hc09PDSfy7CuNCkAfxtOdY=; b=fOf/dur1s/GVlI+FLd2kFWHvCHyJSy70CMTpERiS4WadJmkzNXMu7uA0BSgojq6EnN MF0XYfeAJMQbSgzjUqzGnPmhIIRBUpqrLBF1yajTeiVSZG5KansypaX9VG/p1r0MXE1y zgEJB3l3LwSflACydHrgmJ1ancVrCxcM21XA0rwXqfwdk7ZQ1ABDCtcreiqxGFTM9qPu XiMf7N1e6ptHT1coaJ3jGZipk4kT/gIzwu9WlL/2C8ztXP1Bn1p8nhjbNW1V39EpCPML D+JNS2iezV2Asl/KofwmXoDwE9+dZL3xAglZX9aqbRd8FjRIUOctq3G0lK7ReUnSzlcW ltYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=D4/37p0JueK0QSOHtEqH8Hc09PDSfy7CuNCkAfxtOdY=; b=udv/M851eJ0nbrYEHXXxMmrwYGR8ju3Ig2VuodAvKJXcC/IP6PPP0xokpfB09bRNuH O+E29cxW5pmdHJx0HLBSP4iZO6mWfomwgADbOhHtovrkEX/7YIoUmcOgxPZj01llGc7X kwOqxUtlovM3MfZNJF0bSH741wS0TMNwSjEvNQCKGzWY558aDg7R4wfZBu1uZXdHcJKT DRow68kEaw7MVyb5WbzOhIo1m7C55kRT0rWNM7J/yJAjqgKyGUju/Oxh+zzPRwJwa6z7 t5RqNWrXp6gN+x7hr9jt2Wovp3Dk/UPOBgvKdozHCzpAQG9sbu4NwycKvS6vBcLNQIzg j6Hw== X-Gm-Message-State: ACgBeo0EaMb0P9Z0RKFQIle07nYQo/UyId/bGfLOmv8rZK6GtS5EK0SN bj7cRlH3o0e3aZrZRWCE4AIu2w== X-Google-Smtp-Source: AA6agR4KDGO99zaiFVFWG1XyWLexUR+MK+oQ+gaEXNfnxDk12kiHDE8rLc1tZkRx819D6tj/gfBZ0Q== X-Received: by 2002:a05:622a:1c5:b0:343:6cfb:32b with SMTP id t5-20020a05622a01c500b003436cfb032bmr24061630qtw.31.1661349628839; Wed, 24 Aug 2022 07:00:28 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id c13-20020ac8054d000000b00343681ee2e2sm12524895qth.35.2022.08.24.07.00.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Aug 2022 07:00:28 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 95613800800; Wed, 24 Aug 2022 09:00:27 -0500 (CDT) Date: Wed, 24 Aug 2022 09:00:27 -0500 From: Justin Pryzby To: David Rowley Cc: pgsql-hackers@postgresql.org, Tomas Vondra , Peter Smith , Alvaro Herrera Subject: Re: shadow variables - pg15 edition Message-ID: <20220824140027.GN2342@telsasoft.com> References: <20220818232141.GQ26426@telsasoft.com> <20220819042816.GU26426@telsasoft.com> <20220823011659.GF2342@telsasoft.com> <20220823021412.GG2342@telsasoft.com> <20220824023944.GM2342@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Aug 24, 2022 at 10:47:31PM +1200, David Rowley wrote: > I was hoping we'd already caught all of the #1s in 421892a19, but I > caught a few of those in some of your other patches. One you'd done > another way and some you'd done the rescope but just put it in the > wrong patch. The others had not been done yet. I just pushed > f959bf9a5 to fix those ones. This fixed pg_get_statisticsobj_worker() but not pg_get_indexdef_worker() nor pg_get_partkeydef_worker(). (Also, I'd mentioned that my fixes for those deliberately re-used the outer-scope vars, which isn't what you did, and it's why I didn't include them with the patch for inner-scope). > I really think #2s should be done last. I'm not as comfortable with > the renaming and we might want to discuss tactics on that. We could > either opt to rename the shadowed or shadowing variable, or both. If > we rename the shadowing variable, then pending patches or forward > patches could use the wrong variable. If we rename the shadowed > variable then it's not impossible that backpatching could go wrong > where the new code intends to reference the outer variable using the > newly named variable, but when that's backpatched it uses the variable > with the same name in the inner scope. Renaming both would make the > problem more obvious. I'm not sure which is best. The answer may > depend on how many lines the variable is in scope for. If it's just > for a few lines then the hunk context would conflict and the committer > would likely notice the issue when resolving the conflict. Yes, the hope is to limit the change to variables that are only used a couple times within a few lines. It's also possible that these will break patches in development, but that's normal for any change at all. > I'll study #7 a bit more. My eyes glazed over a bit from doing all > that analysis, so I might be mistaken about that being a bug. I reported this last week. https://www.postgresql.org/message-id/20220819211824.GX26426@telsasoft.com -- Justin