Re: Allow default \watch interval in psql to be configured

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: Greg Sabino Mullane <htamfids(at)gmail(dot)com>, Masahiro Ikeda <ikedamsh(at)oss(dot)nttdata(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Allow default \watch interval in psql to be configured
Date: 2025-03-17 12:37:27
Message-ID: CAExHW5vSo6uJXTtpgKhSpYbYrvu24QbpcrW4oD5iffVesfOu6w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Daniel,

On Fri, Mar 14, 2025 at 2:26 PM Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
>
> On 13 Mar 2025, at 15:03, Greg Sabino Mullane <htamfids(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-03-17 13:10:06 Re: lwlocknames.h beautification attempt
Previous Message Shubham Khanna 2025-03-17 12:34:23 Re: Adding a '--clean-publisher-objects' option to 'pg_createsubscriber' utility.