Re: Define variables in the approprieate scope

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Antonin Houska <ah(at)cybertec(dot)at>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Define variables in the approprieate scope
Date: 2020-03-24 02:41:34
Message-ID: 15375.1585017694@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Michael Paquier <michael(at)paquier(dot)xyz> writes:
> On Mon, Mar 23, 2020 at 08:50:55PM -0400, Bruce Momjian wrote:
>> I am fine with either usage, frankly. I was just pointing out what
>> might be the benefit of the current coding.

> Personal opinion here. I tend to prefer putting variable declarations
> into the inner portions because it makes it easier to reason about the
> code, though I agree that this concept does not need to be applied all
> the time.

My vote is to not make this sort of change until there's another
reason to touch the code in question. All changes create hazards for
back-patching, and I don't think this change is worth it on its own.
But if there are going to be diffs in the immediate vicinity anyway,
then sure.

(I'm feeling a bit sensitized to this, perhaps, because of recent
unpleasant experience with back-patching b4570d33a. That didn't touch
very much code, and the functions in question seemed like fairly stagnant
backwaters of the code base, so it should not have been painful to
back-patch ... but it was, because of assorted often-cosmetic changes
in said code.)

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2020-03-24 03:04:56 Re: weird hash plan cost, starting with pg10
Previous Message Fujii Masao 2020-03-24 02:13:44 Re: Wait event that should be reported while waiting for WAL archiving to finish