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?
if (!hs || !ro)
strlcpy(buf, "unknown", sizeof(buf));
else if ((hs && strcmp(hs, "on") == 0) ||
(ro && strcmp(ro, "on") == 0))
strlcpy(buf, "read-only", sizeof(buf));
else
strlcpy(buf, "read/write", sizeof(buf));
Best, Jim
- Re: display hot standby state in psql prompt Nathan Bossart
- Re: display hot standby state in psql promp... Jim Jones
- Re: display hot standby state in psql p... Nathan Bossart
- Re: display hot standby state in ps... Greg Sabino Mullane
- Re: display hot standby state i... Nathan Bossart
- Re: display hot standby st... Greg Sabino Mullane
- Re: display hot standb... Srinath Reddy Sadipiralla
- Re: display hot st... Nathan Bossart
- Re: display hot standby state in psql promp... Fujii Masao
- Re: display hot standby state in psql p... Jim Jones
- Re: display hot standby state in ps... Jim Jones
- Re: display hot standby state in ps... Fujii Masao
- Re: display hot standby state i... Jim Jones
- Re: display hot standby st... Nathan Bossart
- Re: display hot standb... Jim Jones
- Re: display hot st... Nathan Bossart
- Re: display hot st... Fujii Masao
- Re: display hot st... Jim Jones
- Re: display hot st... Nathan Bossart
- Re: display hot st... Jim Jones
