pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: pgsql-hackers@postgresql.org, Tomas Vondra <tomas.vondra@postgresql.org>
Cc: Peter Smith <smithpb2250@gmail.com>
Subject: Re: shadow variables - pg15 edition
Date: Wed, 5 Oct 2022 15:34:16 +0200
Message-ID: <20221005133416.jdrlmn4b2qyorm24@alvherre.pgsql> (raw)
In-Reply-To: <CAApHDvqWGMdB_pATeUqE=JCtNqNxObPOJ00jFEa2_sZ20j_Wvg@mail.gmail.com>

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)





view thread (56+ messages)  latest in thread

Message-ID: <20221005133416.jdrlmn4b2qyorm24@alvherre.pgsql>
Permalink:  ../20221005133416.jdrlmn4b2qyorm24@alvherre.pgsql/
Also on:    postgresql.org/message-id/20221005133416.jdrlmn4b2qyorm24@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@alvh.no-ip.org, dgrowleyml@gmail.com, pryzby@telsasoft.com, tomas.vondra@postgresql.org, smithpb2250@gmail.com
  Subject: Re: shadow variables - pg15 edition
  In-Reply-To: <20221005133416.jdrlmn4b2qyorm24@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox