mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Allow GRANTED BY clause in normal GRANT and REVOKE statements
The SQL standard allows a GRANTED BY clause on GRANT and REVOKE (privilege) statements that can specify CURRENT_USER or CURRENT_ROLE. In PostgreSQL, both of these are the default behavior. Since we already have all the parsing support for this for the GRANT (role) statement, we might as well add basic support for this for the privilege variant as well. This allows us to check off SQL feature T332. In the future, perhaps more interesting things could be done with this, too. Reviewed-by: Simon Riggs <simon@2ndquadrant.com> Discussion: https://www.postgresql.org/message-id/flat/f2feac44-b4c5-f38f-3699-2851d6a76dc9@2ndquadrant.com
This commit is contained in:
@@ -6772,7 +6772,7 @@ opt_from_in: from_in
|
||||
*****************************************************************************/
|
||||
|
||||
GrantStmt: GRANT privileges ON privilege_target TO grantee_list
|
||||
opt_grant_grant_option
|
||||
opt_grant_grant_option opt_granted_by
|
||||
{
|
||||
GrantStmt *n = makeNode(GrantStmt);
|
||||
n->is_grant = true;
|
||||
@@ -6782,13 +6782,14 @@ GrantStmt: GRANT privileges ON privilege_target TO grantee_list
|
||||
n->objects = ($4)->objs;
|
||||
n->grantees = $6;
|
||||
n->grant_option = $7;
|
||||
n->grantor = $8;
|
||||
$$ = (Node*)n;
|
||||
}
|
||||
;
|
||||
|
||||
RevokeStmt:
|
||||
REVOKE privileges ON privilege_target
|
||||
FROM grantee_list opt_drop_behavior
|
||||
FROM grantee_list opt_granted_by opt_drop_behavior
|
||||
{
|
||||
GrantStmt *n = makeNode(GrantStmt);
|
||||
n->is_grant = false;
|
||||
@@ -6798,11 +6799,12 @@ RevokeStmt:
|
||||
n->objtype = ($4)->objtype;
|
||||
n->objects = ($4)->objs;
|
||||
n->grantees = $6;
|
||||
n->behavior = $7;
|
||||
n->grantor = $7;
|
||||
n->behavior = $8;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| REVOKE GRANT OPTION FOR privileges ON privilege_target
|
||||
FROM grantee_list opt_drop_behavior
|
||||
FROM grantee_list opt_granted_by opt_drop_behavior
|
||||
{
|
||||
GrantStmt *n = makeNode(GrantStmt);
|
||||
n->is_grant = false;
|
||||
@@ -6812,7 +6814,8 @@ RevokeStmt:
|
||||
n->objtype = ($7)->objtype;
|
||||
n->objects = ($7)->objs;
|
||||
n->grantees = $9;
|
||||
n->behavior = $10;
|
||||
n->grantor = $10;
|
||||
n->behavior = $11;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
;
|
||||
|
Reference in New Issue
Block a user