diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c new file mode 100644 index dab1ed4..e8c1906 *** a/src/bin/pgbench/pgbench.c --- b/src/bin/pgbench/pgbench.c *************** parseScriptWeight(const char *option, ch *** 2855,2864 **** fprintf(stderr, "invalid weight specification: %s\n", sep); exit(1); } ! if (wtmp > INT_MAX || wtmp <= 0) { fprintf(stderr, ! "weight specification out of range (1 .. %u): " INT64_FORMAT "\n", INT_MAX, (int64) wtmp); exit(1); } --- 2855,2864 ---- fprintf(stderr, "invalid weight specification: %s\n", sep); exit(1); } ! if (wtmp > INT_MAX || wtmp < 0) { fprintf(stderr, ! "weight specification out of range (0 .. %u): " INT64_FORMAT "\n", INT_MAX, (int64) wtmp); exit(1); } *************** main(int argc, char **argv) *** 3429,3434 **** --- 3429,3440 ---- /* cannot overflow: weight is 32b, total_weight 64b */ total_weight += sql_script[i].weight; + if (total_weight == 0) + { + fprintf(stderr, "The total of script weights (from -b and -f options) cannot be zero.\n"); + exit(1); + } + /* show per script stats if several scripts are used */ if (num_scripts > 1) per_script_stats = true;