-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
104119: sql: SHOW GRANTS includes inherited roles r=postamar a=postamar Previously, SHOW GRANTS would only list explicitly-granted privileges. This commit changes its output to include privileges inherited by role membership. Consider for example: CREATE DATABASE d1; CREATE ROLE r1; CREATE USER u1; GRANT r1 TO u1; SET database = d1; CREATE TABLE t1 (id INT8); GRANT ALL ON TABLE t1 TO r1; We want `SHOW GRANTS ON TABLE t1 FOR u1` to list the ALL privilege that u1 inherits from r1. For this purpose this commit also adds a new `kv_inherited_role_members` virtual table in `crdb_internal` which is essentially a recursive self-join of `system.role_members` run by the node user. This commit also changes the output of `SHOW GRANTS ON ROLE` to list both explicit and implicit grantees: the former are the direct result of a `GRANT ... TO ...` statement, the latter comprise also all the roles which inherit the privileges following further role membership relationships. For this purpose it also uses the new virtual table and therefore the current user no longer requires SELECT privileges on the `system.role_members` table. Fixes #97299. Release note (sql change): SHOW GRANTS now lists not just privileges explicitly granted to each role, but also roles which inherit from those. SHOW GRANTS ON ROLE statements no longer require any privileges and also lists implicit grantees. Co-authored-by: Marius Posta <[email protected]>
- Loading branch information
Showing
24 changed files
with
1,835 additions
and
711 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.