Re: \watch 0 or \watch 0.00001 doesn't do what I want
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, Daniel Gustafsson <daniel@yesql.se>
Date: 2024-10-09T23:49:44Z
Lists: pgsql-hackers
Attachments
- psql-watch.patch (text/x-diff) patch
On Wed, Oct 09, 2024 at 11:03:03AM -0400, Tom Lane wrote: > in the loop, which I bet some cowboy added to fix the zero-wait > problem you complained of. But it's doing the wrong thing because > it checks sleep not sleep_ms. > > We should change this to test sleep_ms, and we should probably > fix the code that says what the wait interval is to print > sleep_ms/1000.0 not sleep. And some more comments would be good. Cowboy of 6f9ee74d45aa reporting for duty. This was not backpatched as of the reason written in the commit log. If folks would rather get the zero behavior backported, I'm OK with a more aggressive backpatch if that's the consensus. A cherry-pick of 6f9ee74d45aa down to v12 is clean enough, with a small conflict related to pagerpipe so it looks pretty much fine. Also, long is 4 bytes on Windows. Should we just use uint64 for sleep_ms? I am not sure that it is worth changing as it still gives plenty of maximum interval time even with sleep_ms in milliseconds. Anyway, I agree that this could be better for values with lower digits, even if \watch would output 0s when using an internal lower than 10^-3. How about something like the simple patch attached? -- Michael
Commits
-
psql: Fix \watch when using interval values less than 1ms
- 6331972c7bc9 16.5 landed
- 8a6170860c83 17.1 landed
- 9f34cae1426f 18.0 landed