aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2013-12-12 19:01:01 +0900
committerTatsuo Ishii <ishii@postgresql.org>2013-12-12 19:10:35 +0900
commit841a65482d6e198b71a0df987b8b9822608d5ef4 (patch)
tree2470e8add62a955dfab1f6e392b0759ddca9968d
parent108e3992cdae890c9b5b4778c3598fce35eea4ca (diff)
downloadpostgresql-841a65482d6e198b71a0df987b8b9822608d5ef4.tar.gz
postgresql-841a65482d6e198b71a0df987b8b9822608d5ef4.zip
Fix progress logging when scale factor is large.
Integer overflow showed minus percent and minus remaining time something like this. 239300000 of 3800000000 tuples (-48%) done (elapsed 226.86 s, remaining -696.10 s).
-rw-r--r--contrib/pgbench/pgbench.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index 2c96fae7824..2ae85a104b5 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -1720,11 +1720,11 @@ init(bool is_no_vacuum)
INSTR_TIME_SUBTRACT(diff, start);
elapsed_sec = INSTR_TIME_GET_DOUBLE(diff);
- remaining_sec = (scale * naccounts - j) * elapsed_sec / j;
+ remaining_sec = ((double) scale * naccounts - j) * elapsed_sec / j;
fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s).\n",
j, (int64) naccounts * scale,
- (int) (((int64) j * 100) / (naccounts * scale)),
+ (int) (((int64) j * 100) / (naccounts * (int64) scale)),
elapsed_sec, remaining_sec);
}
/* let's not call the timing for each row, but only each 100 rows */
@@ -1734,14 +1734,14 @@ init(bool is_no_vacuum)
INSTR_TIME_SUBTRACT(diff, start);
elapsed_sec = INSTR_TIME_GET_DOUBLE(diff);
- remaining_sec = (scale * naccounts - j) * elapsed_sec / j;
+ remaining_sec = ((double) scale * naccounts - j) * elapsed_sec / j;
/* have we reached the next interval (or end)? */
if ((j == scale * naccounts) || (elapsed_sec >= log_interval * LOG_STEP_SECONDS))
{
fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s).\n",
j, (int64) naccounts * scale,
- (int) (((int64) j * 100) / (naccounts * scale)), elapsed_sec, remaining_sec);
+ (int) (((int64) j * 100) / (naccounts * (int64) scale)), elapsed_sec, remaining_sec);
/* skip to the next interval */
log_interval = (int) ceil(elapsed_sec / LOG_STEP_SECONDS);