From 1a759c83278fcdae11ee5da8318b646b9d47129c Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Tue, 25 Mar 2025 17:53:33 +0100 Subject: psql: Make default \watch interval configurable The default interval for \watch to wait between executing queries, when executed without a specified interval, was hardcoded to two seconds. This adds the new variable WATCH_INTERVAL which is used to set the default interval, making it configurable for the user. This makes \watch the first command which has a user configurable default setting. Author: Daniel Gustafsson Reviewed-by: Heikki Linnakangas Reviewed-by: Michael Paquier Reviewed-by: Kirill Reshke Reviewed-by: Masahiro Ikeda Reviewed-by: Laurenz Albe Reviewed-by: Greg Sabino Mullane Reviewed-by: Ashutosh Bapat Discussion: https://postgr.es/m/B2FD26B4-8F64-4552-A603-5CC3DF1C7103@yesql.se --- src/bin/psql/command.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/bin/psql/command.c') diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index bbe337780ff..a8a13c2b88b 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -3278,7 +3278,7 @@ exec_command_watch(PsqlScanState scan_state, bool active_branch, bool have_sleep = false; bool have_iter = false; bool have_min_rows = false; - double sleep = 2; + double sleep = pset.watch_interval; int iter = 0; int min_rows = 0; @@ -3292,7 +3292,9 @@ exec_command_watch(PsqlScanState scan_state, bool active_branch, /* * Parse arguments. We allow either an unlabeled interval or * "name=value", where name is from the set ('i', 'interval', 'c', - * 'count', 'm', 'min_rows'). + * 'count', 'm', 'min_rows'). The parsing of interval value should be + * kept in sync with ParseVariableDouble which is used for setting the + * default interval value. */ while (success) { -- cgit v1.2.3