Skip to content

Commit

Permalink
planner: return error when SPLIT PARTITION TABLE on non-partitioned…
Browse files Browse the repository at this point in the history
… table (pingcap#17218)
  • Loading branch information
winoros authored May 18, 2020
1 parent 121c153 commit f06fc35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4251,6 +4251,9 @@ func (s *testSplitTable) TestShowTableRegion(c *C) {
tk.MustExec("set global tidb_scatter_region = 1")
atomic.StoreUint32(&ddl.EnableSplitTableRegion, 1)
tk.MustExec("create table t_regions (a int key, b int, c int, index idx(b), index idx2(c))")
_, err := tk.Exec("split partition table t_regions partition (p1,p2) index idx between (0) and (20000) regions 2;")
c.Assert(err.Error(), Equals, plannercore.ErrPartitionClauseOnNonpartitioned.Error())

// Test show table regions.
tk.MustQuery(`split table t_regions between (-10000) and (10000) regions 4;`).Check(testkit.Rows("4 1"))
re := tk.MustQuery("show table t_regions regions")
Expand Down
3 changes: 3 additions & 0 deletions planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2394,6 +2394,9 @@ func (b *PlanBuilder) buildIndexAdvise(node *ast.IndexAdviseStmt) Plan {
}

func (b *PlanBuilder) buildSplitRegion(node *ast.SplitRegionStmt) (Plan, error) {
if node.SplitSyntaxOpt != nil && node.SplitSyntaxOpt.HasPartition && node.Table.TableInfo.Partition == nil {
return nil, ErrPartitionClauseOnNonpartitioned
}
if len(node.IndexName.L) != 0 {
return b.buildSplitIndexRegion(node)
}
Expand Down

0 comments on commit f06fc35

Please sign in to comment.