diff --git a/doc/src/sgml/ref/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgml
index c6d1454..e31d5ee 100644
--- a/doc/src/sgml/ref/pgbench.sgml
+++ b/doc/src/sgml/ref/pgbench.sgml
@@ -698,6 +698,7 @@ pgbench options> dbname>
Each script may be given a relative weight specified after a
@> so as to change its drawing probability.
The default weight is 1>.
+ Weight 0> scripts are ignored.
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 4196b0e..0c1a0ee 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -2953,10 +2953,10 @@ parseScriptWeight(const char *option, char **script)
fprintf(stderr, "invalid weight specification: %s\n", sep);
exit(1);
}
- if (wtmp > INT_MAX || wtmp <= 0)
+ if (wtmp > INT_MAX || wtmp < 0)
{
fprintf(stderr,
- "weight specification out of range (1 .. %u): " INT64_FORMAT "\n",
+ "weight specification out of range (0 .. %u): " INT64_FORMAT "\n",
INT_MAX, (int64) wtmp);
exit(1);
}
@@ -2987,6 +2987,13 @@ addScript(ParsedScript script)
exit(1);
}
+ if (script.weight == 0)
+ {
+ fprintf(stderr,
+ "warning, script \"%s\" (%d) weight is zero, will be ignored\n",
+ script.desc, num_scripts);
+ }
+
sql_script[num_scripts] = script;
num_scripts++;
}
@@ -3527,6 +3534,12 @@ main(int argc, char **argv)
/* cannot overflow: weight is 32b, total_weight 64b */
total_weight += sql_script[i].weight;
+ if (total_weight == 0)
+ {
+ fprintf(stderr, "total weight for scripts (-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;