From 277279981fba7646d0f05a664d58b845d2fdf69d Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas <heikki.linnakangas@iki.fi> Date: Fri, 17 Jan 2014 10:10:43 +0200 Subject: [PATCH] Prevent integer overflow with --progress >= 2148 If --progress=2148 or higher was given, the calculation of the next time to report overflowed, and pgbench would print a progress report very frequently. Kingter Wang --- contrib/pgbench/pgbench.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 8f125830965..16b7ab5ddc7 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -2974,7 +2974,7 @@ threadRun(void *arg) /* for reporting progress: */ int64 thread_start = INSTR_TIME_GET_MICROSEC(thread->start_time); int64 last_report = thread_start; - int64 next_report = last_report + progress * 1000000; + int64 next_report = last_report + (int64) progress * 1000000; int64 last_count = 0, last_lats = 0, last_sqlats = 0, last_lags = 0; AggVals aggs; @@ -3210,7 +3210,7 @@ threadRun(void *arg) last_sqlats = sqlats; last_lags = lags; last_report = now; - next_report += progress * 1000000; + next_report += (int64) progress * 1000000; } } #else @@ -3261,7 +3261,7 @@ threadRun(void *arg) last_sqlats = sqlats; last_lags = lags; last_report = now; - next_report += progress * 1000000; + next_report += (int64) progress * 1000000; } } #endif /* PTHREAD_FORK_EMULATION */ -- GitLab