summaryrefslogtreecommitdiff
path: root/src/bin/psql/startup.c
diff options
context:
space:
mode:
authorDaniel Gustafsson <dgustafsson@postgresql.org>2025-03-25 17:53:33 +0100
committerDaniel Gustafsson <dgustafsson@postgresql.org>2025-03-25 17:53:33 +0100
commit1a759c83278fcdae11ee5da8318b646b9d47129c (patch)
tree6b61dad74bd7337ac9c950bb5343ee18c3915caa /src/bin/psql/startup.c
parenta19db082749662a933d0bf72722982b1ee2c4725 (diff)
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 <daniel@yesql.se> Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Kirill Reshke <reshkekirill@gmail.com> Reviewed-by: Masahiro Ikeda <ikedamsh@oss.nttdata.com> Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at> Reviewed-by: Greg Sabino Mullane <htamfids@gmail.com> Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Discussion: https://postgr.es/m/B2FD26B4-8F64-4552-A603-5CC3DF1C7103@yesql.se
Diffstat (limited to 'src/bin/psql/startup.c')
-rw-r--r--src/bin/psql/startup.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 5018eedf1e5..249b6aa5169 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -945,6 +945,21 @@ histsize_hook(const char *newval)
}
static char *
+watch_interval_substitute_hook(char *newval)
+{
+ if (newval == NULL)
+ newval = pg_strdup(DEFAULT_WATCH_INTERVAL);
+ return newval;
+}
+
+static bool
+watch_interval_hook(const char *newval)
+{
+ return ParseVariableDouble(newval, "WATCH_INTERVAL", &pset.watch_interval,
+ 0, DEFAULT_WATCH_INTERVAL_MAX);
+}
+
+static char *
ignoreeof_substitute_hook(char *newval)
{
int dummy;
@@ -1270,4 +1285,7 @@ EstablishVariableSpace(void)
SetVariableHooks(pset.vars, "HIDE_TABLEAM",
bool_substitute_hook,
hide_tableam_hook);
+ SetVariableHooks(pset.vars, "WATCH_INTERVAL",
+ watch_interval_substitute_hook,
+ watch_interval_hook);
}