Created
April 4, 2013 13:15
-
-
Save mikebuchanon/5310263 to your computer and use it in GitHub Desktop.
Find rights for 'reporting' user on mdl_assign* tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select usename, nspname || '.' || relname as relation, | |
case relkind when 'r' then 'TABLE' when 'v' then 'VIEW' end as relation_type, | |
priv | |
from pg_class join pg_namespace on pg_namespace.oid = pg_class.relnamespace, | |
pg_user, | |
(values('SELECT', 1),('INSERT', 2),('UPDATE', 3),('DELETE', 4)) privs(priv, privorder) | |
where relkind in ('r', 'v') | |
and has_table_privilege(pg_user.usesysid, pg_class.oid, priv) | |
and not (nspname ~ '^pg_' or nspname = 'information_schema') | |
and relname ilike 'mdl_assign%' and usename ='reporting' | |
order by 2, 1, 3, privorder; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
stolen/borrowed/tweaked from http://stackoverflow.com/questions/946804/find-out-if-user-got-permission-to-select-update-a-table-function-in-pos