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

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Allow default \watch interval in psql to be configured
Date: 2024-10-09 14:05:16
Message-ID: 8b166af3-dc91-4d8e-8249-5bae05887739@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 09/10/2024 16:08, Daniel Gustafsson wrote:
> Scratching an old itch; I've long wanted to be able to set the default interval
> for \watch in psql since I almost never want a 2 second wait. The interval can
> of course be set by passing it to \watch but it's handy during testing and
> debugging to save that with just quick \watch.
>
> The attached adds a new variable, WATCH_INTERVAL, which is used as the default
> value in case no value is defined when executing the command. The defualt of
> this remains at 2 seconds as it is now. The count and min_rows values are not
> affected by this as those seem less meaningful to set defaults on.

../src/bin/psql/startup.c:953:80: error: too many arguments to function
call, expected 4, have 5
return ParseVariableDouble(newval, "WATCH_INTERVAL",
&pset.watch_interval, 0, 1000);
~~~~~~~~~~~~~~~~~~~
^~~~
../src/bin/psql/variables.h:84:7: note: 'ParseVariableDouble' declared here
bool ParseVariableDouble(const char *value, const char *name,
^
1 error generated.

I guess the '1000' was supposed to be the maximum, but
ParseVariableDouble doesn't take a maximum.

After fixing that by removing the '1000' argument:

postgres=# \set WATCH_INTERVAL -10
invalid value "-10" for "WATCH_INTERVAL": must be greater than 0.00

That's a little inaccurate: 0 is also accepted, so should be "must be
greater than *or equal to* 0". Or maybe "cannot be negative". -0 is also
accepted, though.

> + This variable set the default interval which <command>\watch</command>

set -> sets

> + HELP0(" WATCH_INTERVAL\n"
> + " number of seconds \\watch waits beetween queries\n");

beetween -> between

--
Heikki Linnakangas
Neon (https://neon.tech)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Srinath Reddy Sadipiralla 2024-10-09 14:07:38 Re: \watch 0 or \watch 0.00001 doesn't do what I want
Previous Message David Rowley 2024-10-09 13:59:45 Re: Make tuple deformation faster