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 1og4Xh-0006Oa-0A for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Oct 2022 13:34:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1og4Xf-0001tM-T6 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Oct 2022 13:34:31 +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 1og4Xf-0001rG-JV for pgsql-hackers@lists.postgresql.org; Wed, 05 Oct 2022 13:34:31 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1og4XY-0008Gc-HE; Wed, 05 Oct 2022 13:34:30 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 0D8D632007CF; Wed, 5 Oct 2022 09:34:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 05 Oct 2022 09:34:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1664976859; x=1665063259; bh=3 IxKTMVl4x7z+jZ/eICQxAzr8aiPhBO+1b2WFiLarEk=; b=yR/S/4gZiWJ9p6Vce 4YrssPxC8zO7o+omW5UucnTGZiL8z/btNXiDgz0e7NAy5UK1PjDpRTUrDfLK9NMT GhgMYvbpKA66Gro4h9jdkT7IoEdbP2gyuMFwGpULQic24hrMVql8qjOPJDk7VBtZ ihKGhYeenIwN3ayjeQcZUXjOstlrIAAMM82uHezoYJrTwUPk5BDWH7IKaZ9QGIDw UZK434oysJfQITgZGOS/5ponFFjX7OqEloU2pucxsdWFgLHmGoWC+nVRcOqvX6UX ww8nklvUUqJ7mv7lqi89KT7jSK9VDPxj5lEFkY2CEOQ76E3OH9+92nv+74FyJrVV EYpuw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeeifedgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepkefghfdvleefvefgteffhfehgfetjedtiedvueelieeu gfejheegleeufffhffeunecuffhomhgrihhnpeguohhorhifrgihthhomhgvgihitghord gtohhmpdgvnhhtvghrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqih hprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 5 Oct 2022 09:34:18 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 3B14362; Wed, 5 Oct 2022 15:34:16 +0200 (CEST) Date: Wed, 5 Oct 2022 15:34:16 +0200 From: Alvaro Herrera To: David Rowley Cc: Justin Pryzby , pgsql-hackers@postgresql.org, Tomas Vondra , Peter Smith Subject: Re: shadow variables - pg15 edition Message-ID: <20221005133416.jdrlmn4b2qyorm24@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Oct-05, David Rowley wrote: > The only warning remaining after applying the attached is the "now" > warning in pgbench.c:7509. I'd considered changing this to "thenow" > which translates to "right now" in the part of Scotland that I'm from. > I also considered "nownow", which is used in South Africa [1]. > Anyway, I'm not really being serious, but I didn't come up with > anything better than "now2". It's just I didn't like that as it sort > of implies there are multiple definitions of "now" and I struggle with > that... maybe I'm just thinking too much in terms of Newtonian > Relativity... :-D A simpler idea might be to just remove the inner declaration, and have that block set the outer var. There's no damage, since the block is going to end and not access the previous value anymore. diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index aa1a3541fe..91a067859b 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -7506,7 +7506,7 @@ threadRun(void *arg) /* progress report is made by thread 0 for all threads */ if (progress && thread->tid == 0) { - pg_time_usec_t now = pg_time_now(); + now = pg_time_now(); /* not lazy; clobbers outer value */ if (now >= next_report) { The "now now" reference reminded me of "ahorita" https://doorwaytomexico.com/paulina/ahorita-meaning-examples/ which is source of misunderstandings across borders in South America ... -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "The important things in the world are problems with society that we don't understand at all. The machines will become more complicated but they won't be more complicated than the societies that run them." (Freeman Dyson)