On 2026-Jul-22, Christoph Berg wrote:
> Thanks for the review!
>
> Re: Fujii Masao
> > The pg_read_all_stats check should be fine in master, since psql there
> > no longer supports pre-v10 servers, which don't have that role. But,
> > if this is backpatched, psql still needs to work with pre-v10 servers,
> > so we'll probably need a server version check (e.g., pset.sversion >=
> > 100000)
> > before checking for pg_read_all_stats, at least in the older stable
> > branches.
>
> The SQL-generating code there is already quite complex, and since no
> one complained, perhaps just skip the backpatching if it's complicated.
I think it's simple enough:
@@ -1069,12 +1069,16 @@ listAllDbs(const char *pattern, bool verbose)
appendPQExpBufferStr(&buf, " ");
printACLColumn(&buf, "d.datacl");
if (verbose && pset.sversion >= 80200)
+ {
appendPQExpBuffer(&buf,
",\n CASE WHEN
pg_catalog.has_database_privilege(d.datname, 'CONNECT')\n"
+ " %s"
" THEN
pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname))\n"
" ELSE 'No
Access'\n"
" END as \"%s\"",
+ pset.sversion >= 100000 ? "OR
pg_catalog.pg_has_role('pg_read_all_stats', 'USAGE')\n" : "",
gettext_noop("Size"));
+ }
if (verbose && pset.sversion >= 80000)
appendPQExpBuffer(&buf,
",\n t.spcname as
\"%s\"",
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/