diff --git a/executor/executor_test.go b/executor/executor_test.go index e93ba0621f831..14def89c0d914 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -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) { diff --git a/planner/core/rule_partition_processor.go b/planner/core/rule_partition_processor.go index b3a6200151ce8..4b04412e5c02a 100644 --- a/planner/core/rule_partition_processor.go +++ b/planner/core/rule_partition_processor.go @@ -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