aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r--src/bin/psql/command.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 955397ee9dc..61ec049f054 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -2776,9 +2776,18 @@ exec_command_watch(PsqlScanState scan_state, bool active_branch,
/* Convert optional sleep-length argument */
if (opt)
{
- sleep = strtod(opt, NULL);
- if (sleep <= 0)
- sleep = 1;
+ char *opt_end;
+
+ errno = 0;
+ sleep = strtod(opt, &opt_end);
+ if (sleep < 0 || *opt_end || errno == ERANGE)
+ {
+ pg_log_error("\\watch: incorrect interval value '%s'", opt);
+ free(opt);
+ resetPQExpBuffer(query_buf);
+ psql_scan_reset(scan_state);
+ return PSQL_CMD_ERROR;
+ }
free(opt);
}
@@ -5183,6 +5192,9 @@ do_watch(PQExpBuffer query_buf, double sleep)
if (pagerpipe && ferror(pagerpipe))
break;
+ if (sleep == 0)
+ continue;
+
#ifdef WIN32
/*