diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2023-04-06 13:18:14 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2023-04-06 13:18:14 -0400 |
commit | 00beecfe839c878abb366b68272426ed5296bc2b (patch) | |
tree | 06e479aff010d16e0f86ada78fba8a5bfff156da /src/bin/psql/t/001_basic.pl | |
parent | 2820adf7755d2a377546d5b55f5b1a4a39889336 (diff) | |
download | postgresql-00beecfe839c878abb366b68272426ed5296bc2b.tar.gz postgresql-00beecfe839c878abb366b68272426ed5296bc2b.zip |
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
Diffstat (limited to 'src/bin/psql/t/001_basic.pl')
-rw-r--r-- | src/bin/psql/t/001_basic.pl | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl index 64ce0120621..56b1e3e4a6f 100644 --- a/src/bin/psql/t/001_basic.pl +++ b/src/bin/psql/t/001_basic.pl @@ -350,21 +350,38 @@ psql_like( '\copy from with DEFAULT' ); +# Check \watch +psql_like( + $node, + 'SELECT 1 \watch c=3 i=0.01', + qr/1\n1\n1/, + '\watch with 3 iterations'); + # Check \watch errors psql_fails_like( $node, - 'SELECT 1;\watch -10', - qr/incorrect interval value '-10'/, + 'SELECT 1 \watch -10', + qr/incorrect interval value "-10"/, '\watch, negative interval'); psql_fails_like( $node, - 'SELECT 1;\watch 10ab', - qr/incorrect interval value '10ab'/, - '\watch incorrect interval'); + 'SELECT 1 \watch 10ab', + qr/incorrect interval value "10ab"/, + '\watch, incorrect interval'); +psql_fails_like( + $node, + 'SELECT 1 \watch 10e400', + qr/incorrect interval value "10e400"/, + '\watch, out-of-range interval'); +psql_fails_like( + $node, + 'SELECT 1 \watch 1 1', + qr/interval value is specified more than once/, + '\watch, interval value is specified more than once'); psql_fails_like( $node, - 'SELECT 1;\watch 10e400', - qr/incorrect interval value '10e400'/, - '\watch out-of-range interval'); + 'SELECT 1 \watch c=1 c=1', + qr/iteration count is specified more than once/, + '\watch, iteration count is specified more than once'); done_testing(); |