diff options
author | Fujii Masao <fujii@postgresql.org> | 2025-09-25 12:09:32 +0900 |
---|---|---|
committer | Fujii Masao <fujii@postgresql.org> | 2025-09-25 12:09:32 +0900 |
commit | b6290ea48e1b8e868516d95cb86a0d3565d63847 (patch) | |
tree | 719ed45c8d4d4edaa754969972e1380dd491105c | |
parent | 879c492480d0e9ad8155c4269f95c5e8add41901 (diff) |
pgbench: Clarify documentation for \gset and \aset.
This commit updates the pgbench documentation to list \gset and \aset
as separate terms for easier reading. It also clarifies that \gset raises
an error if the query returns zero or multiple rows, and explains how to
detect cases where the query with \aset returned no rows.
Author: Yugo Nagata <nagata@sraoss.co.jp>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/20250626180125.5b896902a3d0bcd93f86c240@sraoss.co.jp
-rw-r--r-- | doc/src/sgml/ref/pgbench.sgml | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/doc/src/sgml/ref/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgml index ab252d9fc74..5ca9de63fa3 100644 --- a/doc/src/sgml/ref/pgbench.sgml +++ b/doc/src/sgml/ref/pgbench.sgml @@ -1188,10 +1188,8 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d <variablelist> <varlistentry id="pgbench-metacommand-gset"> - <term> - <literal>\gset [<replaceable>prefix</replaceable>]</literal> - <literal>\aset [<replaceable>prefix</replaceable>]</literal> - </term> + <term><literal>\gset [<replaceable>prefix</replaceable>]</literal></term> + <term><literal>\aset [<replaceable>prefix</replaceable>]</literal></term> <listitem> <para> @@ -1203,16 +1201,17 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d When the <literal>\gset</literal> command is used, the preceding SQL query is expected to return one row, the columns of which are stored into variables named after column names, and prefixed with <replaceable>prefix</replaceable> - if provided. + if provided. If the query returns zero or multiple rows, an error is raised. </para> <para> When the <literal>\aset</literal> command is used, all combined SQL queries (separated by <literal>\;</literal>) have their columns stored into variables named after column names, and prefixed with <replaceable>prefix</replaceable> - if provided. If a query returns no row, no assignment is made and the variable - can be tested for existence to detect this. If a query returns more than one - row, the last value is kept. + if provided. If a query returns no rows, no assignment is made. + This can be detected by initializing the variable beforehand with + a value the query cannot return, then checking whether it changes. + If a query returns more than one row, the last values is kept. </para> <para> |