pgsql: psql: Allow pg_read_all_stats to see database size in \l+ - Mailing list pgsql-committers

From Fujii Masao
Subject pgsql: psql: Allow pg_read_all_stats to see database size in \l+
Date
Msg-id E1wnZNK-00000000EQF-2kLQ@gemulon.postgresql.org
Whole thread
List 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@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_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/77aeca80249c9e640c811e80633a2e334a9320de

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


pgsql-committers by date:

Previous
From: Fujii Masao
Date:
Subject: pgsql: Fix EXCEPT publication test to check subscriber
Next
From: Peter Geoghegan
Date:
Subject: pgsql: Fix another empty nbtree index SSI race.