Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-23.2: sql/delegate: don't include external connections in SHOW SYSTEM GRANTS #122905

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/sql/delegate/show_grants.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ SELECT a.username AS grantee,
FROM (
SELECT username, unnest(privileges) AS privilege
FROM crdb_internal.kv_system_privileges
WHERE path LIKE '/global%'
) AS a`
const externalConnectionPrivilegeQuery = `
SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,3 +671,33 @@ test public owner_grant_option admin ALL
test public owner_grant_option other_owner ALL true
test public owner_grant_option owner_grant_option_child SELECT false
test public owner_grant_option root ALL true

statement ok
CREATE USER roach;
CREATE TYPE mood AS enum ('sad','happy');
GRANT USAGE ON TYPE mood TO roach;
CREATE SEQUENCE test_sequence;
GRANT SELECT ON SEQUENCE test_sequence TO roach;
CREATE EXTERNAL CONNECTION connection1 AS 'nodelocal://1/foo';
GRANT USAGE ON EXTERNAL CONNECTION connection1 TO roach WITH GRANT OPTION;
GRANT SYSTEM VIEWCLUSTERSETTING TO roach WITH GRANT OPTION;
GRANT SYSTEM VIEWACTIVITY TO roach;

# The purpose of this test is to verify the object_type column.
query TTTTTTB colnames,rowsort
SHOW GRANTS FOR roach
----
database_name schema_name object_name object_type grantee privilege_type is_grantable
NULL NULL connection1 external_connection roach USAGE true
test public mood type roach USAGE false
test public test_sequence sequence roach SELECT false

# Verify that only system grants appear in SHOW SYSTEM GRANTS. Previously,
# there was a bug that would cause external connection privileges to appear
# also, since those privileges are also implemented with synthetic privileges.
query TTB colnames,rowsort
SHOW SYSTEM GRANTS FOR roach
----
grantee privilege_type is_grantable
roach VIEWACTIVITY false
roach VIEWCLUSTERSETTING true
18 changes: 0 additions & 18 deletions pkg/sql/logictest/testdata/logic_test/role
Original file line number Diff line number Diff line change
Expand Up @@ -1865,21 +1865,3 @@ statement ok
DROP ROLE creator_of_databases

subtest end

# The purpose of this test is to verify the object_type column
statement ok
create user roach;
create type mood as enum ('sad','happy');
grant usage on type mood to roach;
create sequence test_sequence;
grant usage on sequence test_sequence to roach;
CREATE EXTERNAL CONNECTION connection1 AS 'nodelocal://1/foo';
grant usage on EXTERNAL CONNECTION connection1 to roach;

query TTTTTTB colnames,rowsort
show grants for roach
----
database_name schema_name object_name object_type grantee privilege_type is_grantable
NULL NULL connection1 external_connection roach USAGE false
test public mood type roach USAGE false
test public test_sequence sequence roach USAGE false