leave out database sizes for databases the user cannot connect to

this prevents permissions errors.
This commit is contained in:
eelke 2021-04-14 19:40:07 +02:00
parent fd5ad9bbf0
commit 5a70749308
2 changed files with 4 additions and 2 deletions

View file

@ -157,7 +157,8 @@ QVariant DatabasesTableModel::getData(const QModelIndex &index) const
v = db.description;
break;
case SizeCol:
v = db.sizeBytes;
if (db.sizeBytes >= 0)
v = db.sizeBytes;
break;
case AclCol:
v = db.aclString();

View file

@ -5,7 +5,8 @@ std::string PgDatabaseContainer::getLoadQuery() const
{
return
"SELECT pg_database.oid, datname, datdba, encoding, pg_encoding_to_char(encoding), datcollate,\n"
" datctype, datistemplate, datallowconn, datconnlimit, dattablespace, pg_database_size(pg_database.oid),\n"
" datctype, datistemplate, datallowconn, datconnlimit, dattablespace, \n"
" case when has_database_privilege(current_role, oid, 'connect') then pg_database_size(oid) else -1 end,\n"
" d.description, datacl\n"
"FROM pg_database\n"
" LEFT JOIN pg_catalog.pg_shdescription AS d ON (objoid=pg_database.oid)";