The output of SELECT version();
------------------------------------------------------------
PostgreSQL 14.1, compiled by Visual C++ build 1914, 64-bit
(1 row)
and it's a binary distribution from EnterpriseDB. Might also be using 12 or 13, but I don't imagine it makes much of a difference.
I'm running Windows 10, but I will also be running Linux - any differences to be noted would be appreciated.
The psql \watch
command is great. If I run
SELECT 1 AS "Waste of my time"
\watch 1;
then the output is:
27/11/2021 07:06:41 (every 1s)
Waste of my time
------------------
1
(1 row)
27/11/2021 07:06:42 (every 1s)
Waste of my time
------------------
1
(1 row)
&c....
which is great. But, if I try to stop it by typing q
or Ctrl-D
or Ctrl-Z
- no joy.
The only thing that works is Ctrl-C
but that has the problem of stopping my server which is a PITA.
How can I interrupt the \watch
process in a way that just returns me to the psql
prompt?
-
1There is no need to use virtual desktops for this (neither the built-in from Windows 10, nor any external tool) if you install Postgres correctly.user1822– user18222021年11月27日 18:12:20 +00:00Commented Nov 27, 2021 at 18:12
1 Answer 1
This is what I do. The reason it happens in the first place is that I don't like having many windows open on 1 desktop so I start the server running in the background and then start the psql tool in the same window.
So, what I did was download Sysinternals virtual desktop utitly - 4 desktops, just like real operating system!
1 - I start my Postgres server from a window on desktop 4.
2 - then I go to desktop 1 (number not important). What is important is that the window that's running psql tool is NOT the same as window used to start the server.
3 - run the psql tool from desktop 1.
4 - run my command
SELECT 1
\watch
5 - let the psql tool run watch for a few seconds
6 - hit Ctrl-C. I fall back into psql prompt. I don't lose my connection to the databases and the server doesn't stop.
I hope this can help somebody with the same problem?