Subject: [PATCH v1] Allow pg_read_all_stats to see database size in \l+

From: Christoph Berg <[email-masked]>
Date: Wed, 22 Jul 2026 13:16:16 +0200

The server already allowed members of pg_read_all_stats to see the size
of all databases, but psql's \l+ was too restrictive.
---
 src/bin/psql/describe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index a2f09c26369..ad9c8affb4f 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -986,7 +986,8 @@ listAllDbs(const char *pattern, bool verbose)
 	printACLColumn(&buf, "d.datacl");
 	if (verbose)
 		appendPQExpBuffer(&buf,
-						  ",\n  CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT')\n"
+						  ",\n  CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT') OR\n"
+						  "               pg_catalog.pg_has_role('pg_read_all_stats', 'USAGE')\n"
 						  "       THEN pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname))\n"
 						  "       ELSE 'No Access'\n"
 						  "  END as \"%s\""
-- 
2.53.0

--bukXArRbhiisqidC--