cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.12k stars 3.81k forks source link

workload/schemachange: add role operations #54938

Open ajwerner opened 4 years ago

ajwerner commented 4 years ago

Is your feature request related to a problem? Please describe.

We should add operations that interact with roles to the random schema change workload. I envision that this will look like at least the below operations.

diff --git a/pkg/workload/schemachange/schemachange.go b/pkg/workload/schemachange/schemachange.go
index 42bfc6a4cc..9917730b71 100644
--- a/pkg/workload/schemachange/schemachange.go
+++ b/pkg/workload/schemachange/schemachange.go
@@ -116,6 +116,7 @@ const (
        createTableAs  // CREATE TABLE <table> AS <def>
        createView     // CREATE VIEW <view> AS <def>
        createEnum     // CREATE TYPE <type> ENUM AS <def>
+       createRole     // CREATE ROLE [IF NOT EXISTS] <name> [ [WITH] <OPTIONS...> ]

        dropColumn        // ALTER TABLE <table> DROP COLUMN <column>
        dropColumnDefault // ALTER TABLE <table> ALTER [COLUMN] <column> DROP DEFAULT
@@ -138,6 +139,12 @@ const (
        setColumnType    // ALTER TABLE <table> ALTER [COLUMN] <column> [SET DATA] TYPE <type>

        insertRow // INSERT INTO <table> (<cols>) VALUES (<values>)
+
+       grantPrivilege // GRANT {ALL | <privileges...> } ON <targets...> TO <grantees...>
+       grantRole      // GRANT <roles...> TO <grantees...> [WITH ADMIN OPTION]
+
+       revokePrivilege // REVOKE {ALL | <privileges...> } ON <targets...> FROM <grantees...>
+       revokeRole      // REVOKE [ADMIN OPTION FOR] <roles...> FROM <grantees...>
 )

We can also have transactions execute SET LOCAL ROLE = random_role_name at the beginning of the transaction, with some probability.

Jira issue: CRDB-3703

Epic CRDB-19168

blathers-crl[bot] commented 4 years ago

Hi @ajwerner, I've guessed the C-ategory of your issue and suitably labeled it. Please re-label if inaccurate.

While you're here, please consider adding an A- label to help keep our repository tidy.

:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.