The following code example shows the effective privileges of the roles directly assigned to the user running the query:
SELECTAR.grantee, AR.role_name, OP.privilege_type, OP.object_type, OP.object_nameFROM information_schema.applicable_roles AS ARJOIN information_schema.object_privileges AS OPON (AR.role_name = OP.grantee)WHERE AR.grantee = session_user();
grantee text
role_name text
privilege_type text
object_type text
object_name text
demoproxy
proxy_role
SELECT
table
usaccidentdata
demoproxy
proxy_role
SELECT
table
tournaments
demoproxy
proxy_role
SELECT
table
t
demoproxy
proxy_role
SELECT
table
rankings
demoproxy
proxy_role
SELECT
table
playstats
demoproxy
proxy_role
SELECT
table
players
demoproxy
proxy_role
SELECT
table
levels
demoproxy
proxy_role
SELECT
table
games
demoproxy
proxy_role
USAGE
schema
public
Rows: 9Execution time: 40.41ms
ExampleDynamic security through a view which uses session_user().
-- user bob created view:create view my_employee_data as select * from employees where user_name = session_user();-- user alice queries it:select * from my_employee_data; -- session_user() will be evaluated to 'alice' for this query