0

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?

Vérace
31k9 gold badges73 silver badges86 bronze badges
asked Nov 27, 2021 at 7:09
1
  • 1
    There 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. Commented Nov 27, 2021 at 18:12

1 Answer 1

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?

answered Nov 27, 2021 at 17:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.