From d5d5f825e60c69100c6f7c9a29fa911d821b8bf6 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Wed, 1 Sep 2021 18:38:46 +0800 Subject: [PATCH 1/2] fixup --- statistics/handle/handle_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/statistics/handle/handle_test.go b/statistics/handle/handle_test.go index 53b9549d5e7ba..19cc744ba4d97 100644 --- a/statistics/handle/handle_test.go +++ b/statistics/handle/handle_test.go @@ -903,14 +903,14 @@ func (s *testSerialStatsSuite) prepareForGlobalStatsWithOpts(c *C, tk *testkit.T // nolint:unused func (s *testSerialStatsSuite) checkForGlobalStatsWithOpts(c *C, tk *testkit.TestKit, t string, p string, topn, buckets int) { - delta := buckets/2 + 1 + delta := buckets/2 + 10 for _, isIdx := range []int{0, 1} { c.Assert(len(tk.MustQuery(fmt.Sprintf("show stats_topn where table_name='%v' and partition_name='%v' and is_index=%v", t, p, isIdx)).Rows()), Equals, topn) numBuckets := len(tk.MustQuery(fmt.Sprintf("show stats_buckets where table_name='%v' and partition_name='%v' and is_index=%v", t, p, isIdx)).Rows()) // since the hist-building algorithm doesn't stipulate the final bucket number to be equal to the expected number exactly, // we have to check the results by a range here. - c.Assert(numBuckets >= buckets-delta, IsTrue) - c.Assert(numBuckets <= buckets+delta, IsTrue) + c.Assert(numBuckets, GreaterEqual, buckets-delta) + c.Assert(numBuckets, LessEqual, buckets+delta) } } @@ -1115,8 +1115,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( @@ -1146,7 +1146,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( @@ -1160,7 +1160,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 a8be78a8ef940b2edb5ec35eef9d2c8927fd509b Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 6 Sep 2021 14:45:40 +0800 Subject: [PATCH 2/2] fixup --- 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 19cc744ba4d97..d0fc072c8a2aa 100644 --- a/statistics/handle/handle_test.go +++ b/statistics/handle/handle_test.go @@ -1115,8 +1115,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( @@ -1146,7 +1146,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( @@ -1160,7 +1160,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)