WITH db_privs AS (SELECT unnest(datacl)::text AS priv
FROM pg_database
WHERE datname=current_database()),
privs_extracted AS (SELECT
left(priv, (position('=' IN priv)-1)) AS grantee,
substring(priv, position('=' IN priv)+1, position('/' IN priv)-position('=' IN priv)-1) AS privileges
FROM db_privs)
SELECT CASE WHEN grantee='' THEN 'PUBLIC' ELSE grantee END AS grantee,
usesuper AS is_grantee_superuser, privileges
FROM privs_extracted LEFT JOIN pg_user ON privs_extracted.grantee=pg_user.usename
ORDER BY grantee;
Collections
This query belongs to the following collections:
Name
Description
Find problems by overview
Queries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not .
Categories
This query is classified under the following categories:
Name
Description
Security
Queries of this category provide information about the security measures.