From bdf6fcf1a0fb613cf2527a2ad31dacb07b889f13 Mon Sep 17 00:00:00 2001 From: crazycs Date: Wed, 21 Aug 2019 11:52:42 +0800 Subject: [PATCH] *: add scatter_finish_region in split result --- executor/executor_test.go | 10 +++++----- executor/split.go | 1 + planner/core/planbuilder.go | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/executor/executor_test.go b/executor/executor_test.go index fe22553a41a0e..465671b8e9356 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -2151,7 +2151,7 @@ func (s *testSuite4) TestSplitRegionTimeout(c *C) { tk.MustExec(`split table t index idx1 by (10000,"abcd"),(10000000);`) tk.MustExec(`set @@tidb_wait_split_region_timeout=1`) // result 0 0 means split 0 region and 0 region finish scatter regions before timeout. - tk.MustQuery(`split table t between (0) and (10000) regions 10`).Check(testkit.Rows("0 0")) + tk.MustQuery(`split table t between (0) and (10000) regions 10`).Check(testkit.Rows("0 0 0")) c.Assert(failpoint.Disable("github.com/pingcap/tidb/executor/mockSplitRegionTimeout"), IsNil) } @@ -4131,7 +4131,7 @@ func (s *testSuite) TestShowTableRegion(c *C) { // Test show table regions. tk.MustExec(`split table t_regions1 by (0)`) - tk.MustQuery(`split table t_regions between (-10000) and (10000) regions 4;`).Check(testkit.Rows("3 1")) + tk.MustQuery(`split table t_regions between (-10000) and (10000) regions 4;`).Check(testkit.Rows("3 1 3")) re := tk.MustQuery("show table t_regions regions") rows := re.Rows() // Table t_regions should have 4 regions now. @@ -4146,7 +4146,7 @@ func (s *testSuite) TestShowTableRegion(c *C) { c.Assert(rows[3][1], Equals, fmt.Sprintf("t_%d_r_5000", tbl.Meta().ID)) // Test show table index regions. - tk.MustQuery(`split table t_regions index idx between (-1000) and (1000) regions 4;`).Check(testkit.Rows("4 1")) + tk.MustQuery(`split table t_regions index idx between (-1000) and (1000) regions 4;`).Check(testkit.Rows("4 1 4")) re = tk.MustQuery("show table t_regions index idx regions") rows = re.Rows() // The index `idx` of table t_regions should have 4 regions now. @@ -4175,7 +4175,7 @@ func (s *testSuite) TestShowTableRegion(c *C) { // Test show table regions. tk.MustExec(`set @@session.tidb_wait_split_region_finish=1;`) - tk.MustQuery(`split table t_regions by (2500),(5000),(7500);`).Check(testkit.Rows("3 1")) + tk.MustQuery(`split table t_regions by (2500),(5000),(7500);`).Check(testkit.Rows("3 1 3")) re = tk.MustQuery("show table t_regions regions") rows = re.Rows() // Table t_regions should have 4 regions now. @@ -4188,7 +4188,7 @@ func (s *testSuite) TestShowTableRegion(c *C) { c.Assert(rows[3][1], Equals, fmt.Sprintf("t_%d_r_7500", tbl.Meta().ID)) // Test show table index regions. - tk.MustQuery(`split table t_regions index idx by (250),(500),(750);`).Check(testkit.Rows("4 1")) + tk.MustQuery(`split table t_regions index idx by (250),(500),(750);`).Check(testkit.Rows("4 1 4")) re = tk.MustQuery("show table t_regions index idx regions") rows = re.Rows() // The index `idx` of table t_regions should have 4 regions now. diff --git a/executor/split.go b/executor/split.go index eefda2fa65601..485f27737d398 100755 --- a/executor/split.go +++ b/executor/split.go @@ -357,6 +357,7 @@ func appendSplitRegionResultToChunk(chk *chunk.Chunk, totalRegions, finishScatte } else { chk.AppendFloat64(1, float64(0)) } + chk.AppendInt64(2, int64(finishScatterNum)) } func isCtxDone(ctx context.Context) bool { diff --git a/planner/core/planbuilder.go b/planner/core/planbuilder.go index 574f60afa8b2f..39f8a5ea71386 100644 --- a/planner/core/planbuilder.go +++ b/planner/core/planbuilder.go @@ -1219,9 +1219,10 @@ func buildTableRegionsSchema() *expression.Schema { } func buildSplitRegionsSchema() *expression.Schema { - schema := expression.NewSchema(make([]*expression.Column, 0, 2)...) + schema := expression.NewSchema(make([]*expression.Column, 0, 3)...) schema.Append(buildColumn("", "TOTAL_SPLIT_REGION", mysql.TypeLonglong, 4)) schema.Append(buildColumn("", "SCATTER_FINISH_RATIO", mysql.TypeDouble, 8)) + schema.Append(buildColumn("", "SCATTER_FINISH_REGION", mysql.TypeLonglong, 4)) return schema }