Skip to content

Commit

Permalink
planner: fix union scan on partition table bug (pingcap#11187) (pingc…
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 authored and winkyao committed Jul 11, 2019
1 parent 3c614bb commit 26afeda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3572,6 +3572,13 @@ func (s *testSuite3) TestSelectPartition(c *C) {
c.Assert(err.Error(), Equals, "[table:1735]Unknown partition 'p4' in table 'th'")
err = tk.ExecToErr("select b from tr partition (r1,r4)")
c.Assert(err.Error(), Equals, "[table:1735]Unknown partition 'r4' in table 'tr'")

// test select partition table in transaction.
tk.MustExec("begin")
tk.MustExec("insert into th values (10,10),(11,11)")
tk.MustQuery("select a, b from th where b>10").Check(testkit.Rows("11 11"))
tk.MustExec("commit")
tk.MustQuery("select a, b from th where b>10").Check(testkit.Rows("11 11"))
}

func (s *testSuite) TestSelectView(c *C) {
Expand Down
7 changes: 4 additions & 3 deletions planner/core/rule_partition_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ func (s *partitionProcessor) rewriteDataSource(lp LogicalPlan) (LogicalPlan, err
// Union->(UnionScan->DataSource1), (UnionScan->DataSource2)
children := make([]LogicalPlan, 0, len(ua.Children()))
for _, child := range ua.Children() {
us := LogicalUnionScan{}.Init(ua.ctx)
us.SetChildren(child)
children = append(children, us)
usChild := LogicalUnionScan{}.Init(ua.ctx)
usChild.conditions = us.conditions
usChild.SetChildren(child)
children = append(children, usChild)
}
ua.SetChildren(children...)
return ua, nil
Expand Down

0 comments on commit 26afeda

Please sign in to comment.