1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

psql: add an optional execution-count limit to \watch.

\watch can now be told to stop after N executions of the query.

With the idea that we might want to add more options to \watch
in future, this patch generalizes the command's syntax to a list
of name=value options, with the interval allowed to omit the name
for backwards compatibility.

Andrey Borodin, reviewed by Kyotaro Horiguchi, Nathan Bossart,
Michael Paquier, Yugo Nagata, and myself

Discussion: https://postgr.es/m/CAAhFRxiZ2-n_L1ErMm9AZjgmUK=qS6VHb+0SaMn8sqqbhF7How@mail.gmail.com
This commit is contained in:
Tom Lane
2023-04-06 13:18:14 -04:00
parent 2820adf775
commit 00beecfe83
6 changed files with 135 additions and 32 deletions

View File

@ -3551,12 +3551,16 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
<varlistentry id="app-psql-meta-command-watch">
<term><literal>\watch [ <replaceable class="parameter">seconds</replaceable> ]</literal></term>
<term><literal>\watch [ i[nterval]=<replaceable class="parameter">seconds</replaceable> ] [ c[ount]=<replaceable class="parameter">times</replaceable> ] [ <replaceable class="parameter">seconds</replaceable> ]</literal></term>
<listitem>
<para>
Repeatedly execute the current query buffer (as <literal>\g</literal> does)
until interrupted or the query fails. Wait the specified number of
seconds (default 2) between executions. Each query result is
until interrupted, or the query fails, or the execution count limit
(if given) is reached. Wait the specified number of
seconds (default 2) between executions. For backwards compatibility,
<replaceable class="parameter">seconds</replaceable> can be specified
with or without an <literal>interval=</literal> prefix.
Each query result is
displayed with a header that includes the <literal>\pset title</literal>
string (if any), the time as of query start, and the delay interval.
</para>