GRANT (User Defined Extension)
Grants privileges on user-defined extensions to users and roles.
Syntax
GRANT privilege ON { UDx‑type [[database.]schema.]function‑name( [argument‑list] )[,…] | ALL FUNCTIONS IN SCHEMA schema[,…] } TO grantee[,…] [ WITH GRANT OPTION ]
Parameters
| privilege |
One of the following:
|
ON UDx‑type
|
Specifies the function's user-defined extension (UDx) type, where UDx‑type is one of the following:
|
[database.]schema
|
Specifies a schema, by default myschema.thisDbObject If you specify a database, it must be the current database. |
| function‑name | Name of the user-defined function on which to grant privileges. |
ON ALL FUNCTIONS IN SCHEMA schema
|
Grants privileges on all functions in the specified schema. |
| argument-list |
Required for all polymorphic functions, a comma-delimited list of function arguments, where each argument is specified as follows: [ argname ] argtype If the procedure is defined with no arguments, supply an empty argument list. |
| grantee |
Specifies who is granted privileges, one of the following: Note: Grantees must have |
WITH GRANT OPTION
|
Gives grantee the privilege to grant the same privileges to other users or roles. For details, see How to Grant Privileges in the Administrator's Guide. |
Privileges
All grantees must have USAGE privileges on the schema, and be one of the following:
- Superuser or owner of the target function
- Privileges grantee who was given the option (
WITH GRANT OPTION) of extending these privileges to other users
Examples
Grant EXECUTE privileges on the myzeroifnull SQL function to users Bob and Jules, and to the role Operator. The function takes one integer argument:
=> GRANT EXECUTE ON FUNCTION myzeroifnull (x INT) TO Bob, Jules, Operator;
Grant EXECUTE privileges on all functions in the zero-schema schema to user Bob:
=> GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA zero-schema TO Bob;
Grant EXECUTE privileges on the tokenize transform function to user Bob and the role Operator:
=> GRANT EXECUTE ON TRANSFORM FUNCTION tokenize(VARCHAR) TO Bob, Operator;
Grant EXECUTE privileges on the ExampleSource() source to user Alice:
=> CREATE USER Alice;
=> GRANT USAGE ON SCHEMA hdfs TO Alice;
=> GRANT EXECUTE ON SOURCE ExampleSource() TO Alice;
Grant all privileges on the ExampleSource() source to user Alice:
=> GRANT ALL ON SOURCE ExampleSource() TO Alice;
Grant all privileges on polymorphic function Pagerank to the dbadmin role:
=> GRANT ALL ON TRANSFORM FUNCTION Pagerank(z varchar) to dbadmin;
See Also
- REVOKE (User Defined Extension)
- Granting and Revoking Privileges in the Administrator's Guide
- Developing User-Defined Extensions (UDxs) in Extending Vertica