Contents
has_tablespace_privilege()
A system function determining whether a user has a privilege for a tablespace
has_tablespace_privilege()
is a system function determining whether a user has the specified privilege for the specified tablespace.
has_tablespace_privilege()
was added in PostgreSQL 8.0.
Usage
has_tablespace_privilege()
has two forms:
has_tablespace_privilege(tablespace TEXT or OID, privilege TEXT)
has_tablespace_privilege(user TEXT or OID, tablespace TEXT or OID, privilege TEXT)
The only privilege which can be queried with has_tablespace_privilege()
is: CREATE
.
Change history
- PostgreSQL 8.0
- added (commit e47cbb3b)
Examples
Determine if the current user has the CREATE
privilege for the specified tablespace:
postgres=# SELECT has_tablespace_privilege('tblspc_1', 'CREATE'); has_tablespace_privilege -------------------------- t (1 row)
Determine if the specified user has the CREATE
privilege for the specified tablespace:
postgres=# SELECT has_tablespace_privilege('foo', 'tblspc_2', 'CREATE'); has_tablespace_privilege -------------------------- f (1 row)
Privileges other than CREATE
are not recognized:
postgres=# SELECT has_tablespace_privilege('tblspc_1', 'DELETE'); ERROR: unrecognized privilege type: "DELETE"
Attempting to determine privileges for a non-existent tablespace:
postgres=# SELECT has_tablespace_privilege('tblspc_foo', 'CREATE'); ERROR: tablespace "tblspc_foo" does not exist
References
- PostgreSQL documentation: Access Privilege Inquiry Functions