From 484f9ad67edc7c31e9ca1498acb94f2f3cdfe420 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Tue, 1 Jun 2021 16:28:35 +0800 Subject: [PATCH 1/6] try to fix some unstable tests --- executor/analyze_test.go | 68 ++++++++++++++++---------------- executor/simple_test.go | 24 +++++------ statistics/handle/handle_test.go | 35 ++++++++-------- 3 files changed, 64 insertions(+), 63 deletions(-) diff --git a/executor/analyze_test.go b/executor/analyze_test.go index f5b822b51f45f..7252c32cc644f 100644 --- a/executor/analyze_test.go +++ b/executor/analyze_test.go @@ -511,18 +511,18 @@ func (s *testFastAnalyze) TestFastAnalyze(c *C) { } func (s *testSerialSuite2) TestFastAnalyze4GlobalStats(c *C) { - c.Skip("unstable") tk := testkit.NewTestKit(c, s.store) - tk.MustExec("use test") + tk.MustExec(`create database if not exists test_fast_gstats`) + tk.MustExec("use test_fast_gstats") tk.MustExec("set @@session.tidb_enable_fast_analyze=1") tk.MustExec("set @@session.tidb_build_stats_concurrency=1") // test fast analyze in dynamic mode tk.MustExec("set @@session.tidb_analyze_version = 2;") tk.MustExec("set @@session.tidb_partition_prune_mode = 'dynamic';") - tk.MustExec("drop table if exists t4;") - tk.MustExec("create table t4(a int, b int) PARTITION BY HASH(a) PARTITIONS 2;") - tk.MustExec("insert into t4 values(1,1),(3,3),(4,4),(2,2),(5,5);") - err := tk.ExecToErr("analyze table t4;") + tk.MustExec("drop table if exists test_fast_gstats;") + tk.MustExec("create table test_fast_gstats(a int, b int) PARTITION BY HASH(a) PARTITIONS 2;") + tk.MustExec("insert into test_fast_gstats values(1,1),(3,3),(4,4),(2,2),(5,5);") + err := tk.ExecToErr("analyze table test_fast_gstats;") c.Assert(err.Error(), Equals, "Fast analyze hasn't reached General Availability and only support analyze version 1 currently.") } @@ -747,21 +747,21 @@ func (s *testSuite10) TestFailedAnalyzeRequest(c *C) { } func (s *testSuite1) TestExtractTopN(c *C) { - c.Skip("unstable") tk := testkit.NewTestKit(c, s.store) - tk.MustExec("use test") - tk.MustExec("drop table if exists t") - tk.MustExec("create table t(a int primary key, b int, index index_b(b))") + tk.MustExec("create database if not exists test_extract_topn") + tk.MustExec("use test_extract_topn") + tk.MustExec("drop table if exists test_extract_topn") + tk.MustExec("create table test_extract_topn(a int primary key, b int, index index_b(b))") tk.MustExec("set @@session.tidb_analyze_version=2") for i := 0; i < 10; i++ { - tk.MustExec(fmt.Sprintf("insert into t values (%d, %d)", i, i)) + tk.MustExec(fmt.Sprintf("insert into test_extract_topn values (%d, %d)", i, i)) } for i := 0; i < 10; i++ { - tk.MustExec(fmt.Sprintf("insert into t values (%d, 0)", i+10)) + tk.MustExec(fmt.Sprintf("insert into test_extract_topn values (%d, 0)", i+10)) } - tk.MustExec("analyze table t") + tk.MustExec("analyze table test_extract_topn") is := s.dom.InfoSchema() - table, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("t")) + table, err := is.TableByName(model.NewCIStr("test_extract_topn"), model.NewCIStr("test_extract_topn")) c.Assert(err, IsNil) tblInfo := table.Meta() tblStats := s.dom.StatsHandle().GetTableStats(tblInfo) @@ -774,26 +774,26 @@ func (s *testSuite1) TestExtractTopN(c *C) { idxItem := idxStats.TopN.TopN[0] c.Assert(idxItem.Count, Equals, uint64(11)) // The columns are: DBName, table name, column name, is index, value, count. - tk.MustQuery("show stats_topn").Sort().Check(testkit.Rows("test t b 0 0 11", - "test t b 0 1 1", - "test t b 0 2 1", - "test t b 0 3 1", - "test t b 0 4 1", - "test t b 0 5 1", - "test t b 0 6 1", - "test t b 0 7 1", - "test t b 0 8 1", - "test t b 0 9 1", - "test t index_b 1 0 11", - "test t index_b 1 1 1", - "test t index_b 1 2 1", - "test t index_b 1 3 1", - "test t index_b 1 4 1", - "test t index_b 1 5 1", - "test t index_b 1 6 1", - "test t index_b 1 7 1", - "test t index_b 1 8 1", - "test t index_b 1 9 1", + tk.MustQuery("show stats_topn").Sort().Check(testkit.Rows("test_extract_topn test_extract_topn b 0 0 11", + "test_extract_topn test_extract_topn b 0 1 1", + "test_extract_topn test_extract_topn b 0 2 1", + "test_extract_topn test_extract_topn b 0 3 1", + "test_extract_topn test_extract_topn b 0 4 1", + "test_extract_topn test_extract_topn b 0 5 1", + "test_extract_topn test_extract_topn b 0 6 1", + "test_extract_topn test_extract_topn b 0 7 1", + "test_extract_topn test_extract_topn b 0 8 1", + "test_extract_topn test_extract_topn b 0 9 1", + "test_extract_topn test_extract_topn index_b 1 0 11", + "test_extract_topn test_extract_topn index_b 1 1 1", + "test_extract_topn test_extract_topn index_b 1 2 1", + "test_extract_topn test_extract_topn index_b 1 3 1", + "test_extract_topn test_extract_topn index_b 1 4 1", + "test_extract_topn test_extract_topn index_b 1 5 1", + "test_extract_topn test_extract_topn index_b 1 6 1", + "test_extract_topn test_extract_topn index_b 1 7 1", + "test_extract_topn test_extract_topn index_b 1 8 1", + "test_extract_topn test_extract_topn index_b 1 9 1", )) } diff --git a/executor/simple_test.go b/executor/simple_test.go index 8c09fc336f5d2..135442693b24d 100644 --- a/executor/simple_test.go +++ b/executor/simple_test.go @@ -604,12 +604,12 @@ func (s *testFlushSuite) TestFlushPrivilegesPanic(c *C) { } func (s *testSerialSuite) TestDropPartitionStats(c *C) { - c.Skip("unstable") // Use the testSerialSuite to fix the unstable test tk := testkit.NewTestKit(c, s.store) - tk.MustExec("use test") - tk.MustExec("drop table if exists t;") - tk.MustExec(`create table t ( + tk.MustExec(`create database if not exists test_drop_gstats`) + tk.MustExec("use test_drop_gstats") + tk.MustExec("drop table if exists test_drop_gstats;") + tk.MustExec(`create table test_drop_gstats ( a int, key(a) ) @@ -620,7 +620,7 @@ partition by range (a) ( )`) tk.MustExec("set @@tidb_analyze_version = 2") tk.MustExec("set @@tidb_partition_prune_mode='dynamic'") - tk.MustExec("insert into t values (1), (5), (11), (15), (21), (25)") + tk.MustExec("insert into test_drop_gstats values (1), (5), (11), (15), (21), (25)") c.Assert(s.domain.StatsHandle().DumpStatsDeltaToKV(handle.DumpAll), IsNil) checkPartitionStats := func(names ...string) { @@ -631,26 +631,26 @@ partition by range (a) ( } } - tk.MustExec("analyze table t") + tk.MustExec("analyze table test_drop_gstats") checkPartitionStats("global", "p0", "p1", "global") - tk.MustExec("drop stats t partition p0") + tk.MustExec("drop stats test_drop_gstats partition p0") checkPartitionStats("global", "p1", "global") - err := tk.ExecToErr("drop stats t partition abcde") + err := tk.ExecToErr("drop stats test_drop_gstats partition abcde") c.Assert(err, NotNil) c.Assert(err.Error(), Equals, "can not found the specified partition name abcde in the table definition") - tk.MustExec("drop stats t partition global") + tk.MustExec("drop stats test_drop_gstats partition global") checkPartitionStats("global", "p1") - tk.MustExec("drop stats t global") + tk.MustExec("drop stats test_drop_gstats global") checkPartitionStats("p1") - tk.MustExec("analyze table t") + tk.MustExec("analyze table test_drop_gstats") checkPartitionStats("global", "p0", "p1", "global") - tk.MustExec("drop stats t partition p0, p1, global") + tk.MustExec("drop stats test_drop_gstats partition p0, p1, global") checkPartitionStats("global") } diff --git a/statistics/handle/handle_test.go b/statistics/handle/handle_test.go index 1518503fa73ba..cb2a7596419da 100644 --- a/statistics/handle/handle_test.go +++ b/statistics/handle/handle_test.go @@ -837,13 +837,14 @@ func (s *testStatsSuite) TestBuildGlobalLevelStats(c *C) { c.Assert(len(result.Rows()), Equals, 20) } -func (s *testStatsSuite) prepareForGlobalStatsWithOpts(c *C, tk *testkit.TestKit) { - tk.MustExec("use test") - tk.MustExec("drop table if exists t") - tk.MustExec(` create table t (a int, key(a)) partition by range (a) ` + +func (s *testStatsSuite) prepareForGlobalStatsWithOpts(c *C, tk *testkit.TestKit, tblName, dbName string) { + tk.MustExec("create database if not exists " + dbName) + tk.MustExec("use " + dbName) + tk.MustExec("drop table if exists " + tblName) + tk.MustExec(` create table ` + tblName + ` (a int, key(a)) partition by range (a) ` + `(partition p0 values less than (100000), partition p1 values less than (200000))`) - buf1 := bytes.NewBufferString("insert into t values (0)") - buf2 := bytes.NewBufferString("insert into t values (100000)") + buf1 := bytes.NewBufferString("insert into " + tblName + " values (0)") + buf2 := bytes.NewBufferString("insert into " + tblName + " values (100000)") for i := 0; i < 5000; i += 3 { buf1.WriteString(fmt.Sprintf(", (%v)", i)) buf2.WriteString(fmt.Sprintf(", (%v)", 100000+i)) @@ -870,7 +871,7 @@ func (s *testStatsSuite) checkForGlobalStatsWithOpts(c *C, tk *testkit.TestKit, func (s *testStatsSuite) TestAnalyzeGlobalStatsWithOpts(c *C) { defer cleanEnv(c, s.store, s.do) tk := testkit.NewTestKit(c, s.store) - s.prepareForGlobalStatsWithOpts(c, tk) + s.prepareForGlobalStatsWithOpts(c, tk, "test_gstats_opt", "test_gstats_opt") type opt struct { topn int @@ -889,7 +890,7 @@ func (s *testStatsSuite) TestAnalyzeGlobalStatsWithOpts(c *C) { {77, 47000, true}, } for _, ca := range cases { - sql := fmt.Sprintf("analyze table t with %v topn, %v buckets", ca.topn, ca.buckets) + sql := fmt.Sprintf("analyze table test_gstats_opt with %v topn, %v buckets", ca.topn, ca.buckets) if !ca.err { tk.MustExec(sql) s.checkForGlobalStatsWithOpts(c, tk, "global", ca.topn, ca.buckets) @@ -905,25 +906,25 @@ func (s *testStatsSuite) TestAnalyzeGlobalStatsWithOpts(c *C) { func (s *testStatsSuite) TestAnalyzeGlobalStatsWithOpts2(c *C) { defer cleanEnv(c, s.store, s.do) tk := testkit.NewTestKit(c, s.store) - s.prepareForGlobalStatsWithOpts(c, tk) + s.prepareForGlobalStatsWithOpts(c, tk, "test_gstats_opt2", "test_gstats_opt2") - tk.MustExec("analyze table t with 20 topn, 50 buckets") + tk.MustExec("analyze table test_gstats_opt2 with 20 topn, 50 buckets") s.checkForGlobalStatsWithOpts(c, tk, "global", 20, 50) s.checkForGlobalStatsWithOpts(c, tk, "p0", 20, 50) s.checkForGlobalStatsWithOpts(c, tk, "p1", 20, 50) // analyze a partition to let its options be different with others' - tk.MustExec("analyze table t partition p0 with 10 topn, 20 buckets") + tk.MustExec("analyze table test_gstats_opt2 partition p0 with 10 topn, 20 buckets") s.checkForGlobalStatsWithOpts(c, tk, "global", 10, 20) // use new options s.checkForGlobalStatsWithOpts(c, tk, "p0", 10, 20) s.checkForGlobalStatsWithOpts(c, tk, "p1", 20, 50) - tk.MustExec("analyze table t partition p1 with 100 topn, 200 buckets") + tk.MustExec("analyze table test_gstats_opt2 partition p1 with 100 topn, 200 buckets") s.checkForGlobalStatsWithOpts(c, tk, "global", 100, 200) s.checkForGlobalStatsWithOpts(c, tk, "p0", 10, 20) s.checkForGlobalStatsWithOpts(c, tk, "p1", 100, 200) - tk.MustExec("analyze table t partition p0") // default options + tk.MustExec("analyze table test_gstats_opt2 partition p0") // default options s.checkForGlobalStatsWithOpts(c, tk, "global", 20, 256) s.checkForGlobalStatsWithOpts(c, tk, "p0", 20, 256) s.checkForGlobalStatsWithOpts(c, tk, "p1", 100, 200) @@ -1061,8 +1062,8 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustExec("analyze table tint with 2 topn, 2 buckets") tk.MustQuery("select modify_count, count from mysql.stats_meta order by table_id asc").Check(testkit.Rows( - "0 20", // global: g.count = p0.count + p1.count - "0 9", // p0 + "0 20", // global: g.count = p0.count + p1.count + "0 9", // p0 "0 11")) // p1 tk.MustQuery("show stats_topn where table_name='tint' and is_index=0").Check(testkit.Rows( @@ -1092,7 +1093,7 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustQuery("select distinct_count, null_count, tot_col_size from mysql.stats_histograms where is_index=0 order by table_id asc").Check( testkit.Rows("12 1 19", // global, g = p0 + p1 - "5 1 8", // p0 + "5 1 8", // p0 "7 0 11")) // p1 tk.MustQuery("show stats_buckets where is_index=1").Check(testkit.Rows( @@ -1106,7 +1107,7 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustQuery("select distinct_count, null_count from mysql.stats_histograms where is_index=1 order by table_id asc").Check( testkit.Rows("12 1", // global, g = p0 + p1 - "5 1", // p0 + "5 1", // p0 "7 0")) // p1 // double + (column + index with 1 column) From bb3e397ab2a48e2cb4eb735d83e82ff271c2947d Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Tue, 1 Jun 2021 16:37:45 +0800 Subject: [PATCH 2/6] make linter happy --- statistics/handle/handle_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/statistics/handle/handle_test.go b/statistics/handle/handle_test.go index cb2a7596419da..c66e534b0a386 100644 --- a/statistics/handle/handle_test.go +++ b/statistics/handle/handle_test.go @@ -1062,8 +1062,8 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustExec("analyze table tint with 2 topn, 2 buckets") tk.MustQuery("select modify_count, count from mysql.stats_meta order by table_id asc").Check(testkit.Rows( - "0 20", // global: g.count = p0.count + p1.count - "0 9", // p0 + "0 20", // global: g.count = p0.count + p1.count + "0 9", // p0 "0 11")) // p1 tk.MustQuery("show stats_topn where table_name='tint' and is_index=0").Check(testkit.Rows( @@ -1093,7 +1093,7 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustQuery("select distinct_count, null_count, tot_col_size from mysql.stats_histograms where is_index=0 order by table_id asc").Check( testkit.Rows("12 1 19", // global, g = p0 + p1 - "5 1 8", // p0 + "5 1 8", // p0 "7 0 11")) // p1 tk.MustQuery("show stats_buckets where is_index=1").Check(testkit.Rows( @@ -1107,7 +1107,7 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustQuery("select distinct_count, null_count from mysql.stats_histograms where is_index=1 order by table_id asc").Check( testkit.Rows("12 1", // global, g = p0 + p1 - "5 1", // p0 + "5 1", // p0 "7 0")) // p1 // double + (column + index with 1 column) From 7846a3b4c88c34bb4a6244640a01daf1d0b3840d Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Thu, 3 Jun 2021 10:55:00 +0800 Subject: [PATCH 3/6] skip them under RACE TEST --- executor/analyze_test.go | 7 +++++++ executor/simple_test.go | 4 ++++ statistics/handle/handle_test.go | 15 +++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/executor/analyze_test.go b/executor/analyze_test.go index 7252c32cc644f..958778c58a55e 100644 --- a/executor/analyze_test.go +++ b/executor/analyze_test.go @@ -46,6 +46,7 @@ import ( "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util/codec" "github.com/pingcap/tidb/util/collate" + "github.com/pingcap/tidb/util/israce" "github.com/pingcap/tidb/util/testkit" ) @@ -511,6 +512,9 @@ func (s *testFastAnalyze) TestFastAnalyze(c *C) { } func (s *testSerialSuite2) TestFastAnalyze4GlobalStats(c *C) { + if israce.RaceEnabled { + c.Skip("unstable, skip race test") + } tk := testkit.NewTestKit(c, s.store) tk.MustExec(`create database if not exists test_fast_gstats`) tk.MustExec("use test_fast_gstats") @@ -747,6 +751,9 @@ func (s *testSuite10) TestFailedAnalyzeRequest(c *C) { } func (s *testSuite1) TestExtractTopN(c *C) { + if israce.RaceEnabled { + c.Skip("unstable, skip race test") + } tk := testkit.NewTestKit(c, s.store) tk.MustExec("create database if not exists test_extract_topn") tk.MustExec("use test_extract_topn") diff --git a/executor/simple_test.go b/executor/simple_test.go index 135442693b24d..dc464c38b83c0 100644 --- a/executor/simple_test.go +++ b/executor/simple_test.go @@ -32,6 +32,7 @@ import ( "github.com/pingcap/tidb/statistics/handle" "github.com/pingcap/tidb/store/mockstore" "github.com/pingcap/tidb/util" + "github.com/pingcap/tidb/util/israce" "github.com/pingcap/tidb/util/testkit" "github.com/pingcap/tidb/util/testutil" ) @@ -604,6 +605,9 @@ func (s *testFlushSuite) TestFlushPrivilegesPanic(c *C) { } func (s *testSerialSuite) TestDropPartitionStats(c *C) { + if israce.RaceEnabled { + c.Skip("unstable, skip race test") + } // Use the testSerialSuite to fix the unstable test tk := testkit.NewTestKit(c, s.store) tk.MustExec(`create database if not exists test_drop_gstats`) diff --git a/statistics/handle/handle_test.go b/statistics/handle/handle_test.go index c66e534b0a386..c44e5f7c69d50 100644 --- a/statistics/handle/handle_test.go +++ b/statistics/handle/handle_test.go @@ -37,6 +37,7 @@ import ( "github.com/pingcap/tidb/store/tikv/oracle" "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util/collate" + "github.com/pingcap/tidb/util/israce" "github.com/pingcap/tidb/util/testkit" ) @@ -869,6 +870,9 @@ func (s *testStatsSuite) checkForGlobalStatsWithOpts(c *C, tk *testkit.TestKit, } func (s *testStatsSuite) TestAnalyzeGlobalStatsWithOpts(c *C) { + if israce.RaceEnabled { + c.Skip("unstable, skip race test") + } defer cleanEnv(c, s.store, s.do) tk := testkit.NewTestKit(c, s.store) s.prepareForGlobalStatsWithOpts(c, tk, "test_gstats_opt", "test_gstats_opt") @@ -904,6 +908,9 @@ func (s *testStatsSuite) TestAnalyzeGlobalStatsWithOpts(c *C) { } func (s *testStatsSuite) TestAnalyzeGlobalStatsWithOpts2(c *C) { + if israce.RaceEnabled { + c.Skip("unstable, skip race test") + } defer cleanEnv(c, s.store, s.do) tk := testkit.NewTestKit(c, s.store) s.prepareForGlobalStatsWithOpts(c, tk, "test_gstats_opt2", "test_gstats_opt2") @@ -1062,8 +1069,8 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustExec("analyze table tint with 2 topn, 2 buckets") tk.MustQuery("select modify_count, count from mysql.stats_meta order by table_id asc").Check(testkit.Rows( - "0 20", // global: g.count = p0.count + p1.count - "0 9", // p0 + "0 20", // global: g.count = p0.count + p1.count + "0 9", // p0 "0 11")) // p1 tk.MustQuery("show stats_topn where table_name='tint' and is_index=0").Check(testkit.Rows( @@ -1093,7 +1100,7 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustQuery("select distinct_count, null_count, tot_col_size from mysql.stats_histograms where is_index=0 order by table_id asc").Check( testkit.Rows("12 1 19", // global, g = p0 + p1 - "5 1 8", // p0 + "5 1 8", // p0 "7 0 11")) // p1 tk.MustQuery("show stats_buckets where is_index=1").Check(testkit.Rows( @@ -1107,7 +1114,7 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustQuery("select distinct_count, null_count from mysql.stats_histograms where is_index=1 order by table_id asc").Check( testkit.Rows("12 1", // global, g = p0 + p1 - "5 1", // p0 + "5 1", // p0 "7 0")) // p1 // double + (column + index with 1 column) From e72c7fba61a7c19edd70831e6513ed786e5f8790 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Thu, 3 Jun 2021 10:58:10 +0800 Subject: [PATCH 4/6] fixup --- executor/analyze_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/executor/analyze_test.go b/executor/analyze_test.go index 958778c58a55e..45be004a2578a 100644 --- a/executor/analyze_test.go +++ b/executor/analyze_test.go @@ -238,7 +238,9 @@ func (s *testSuite1) TestAnalyzeTooLongColumns(c *C) { } func (s *testSuite1) TestAnalyzeIndexExtractTopN(c *C) { - c.Skip("unstable") + if israce.RaceEnabled { + c.Skip("unstable, skip race test") + } store, err := mockstore.NewMockStore() c.Assert(err, IsNil) defer func() { @@ -253,7 +255,8 @@ func (s *testSuite1) TestAnalyzeIndexExtractTopN(c *C) { defer dom.Close() tk := testkit.NewTestKit(c, store) - tk.MustExec("use test") + tk.MustExec("create database test_index_extract_topn") + tk.MustExec("use test_index_extract_topn") tk.MustExec("drop table if exists t") tk.MustExec("create table t(a int, b int, index idx(a, b))") tk.MustExec("insert into t values(1, 1), (1, 1), (1, 2), (1, 2)") @@ -261,7 +264,7 @@ func (s *testSuite1) TestAnalyzeIndexExtractTopN(c *C) { tk.MustExec("analyze table t with 10 cmsketch width") is := tk.Se.(sessionctx.Context).GetInfoSchema().(infoschema.InfoSchema) - table, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("t")) + table, err := is.TableByName(model.NewCIStr("test_index_extract_topn"), model.NewCIStr("t")) c.Assert(err, IsNil) tableInfo := table.Meta() tbl := dom.StatsHandle().GetTableStats(tableInfo) From 80a2664a579fe6ba27d326cdc0fb6e469e30316b Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Thu, 3 Jun 2021 14:33:03 +0800 Subject: [PATCH 5/6] refmt --- statistics/handle/handle_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/statistics/handle/handle_test.go b/statistics/handle/handle_test.go index a6d975b22eae9..51fcc5143147d 100644 --- a/statistics/handle/handle_test.go +++ b/statistics/handle/handle_test.go @@ -1073,8 +1073,8 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustExec("analyze table tint with 2 topn, 2 buckets") tk.MustQuery("select modify_count, count from mysql.stats_meta order by table_id asc").Check(testkit.Rows( - "0 20", // global: g.count = p0.count + p1.count - "0 9", // p0 + "0 20", // global: g.count = p0.count + p1.count + "0 9", // p0 "0 11")) // p1 tk.MustQuery("show stats_topn where table_name='tint' and is_index=0").Check(testkit.Rows( @@ -1104,7 +1104,7 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustQuery("select distinct_count, null_count, tot_col_size from mysql.stats_histograms where is_index=0 order by table_id asc").Check( testkit.Rows("12 1 19", // global, g = p0 + p1 - "5 1 8", // p0 + "5 1 8", // p0 "7 0 11")) // p1 tk.MustQuery("show stats_buckets where is_index=1").Check(testkit.Rows( @@ -1118,7 +1118,7 @@ func (s *testStatsSuite) TestGlobalStatsData2(c *C) { tk.MustQuery("select distinct_count, null_count from mysql.stats_histograms where is_index=1 order by table_id asc").Check( testkit.Rows("12 1", // global, g = p0 + p1 - "5 1", // p0 + "5 1", // p0 "7 0")) // p1 // double + (column + index with 1 column) From 53083f078fbc84407a5bb19cb035e49d7b807a59 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Thu, 3 Jun 2021 15:01:26 +0800 Subject: [PATCH 6/6] fixup --- statistics/handle/handle_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/statistics/handle/handle_test.go b/statistics/handle/handle_test.go index 51fcc5143147d..234e5f3cae0cc 100644 --- a/statistics/handle/handle_test.go +++ b/statistics/handle/handle_test.go @@ -919,7 +919,7 @@ func (s *testStatsSuite) TestAnalyzeGlobalStatsWithOpts2(c *C) { tk := testkit.NewTestKit(c, s.store) s.prepareForGlobalStatsWithOpts(c, tk, "test_gstats_opt2", "test_gstats_opt2") - tk.MustExec("analyze table t with 20 topn, 50 buckets, 1000 samples") + tk.MustExec("analyze table test_gstats_opt2 with 20 topn, 50 buckets, 1000 samples") s.checkForGlobalStatsWithOpts(c, tk, "global", 2, 50) s.checkForGlobalStatsWithOpts(c, tk, "p0", 1, 50) s.checkForGlobalStatsWithOpts(c, tk, "p1", 1, 50) @@ -935,7 +935,7 @@ func (s *testStatsSuite) TestAnalyzeGlobalStatsWithOpts2(c *C) { s.checkForGlobalStatsWithOpts(c, tk, "p0", 10, 20) s.checkForGlobalStatsWithOpts(c, tk, "p1", 100, 200) - tk.MustExec("analyze table t partition p0 with 20 topn") // change back to 20 topn + tk.MustExec("analyze table test_gstats_opt2 partition p0 with 20 topn") // change back to 20 topn s.checkForGlobalStatsWithOpts(c, tk, "global", 20, 256) s.checkForGlobalStatsWithOpts(c, tk, "p0", 20, 256) s.checkForGlobalStatsWithOpts(c, tk, "p1", 100, 200)