pgsql: Allow \watch queries to stop on minimum rows returned

From: Daniel Gustafsson <dgustafsson(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow \watch queries to stop on minimum rows returned
Date: 2023-08-29 09:35:33
Message-ID: E1qav8G-001VJf-SN@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)gmail(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Reviewed-by: Daniel Gustafsson <daniel(at)yesql(dot)se>
Discussion: https://postgr.es/m/CAKAnmmKStATuddYxP71L+p0DHtp9Rvjze3XRoy0Dyw67VQ45UA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f347ec76e2a227e5c5b5065cce7adad16d58d209

Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml | 7 ++++---
src/bin/psql/command.c | 32 +++++++++++++++++++++++++++-----
src/bin/psql/common.c | 19 ++++++++++++++-----
src/bin/psql/common.h | 2 +-
src/bin/psql/help.c | 4 +++-
src/bin/psql/t/001_basic.pl | 23 +++++++++++++++++++++++
6 files changed, 72 insertions(+), 15 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2023-08-29 12:38:51 pgsql: Reword user-facing message for "power of two"
Previous Message Daniel Gustafsson 2023-08-29 09:22:50 pgsql: Reword user-facing message for "power of two"