agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedFrom: Christoph Berg <myon@debian.org>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Zsolt Parragi <zsolt.parragi@percona.com>
Subject: Allow pg_read_all_stats to see database size in \l+
Date: Wed, 22 Jul 2026 13:26:34 +0200
Message-ID: <amCo6qRmnfPVk4-V@msg.df7cb.de> (raw)
psql \l+ didn't consider pg_read_all_stats when determining whether
the user was allowed to see the database size.
Split off from the "Available disk space per tablespace" patch since
it's really an independent fix. Thanks Zsolt for pointing that out.
This might be considered for backpatching.
Christoph
Attachments:
[text/x-diff] v1-0001-Allow-pg_read_all_stats-to-see-database-size-in-l.patch (1.1K, ../amCo6qRmnfPVk4-V@msg.df7cb.de/2-v1-0001-Allow-pg_read_all_stats-to-see-database-size-in-l.patch)
download | inline diff:
From 9e6f09d62ecd373d80b14a8da39feb9f968c14a0 Mon Sep 17 00:00:00 2001
From: Christoph Berg <myon@debian.org>
Date: Wed, 22 Jul 2026 13:16:16 +0200
Subject: [PATCH v1] Allow pg_read_all_stats to see database size in \l+
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
view thread (12+ messages) latest in thread
Message-ID: <amCo6qRmnfPVk4-V@msg.df7cb.de>
Permalink: ../amCo6qRmnfPVk4-V@msg.df7cb.de/
Also on: postgresql.org/message-id/amCo6qRmnfPVk4-V@msg.df7cb.de
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-hackers@postgresql.org
Cc: myon@debian.org, pgsql-hackers@lists.postgresql.org, zsolt.parragi@percona.com
Subject: Re: Allow pg_read_all_stats to see database size in \l+
In-Reply-To: <amCo6qRmnfPVk4-V@msg.df7cb.de>
* 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