Skip to content

Commit 1b7a41d

Browse files
authored
planner/core: fix some test cases when using infoschema v2 (#51937)
ref #50959
1 parent 1469e3d commit 1b7a41d

File tree

3 files changed

+48
-24
lines changed

3 files changed

+48
-24
lines changed

pkg/planner/core/integration_test.go

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ func TestAggPushDownEngine(t *testing.T) {
8282
is := dom.InfoSchema()
8383
db, exists := is.SchemaByName(model.NewCIStr("test"))
8484
require.True(t, exists)
85-
for _, tblInfo := range db.Tables {
85+
for _, tbl := range is.SchemaTables(db.Name) {
86+
tblInfo := tbl.Meta()
8687
if tblInfo.Name.L == "t" {
8788
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
8889
Count: 1,
@@ -130,7 +131,8 @@ func TestIssue15110And49616(t *testing.T) {
130131
is := dom.InfoSchema()
131132
db, exists := is.SchemaByName(model.NewCIStr("test"))
132133
require.True(t, exists)
133-
for _, tblInfo := range db.Tables {
134+
for _, tbl := range is.SchemaTables(db.Name) {
135+
tblInfo := tbl.Meta()
134136
if tblInfo.Name.L == "crm_rd_150m" {
135137
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
136138
Count: 1,
@@ -190,7 +192,8 @@ func TestNotReadOnlySQLOnTiFlash(t *testing.T) {
190192
is := dom.InfoSchema()
191193
db, exists := is.SchemaByName(model.NewCIStr("test"))
192194
require.True(t, exists)
193-
for _, tblInfo := range db.Tables {
195+
for _, tbl := range is.SchemaTables(db.Name) {
196+
tblInfo := tbl.Meta()
194197
if tblInfo.Name.L == "t" {
195198
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
196199
Count: 1,
@@ -226,7 +229,8 @@ func TestTimeToSecPushDownToTiFlash(t *testing.T) {
226229
is := dom.InfoSchema()
227230
db, exists := is.SchemaByName(model.NewCIStr("test"))
228231
require.True(t, exists)
229-
for _, tblInfo := range db.Tables {
232+
for _, tbl := range is.SchemaTables(db.Name) {
233+
tblInfo := tbl.Meta()
230234
if tblInfo.Name.L == "t" {
231235
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
232236
Count: 1,
@@ -260,7 +264,8 @@ func TestRightShiftPushDownToTiFlash(t *testing.T) {
260264
is := dom.InfoSchema()
261265
db, exists := is.SchemaByName(model.NewCIStr("test"))
262266
require.True(t, exists)
263-
for _, tblInfo := range db.Tables {
267+
for _, tbl := range is.SchemaTables(db.Name) {
268+
tblInfo := tbl.Meta()
264269
if tblInfo.Name.L == "t" {
265270
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
266271
Count: 1,
@@ -700,7 +705,8 @@ func TestReverseUTF8PushDownToTiFlash(t *testing.T) {
700705
is := dom.InfoSchema()
701706
db, exists := is.SchemaByName(model.NewCIStr("test"))
702707
require.True(t, exists)
703-
for _, tblInfo := range db.Tables {
708+
for _, tbl := range is.SchemaTables(db.Name) {
709+
tblInfo := tbl.Meta()
704710
if tblInfo.Name.L == "t" {
705711
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
706712
Count: 1,
@@ -734,7 +740,8 @@ func TestReversePushDownToTiFlash(t *testing.T) {
734740
is := dom.InfoSchema()
735741
db, exists := is.SchemaByName(model.NewCIStr("test"))
736742
require.True(t, exists)
737-
for _, tblInfo := range db.Tables {
743+
for _, tbl := range is.SchemaTables(db.Name) {
744+
tblInfo := tbl.Meta()
738745
if tblInfo.Name.L == "t" {
739746
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
740747
Count: 1,
@@ -768,7 +775,8 @@ func TestSpacePushDownToTiFlash(t *testing.T) {
768775
is := dom.InfoSchema()
769776
db, exists := is.SchemaByName(model.NewCIStr("test"))
770777
require.True(t, exists)
771-
for _, tblInfo := range db.Tables {
778+
for _, tbl := range is.SchemaTables(db.Name) {
779+
tblInfo := tbl.Meta()
772780
if tblInfo.Name.L == "t" {
773781
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
774782
Count: 1,
@@ -908,7 +916,8 @@ func TestConflictReadFromStorage(t *testing.T) {
908916
is := dom.InfoSchema()
909917
db, exists := is.SchemaByName(model.NewCIStr("test"))
910918
require.True(t, exists)
911-
for _, tblInfo := range db.Tables {
919+
for _, tbl := range is.SchemaTables(db.Name) {
920+
tblInfo := tbl.Meta()
912921
if tblInfo.Name.L == "t" {
913922
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
914923
Count: 1,
@@ -1189,7 +1198,8 @@ func TestRepeatPushDownToTiFlash(t *testing.T) {
11891198
is := dom.InfoSchema()
11901199
db, exists := is.SchemaByName(model.NewCIStr("test"))
11911200
require.True(t, exists)
1192-
for _, tblInfo := range db.Tables {
1201+
for _, tbl := range is.SchemaTables(db.Name) {
1202+
tblInfo := tbl.Meta()
11931203
if tblInfo.Name.L == "t" {
11941204
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
11951205
Count: 1,
@@ -1218,7 +1228,8 @@ func TestIssue36194(t *testing.T) {
12181228
is := dom.InfoSchema()
12191229
db, exists := is.SchemaByName(model.NewCIStr("test"))
12201230
require.True(t, exists)
1221-
for _, tblInfo := range db.Tables {
1231+
for _, tbl := range is.SchemaTables(db.Name) {
1232+
tblInfo := tbl.Meta()
12221233
if tblInfo.Name.L == "t" {
12231234
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
12241235
Count: 1,
@@ -1274,7 +1285,8 @@ func TestAggWithJsonPushDownToTiFlash(t *testing.T) {
12741285
is := dom.InfoSchema()
12751286
db, exists := is.SchemaByName(model.NewCIStr("test"))
12761287
require.True(t, exists)
1277-
for _, tblInfo := range db.Tables {
1288+
for _, tbl := range is.SchemaTables(db.Name) {
1289+
tblInfo := tbl.Meta()
12781290
if tblInfo.Name.L == "t" {
12791291
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
12801292
Count: 1,
@@ -1323,7 +1335,8 @@ func TestLeftShiftPushDownToTiFlash(t *testing.T) {
13231335
is := dom.InfoSchema()
13241336
db, exists := is.SchemaByName(model.NewCIStr("test"))
13251337
require.True(t, exists)
1326-
for _, tblInfo := range db.Tables {
1338+
for _, tbl := range is.SchemaTables(db.Name) {
1339+
tblInfo := tbl.Meta()
13271340
if tblInfo.Name.L == "t" {
13281341
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
13291342
Count: 1,
@@ -1415,7 +1428,8 @@ func TestEltPushDownToTiFlash(t *testing.T) {
14151428
is := dom.InfoSchema()
14161429
db, exists := is.SchemaByName(model.NewCIStr("test"))
14171430
require.True(t, exists)
1418-
for _, tblInfo := range db.Tables {
1431+
for _, tbl := range is.SchemaTables(db.Name) {
1432+
tblInfo := tbl.Meta()
14191433
if tblInfo.Name.L == "t" {
14201434
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
14211435
Count: 1,
@@ -1448,7 +1462,8 @@ func TestRegexpInstrPushDownToTiFlash(t *testing.T) {
14481462
is := dom.InfoSchema()
14491463
db, exists := is.SchemaByName(model.NewCIStr("test"))
14501464
require.True(t, exists)
1451-
for _, tblInfo := range db.Tables {
1465+
for _, tbl := range is.SchemaTables(db.Name) {
1466+
tblInfo := tbl.Meta()
14521467
if tblInfo.Name.L == "t" {
14531468
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
14541469
Count: 1,
@@ -1481,7 +1496,8 @@ func TestRegexpSubstrPushDownToTiFlash(t *testing.T) {
14811496
is := dom.InfoSchema()
14821497
db, exists := is.SchemaByName(model.NewCIStr("test"))
14831498
require.True(t, exists)
1484-
for _, tblInfo := range db.Tables {
1499+
for _, tbl := range is.SchemaTables(db.Name) {
1500+
tblInfo := tbl.Meta()
14851501
if tblInfo.Name.L == "t" {
14861502
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
14871503
Count: 1,
@@ -1514,7 +1530,8 @@ func TestRegexpReplacePushDownToTiFlash(t *testing.T) {
15141530
is := dom.InfoSchema()
15151531
db, exists := is.SchemaByName(model.NewCIStr("test"))
15161532
require.True(t, exists)
1517-
for _, tblInfo := range db.Tables {
1533+
for _, tbl := range is.SchemaTables(db.Name) {
1534+
tblInfo := tbl.Meta()
15181535
if tblInfo.Name.L == "t" {
15191536
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
15201537
Count: 1,
@@ -1551,7 +1568,8 @@ func TestCastTimeAsDurationToTiFlash(t *testing.T) {
15511568
is := dom.InfoSchema()
15521569
db, exists := is.SchemaByName(model.NewCIStr("test"))
15531570
require.True(t, exists)
1554-
for _, tblInfo := range db.Tables {
1571+
for _, tbl := range is.SchemaTables(db.Name) {
1572+
tblInfo := tbl.Meta()
15551573
if tblInfo.Name.L == "t" {
15561574
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
15571575
Count: 1,
@@ -1933,7 +1951,8 @@ func TestIsIPv4ToTiFlash(t *testing.T) {
19331951
is := dom.InfoSchema()
19341952
db, exists := is.SchemaByName(model.NewCIStr("test"))
19351953
require.True(t, exists)
1936-
for _, tblInfo := range db.Tables {
1954+
for _, tbl := range is.SchemaTables(db.Name) {
1955+
tblInfo := tbl.Meta()
19371956
if tblInfo.Name.L == "t" {
19381957
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
19391958
Count: 1,
@@ -1968,7 +1987,8 @@ func TestIsIPv6ToTiFlash(t *testing.T) {
19681987
is := dom.InfoSchema()
19691988
db, exists := is.SchemaByName(model.NewCIStr("test"))
19701989
require.True(t, exists)
1971-
for _, tblInfo := range db.Tables {
1990+
for _, tbl := range is.SchemaTables(db.Name) {
1991+
tblInfo := tbl.Meta()
19721992
if tblInfo.Name.L == "t" {
19731993
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
19741994
Count: 1,
@@ -2030,7 +2050,8 @@ func TestVirtualExprPushDown(t *testing.T) {
20302050
is := dom.InfoSchema()
20312051
db, exists := is.SchemaByName(model.NewCIStr("test"))
20322052
require.True(t, exists)
2033-
for _, tblInfo := range db.Tables {
2053+
for _, tbl := range is.SchemaTables(db.Name) {
2054+
tblInfo := tbl.Meta()
20342055
if tblInfo.Name.L == "t" {
20352056
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
20362057
Count: 1,
@@ -2086,7 +2107,8 @@ func TestWindowRangeFramePushDownTiflash(t *testing.T) {
20862107
is := dom.InfoSchema()
20872108
db, exists := is.SchemaByName(model.NewCIStr("test"))
20882109
require.True(t, exists)
2089-
for _, tblInfo := range db.Tables {
2110+
for _, tbl := range is.SchemaTables(db.Name) {
2111+
tblInfo := tbl.Meta()
20902112
if tblInfo.Name.L == "first_range" || tblInfo.Name.L == "first_range_d64" {
20912113
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
20922114
Count: 1,

pkg/planner/core/plan_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ func TestExplainFormatHintRecoverableForTiFlashReplica(t *testing.T) {
370370
is := dom.InfoSchema()
371371
db, exists := is.SchemaByName(model.NewCIStr("test"))
372372
require.True(t, exists)
373-
for _, tblInfo := range db.Tables {
373+
for _, tbl := range is.SchemaTables(db.Name) {
374+
tblInfo := tbl.Meta()
374375
if tblInfo.Name.L == "t" {
375376
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
376377
Count: 1,

pkg/planner/core/runtime_filter_generator_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ func TestRuntimeFilterGenerator(t *testing.T) {
5353
is := dom.InfoSchema()
5454
db, exists := is.SchemaByName(model.NewCIStr("test"))
5555
require.True(t, exists)
56-
for _, tblInfo := range db.Tables {
56+
for _, tbl := range is.SchemaTables(db.Name) {
57+
tblInfo := tbl.Meta()
5758
tableName := tblInfo.Name.L
5859
if tableName == "t1" || tableName == "t2" {
5960
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{

0 commit comments

Comments
 (0)