@@ -10,7 +10,6 @@ import (
10
10
"testing"
11
11
12
12
"github.com/cockroachdb/cockroach/pkg/base"
13
- "github.com/cockroachdb/cockroach/pkg/keys"
14
13
"github.com/cockroachdb/cockroach/pkg/sql"
15
14
"github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils"
16
15
"github.com/cockroachdb/cockroach/pkg/sql/sqltestutils"
@@ -31,7 +30,7 @@ func TestMaterializedViewClearedAfterRefresh(t *testing.T) {
31
30
defer log .Scope (t ).Close (t )
32
31
33
32
ctx := context .Background ()
34
- params , _ := createTestServerParams ()
33
+ params , _ := createTestServerParamsAllowTenants ()
35
34
36
35
s , sqlDB , kvDB := serverutils .StartServer (t , params )
37
36
defer s .Stopper ().Stop (ctx )
@@ -49,7 +48,7 @@ CREATE MATERIALIZED VIEW t.v AS SELECT x FROM t.t;
49
48
t .Fatal (err )
50
49
}
51
50
52
- descBeforeRefresh := desctestutils .TestingGetPublicTableDescriptor (kvDB , keys . SystemSQLCodec , "t" , "v" )
51
+ descBeforeRefresh := desctestutils .TestingGetPublicTableDescriptor (kvDB , s . Codec () , "t" , "v" )
53
52
54
53
// Update the view and refresh it.
55
54
if _ , err := sqlDB .Exec (`
@@ -80,7 +79,7 @@ REFRESH MATERIALIZED VIEW t.v;
80
79
81
80
// The data should be deleted.
82
81
testutils .SucceedsSoon (t , func () error {
83
- indexPrefix := keys . SystemSQLCodec .IndexPrefix (uint32 (descBeforeRefresh .GetID ()), uint32 (descBeforeRefresh .GetPrimaryIndexID ()))
82
+ indexPrefix := s . Codec () .IndexPrefix (uint32 (descBeforeRefresh .GetID ()), uint32 (descBeforeRefresh .GetPrimaryIndexID ()))
84
83
indexEnd := indexPrefix .PrefixEnd ()
85
84
if kvs , err := kvDB .Scan (ctx , indexPrefix , indexEnd , 0 ); err != nil {
86
85
t .Fatal (err )
@@ -98,7 +97,7 @@ func TestMaterializedViewRefreshVisibility(t *testing.T) {
98
97
defer log .Scope (t ).Close (t )
99
98
100
99
ctx := context .Background ()
101
- params , _ := createTestServerParams ()
100
+ params , _ := createTestServerParamsAllowTenants ()
102
101
103
102
waitForCommit , waitToProceed , refreshDone := make (chan struct {}), make (chan struct {}), make (chan struct {})
104
103
params .Knobs = base.TestingKnobs {
@@ -146,7 +145,7 @@ func TestMaterializedViewCleansUpOnRefreshFailure(t *testing.T) {
146
145
defer log .Scope (t ).Close (t )
147
146
148
147
ctx := context .Background ()
149
- params , _ := createTestServerParams ()
148
+ params , _ := createTestServerParamsAllowTenants ()
150
149
151
150
// Protects shouldError
152
151
var mu syncutil.Mutex
@@ -182,7 +181,7 @@ CREATE MATERIALIZED VIEW t.v AS SELECT x FROM t.t;
182
181
t .Fatal (err )
183
182
}
184
183
185
- descBeforeRefresh := desctestutils .TestingGetPublicTableDescriptor (kvDB , keys . SystemSQLCodec , "t" , "v" )
184
+ descBeforeRefresh := desctestutils .TestingGetPublicTableDescriptor (kvDB , s . Codec () , "t" , "v" )
186
185
187
186
// Add a zone config to delete all table data.
188
187
_ , err := sqltestutils .AddImmediateGCZoneConfig (sqlDB , descBeforeRefresh .GetID ())
@@ -196,7 +195,7 @@ CREATE MATERIALIZED VIEW t.v AS SELECT x FROM t.t;
196
195
}
197
196
198
197
testutils .SucceedsSoon (t , func () error {
199
- tableStart := keys . SystemSQLCodec .TablePrefix (uint32 (descBeforeRefresh .GetID ()))
198
+ tableStart := s . Codec () .TablePrefix (uint32 (descBeforeRefresh .GetID ()))
200
199
tableEnd := tableStart .PrefixEnd ()
201
200
if kvs , err := kvDB .Scan (ctx , tableStart , tableEnd , 0 ); err != nil {
202
201
t .Fatal (err )
@@ -212,7 +211,7 @@ func TestDropMaterializedView(t *testing.T) {
212
211
defer log .Scope (t ).Close (t )
213
212
214
213
ctx := context .Background ()
215
- params , _ := createTestServerParams ()
214
+ params , _ := createTestServerParamsAllowTenants ()
216
215
s , sqlRaw , kvDB := serverutils .StartServer (t , params )
217
216
defer s .Stopper ().Stop (ctx )
218
217
@@ -229,7 +228,7 @@ CREATE TABLE t.t (x INT);
229
228
INSERT INTO t.t VALUES (1), (2);
230
229
CREATE MATERIALIZED VIEW t.v AS SELECT x FROM t.t;
231
230
` )
232
- desc := desctestutils .TestingGetPublicTableDescriptor (kvDB , keys . SystemSQLCodec , "t" , "v" )
231
+ desc := desctestutils .TestingGetPublicTableDescriptor (kvDB , s . Codec () , "t" , "v" )
233
232
// Add a zone config to delete all table data.
234
233
_ , err := sqltestutils .AddImmediateGCZoneConfig (sqlRaw , desc .GetID ())
235
234
require .NoError (t , err )
@@ -240,7 +239,7 @@ CREATE MATERIALIZED VIEW t.v AS SELECT x FROM t.t;
240
239
241
240
// All of the table data should be cleaned up.
242
241
testutils .SucceedsSoon (t , func () error {
243
- tableStart := keys . SystemSQLCodec .TablePrefix (uint32 (desc .GetID ()))
242
+ tableStart := s . Codec () .TablePrefix (uint32 (desc .GetID ()))
244
243
tableEnd := tableStart .PrefixEnd ()
245
244
if kvs , err := kvDB .Scan (ctx , tableStart , tableEnd , 0 ); err != nil {
246
245
t .Fatal (err )
0 commit comments