Allow \watch queries to stop on minimum rows returned
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Tue, 29 Aug 2023 09:30:11 +0000 (11:30 +0200)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Tue, 29 Aug 2023 09:30:11 +0000 (11:30 +0200)
commitf347ec76e2a227e5c5b5065cce7adad16d58d209
tree0d03e7a4caa335a0b9ae014299ccabbac8486c3f
parent95fff2abee66c16ca3609b3c1638cbd553730a90
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 <htamfids@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAKAnmmKStATuddYxP71L+p0DHtp9Rvjze3XRoy0Dyw67VQ45UA@mail.gmail.com
doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/command.c
src/bin/psql/common.c
src/bin/psql/common.h
src/bin/psql/help.c
src/bin/psql/t/001_basic.pl