Skip to content

Commit

Permalink
sql: add new system.privileges table
Browse files Browse the repository at this point in the history
First step in upcoming privileges work.
Explained in RFC: cockroachdb#80580

Release note: None
  • Loading branch information
RichardJCai committed Jun 7, 2022
1 parent abc8afd commit 7775324
Show file tree
Hide file tree
Showing 49 changed files with 510 additions and 160 deletions.
2 changes: 1 addition & 1 deletion docs/generated/settings/settings-for-tenants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,4 @@ trace.jaeger.agent string the address of a Jaeger agent to receive traces using
trace.opentelemetry.collector string address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as <host>:<port>. If no port is specified, 4317 will be used.
trace.span_registry.enabled boolean true if set, ongoing traces can be seen at https://<ui>/#/debug/tracez
trace.zipkin.collector string the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.
version version 22.1-10 set the active cluster version in the format '<major>.<minor>'
version version 22.1-12 set the active cluster version in the format '<major>.<minor>'
2 changes: 1 addition & 1 deletion docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,6 @@
<tr><td><code>trace.opentelemetry.collector</code></td><td>string</td><td><code></code></td><td>address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as <host>:<port>. If no port is specified, 4317 will be used.</td></tr>
<tr><td><code>trace.span_registry.enabled</code></td><td>boolean</td><td><code>true</code></td><td>if set, ongoing traces can be seen at https://<ui>/#/debug/tracez</td></tr>
<tr><td><code>trace.zipkin.collector</code></td><td>string</td><td><code></code></td><td>the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>22.1-10</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>22.1-12</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
</tbody>
</table>
3 changes: 3 additions & 0 deletions pkg/ccl/backupccl/system_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ var systemTableBackupConfiguration = map[string]systemBackupConfiguration{
systemschema.SpanCountTable.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
systemschema.SystemPrivilegeTable.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
}

// GetSystemTablesToIncludeInClusterBackup returns a set of system table names that
Expand Down
6 changes: 5 additions & 1 deletion pkg/ccl/spanconfigccl/spanconfigcomparedccl/testdata/basic
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ configs version=current offset=41
/Table/46 database system (host)
/Table/47 database system (host)
/Table/50 database system (host)
/Table/51 database system (host)
/Table/106 num_replicas=7 num_voters=5
/Table/107 num_replicas=7

Expand All @@ -58,6 +59,7 @@ configs version=legacy offset=41
/Table/46 database system (host)
/Table/47 database system (host)
/Table/50 range system
/Table/51 range system
/Table/106 num_replicas=7 num_voters=5
/Table/107 num_replicas=7

Expand Down Expand Up @@ -112,11 +114,13 @@ diff
+/Table/38 range system
/Table/39 database system (host)
/Table/40 database system (host)
@@ -42,5 +42,5 @@
@@ -42,6 +42,6 @@
/Table/46 database system (host)
/Table/47 database system (host)
-/Table/50 range system
-/Table/51 range system
+/Table/50 database system (host)
+/Table/51 database system (host)
/Table/106 num_replicas=7 num_voters=5
/Table/107 num_replicas=7

Expand Down
19 changes: 19 additions & 0 deletions pkg/ccl/spanconfigccl/spanconfigcomparedccl/testdata/multitenant
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ configs version=current offset=43
----
...
/Table/50 database system (host)
/Table/51 database system (host)
/Tenant/10 database system (tenant)
/Tenant/11 database system (tenant)

Expand All @@ -27,6 +28,8 @@ diff offset=50
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
/Tenant/10 database system (tenant)
/Tenant/11 database system (tenant)

reconcile tenant=11
----
Expand All @@ -40,6 +43,8 @@ diff offset=48 limit=10
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
+/Table/50 database system (host)
+/Table/51 database system (host)
/Tenant/10 database system (tenant)
/Tenant/11 database system (tenant)

Expand All @@ -66,6 +71,8 @@ diff offset=48
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
+/Table/50 database system (host)
+/Table/51 database system (host)
/Tenant/10 database system (tenant)
/Tenant/11 database system (tenant)
+/Tenant/11/Table/106 range default
Expand All @@ -83,6 +90,8 @@ diff offset=48
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
+/Table/50 database system (host)
+/Table/51 database system (host)
/Tenant/10 database system (tenant)
/Tenant/11 database system (tenant)
+/Tenant/11/Table/106 range default
Expand All @@ -101,6 +110,8 @@ diff offset=48
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
+/Table/50 database system (host)
+/Table/51 database system (host)
/Tenant/10 database system (tenant)
/Tenant/11 database system (tenant)
+/Tenant/11/Table/106 range default
Expand All @@ -116,6 +127,8 @@ diff offset=48
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
+/Table/50 database system (host)
+/Table/51 database system (host)
/Tenant/10 database system (tenant)
/Tenant/11 database system (tenant)
+/Tenant/11/Table/106 range default
Expand All @@ -134,6 +147,8 @@ diff offset=48
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
+/Table/50 database system (host)
+/Table/51 database system (host)
/Tenant/10 database system (tenant)
/Tenant/11 database system (tenant)
+/Tenant/11/Table/106 range default
Expand All @@ -149,6 +164,8 @@ diff offset=48
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
+/Table/50 database system (host)
+/Table/51 database system (host)
/Tenant/10 database system (tenant)
/Tenant/11 database system (tenant)
+/Tenant/11/Table/106 range default
Expand All @@ -164,6 +181,8 @@ diff offset=48
--- gossiped system config span (legacy)
+++ span config infrastructure (current)
...
+/Table/50 database system (host)
+/Table/51 database system (host)
/Tenant/10 database system (tenant)
/Tenant/11 database system (tenant)
+/Tenant/11/Table/106 range default
Expand Down
4 changes: 4 additions & 0 deletions pkg/ccl/spanconfigccl/spanconfigreconcilerccl/testdata/basic
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ upsert /Table/4{5-6} ttl_seconds=7200 ignore_strict_gc=tru
upsert /Table/4{6-7} database system (host)
upsert /Table/4{7-8} database system (host)
upsert /Table/5{0-1} database system (host)
upsert /Table/5{1-2} database system (host)

exec-sql
CREATE DATABASE db;
Expand Down Expand Up @@ -92,6 +93,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/10{6-7} num_replicas=7 num_voters=5
/Table/10{7-8} num_replicas=7
/Table/11{2-3} num_replicas=7
Expand Down Expand Up @@ -183,6 +185,8 @@ delete /Table/4{7-8}
upsert /Table/4{7-8} ttl_seconds=100 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
delete /Table/5{0-1}
upsert /Table/5{0-1} ttl_seconds=100 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
delete /Table/5{1-2}
upsert /Table/5{1-2} ttl_seconds=100 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true

state offset=5 limit=42
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/10{6-7} range default

exec-sql
Expand All @@ -44,6 +45,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/106{-/2} num_replicas=7
/Table/106/{2-3} num_replicas=7 num_voters=5
/Table/10{6/3-7} num_replicas=7
Expand All @@ -68,6 +70,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/106{-/2} ttl_seconds=3600 num_replicas=7
/Table/106/{2-3} ttl_seconds=25 num_replicas=7 num_voters=5
/Table/10{6/3-7} ttl_seconds=3600 num_replicas=7
Expand All @@ -82,6 +85,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/106{-/2} ttl_seconds=3600 num_replicas=9
/Table/106/{2-3} ttl_seconds=25 num_replicas=9 num_voters=5
/Table/10{6/3-7} ttl_seconds=3600 num_replicas=9
Expand Down Expand Up @@ -110,3 +114,4 @@ state offset=46
...
/Table/4{7-8} database system (host)
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Tenant/10{-"\x00"} database system (tenant)
/Tenant/11{-"\x00"} database system (tenant)

Expand Down Expand Up @@ -68,11 +69,13 @@ upsert /Tenant/10/Table/4{3-4} database system (tenant)
upsert /Tenant/10/Table/4{4-5} database system (tenant)
upsert /Tenant/10/Table/4{6-7} database system (tenant)
upsert /Tenant/10/Table/5{0-1} database system (tenant)
upsert /Tenant/10/Table/5{1-2} database system (tenant)

state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Tenant/10{-/Table/4} database system (tenant)
/Tenant/10/Table/{4-5} database system (tenant)
/Tenant/10/Table/{5-6} database system (tenant)
Expand Down Expand Up @@ -108,6 +111,7 @@ state offset=47
/Tenant/10/Table/4{4-5} database system (tenant)
/Tenant/10/Table/4{6-7} database system (tenant)
/Tenant/10/Table/5{0-1} database system (tenant)
/Tenant/10/Table/5{1-2} database system (tenant)
/Tenant/11{-"\x00"} database system (tenant)

exec-sql tenant=10
Expand All @@ -131,8 +135,10 @@ upsert /Tenant/10/Table/11{3-4} range default
state offset=81
----
...
/Tenant/10/Table/4{4-5} database system (tenant)
/Tenant/10/Table/4{6-7} database system (tenant)
/Tenant/10/Table/5{0-1} database system (tenant)
/Tenant/10/Table/5{1-2} database system (tenant)
/Tenant/10/Table/10{6-7} range default
/Tenant/10/Table/10{7-8} range default
/Tenant/10/Table/11{2-3} range default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Tenant/10{-"\x00"} database system (tenant)

# Write a protected timestamp record on the system tenant cluster.
Expand Down Expand Up @@ -84,6 +85,7 @@ upsert /Tenant/10/Table/4{3-4} database system (tenant)
upsert /Tenant/10/Table/4{4-5} database system (tenant)
upsert /Tenant/10/Table/4{6-7} database system (tenant)
upsert /Tenant/10/Table/5{0-1} database system (tenant)
upsert /Tenant/10/Table/5{1-2} database system (tenant)

exec-sql tenant=10
CREATE DATABASE db;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ state offset=46
...
/Table/4{7-8} database system (host)
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/10{6-7} ttl_seconds=50

# Make sure future descendants observe the same.
Expand All @@ -141,6 +142,7 @@ state offset=46
...
/Table/4{7-8} database system (host)
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/10{6-7} ttl_seconds=50
/Table/10{7-8} ttl_seconds=50

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)

exec-sql
CREATE DATABASE db;
Expand All @@ -34,6 +35,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/10{6-7} range default

# All parent schema zone config changes cascade to the entire table's span.
Expand All @@ -51,6 +53,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/10{6-7} num_replicas=7 num_voters=5

# Apply a zone configuration on one of the partitions, `one_two`, which
Expand All @@ -73,6 +76,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/106{-/1/1} num_replicas=7 num_voters=5
/Table/106/1/{1-2} global_reads=true num_replicas=7 num_voters=5
/Table/106/1/{2-3} global_reads=true num_replicas=7 num_voters=5
Expand All @@ -95,6 +99,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/106{-/1/1} num_replicas=7 num_voters=5
/Table/106/1/{1-2} global_reads=true num_replicas=7 num_voters=5
/Table/106/1/{2-3} global_reads=true num_replicas=7 num_voters=5
Expand Down Expand Up @@ -131,6 +136,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/106{-/1} num_replicas=7 num_voters=5
/Table/106/1{-/1} num_replicas=7 num_voters=6
/Table/106/1/{1-2} global_reads=true num_replicas=7 num_voters=5
Expand Down Expand Up @@ -165,6 +171,7 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/106{-/1} num_replicas=7
/Table/106/1{-/1} num_replicas=7 num_voters=6
/Table/106/1/{1-2} global_reads=true num_replicas=7
Expand Down Expand Up @@ -193,3 +200,4 @@ state offset=47
----
...
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ state limit=3
state offset=51
----
...
/Table/5{1-2} database system (host)
/Table/10{6-7} protection_policies=[{ts: 3} {ts: 4}]
/Table/10{7-8} protection_policies=[{ts: 3} {ts: 4}]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ full-translate
/Table/4{6-7} database system (host)
/Table/4{7-8} database system (host)
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
/Table/11{0-1} range default
/Table/11{1-2} range default
/Table/11{2-3} range default
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ full-translate
/Table/4{6-7} database system (host)
/Table/4{7-8} database system (host)
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ translate database=system
/Table/4{6-7} database system (host)
/Table/4{7-8} database system (host)
/Table/5{0-1} database system (host)
/Table/5{1-2} database system (host)

# Alter zone config fields on the database to ensure the effects cascade.
exec-sql
Expand Down Expand Up @@ -98,6 +99,7 @@ translate database=system
/Table/4{6-7} ignore_strict_gc=true num_replicas=7 rangefeed_enabled=true
/Table/4{7-8} ignore_strict_gc=true num_replicas=7 rangefeed_enabled=true
/Table/5{0-1} ignore_strict_gc=true num_replicas=7 rangefeed_enabled=true
/Table/5{1-2} ignore_strict_gc=true num_replicas=7 rangefeed_enabled=true

# Alter a named range that maps to a pseudo table ID, ensuring that its effects
# are independent.
Expand Down Expand Up @@ -155,3 +157,4 @@ full-translate
/Table/4{6-7} ignore_strict_gc=true num_replicas=7 rangefeed_enabled=true
/Table/4{7-8} ignore_strict_gc=true num_replicas=7 rangefeed_enabled=true
/Table/5{0-1} ignore_strict_gc=true num_replicas=7 rangefeed_enabled=true
/Table/5{1-2} ignore_strict_gc=true num_replicas=7 rangefeed_enabled=true
Loading

0 comments on commit 7775324

Please sign in to comment.