Skip to content

Commit e68570e

Browse files
Revert b2a459e "Fix GRANTED BY support in REVOKE ROLE statements"
The reverted commit attempted to fix SQL specification compliance for the cases which 6aaaa76 left. This however broke existing behavior which takes precedence over spec compliance so revert. The introduced tests are left after the revert since the codepath isn't well covered. Per bug report 17346. Backpatch down to 14 where it was introduced. Reported-by: Andrew Bille <andrewbille@gmail.com> Discussion: https://postgr.es/m/17346-f72b28bd1a341060@postgresql.org
1 parent 8112bcf commit e68570e

File tree

3 files changed

+0
-15
lines changed

3 files changed

+0
-15
lines changed

src/backend/commands/user.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,18 +1259,7 @@ GrantRole(GrantRoleStmt *stmt)
12591259
ListCell *item;
12601260

12611261
if (stmt->grantor)
1262-
{
12631262
grantor = get_rolespec_oid(stmt->grantor, false);
1264-
1265-
/*
1266-
* Currently, this clause is only for SQL compatibility, not very
1267-
* interesting otherwise.
1268-
*/
1269-
if (grantor != GetUserId())
1270-
ereport(ERROR,
1271-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1272-
errmsg("grantor must be current user")));
1273-
}
12741263
else
12751264
grantor = GetUserId();
12761265

src/backend/parser/gram.y

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7284,7 +7284,6 @@ RevokeRoleStmt:
72847284
n->admin_opt = false;
72857285
n->granted_roles = $2;
72867286
n->grantee_roles = $4;
7287-
n->grantor = $5;
72887287
n->behavior = $6;
72897288
$$ = (Node*)n;
72907289
}
@@ -7295,7 +7294,6 @@ RevokeRoleStmt:
72957294
n->admin_opt = true;
72967295
n->granted_roles = $5;
72977296
n->grantee_roles = $7;
7298-
n->grantor = $8;
72997297
n->behavior = $9;
73007298
$$ = (Node*)n;
73017299
}

src/test/regress/expected/privileges.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ ALTER FUNCTION leak(integer,integer) OWNER TO regress_priv_user1;
6969
-- test owner privileges
7070
GRANT regress_priv_role TO regress_priv_user1 WITH ADMIN OPTION GRANTED BY CURRENT_ROLE;
7171
REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY foo; -- error
72-
ERROR: role "foo" does not exist
7372
REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY regress_priv_user2; -- error
74-
ERROR: grantor must be current user
7573
REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY CURRENT_USER;
7674
REVOKE regress_priv_role FROM regress_priv_user1 GRANTED BY CURRENT_ROLE;
7775
DROP ROLE regress_priv_role;

0 commit comments

Comments
 (0)