pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Álvaro Herrera <alvherre@kurilemu.de>
To: Christoph Berg <myon@debian.org>
Cc: Fujii Masao <masao.fujii@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Zsolt Parragi <zsolt.parragi@percona.com>
Subject: Re: Allow pg_read_all_stats to see database size in \l+
Date: Wed, 22 Jul 2026 16:38:55 +0200
Message-ID: <amDSbI2vYIv_oFY1@alvherre.pgsql> (raw)
In-Reply-To: <amDBusAY5ysRg-LQ@msg.df7cb.de>

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/





view thread (12+ messages)  latest in thread

Message-ID: <amDSbI2vYIv_oFY1@alvherre.pgsql>
Permalink:  ../amDSbI2vYIv_oFY1@alvherre.pgsql/
Also on:    postgresql.org/message-id/amDSbI2vYIv_oFY1@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@kurilemu.de, myon@debian.org, masao.fujii@gmail.com, pgsql-hackers@lists.postgresql.org, zsolt.parragi@percona.com
  Subject: Re: Allow pg_read_all_stats to see database size in \l+
  In-Reply-To: <amDSbI2vYIv_oFY1@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox