From f347ec76e2a227e5c5b5065cce7adad16d58d209 Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Tue, 29 Aug 2023 11:30:11 +0200 Subject: Allow \watch queries to stop on minimum rows returned When running a repeat query with \watch in psql, it can be helpful to be able to stop the watch process when the query no longer returns the expected amount of rows. An example would be to watch for the presence of a certain event in pg_stat_activity and stopping when the event is no longer present, or to watch an index creation and stop when the index is created. This adds a min_rows=MIN parameter to \watch which can be set to a non-negative integer, and the watch query will stop executing when it returns less than MIN rows. Author: Greg Sabino Mullane Reviewed-by: Michael Paquier Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/CAKAnmmKStATuddYxP71L+p0DHtp9Rvjze3XRoy0Dyw67VQ45UA@mail.gmail.com --- doc/src/sgml/ref/psql-ref.sgml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 182e58353f1..d94e3cacfcc 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -3566,13 +3566,14 @@ testdb=> \setenv LESS -imx4F - \watch [ i[nterval]=seconds ] [ c[ount]=times ] [ seconds ] + \watch [ i[nterval]=seconds ] [ c[ount]=times ] [ m[in_rows]=rows ] [ seconds ] Repeatedly execute the current query buffer (as \g does) 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, + (if given) is reached, or the query no longer returns the minimum number + of rows. Wait the specified number of seconds (default 2) between executions. + For backwards compatibility, seconds can be specified with or without an interval= prefix. Each query result is -- cgit v1.2.3