pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@anarazel.de>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: Tatsuo Ishii <ishii@postgresql.org>
Cc: pgsql-release@lists.postgresql.org
Cc: pgsql-hackers@postgresql.org
Subject: Re: Fix for Extra Parenthesis in pgbench progress message
Date: Fri, 7 Feb 2025 12:02:56 -0600
Message-ID: <Z6ZK0LBTInOt7VWE@nathan> (raw)
In-Reply-To: <1456496.1738951118@sss.pgh.pa.us>
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>
	<ffc99be5-e418-40ee-91d6-62c3deb42918@oss.nttdata.com>
	<4k4drkh7bcmdezq6zbkhp25mnrzpswqi2o75d5uv2eeg3aq6q7@b7kqdmzzwzgb>
	<1456496.1738951118@sss.pgh.pa.us>

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.

inline patch 1: src/bin/pgbench/pgbench.c (+5/-1 lines) download inline-1.patchdiff --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

view thread (24+ messages)  latest in thread

Message-ID: <Z6ZK0LBTInOt7VWE@nathan>
Permalink:  ../Z6ZK0LBTInOt7VWE@nathan/
Also on:    postgresql.org/message-id/Z6ZK0LBTInOt7VWE@nathan

 ·  · 

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: nathandbossart@gmail.com, tgl@sss.pgh.pa.us, andres@anarazel.de, masao.fujii@oss.nttdata.com, ishii@postgresql.org, pgsql-release@lists.postgresql.org
  Subject: Re: Fix for Extra Parenthesis in pgbench progress message
  In-Reply-To: <Z6ZK0LBTInOt7VWE@nathan>

* 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