diff options
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r-- | src/bin/psql/command.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 4d2c81aa753..f8a21a79c7d 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -5231,6 +5231,10 @@ do_shell(const char *command) * * We break this out of exec_command to avoid having to plaster "volatile" * onto a bunch of exec_command's variables to silence stupider compilers. + * + * "sleep" is the amount of time to sleep during each loop, measured in + * seconds. The internals of this function should use "sleep_ms" for + * precise sleep time calculations. */ static bool do_watch(PQExpBuffer query_buf, double sleep, int iter, int min_rows) @@ -5356,10 +5360,10 @@ do_watch(PQExpBuffer query_buf, double sleep, int iter, int min_rows) if (user_title) snprintf(title, title_len, _("%s\t%s (every %gs)\n"), - user_title, timebuf, sleep); + user_title, timebuf, sleep_ms / 1000.0); else snprintf(title, title_len, _("%s (every %gs)\n"), - timebuf, sleep); + timebuf, sleep_ms / 1000.0); myopt.title = title; /* Run the query and print out the result */ @@ -5380,7 +5384,8 @@ do_watch(PQExpBuffer query_buf, double sleep, int iter, int min_rows) if (pagerpipe && ferror(pagerpipe)) break; - if (sleep == 0) + /* Tight loop, no wait needed */ + if (sleep_ms == 0) continue; #ifdef WIN32 |