From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Jeff Janes <jeff.janes@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@postgresql.org>
Subject: Re: pgbench stats per script & other stuff
Date: Mon, 28 Mar 2016 09:32:59 +0200 (CEST)
Message-ID: <alpine.DEB.2.10.1603280920070.16239@sto> (raw)
In-Reply-To: <alpine.DEB.2.10.1603200725210.7678@sto>
References: <alpine.DEB.2.10.1507171544450.26125@sto>
<CAMkU=1wJapNYRPsieqxWEkgsTiFZguqxmjwv+1YT_dD5+G2R+A@mail.gmail.com>
<alpine.DEB.2.10.1603200725210.7678@sto>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
> - that it does work:-) I'm not sure what happens by the script selection
> process, it should be checked carefully because it was not designed
> with allowing a zero weight, and it may depend on its/their positions.
> It may already work, but it really needs checking.
Hmmm, it seems ok.
Attached is an updated patch, which:
> - I would suggest that a warning is shown when a weight is zero,
> something like "warning, script #%d weight is zero, will be ignored".
includes such a warning.
> - the documentation should be updated:-)
adds a line about 0 weight in the documentation.
--
Fabien.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackersAttachments:
[text/x-diff] pgbench-zero-weight-2.patch (1.8K, ../alpine.DEB.2.10.1603280920070.16239@sto/2-pgbench-zero-weight-2.patch)
download | inline diff:diff --git a/doc/src/sgml/ref/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgmlindex c6d1454..e31d5ee 100644--- a/doc/src/sgml/ref/pgbench.sgml+++ b/doc/src/sgml/ref/pgbench.sgml@@ -698,6 +698,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
Each script may be given a relative weight specified after a
<literal>@</> so as to change its drawing probability.
The default weight is <literal>1</>.
+ Weight <literal>0</> scripts are ignored.
</para>
<para>
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.cindex 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;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: coelho@cri.ensmp.fr, jeff.janes@gmail.com
Subject: Re: pgbench stats per script & other stuff
In-Reply-To: <alpine.DEB.2.10.1603280920070.16239@sto>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox