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
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);