PG_HAS_ROLE
Return true
if a user can access a role with MEMBER
or USAGE
privilege.
PG_HAS_ROLE([user,] role, privilege)
If the user
name is omitted, the function returns results for the current user.
Valid privilege values are:
MEMBER
: whether the user has direct or indirect membership in the role (the right to do SET ROLE).USAGE
: whether the privileges of the role are immediately available (without doing SET ROLE).
Note: This function cannot be used in a query that has a FROM clause (in other words, a query that selects from tables).
premdb=# select pg_has_role('bobr','member');
pg_has_role
-------------
t
(1 row)
premdb=# select pg_has_role('bobr','bobr','member');
pg_has_role
-------------
t
(1 row)
Parent topic:System Functions