Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tgSgy-00AtM7-8t for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Feb 2025 18:03:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tgSgx-003wmi-5u for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Feb 2025 18:03:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tgSgw-003wmE-Ss for pgsql-hackers@lists.postgresql.org; Fri, 07 Feb 2025 18:03:02 +0000 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tgSgu-004PJc-0d; Fri, 07 Feb 2025 18:03:02 +0000 Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-3d1469adf26so1747015ab.0; Fri, 07 Feb 2025 10:03:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738951379; x=1739556179; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ivviozNyQCRzHQ2/534iq9X1eL5keTNPyAgSV7jH0+g=; b=hzgUeGfeNLKVBmPwys+s79w18+wIp9Jx4NBWHWBHupKMazHcu4bVd40OlFUKovdqr6 SqD15c65gpQ8iu4W3CBfk0EHd7SRJ2LPtfFUprBBsMCOCknrBkcGkezanV2+oX36YEWv SgXSrxkbGH/1yVFrrG94HzGxuSp5A+3wxM2u+wJbFTAoYWKiCfwFRu+zcBjepspdg5nt cPlXqvQbtLSGbackNxrPA7PCwJX8CDIpnceMtif5OGvQqVtVKy4SXDWgAImAauhosovO NoCBab/1kwP2KVRSZM3Zj30sXfMSv43hu0uaeJnhyvhbK/NurybFb8RqQZ4DHSFLQRke 0dpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738951379; x=1739556179; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ivviozNyQCRzHQ2/534iq9X1eL5keTNPyAgSV7jH0+g=; b=PQ/YlTMxaqO3B88WrS+ZJp6ley0XdpRnS/RdXXQj0VNHPXL3rMqCF5onf8yWxhWEQ/ iRdHcUHtq4UrX9yif4d6gxysnxBNAGzswobnrguIhY4zrHmW/Zx8YBqxwd6wCgvw2z0F edOfiGdxm/DfPVvWBur80jUiV26rPl/Z6/bYGZZMDoh4Q0iq/g2in4FTU8Cg1CJ+vxJr G3sJMFD+rX9Nz0Fv5pxmM3tmpsD8uyS8xtT005t8XLNnWYNknSKnPq5Il6hxopJDkGmQ NfnaN0JIvMaRfh6MHKU10Jk+RPZhjxnHaDSGuqrY7WFQYEBG1qV17AT9ixXL7DNXOdpM n1PQ== X-Forwarded-Encrypted: i=1; AJvYcCVDgd164tXZZAnBQsaYD30qeujwzuDs0KtAQaoFcClVovXcowVlCK9jAHQ7Y/R25OP35QSQ9g==@postgresql.org, AJvYcCX0/8KCdaKcCcN0PpE2pMR9ghqY6V6Zi958+1bhUYS+ElmfZTNdxeQOkMgMgC9bf9ZEBq+6Xb/Vtzd2wX8m3w==@postgresql.org X-Gm-Message-State: AOJu0YwOkH/hYCb33+b0i2zIJrg5/2GrTIW9JjN5waxCvjEAhBuOZyQ6 5XivNBo3O+3o4u8nsS18CU3RqUp5Z3jhiMbeAZyoIhFBJJJBhooW X-Gm-Gg: ASbGncvYiT+EgRAnnUYVMYve0GvKjXttLcvEtV6DB87DydhRwCf/pKWu6bvHgllb/Qu VIg28ZpqBToECNSUjg7QjvoWZfzjTE6+t9lRbNLuEi+V71LKFUKxRXO3epYKhna3GPKb8vsP3U8 jtvPL+P6/fWSMqDDBMVKfW7BBZZaYNTeyCqbRz35BZmMrC2ikWn8Gj9bBerFUU5PNUo00rngrT1 Xxa3BlJzEvs0m6JBtKiMuPYYo+t13sc3w6GxvBVu/DPayuQtmP0nUu08+BwkOtJvdhLP2iixHqb GqEoUpKESN6H5Db0zitV3nCkth03AaVrBQyijGV8DOQ5/tQZbxRnDP/5C8cdCGbgoiN9H0QeWqt dmh0Rpg== X-Google-Smtp-Source: AGHT+IFt1MpQrbqZx43FMmCACLrh4ZWcKRMb++01nZ8aAma77UAKazWuOB71Zao6JX3TQN2D0yNf1A== X-Received: by 2002:a05:6e02:1a41:b0:3cf:bac5:d90c with SMTP id e9e14a558f8ab-3d13defdaebmr32046785ab.18.1738951378693; Fri, 07 Feb 2025 10:02:58 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4ecde17f8cesm299863173.14.2025.02.07.10.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 10:02:58 -0800 (PST) Date: Fri, 7 Feb 2025 12:02:56 -0600 From: Nathan Bossart To: Tom Lane Cc: Andres Freund , Fujii Masao , Tatsuo Ishii , pgsql-release@lists.postgresql.org, pgsql-hackers@postgresql.org Subject: Re: Fix for Extra Parenthesis in pgbench progress message Message-ID: References: <85fe426d-248a-47f7-8784-22af811ee572@oss.nttdata.com> <20241108.114713.484828673471024549.ishii@postgresql.org> <95f1100e-e59b-41b7-a406-f865c2e69db7@oss.nttdata.com> <20241125.083155.1820744655877715597.ishii@postgresql.org> <4k4drkh7bcmdezq6zbkhp25mnrzpswqi2o75d5uv2eeg3aq6q7@b7kqdmzzwzgb> <1456496.1738951118@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1456496.1738951118@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Feb 07, 2025 at 12:58:38PM -0500, Tom Lane wrote: > Let me have a go at fixing it, and if it turns out to be harder > than I think, I'll revert it instead. Oops, I was already taking a look at this. I figured it'd just be something like the following, although maybe there's a more elegant way. diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 40592e62606..b73921c36e3 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -4990,6 +4990,7 @@ initPopulateTable(PGconn *con, const char *table, int64 base, for (k = 0; k < total; k++) { int64 j = k + 1; + bool printed = false; init_row(&sql, k); if (PQputline(con, sql.data)) @@ -5011,6 +5012,7 @@ initPopulateTable(PGconn *con, const char *table, int64 base, j, total, (int) ((j * 100) / total), table, elapsed_sec, remaining_sec); + printed = true; } /* let's not call the timing for each row, but only each 100 rows */ else if (use_quiet && (j % 100 == 0)) @@ -5025,6 +5027,7 @@ initPopulateTable(PGconn *con, const char *table, int64 base, j, total, (int) ((j * 100) / total), table, elapsed_sec, remaining_sec); + printed = true; /* skip to the next interval */ log_interval = (int) ceil(elapsed_sec / LOG_STEP_SECONDS); @@ -5038,7 +5041,8 @@ initPopulateTable(PGconn *con, const char *table, int64 base, */ if (prev_chars > chars) fprintf(stderr, "%*c", prev_chars - chars, ' '); - fputc(eol, stderr); + if (printed) + fputc(eol, stderr); prev_chars = chars; } -- nathan