| From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
|---|---|
| To: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
| Cc: | 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-27 03:32:10 |
| Message-ID: | CAHGQGwHzNr71zQ7i73Jt55gnW0D-DYJtdoXHKEs0BgsjXAXw5Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sat, Oct 25, 2025 at 1:13 AM Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> wrote:
>
>
>
> On 24/10/2025 17:21, Fujii Masao wrote:
> > + const char *hs = PQparameterStatus(pset.db, "in_hot_standby");
> > + const char *ro = PQparameterStatus(pset.db, "default_transaction_read_only");
> >
> > When either hs or ro is NULL, the displayed status can be incorrect.
> > For example, connecting to a standby server running PostgreSQL 10
> > incorrectly shows "read/write". In such cases, wouldn't it be clearer
> > to display something like "unknown", similar to how the "Hot Standby"
> > column in \conninfo reports "unknown"?
>
> Oh, it didn't occur to me to test this edge case. Thanks for the hint!
>
> Would this be what you have in mind?
Yes, thanks for working on this!
> if (!hs || !ro)
> strlcpy(buf, "unknown", sizeof(buf));
> else if ((hs && strcmp(hs, "on") == 0) ||
> (ro && strcmp(ro, "on") == 0))
I think the "hs &&" and "ro &&" checks are no longer needed,
since we've already confirmed they're not NULL at that point.
Also, should "unknown" be marked for translation, as in the \conninfo code?
I'm not sure whether showing a translated string in the psql prompt is
desirable, though.
Regards,
--
Fujii Masao
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2025-10-27 03:33:11 | Re: Use BumpContext contexts for TupleHashTables' tablecxt |
| Previous Message | Peter Smith | 2025-10-27 02:59:36 | Re: Should we say "wal_level = logical" instead of "wal_level >= logical" |