public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tatsuo Ishii <[email protected]>
To: [email protected]
Cc: [email protected]
Cc: [email protected]
Subject: Re: Fix for Extra Parenthesis in pgbench progress message
Date: Thu, 07 Nov 2024 10:41:43 +0900 (JST)
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
>> The patch works perfectly for the case that there is one extra brace
>> as shown in your example. However I think it will not work if there
>> are two or more extra braces.
>
> Are you suggesting adding more space characters before the carriage
> return
> in the progress reporting line, like this?
No. I thought about dynamically calculating spaces needed to be
printed something like attached patch.
> Since the line includes
> both
> elapsed and remaining times, its total length doesn’t change much.
Maybe. But I am also worried about the case when we would want to
change the log line format in the future. We might introduce this kind
of bug again. By dynamically calculating the number of necessary
spaces, we don't need to think about the concern.
Best reagards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
Attachments:
[text/x-patch] pgbench_extra_braces.patch (1.3K, ../[email protected]/2-pgbench_extra_braces.patch)
download | inline diff:
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index ba247f3f85..4c05076dff 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -4944,6 +4944,7 @@ initPopulateTable(PGconn *con, const char *table, int64 base,
int n;
int64 k;
int chars = 0;
+ int previous_chars = 0;
PGresult *res;
PQExpBufferData sql;
char copy_statement[256];
@@ -5004,10 +5005,18 @@ 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)",
j, total,
(int) ((j * 100) / total),
- table, elapsed_sec, remaining_sec, eol);
+ table, elapsed_sec, remaining_sec);
+ if (previous_chars != 0)
+ {
+ int n_spaces = chars - previous_chars;
+ fprintf(stderr, "%*s", n_spaces, "");
+ chars += n_spaces;
+ }
+ fprintf(stderr, "%c", eol);
+ previous_chars = chars;
}
/* let's not call the timing for each row, but only each 100 rows */
else if (use_quiet && (j % 100 == 0))
view thread (6+ messages) latest in thread
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: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Fix for Extra Parenthesis in pgbench progress message
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox