Re: \watch 0 or \watch 0.00001 doesn't do what I want

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, Daniel Gustafsson <daniel@yesql.se>
Date: 2024-10-09T15:03:03Z
Lists: pgsql-hackers
Heikki Linnakangas <hlinnaka@iki.fi> writes:
> This issue is present on newer versions still.

Here's the problem:

	long		sleep_ms = (long) (sleep * 1000);

If "sleep" is less than 0.0005, sleep_ms rounds to zero, which
results in the subsequent setitimer disarming rather than
arming the interrupt.

There is an uncommented

		if (sleep == 0)
			continue;

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.

			regards, tom lane



Commits

  1. psql: Fix \watch when using interval values less than 1ms