From 878fdcb843e087cc1cdeadc987d6ef55202ddd04 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Mon, 2 Mar 2015 14:21:41 -0500 Subject: pgbench: Add a real expression syntax to \set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- doc/src/sgml/pgbench.sgml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'doc/src') 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 options dbname - \set varname operand1 [ operator operand2 ] + \set varname expression - Sets variable varname to a calculated integer value. - Each operand is either an integer constant or a - :variablename reference to a variable - having an integer value. The operator can be - +, -, *, or /. + Sets variable varname to an integer value calculated + from expression. + The expression may contain integer constants such as 5432, + references to variables :variablename, + and expressions composed of unary (-) or binary operators + (+, -, *, /, %) + with their usual associativity, and parentheses. - Example: + Examples: \set ntellers 10 * :scale +\set aid (1021 * :aid) % (100000 * :scale) + 1 -- cgit v1.2.3