1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-30 17:50:00 +02:00

PostgreSQL: Show only accessible databases

This commit is contained in:
Thomas Daniels
2023-08-01 01:16:29 +02:00
committed by Peter Knut
parent c4ed9500a1
commit 0d0936550c

View File

@@ -274,7 +274,9 @@ if (isset($_GET["pgsql"])) {
}
function get_databases() {
return get_vals("SELECT datname FROM pg_database WHERE has_database_privilege(datname, 'CONNECT') ORDER BY datname");
return get_vals("SELECT d.datname FROM pg_database d JOIN pg_roles r ON d.datdba = r.oid
WHERE d.datallowconn = TRUE AND has_database_privilege(d.datname, 'CONNECT') AND pg_has_role(r.rolname, 'USAGE')
ORDER BY d.datname");
}
function limit($query, $where, $limit, $offset = 0, $separator = " ") {