Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
95461: ui: remove reset sql stats for non-admin r=maryliag a=maryliag

Continuation from #95303

The previous PR missed the reset on the Transactions tab. This PR removes the reset sql stats for non-admin users.

Fixes #95213

Release note (ui change): Remove `reset sql stats` from Transactions page for non-admins.

95466: ingesting: fixup privileges granted during database restore r=rafiss a=adityamaru

Previously, all schemas and tables that were ingested as part of a database restore would "inherit" the privileges of the database. The database would be granted `CONNECT` for the `public` role and `ALL` to `admin` and `root`, and so all ingested schemas would have `ALL` for `admin` and `root`. Since 21.2 we have moved away from tables/schemas inheriting privileges from the parent database and so this logic is stale and partly incorrect. It is incorrect because the restored `public` schema does not have `CREATE` and `USAGE` granted to the `public` role. These privileges are always granted to `public` schemas of a database and so there is a discrepancy in restore's behaviour.

This change simplifies the logic to grant schemas and tables their default set of privileges if ingested via a database restore. It leaves the logic for cluster and table restores unchanged.

Release note (bug fix): fixes a bug where a database restore would not grant `CREATE` and `USAGE` on the public schema to the public role

Fixes: #95456

95467: schemachanger: a bunch of small fixes r=postamar a=postamar

Informs #88294.

Release note: None

95504: schemachangerccl: rename generated tests r=postamar a=postamar

This commit adds an underscore in the generated tests' name where there previously was one missing.

Informs #88294.

Release note: None

95512: kvserver: fix flaky TestLearnerReplicateQueueRace test r=tbg a=aliher1911

Test was not expecting raft snapshots and injected failure at wrong moments.

Fixes #94993

Release note: None

Co-authored-by: maryliag <[email protected]>
Co-authored-by: adityamaru <[email protected]>
Co-authored-by: Marius Posta <[email protected]>
Co-authored-by: Oleg Afanasyev <[email protected]>
  • Loading branch information
5 people committed Jan 19, 2023
6 parents 38407a0 + 4b6d9d8 + 05cfdac + fc10b6d + eff5075 + 41b07fa commit f27fa9d
Show file tree
Hide file tree
Showing 74 changed files with 857 additions and 559 deletions.
1 change: 1 addition & 0 deletions docs/generated/sql/bnf/explainable_stmt.bnf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
explainable_stmt ::=
preparable_stmt
| comment_stmt
| execute_stmt
1 change: 1 addition & 0 deletions docs/generated/sql/bnf/stmt_block.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ drop_tenant_stmt ::=

explainable_stmt ::=
preparable_stmt
| comment_stmt
| execute_stmt

explain_option_list ::=
Expand Down
10 changes: 8 additions & 2 deletions pkg/ccl/backupccl/testdata/backup-restore/restore-grants
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ query-sql
SHOW GRANTS ON SCHEMA testdb.public
----
testdb public admin ALL true
testdb public public CREATE false
testdb public public USAGE false
testdb public root ALL true

query-sql
Expand Down Expand Up @@ -554,8 +556,9 @@ query-sql
SHOW GRANTS ON SCHEMA testdb.public
----
testdb public admin ALL true
testdb public public CREATE false
testdb public public USAGE false
testdb public root ALL true
testdb public testuser ALL true

query-sql
SHOW GRANTS ON testdb.sc.othertable
Expand Down Expand Up @@ -603,10 +606,13 @@ SELECT owner FROM [SHOW SCHEMAS] WHERE schema_name = 'sc'
----
testuser

# In postgres, the user "postgres" is the owner of the public schema in a
# newly created db. In CockroachDB, admin is our substitute for the postgres
# user.
query-sql
SELECT owner FROM [SHOW SCHEMAS] WHERE schema_name = 'public'
----
testuser
admin

# Ensure that testuser is the owner of the type.
query-sql
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/schemachangerccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ sctest_gen(
ccl = True,
new_cluster_func = "newCluster",
package = "schemachangerccl",
suffix = "base",
suffix = "_base",
test_data = [
"//pkg/sql/schemachanger:end_to_end_testdata",
],
Expand All @@ -68,7 +68,7 @@ sctest_gen(
ccl = True,
new_cluster_func = "newCluster",
package = "schemachangerccl",
suffix = "ccl",
suffix = "_ccl",
test_data = glob(["testdata/end_to_end/**"]),
tests = [
"Backup",
Expand Down
48 changes: 24 additions & 24 deletions pkg/ccl/schemachangerccl/backup_base_generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions pkg/ccl/schemachangerccl/ccl_generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ add synthetic descriptor #108:
version: "1"
# end StatementPhase
# begin PreCommitPhase
## PreCommitPhase stage 1 of 1 with 23 MutationType ops
delete all comments for table descriptor 108
## PreCommitPhase stage 1 of 1 with 22 MutationType ops
delete database namespace entry {0 0 multi_region_test_db} -> 104
delete schema namespace entry {104 0 public} -> 105
delete object namespace entry {104 105 crdb_internal_region} -> 106
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ add synthetic descriptor #108:
version: "1"
# end StatementPhase
# begin PreCommitPhase
## PreCommitPhase stage 1 of 1 with 15 MutationType ops
delete all comments for table descriptor 108
## PreCommitPhase stage 1 of 1 with 14 MutationType ops
delete object namespace entry {104 105 table_regional_by_row} -> 108
upsert descriptor #106
type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ add synthetic descriptor #108:
version: "1"
# end StatementPhase
# begin PreCommitPhase
## PreCommitPhase stage 1 of 1 with 10 MutationType ops
delete all comments for table descriptor 108
## PreCommitPhase stage 1 of 1 with 9 MutationType ops
delete object namespace entry {104 105 table_regional_by_table} -> 108
upsert descriptor #106
type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,14 @@ Schema change plan for DROP DATABASE ‹multi_region_test_db› CASCADE;
│ │ ├── PUBLIC → ABSENT IndexColumn:{DescID: 108, ColumnID: 1, IndexID: 1}
│ │ ├── VALIDATED → ABSENT PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1}
│ │ └── PUBLIC → ABSENT IndexName:{DescID: 108, Name: table_regional_by_table_pkey, IndexID: 1}
│ └── 23 Mutation operations
│ └── 22 Mutation operations
│ ├── MarkDescriptorAsDropped {"DescriptorID":104}
│ ├── RemoveDatabaseRoleSettings {"DatabaseID":104}
│ ├── MarkDescriptorAsDropped {"DescriptorID":105}
│ ├── RemoveSchemaParent {"Parent":{"ParentDatabaseID":104,"SchemaID":105}}
│ ├── MarkDescriptorAsDropped {"DescriptorID":106}
│ ├── MarkDescriptorAsDropped {"DescriptorID":107}
│ ├── MarkDescriptorAsDropped {"DescriptorID":108}
│ ├── RemoveAllTableComments {"TableID":108}
│ ├── RemoveBackReferenceInTypes {"BackReferencedDescriptorID":108}
│ ├── DrainDescriptorName {"Namespace":{"DescriptorID":104,"Name":"multi_region_tes..."}}
│ ├── DrainDescriptorName {"Namespace":{"DatabaseID":104,"DescriptorID":105,"Name":"public"}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ Schema change plan for DROP TABLE ‹multi_region_test_db›.‹public›.‹tab
│ │ ├── VALIDATED → ABSENT PrimaryIndex:{DescID: 108, IndexID: 1, ConstraintID: 1}
│ │ ├── PUBLIC → ABSENT IndexPartitioning:{DescID: 108, IndexID: 1}
│ │ └── PUBLIC → ABSENT IndexName:{DescID: 108, Name: table_regional_by_row_pkey, IndexID: 1}
│ └── 15 Mutation operations
│ └── 14 Mutation operations
│ ├── MarkDescriptorAsDropped {"DescriptorID":108}
│ ├── RemoveAllTableComments {"TableID":108}
│ ├── RemoveColumnDefaultExpression {"ColumnID":2,"TableID":108}
│ ├── UpdateTableBackReferencesInTypes {"BackReferencedTableID":108}
│ ├── DrainDescriptorName {"Namespace":{"DatabaseID":104,"DescriptorID":108,"Name":"table_regional_b...","SchemaID":105}}
Expand Down
Loading

0 comments on commit f27fa9d

Please sign in to comment.