-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
crdb_internal
216 lines (183 loc) · 8.23 KB
/
crdb_internal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# LogicTest: local
query IITTITTTII colnames
SELECT * FROM crdb_internal.partitions
----
table_id index_id parent_name name columns column_names list_value range_value zone_id subzone_id
statement ok
CREATE TABLE t1 (
a INT,
b INT,
c INT,
PRIMARY KEY (a, b, c),
INDEX (a, b) PARTITION BY LIST (a, b) (
PARTITION p00 VALUES IN ((0, 0))
)
) PARTITION BY LIST (a) (
PARTITION p12 VALUES IN (1, 2) PARTITION BY LIST (b) (
PARTITION p12p3 VALUES IN (3) PARTITION BY LIST (c) (
PARTITION p12p3p8 VALUES IN (8)
),
PARTITION pd VALUES IN (DEFAULT)
),
PARTITION p6 VALUES IN (6) PARTITION BY RANGE (b) (
PARTITION p6p7 VALUES FROM (MINVALUE) TO (7),
PARTITION p6p8 VALUES FROM (7) TO (8),
PARTITION p6px VALUES FROM (8) TO (MAXVALUE)
)
)
statement ok
CREATE table t2 (a STRING PRIMARY KEY) PARTITION BY LIST (a) (
PARTITION pfoo VALUES IN ('foo')
)
# Since there are no zone configurations on any of these partitions, tables,
# or databases, these partitions inherit directly from the default config.
skipif backup-restore
query IITTITTTII
SELECT * FROM crdb_internal.partitions ORDER BY table_id, index_id, name
----
106 1 NULL p12 1 a (1), (2) NULL 0 0
106 1 p12 p12p3 1 b (3) NULL 0 0
106 1 p12p3 p12p3p8 1 c (8) NULL 0 0
106 1 NULL p6 1 a (6) NULL 0 0
106 1 p6 p6p7 1 b NULL (MINVALUE) TO (7) 0 0
106 1 p6 p6p8 1 b NULL (7) TO (8) 0 0
106 1 p6 p6px 1 b NULL (8) TO (MAXVALUE) 0 0
106 1 p12 pd 1 b (DEFAULT) NULL 0 0
106 2 NULL p00 2 a, b (0, 0) NULL 0 0
107 1 NULL pfoo 1 a ('foo') NULL 0 0
# Test crdb_internal.zones functions correctly on zoned indexes.
subtest privileged_zones_test
statement ok
CREATE DATABASE db2; ALTER DATABASE db2 CONFIGURE ZONE USING num_replicas = 3;
REVOKE CONNECT ON DATABASE db2 FROM public
statement ok
CREATE TABLE t3 (a INT PRIMARY KEY, b INT); CREATE INDEX myt3index ON t3 (b); ALTER INDEX myt3index CONFIGURE ZONE USING num_replicas = 5; ALTER TABLE t3 CONFIGURE ZONE USING num_replicas = 8
statement ok
CREATE TABLE t4 (a INT PRIMARY KEY, b INT); CREATE INDEX myt4index ON t4 (b); ALTER TABLE t4 CONFIGURE ZONE USING num_replicas = 7; ALTER INDEX myt4index CONFIGURE ZONE USING num_replicas = 5; GRANT ALL ON t4 TO testuser
user testuser
skipif backup-restore
query IT
SELECT zone_id, target FROM crdb_internal.zones ORDER BY 1
----
0 RANGE default
16 RANGE meta
17 RANGE system
22 RANGE liveness
111 TABLE test.public.t4
111 INDEX test.public.t4@myt4index
query TT
SELECT * FROM [SHOW ALL ZONE CONFIGURATIONS] ORDER BY 1
----
INDEX test.public.t4@myt4index ALTER INDEX test.public.t4@myt4index CONFIGURE ZONE USING
num_replicas = 5
RANGE default ALTER RANGE default CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 14400,
num_replicas = 3,
constraints = '[]',
lease_preferences = '[]'
RANGE liveness ALTER RANGE liveness CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 600,
num_replicas = 5,
constraints = '[]',
lease_preferences = '[]'
RANGE meta ALTER RANGE meta CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 3600,
num_replicas = 5,
constraints = '[]',
lease_preferences = '[]'
RANGE system ALTER RANGE system CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 14400,
num_replicas = 5,
constraints = '[]',
lease_preferences = '[]'
TABLE test.public.t4 ALTER TABLE test.public.t4 CONFIGURE ZONE USING
num_replicas = 7
query error pq: user testuser has no privileges on database db2
SHOW ZONE CONFIGURATION FOR DATABASE db2
query error pq: user testuser has no privileges on relation t2
SHOW ZONE CONFIGURATION FOR TABLE t2
query error pq: user testuser has no privileges on relation t3
SHOW ZONE CONFIGURATION FOR TABLE t3
query error pq: user testuser has no privileges on relation t3
SHOW ZONE CONFIGURATION FOR INDEX myt3index
query TT
SHOW ZONE CONFIGURATION FOR INDEX myt4index
----
INDEX test.public.t4@myt4index ALTER INDEX test.public.t4@myt4index CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 14400,
num_replicas = 5,
constraints = '[]',
lease_preferences = '[]'
query TT
SHOW ZONE CONFIGURATION FOR TABLE t4
----
TABLE t4 ALTER TABLE t4 CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 14400,
num_replicas = 7,
constraints = '[]',
lease_preferences = '[]'
query TT
SHOW ZONE CONFIGURATION FOR RANGE default
----
RANGE default ALTER RANGE default CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 14400,
num_replicas = 3,
constraints = '[]',
lease_preferences = '[]'
# This test checks that generator backed tables do not concurrently
# access transactions. It does this by scanning two virtual tables at a time.
# If the background generator functions were performing work when not allowed
# to, the background generators would conflict with an error.
statement ok
SELECT a.* FROM crdb_internal.partitions AS a JOIN crdb_internal.partitions AS b ON a.table_id = b.table_id
subtest replication-builtins
user root
query error pq: crdb_internal\.replication_stream_spec\(\): job.*is not a replication stream job
SELECT crdb_internal.replication_stream_spec(crdb_internal.create_sql_schema_telemetry_job())
query error pq: crdb_internal\.stream_ingestion_stats_json\(\): unimplemented
SELECT crdb_internal.stream_ingestion_stats_json(1);
query error pq: crdb_internal\.stream_ingestion_stats_pb\(\): unimplemented
SELECT crdb_internal.stream_ingestion_stats_pb(1);
subtest node_tenant_capabilities_cache
user testuser
statement error only users with the admin role are allowed to node_tenant_capabilities_cache
SELECT * FROM crdb_internal.node_tenant_capabilities_cache
user root
statement ok
SELECT crdb_internal.create_tenant(5)
# Use retry because source data is eventually consistent.
query ITT colnames,retry
SELECT * FROM crdb_internal.node_tenant_capabilities_cache
----
tenant_id capability_name capability_value
1 can_admin_split false
1 can_view_node_info false
1 can_view_tsdb_metrics false
statement ok
ALTER TENANT [5] GRANT CAPABILITY can_admin_split
# Use retry because source data is eventually consistent.
query ITT colnames,retry
SELECT * FROM crdb_internal.node_tenant_capabilities_cache
----
tenant_id capability_name capability_value
1 can_admin_split false
1 can_view_node_info false
1 can_view_tsdb_metrics false
5 can_admin_split false
5 can_view_node_info false
5 can_view_tsdb_metrics false
subtest end