pgsql: psql: Allow pg_read_all_stats to see database size in \l+

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: psql: Allow pg_read_all_stats to see database size in \l+
Date: 2026-07-25 10:12:42
Message-ID: E1wnZN4-00000000EOy-3AM9@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

psql: Allow pg_read_all_stats to see database size in \l+

pg_database_size() allows access to users who have either CONNECT
privilege on the target database or privileges of the pg_read_all_stats
role. However, previously, psql's \l+ checked only for CONNECT,
so users with privileges of pg_read_all_stats still saw "No Access" for
databases they could not connect to.

Fix this by making \l+ also check
pg_has_role('pg_read_all_stats', 'USAGE'), matching
pg_database_size()'s permission rules.

For back branches, emit the pg_read_all_stats check only when
connected to PostgreSQL 10 or later, since earlier releases do not have
that predefined role.

Backpatch to all supported versions.

Author: Christoph Berg <myon(at)debian(dot)org>
Reviewed-by: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/amCo6qRmnfPVk4-V@msg.df7cb.de
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/38afc3dcb25c45b744d4025029ce0a6c90b7059f

Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml | 5 +++--
src/bin/psql/describe.c | 3 ++-
2 files changed, 5 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-07-25 10:12:58 pgsql: psql: Allow pg_read_all_stats to see database size in \l+
Previous Message Fujii Masao 2026-07-25 01:33:33 pgsql: Avoid reporting permission-denied publisher sequences as missing