pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yushi Ogiwara <btogiwarayuushi@oss.nttdata.com>
To: Pgsql Hackers <pgsql-hackers@postgresql.org>
Subject: Fix for Extra Parenthesis in pgbench progress message
Date: Thu, 31 Oct 2024 14:18:09 +0900
Message-ID: <9a9b8b95b6a709877ae48ad5b0c59bb9@oss.nttdata.com> (raw)

Hi,

I noticed an issue in the pgbench progress message where an extra 
closing parenthesis )) appears, as shown below:

7000000 of 10000000 tuples (70%) of pgbench_accounts done (elapsed 19.75 
s, remaining 8.46 s))

This occurs when running commands like pgbench -i -s100 and is caused by 
leftover characters when using \r with fprintf. I made a patch to 
address this by adding extra spaces before \r, which clears any 
remaining characters. While effective, I recognize this solution may not 
be the most sophisticated.

A more refined solution, such as using string padding, might be ideal 
for cases like this.

Best,
Yushi Ogiwara

Attachments:

fix_leftover_character.diff (text/x-diff, 1.3K) download diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index e658d060ad..be984e0c7f 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -5004,7 +5004,7 @@ initPopulateTable(PGconn *con, const char *table, int64 base, double elapsed_sec = PG_TIME_GET_DOUBLE(pg_time_now() - start); double remaining_sec = ((double) total - j) * elapsed_sec / j; - chars = fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) of %s done (elapsed %.2f s, remaining %.2f s)%c", + chars = fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) of %s done (elapsed %.2f s, remaining %.2f s) %c", j, total, (int) ((j * 100) / total), table, elapsed_sec, remaining_sec, eol); @@ -5018,7 +5018,7 @@ initPopulateTable(PGconn *con, const char *table, int64 base, /* have we reached the next interval (or end)? */ if ((j == total) || (elapsed_sec >= log_interval * LOG_STEP_SECONDS)) { - chars = fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) of %s done (elapsed %.2f s, remaining %.2f s)%c", + chars = fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) of %s done (elapsed %.2f s, remaining %.2f s) %c", j, total, (int) ((j * 100) / total), table, elapsed_sec, remaining_sec, eol);

view thread (24+ messages)  latest in thread

Message-ID: <9a9b8b95b6a709877ae48ad5b0c59bb9@oss.nttdata.com>
Permalink:  ../9a9b8b95b6a709877ae48ad5b0c59bb9@oss.nttdata.com/
Also on:    postgresql.org/message-id/9a9b8b95b6a709877ae48ad5b0c59bb9@oss.nttdata.com

 ·  · 

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: btogiwarayuushi@oss.nttdata.com
  Subject: Re: Fix for Extra Parenthesis in pgbench progress message
  In-Reply-To: <9a9b8b95b6a709877ae48ad5b0c59bb9@oss.nttdata.com>

* 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