Contents
has_type_privilege()
A system function determining whether a user has a privilege for a data type
has_type_privilege()
is a system function determining whether a user has a privilege for a particular data type.
was added in PostgreSQL 9.2.has_type_privilege()
Usage
has_type_privilege()
has two forms:
has_type_privilege(type TEXT or OID, privilege TEXT)
has_type_privilege(user TEXT or OID, type TEXT or OID, privilege TEXT)
The only privilege which can be queried with has_type_privilege()
is: USAGE
.
Type and privilege specifications are case-insensitive.
Change history
- PostgreSQL 9.2
- added (commit 72920557)
Examples
Determine if the current user has the USAGE
privilege for the TEXT
data type:
postgres=# SELECT has_type_privilege('TEXT', 'USAGE'); has_type_privilege -------------------- t (1 row)
Determine if the specified user has the USAGE
privilege for the VARCHAR
data type:
postgres=# SELECT has_type_privilege('someuser', 'character varying', 'usage'); has_type_privilege -------------------- t (1 row)
Attempting to determine an unrecognized privilege for this object type:
postgres=# SELECT has_type_privilege('TEXT', 'UPDATE'); ERROR: unrecognized privilege type: "UPDATE"
Attempting to determine privileges for a non-existent data type:
postgres=# SELECT has_type_privilege('MEGABLOB', 'UPDATE'); ERROR: type "megablob" does not exist Time: 0.389 ms
References
- PostgreSQL documentation: Access Privilege Inquiry Functions