Skip to content

Commit 2772799

Browse files
committed
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
1 parent d8a0b96 commit 2772799

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

contrib/pgbench/pgbench.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2974,7 +2974,7 @@ threadRun(void *arg)
29742974
/* for reporting progress: */
29752975
int64 thread_start = INSTR_TIME_GET_MICROSEC(thread->start_time);
29762976
int64 last_report = thread_start;
2977-
int64 next_report = last_report + progress * 1000000;
2977+
int64 next_report = last_report + (int64) progress * 1000000;
29782978
int64 last_count = 0, last_lats = 0, last_sqlats = 0, last_lags = 0;
29792979

29802980
AggVals aggs;
@@ -3210,7 +3210,7 @@ threadRun(void *arg)
32103210
last_sqlats = sqlats;
32113211
last_lags = lags;
32123212
last_report = now;
3213-
next_report += progress * 1000000;
3213+
next_report += (int64) progress * 1000000;
32143214
}
32153215
}
32163216
#else
@@ -3261,7 +3261,7 @@ threadRun(void *arg)
32613261
last_sqlats = sqlats;
32623262
last_lags = lags;
32633263
last_report = now;
3264-
next_report += progress * 1000000;
3264+
next_report += (int64) progress * 1000000;
32653265
}
32663266
}
32673267
#endif /* PTHREAD_FORK_EMULATION */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy