summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2016-03-01 13:04:09 -0500
committerRobert Haas <rhaas@postgresql.org>2016-03-01 13:08:30 -0500
commit7e137f846df2431ce9c61202dcea21ee4a6d7822 (patch)
treedc4119bd7990deb5142971d5918885acc35859a4 /doc/src
parentbd6cf3f237c9aeb4dad1ac3ec2008c5768fe4c1b (diff)
Extend pgbench's expression syntax to support a few built-in functions.
Fabien Coelho, reviewed mostly by Michael Paquier and me, but also by Heikki Linnakangas, BeomYong Lee, Kyotaro Horiguchi, Oleksander Shulgin, and Álvaro Herrera.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/ref/pgbench.sgml64
1 files changed, 61 insertions, 3 deletions
diff --git a/doc/src/sgml/ref/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgml
index ade1b530d26..f39f341a269 100644
--- a/doc/src/sgml/ref/pgbench.sgml
+++ b/doc/src/sgml/ref/pgbench.sgml
@@ -786,7 +786,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
</para>
<variablelist>
- <varlistentry>
+ <varlistentry id='pgbench-metacommand-set'>
<term>
<literal>\set <replaceable>varname</> <replaceable>expression</></literal>
</term>
@@ -798,8 +798,10 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
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.
+ (<literal>+</>, <literal>-</>, <literal>*</>, <literal>/</>,
+ <literal>%</>) with their usual associativity,
+ <link linkend="pgbench-builtin-functions">function calls</>, and
+ parentheses.
</para>
<para>
@@ -994,6 +996,62 @@ END;
</refsect2>
+ <refsect2 id="pgbench-builtin-functions">
+ <title>Built-In Functions</title>
+
+ <para>
+ The following functions are built into <application>pgbench</> and
+ may be used in conjunction with
+ <link linkend="pgbench-metacommand-set"><literal>\set</literal></link>.
+ </para>
+
+ <!-- list pgbench functions in alphabetical order -->
+ <table>
+ <title>pgbench Functions</title>
+ <tgroup cols="5">
+ <thead>
+ <row>
+ <entry>Function</entry>
+ <entry>Return Type</entry>
+ <entry>Description</entry>
+ <entry>Example</entry>
+ <entry>Result</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal><function>abs(<replaceable>a</>)</></></>
+ <entry>same as <replaceable>a</></>
+ <entry>integer value</>
+ <entry><literal>abs(-17)</></>
+ <entry><literal>17</></>
+ </row>
+ <row>
+ <entry><literal><function>debug(<replaceable>a</>)</></></>
+ <entry>same as <replaceable>a</> </>
+ <entry>print to <systemitem>stderr</systemitem> the given argument</>
+ <entry><literal>debug(5432)</></>
+ <entry><literal>5432</></>
+ </row>
+ <row>
+ <entry><literal><function>max(<replaceable>i</> [, <replaceable>...</> ] )</></></>
+ <entry>integer</>
+ <entry>maximum value</>
+ <entry><literal>max(5, 4, 3, 2)</></>
+ <entry><literal>5</></>
+ </row>
+ <row>
+ <entry><literal><function>min(<replaceable>i</> [, <replaceable>...</> ] )</></></>
+ <entry>integer</>
+ <entry>minimum value</>
+ <entry><literal>min(5, 4, 3, 2)</></>
+ <entry><literal>2</></>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </refsect2>
+
<refsect2>
<title>Per-Transaction Logging</title>