diff options
| author | Robert Haas <rhaas@postgresql.org> | 2015-03-02 14:21:41 -0500 |
|---|---|---|
| committer | Robert Haas <rhaas@postgresql.org> | 2015-03-02 14:21:41 -0500 |
| commit | 878fdcb843e087cc1cdeadc987d6ef55202ddd04 (patch) | |
| tree | 46cea8fefefd5d302aef823683372f7cf6b0fd80 /doc/src | |
| parent | ebd092bc2a07787b31b249d62033b9c8140a5d85 (diff) | |
pgbench: Add a real expression syntax to \set
Previously, you could do \set variable operand1 operator operand2, but
nothing more complicated. Now, you can \set variable expression, which
makes it much simpler to do multi-step calculations here. This also
adds support for the modulo operator (%), with the same semantics as in
C.
Robert Haas and Fabien Coelho, reviewed by Álvaro Herrera and
Stephen Frost
Diffstat (limited to 'doc/src')
| -rw-r--r-- | doc/src/sgml/pgbench.sgml | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/doc/src/sgml/pgbench.sgml b/doc/src/sgml/pgbench.sgml index 7d203cda84c..16b82a3bbe0 100644 --- a/doc/src/sgml/pgbench.sgml +++ b/doc/src/sgml/pgbench.sgml @@ -751,22 +751,25 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</> <variablelist> <varlistentry> <term> - <literal>\set <replaceable>varname</> <replaceable>operand1</> [ <replaceable>operator</> <replaceable>operand2</> ]</literal> + <literal>\set <replaceable>varname</> <replaceable>expression</> </term> <listitem> <para> - Sets variable <replaceable>varname</> to a calculated integer value. - Each <replaceable>operand</> is either an integer constant or a - <literal>:</><replaceable>variablename</> reference to a variable - having an integer value. The <replaceable>operator</> can be - <literal>+</>, <literal>-</>, <literal>*</>, or <literal>/</>. + Sets variable <replaceable>varname</> to an integer value calculated + from <replaceable>expression</>. + The expression may contain integer constants such as <literal>5432</>, + references to variables <literal>:</><replaceable>variablename</>, + and expressions composed of unary (<literal>-</>) or binary operators + (<literal>+</>, <literal>-</>, <literal>*</>, <literal>/</>, <literal>%</>) + with their usual associativity, and parentheses. </para> <para> - Example: + Examples: <programlisting> \set ntellers 10 * :scale +\set aid (1021 * :aid) % (100000 * :scale) + 1 </programlisting></para> </listitem> </varlistentry> |
