Re: Allow default \watch interval in psql to be configured - Mailing list pgsql-hackers

From Ashutosh Bapat
Subject Re: Allow default \watch interval in psql to be configured
Date
Msg-id CAExHW5vSo6uJXTtpgKhSpYbYrvu24QbpcrW4oD5iffVesfOu6w@mail.gmail.com
Whole thread Raw
In response to Re: Allow default \watch interval in psql to be configured  (Daniel Gustafsson <daniel@yesql.se>)
Responses Re: Allow default \watch interval in psql to be configured
List pgsql-hackers
Hi Daniel,

On Fri, Mar 14, 2025 at 2:26 PM Daniel Gustafsson <daniel@yesql.se> wrote:
>
> On 13 Mar 2025, at 15:03, Greg Sabino Mullane <htamfids@gmail.com> wrote:
>
> Patch looks good. One minor issue:
>
> greg=# \set WATCH_INTERVAL -1
> invalid value "-1" for "WATCH_INTERVAL": must be greater than 0.00
> greg=# \set WATCH_INTERVAL 0.00
> greg=#
>
> We should disallow 0 as the error message implies
>
>
> Ah, nice catch, fixed in the attached along with a test for the minimum bound (ie zero).

#\watch c=4 i=
Mon 17 Mar 2025 05:52:50 PM IST (every 0s)

 ?column?
----------
        1
(1 row)

Mon 17 Mar 2025 05:52:50 PM IST (every 0s)

 ?column?
----------
        1
(1 row)

Mon 17 Mar 2025 05:52:50 PM IST (every 0s)

 ?column?
----------
        1
(1 row)

Mon 17 Mar 2025 05:52:50 PM IST (every 0s)

 ?column?
----------
        1
(1 row)

0 is an accepted value for interval, even though it might look insensible.

The behaviour should be same in both cases \watch i=<some value> and
\set WATCH_INTERVAL <some value> \watch. In this case it's not. In
fact, we should use the same validation code in both the cases. Why
don't we perform the same  additional validations in
ParseVariableDouble() in exec_watch_command() as well?

The test only validate default variable value. We need a test where we
see variable value being honored lie tests between 369 to 376 in the
same file.

--
Best Wishes,
Ashutosh Bapat



pgsql-hackers by date:

Previous
From: Shubham Khanna
Date:
Subject: Re: Adding a '--clean-publisher-objects' option to 'pg_createsubscriber' utility.
Next
From: Robert Haas
Date:
Subject: Re: lwlocknames.h beautification attempt