Skip to content

Commit

Permalink
Merge pull request cockroachdb#102730 from e-mbrown/backport22.2-102712
Browse files Browse the repository at this point in the history
release-22.2: sql: fix alter default privileges on sequence bug
  • Loading branch information
e-mbrown authored May 2, 2023
2 parents 7210a62 + d1eed89 commit 1b11ca6
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 43 deletions.
2 changes: 1 addition & 1 deletion pkg/sql/alter_default_privileges.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

var targetObjectToPrivilegeObject = map[privilege.TargetObjectType]privilege.ObjectType{
privilege.Tables: privilege.Table,
privilege.Sequences: privilege.Table,
privilege.Sequences: privilege.Sequence,
privilege.Types: privilege.Type,
privilege.Schemas: privilege.Schema,
privilege.Functions: privilege.Function,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,32 @@ SHOW GRANTS FOR testuser3
database_name schema_name relation_name grantee privilege_type is_grantable
test s2 q testuser3 ALL false
test s2 t testuser3 ALL false

statement ok
ALTER DEFAULT PRIVILEGES FOR ALL ROLES GRANT USAGE ON SEQUENCES TO testuser3;

statement ok
CREATE SCHEMA s3;
CREATE SCHEMA s4;
CREATE SEQUENCE s3.q;
CREATE SEQUENCE s4.q;

query TTTTTB colnames
SHOW GRANTS FOR testuser, testuser2
----
database_name schema_name relation_name grantee privilege_type is_grantable
test s q testuser ALL false
test s q testuser2 ALL false
test s2 q testuser ALL false
test s2 q testuser2 ALL false



query TTTTTB colnames
SHOW GRANTS FOR testuser3
----
database_name schema_name relation_name grantee privilege_type is_grantable
test s2 q testuser3 ALL false
test s2 t testuser3 ALL false
test s3 q testuser3 USAGE false
test s4 q testuser3 USAGE false
64 changes: 32 additions & 32 deletions pkg/sql/logictest/testdata/logic_test/pg_catalog_pg_default_acl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
456512573 1546506610 0 r {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*U*a*d*r*w*/,foo=C*U*a*d*r*w*/,=r/}
456512573 1546506610 0 T {bar=U*/,foo=U*/}
456512573 1546506610 0 n {bar=C*U*/,foo=C*U*/,=U/}
456512573 1546506610 0 f {bar=X*/,foo=X*/,=X/}
Expand All @@ -53,17 +53,17 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/,foo=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,foo=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/,foo=C*U*/}
625980300 1791217281 0 f {bar=X*/,foo=X*/}
1062786855 2026795574 0 r {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {bar=C*U*a*d*r*w*/,foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {bar=U*/,foo=U*/,=U/}
1062786855 2026795574 0 n {bar=C*U*/,foo=C*U*/}
1062786855 2026795574 0 f {bar=X*/,foo=X*/}
456512573 1546506610 0 r {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*U*a*d*r*w*/,foo=C*U*a*d*r*w*/,=r/}
456512573 1546506610 0 T {bar=U*/,foo=U*/}
456512573 1546506610 0 n {bar=C*U*/,foo=C*U*/,=U/}
456512573 1546506610 0 f {bar=X*/,foo=X*/,=X/}
Expand Down Expand Up @@ -92,7 +92,7 @@ oid defaclrole defaclnamespace defaclobjtype defaclacl
1062786855 2026795574 0 n {}
1062786855 2026795574 0 f {}
456512573 1546506610 0 r {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*U*a*d*r*w*/,foo=C*U*a*d*r*w*/,=r/}
456512573 1546506610 0 T {bar=U*/,foo=U*/}
456512573 1546506610 0 n {bar=C*U*/,foo=C*U*/,=U/}
456512573 1546506610 0 f {bar=X*/,foo=X*/,=X/}
Expand All @@ -116,17 +116,17 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/}
625980300 1791217281 0 f {bar=X*/}
1062786855 2026795574 0 r {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {foo=U*/,=U/}
1062786855 2026795574 0 n {foo=C*U*/}
1062786855 2026795574 0 f {foo=X*/}
456512573 1546506610 0 r {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*U*a*d*r*w*/,foo=C*U*a*d*r*w*/,=r/}
456512573 1546506610 0 T {bar=U*/,foo=U*/}
456512573 1546506610 0 n {bar=C*U*/,foo=C*U*/,=U/}
456512573 1546506610 0 f {bar=X*/,foo=X*/,=X/}
Expand All @@ -141,17 +141,17 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/}
625980300 1791217281 0 f {bar=X*/}
1062786855 2026795574 0 r {foo=C*a*d*w*/}
1062786855 2026795574 0 S {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {foo=U*/,=U/}
1062786855 2026795574 0 n {foo=C*U*/}
1062786855 2026795574 0 f {foo=X*/}
456512573 1546506610 0 r {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*U*a*d*r*w*/,foo=C*U*a*d*r*w*/,=r/}
456512573 1546506610 0 T {bar=U*/,foo=U*/}
456512573 1546506610 0 n {bar=C*U*/,foo=C*U*/,=U/}
456512573 1546506610 0 f {bar=X*/,foo=X*/,=X/}
Expand All @@ -164,17 +164,17 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/}
625980300 1791217281 0 f {bar=X*/}
1062786855 2026795574 0 r {foo=C*a*d*rw*/}
1062786855 2026795574 0 S {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {foo=U*/,=U/}
1062786855 2026795574 0 n {foo=C*U*/}
1062786855 2026795574 0 f {foo=X*/}
456512573 1546506610 0 r {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/,=r/}
456512573 1546506610 0 S {bar=C*U*a*d*r*w*/,foo=C*U*a*d*r*w*/,=r/}
456512573 1546506610 0 T {bar=U*/,foo=U*/}
456512573 1546506610 0 n {bar=C*U*/,foo=C*U*/,=U/}
456512573 1546506610 0 f {bar=X*/,foo=X*/,=X/}
Expand All @@ -193,12 +193,12 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/}
625980300 1791217281 0 f {bar=X*/}
1062786855 2026795574 0 r {foo=C*a*d*rw*/}
1062786855 2026795574 0 S {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {foo=U*/,=U/}
1062786855 2026795574 0 n {foo=C*U*/}
1062786855 2026795574 0 f {foo=X*/}
Expand All @@ -214,12 +214,12 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/}
625980300 1791217281 0 f {bar=X*/}
1062786855 2026795574 0 r {foo=C*a*d*rw*/}
1062786855 2026795574 0 S {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {foo=U*/,=U/}
1062786855 2026795574 0 n {foo=C*U*/}
1062786855 2026795574 0 f {foo=X*/}
Expand All @@ -242,17 +242,17 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/}
625980300 1791217281 0 f {bar=X*/}
1062786855 2026795574 0 r {foo=C*a*d*rw*/}
1062786855 2026795574 0 S {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {foo=U*/,=U/}
1062786855 2026795574 0 n {foo=C*U*/}
1062786855 2026795574 0 f {foo=X*/}
2946850121 0 0 r {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/}
2946850121 0 0 S {bar=C*a*d*r*w*/,foo=C*a*d*r*w*/}
2946850121 0 0 S {bar=C*U*a*d*r*w*/,foo=C*U*a*d*r*w*/}
2946850121 0 0 T {bar=U*/,foo=U*/}
2946850121 0 0 n {bar=C*U*/,foo=C*U*/}
2946850121 0 0 f {bar=X*/,foo=X*/}
Expand All @@ -269,12 +269,12 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/}
625980300 1791217281 0 f {bar=X*/}
1062786855 2026795574 0 r {foo=C*a*d*rw*/}
1062786855 2026795574 0 S {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {foo=U*/,=U/}
1062786855 2026795574 0 n {foo=C*U*/}
1062786855 2026795574 0 f {foo=X*/}
Expand All @@ -295,12 +295,12 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/}
625980300 1791217281 0 f {bar=X*/}
1062786855 2026795574 0 r {foo=C*a*d*rw*/}
1062786855 2026795574 0 S {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {foo=U*/,=U/}
1062786855 2026795574 0 n {foo=C*U*/}
1062786855 2026795574 0 f {foo=X*/}
Expand All @@ -319,12 +319,12 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/}
625980300 1791217281 0 f {bar=X*/}
1062786855 2026795574 0 r {foo=C*a*d*rw*/}
1062786855 2026795574 0 S {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {foo=U*/,=U/}
1062786855 2026795574 0 n {foo=C*U*/}
1062786855 2026795574 0 f {foo=X*/}
Expand All @@ -345,12 +345,12 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/}
625980300 1791217281 0 f {bar=X*/}
1062786855 2026795574 0 r {foo=C*a*d*rw*/}
1062786855 2026795574 0 S {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {foo=U*/,=U/}
1062786855 2026795574 0 n {foo=C*U*/}
1062786855 2026795574 0 f {foo=X*/}
Expand All @@ -374,17 +374,17 @@ SELECT * FROM PG_CATALOG.PG_DEFAULT_ACL
----
oid defaclrole defaclnamespace defaclobjtype defaclacl
625980300 1791217281 0 r {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*a*d*r*w*/}
625980300 1791217281 0 S {bar=C*U*a*d*r*w*/}
625980300 1791217281 0 T {bar=U*/,=U/}
625980300 1791217281 0 n {bar=C*U*/}
625980300 1791217281 0 f {bar=X*/}
1062786855 2026795574 0 r {foo=C*a*d*rw*/}
1062786855 2026795574 0 S {foo=C*a*d*r*w*/}
1062786855 2026795574 0 S {foo=C*U*a*d*r*w*/}
1062786855 2026795574 0 T {foo=U*/,=U/}
1062786855 2026795574 0 n {foo=C*U*/}
1062786855 2026795574 0 f {foo=X*/}
2295354276 2264919399 0 r {foo=C*a*d*r*w*/}
2295354276 2264919399 0 S {foo=C*a*d*r*w*/}
2295354276 2264919399 0 S {foo=C*U*a*d*r*w*/}
2295354276 2264919399 0 T {foo=U*/,testuser=U*/}
2295354276 2264919399 0 n {foo=C*U*/}
2295354276 2264919399 0 f {foo=X*/}
Loading

0 comments on commit 1b11ca6

Please sign in to comment.