From ab4daa72d0d756ed71ed2f4097708a266547e1a3 Mon Sep 17 00:00:00 2001 From: xufei Date: Fri, 12 Mar 2021 20:56:58 +0800 Subject: [PATCH] Revert "address comments" This reverts commit c661abe52fd5cc52a9b838f6ee123e25158b36d7. --- planner/core/integration_test.go | 30 ++++++++++++++++++++++++------ util/testkit/testkit.go | 13 ------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index fc4460acb255e..e4e8d55975a6a 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -566,9 +566,18 @@ func (s *testIntegrationSerialSuite) TestJoinNotSupportedByTiFlash(c *C) { tk.MustExec("analyze table table_1") // Create virtual tiflash replica info. - tb := testkit.TestGetTableByName(c, tk.Se, "test", "table_1") - err := domain.GetDomain(tk.Se).DDL().UpdateTableReplicaInfo(tk.Se, tb.Meta().ID, true) - c.Assert(err, IsNil) + dom := domain.GetDomain(tk.Se) + is := dom.InfoSchema() + db, exists := is.SchemaByName(model.NewCIStr("test")) + c.Assert(exists, IsTrue) + for _, tblInfo := range db.Tables { + if tblInfo.Name.L == "table_1" { + tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{ + Count: 1, + Available: true, + } + } + } tk.MustExec("set @@session.tidb_isolation_read_engines = 'tiflash'") tk.MustExec("set @@session.tidb_allow_mpp = 1") @@ -626,9 +635,18 @@ func (s *testIntegrationSerialSuite) TestMPPNotSupportedInNewCollation(c *C) { tk.MustExec("analyze table table_1") // Create virtual tiflash replica info. - tb := testkit.TestGetTableByName(c, tk.Se, "test", "table_1") - err := domain.GetDomain(tk.Se).DDL().UpdateTableReplicaInfo(tk.Se, tb.Meta().ID, true) - c.Assert(err, IsNil) + dom := domain.GetDomain(tk.Se) + is := dom.InfoSchema() + db, exists := is.SchemaByName(model.NewCIStr("test")) + c.Assert(exists, IsTrue) + for _, tblInfo := range db.Tables { + if tblInfo.Name.L == "table_1" { + tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{ + Count: 1, + Available: true, + } + } + } collate.SetNewCollationEnabledForTest(true) tk.MustExec("set @@session.tidb_isolation_read_engines = 'tiflash'") diff --git a/util/testkit/testkit.go b/util/testkit/testkit.go index 9e9bb21218441..e82ad885fe939 100644 --- a/util/testkit/testkit.go +++ b/util/testkit/testkit.go @@ -30,9 +30,7 @@ import ( "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/session" - "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/sessionctx/variable" - "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util/sqlexec" "github.com/pingcap/tidb/util/testutil" @@ -369,14 +367,3 @@ func WithPruneMode(tk *TestKit, mode variable.PartitionPruneMode, f func()) { tk.MustExec("set global tidb_partition_prune_mode=`" + string(mode) + "`") f() } - -// TestGetTableByName get the table info by name, will assert error if not found -func TestGetTableByName(c *check.C, ctx sessionctx.Context, db, table string) table.Table { - dom := domain.GetDomain(ctx) - // Make sure the table schema is the new schema. - err := dom.Reload() - c.Assert(err, check.IsNil) - tbl, err := dom.InfoSchema().TableByName(model.NewCIStr(db), model.NewCIStr(table)) - c.Assert(err, check.IsNil) - return tbl -}