Re: Prevent psql \watch from running queries that return no rows

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Greg Sabino Mullane <htamfids@gmail.com>
Cc: daniel@yesql.se, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2023-07-26T00:41:36Z
Lists: pgsql-hackers
On Wed, Jul 05, 2023 at 10:14:22AM -0400, Greg Sabino Mullane wrote:
> Would like to hear others weigh in, I think it's still only three states
> plus a default, so I'm not convinced it warrants multiple statements yet. :)

I find that hard to parse, so having more lines to get a better idea
of what the states are would be good.

While on it, I can see that the patch has no tests.  Could you add
something in psql's 001_basic.pl?  The option to define the number of
iterations for \watch can make the tests predictible even for the
non-failure cases.  I would do checks with incorrect values, as well,
see the part of the test script about the intervals.
--
Michael

Commits

  1. Allow \watch queries to stop on minimum rows returned