From d6c467cb96ccbfb26a9a6c491bf6cfb5a7e02c2b Mon Sep 17 00:00:00 2001 From: Thomas Daniels Date: Tue, 1 Aug 2023 01:16:29 +0200 Subject: [PATCH] PostgreSQL: only show databases you can access When connecting to a PostgreSQL database, Adminer's dropdown also includes all databases you don't have access to, which is not very useful. This commit filters out databases that you don't have the USAGE privilege on, to present a cleaner overview of available databases. --- adminer/drivers/pgsql.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 198e64294..a88efd9d4 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -274,7 +274,7 @@ function connect() { } function get_databases() { - return get_vals("SELECT datname FROM pg_database WHERE has_database_privilege(datname, 'CONNECT') ORDER BY datname"); + return get_vals("SELECT datname FROM pg_database pd JOIN pg_roles pr on pd.datdba = pr.oid WHERE pg_has_role(pr.rolname, 'USAGE') ORDER BY datname"); } function limit($query, $where, $limit, $offset = 0, $separator = " ") {