Re: psql \watch 2nd argument: iteration count

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Andrey Borodin <amborodin86@gmail.com>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, sfrost@snowman.net, peter.eisentraut@enterprisedb.com, pgsql-hackers@postgresql.org, samokhvalov@gmail.com
Date: 2023-03-16T00:54:43Z
Lists: pgsql-hackers
On Wed, Mar 15, 2023 at 04:58:49PM +0900, Michael Paquier wrote:
> Yep.  You are right.

Fixed that and applied 0001.

+    valptr++;
+    if (strncmp("i", opt, strlen("i")) == 0 ||
+            strncmp("interval", opt, strlen("interval")) == 0)
+    {

Did you look at process_command_g_options() and if some consolidation
was possible?  It would be nice to have APIs shaped so as more
sub-commands could rely on the same facility in the future.

-        <term><literal>\watch [ <replaceable class="parameter">seconds</replaceable> ]</literal></term>
+        <term><literal>\watch [ <replaceable class="parameter">seconds</replaceable> [ <replaceable class="parameter">iterations</replaceable> ] ]</literal></term>

This set of changes is not reflected in the documentation.

With an interval in place, we could now automate some tests with
\watch where it does not fail.  What do you think about adding a test
with a simple query, an interval of 0s and one iteration?
--
Michael

Commits

  1. psql: add an optional execution-count limit to \watch.

  2. Improve handling of psql \watch's interval argument