Re: display hot standby state in psql prompt

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: display hot standby state in psql prompt
Date: 2025-10-30 09:20:50
Message-ID: 508b6027-1077-45c2-8677-7a8205e51fd1@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Chao

On 30/10/2025 08:51, Chao Li wrote:
> I did a quick test, and found a problem. I shutdown the server, and “\c” reconnecting failed, but psql still show “read/write”, which seems wrong:
>
> "read/write"\c
> connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
> Is the server running locally and accepting connections on that socket?
> Previous connection kept

I can see that a "read/write" prompt in this case sounds misleading, but
I am not entirely sure it is a problem. The message says "Previous
connection kept", which might suggest that the previous parameter values
are cached? See %p:

postgres=# \set PROMPT1 '[%p] # '
[1268754] # \c
connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file
or directory
Is the server running locally and accepting connections on that
socket?
Previous connection kept
[1268754] #

The backend pid is still displayed, although the server is no longer
running.
> Why wrap “unknown” in "_()” but not “read-only” and “read/write”?
It didn't occur to me that read-only and read/write needed translation,
but I guess you're right. I'll add to the next version.

Thanks for the review. Much appreciated!

Best, Jim

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-10-30 09:29:29 Re: Skip unregistered custom kinds on stats load
Previous Message Bertrand Drouvot 2025-10-30 09:20:02 Re: Consistently use the XLogRecPtrIsInvalid() macro