Fix for Extra Parenthesis in pgbench progress message

Yushi Ogiwara <btogiwarayuushi@oss.nttdata.com>

From: Yushi Ogiwara <btogiwarayuushi@oss.nttdata.com>
To: Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2024-10-31T05:18:09Z
Lists: pgsql-hackers

Attachments

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

Commits

  1. Fix pgbench performance issue induced by commit af35fe501.

  2. pgbench: Ensure previous progress message is fully cleared when updating.