| From: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
|---|---|
| To: | Christoph Berg <myon(at)debian(dot)org> |
| Cc: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
| Subject: | Re: Allow pg_read_all_stats to see database size in \l+ |
| Date: | 2026-07-22 14:38:55 |
| Message-ID: | amDSbI2vYIv_oFY1@alvherre.pgsql |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert Haas | 2026-07-22 14:51:41 | Re: walsummarizer can get stuck when switching timelines |
| Previous Message | ZizhuanLiu X-MAN | 2026-07-22 14:30:00 | Re: Disallow whole-row index references with virtual generated columns? |