pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH v2] Allow pg_read_all_stats to see database size in \l+
1+ messages / 1 participants
[nested] [flat]

* [PATCH v2] Allow pg_read_all_stats to see database size in \l+
@ 2026-07-22 11:16  Christoph Berg <myon@debian.org>
  0 siblings, 0 replies; 1+ messages in thread

From: Christoph Berg @ 2026-07-22 11:16 UTC (permalink / raw)

The server already allows members of pg_read_all_stats to see the size
of all databases, but psql's \l+ was too restrictive.
---
 doc/src/sgml/ref/psql-ref.sgml | 5 +++--
 src/bin/psql/describe.c        | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

inline patch 1: doc/src/sgml/ref/psql-ref.sgml, src/bin/psql/describe.c (+5/-3 lines) download inline-1.patchdiff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 56c2692e618..4d5ee11ddd9 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -2817,8 +2817,9 @@ SELECT are displayed in expanded mode. If <literal>+</literal> is appended to the command name, database sizes, default tablespaces, and descriptions are also displayed. - (Size information is only available for databases that the current - user can connect to.) + Except for superusers or roles with privileges of the + <literal>pg_read_all_stats</literal> role, size information is only + available for databases that the current user can connect to. </para> </listitem> </varlistentry> 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
--GvhE+GC2PI361jLV-- ^ permalink raw reply [nested|flat] 1+ messages in thread


only message in thread

Thread overview: 1+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-22 11:16 [PATCH v2] Allow pg_read_all_stats to see database size in \l+ Christoph Berg <myon@debian.org>

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