agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: psql: Allow pg_read_all_stats to see database size in \l+
Date: Sat, 25 Jul 2026 10:14:08 +0000
Message-ID: <E1wnZOS-00000000EUI-0fRN@gemulon.postgresql.org> (raw)

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@debian.org>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/amCo6qRmnfPVk4-V@msg.df7cb.de
Backpatch-through: 14

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e6e8a3078b094f209f6e40822c1655ebd34429f5

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



view thread (7+ messages)  latest in thread

Message-ID: <E1wnZOS-00000000EUI-0fRN@gemulon.postgresql.org>
Permalink:  ../E1wnZOS-00000000EUI-0fRN@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wnZOS-00000000EUI-0fRN@gemulon.postgresql.org

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-committers@postgresql.org
  Cc: fujii@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: psql: Allow pg_read_all_stats to see database size in \l+
  In-Reply-To: <E1wnZOS-00000000EUI-0fRN@gemulon.postgresql.org>

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

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