Skip to content

Commit

Permalink
sql: standardize column names in SHOW GRANTS
Browse files Browse the repository at this point in the history
Release note (sql change): The SHOW GRANTS ON EXTERNAL CONNECTION and
SHOW SYSTEM GRANTS commands now use a column name of `privilege_type`
rather than `privilege`. For external connections, the `name` column was
changed to `connection_name`. This makes the commands consistent with other
SHOW GRANTS commands.
  • Loading branch information
rafiss committed Jan 19, 2023
1 parent 38407a0 commit 09290f5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions pkg/sql/delegate/show_grants.go
Expand Up @@ -66,7 +66,7 @@ SELECT type_catalog AS database_name,
FROM "".information_schema.type_privileges`
const systemPrivilegeQuery = `
SELECT a.username AS grantee,
privilege,
privilege AS privilege_type,
a.privilege
IN (
SELECT unnest(grant_options)
Expand All @@ -81,15 +81,15 @@ SELECT a.username AS grantee,
const externalConnectionPrivilegeQuery = `
SELECT *
FROM (
SELECT name,
SELECT name AS connection_name,
a.username AS grantee,
privilege,
privilege AS privilege_type,
a.privilege
IN (
SELECT unnest(grant_options)
FROM system.privileges
WHERE username = a.username
) AS grantable
) AS is_grantable
FROM (
SELECT regexp_extract(
path,
Expand Down
Expand Up @@ -84,20 +84,20 @@ GRANT DROP, USAGE ON EXTERNAL CONNECTION foo TO testuser2 WITH GRANT OPTION
query TTTB colnames
SHOW GRANTS ON EXTERNAL CONNECTION foo
----
name grantee privilege grantable
foo bar DROP false
foo bar USAGE false
foo root ALL false
foo testuser DROP true
foo testuser USAGE true
foo testuser2 DROP true
foo testuser2 USAGE true
connection_name grantee privilege_type is_grantable
foo bar DROP false
foo bar USAGE false
foo root ALL false
foo testuser DROP true
foo testuser USAGE true
foo testuser2 DROP true
foo testuser2 USAGE true

query TTTB colnames
SHOW GRANTS ON EXTERNAL CONNECTION foo FOR testuser, testuser2
----
name grantee privilege grantable
foo testuser DROP true
foo testuser USAGE true
foo testuser2 DROP true
foo testuser2 USAGE true
connection_name grantee privilege_type is_grantable
foo testuser DROP true
foo testuser USAGE true
foo testuser2 DROP true
foo testuser2 USAGE true
12 changes: 6 additions & 6 deletions pkg/sql/logictest/testdata/logic_test/show_grants_synthetic
Expand Up @@ -10,15 +10,15 @@ GRANT SYSTEM EXTERNALCONNECTION TO testuser WITH GRANT OPTION
query TTB colnames
SHOW SYSTEM GRANTS
----
grantee privilege is_grantable
grantee privilege_type is_grantable
testuser EXTERNALCONNECTION true
testuser MODIFYCLUSTERSETTING false
testuser VIEWACTIVITY false

query TTB colnames
SHOW SYSTEM GRANTS FOR testuser
----
grantee privilege is_grantable
grantee privilege_type is_grantable
testuser EXTERNALCONNECTION true
testuser MODIFYCLUSTERSETTING false
testuser VIEWACTIVITY false
Expand All @@ -29,7 +29,7 @@ REVOKE SYSTEM VIEWACTIVITY FROM testuser
query TTB colnames
SHOW SYSTEM GRANTS
----
grantee privilege is_grantable
grantee privilege_type is_grantable
testuser EXTERNALCONNECTION true
testuser MODIFYCLUSTERSETTING false

Expand All @@ -45,7 +45,7 @@ GRANT SYSTEM EXTERNALCONNECTION TO testuser2
query TTB colnames
SHOW SYSTEM GRANTS
----
grantee privilege is_grantable
grantee privilege_type is_grantable
testuser EXTERNALCONNECTION true
testuser MODIFYCLUSTERSETTING false
testuser2 EXTERNALCONNECTION false
Expand All @@ -54,14 +54,14 @@ testuser2 VIEWACTIVITY true
query TTB colnames
SHOW SYSTEM GRANTS FOR testuser2
----
grantee privilege is_grantable
grantee privilege_type is_grantable
testuser2 EXTERNALCONNECTION false
testuser2 VIEWACTIVITY true

query TTB colnames
SHOW SYSTEM GRANTS FOR testuser, testuser2
----
grantee privilege is_grantable
grantee privilege_type is_grantable
testuser EXTERNALCONNECTION true
testuser MODIFYCLUSTERSETTING false
testuser2 EXTERNALCONNECTION false
Expand Down

0 comments on commit 09290f5

Please sign in to comment.