Skip to content

Commit

Permalink
planner/core: fix a panic when select for update on join partition ta…
Browse files Browse the repository at this point in the history
…ble with normal table (#26373) (#26563)
  • Loading branch information
ti-srebot authored Sep 16, 2021
1 parent 1cae2c5 commit 5c561eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3902,6 +3902,16 @@ func (s *testIntegrationSerialSuite) TestMergeContinuousSelections(c *C) {
}
}

func (s *testIntegrationSerialSuite) TestIssue26250(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table tp (id int primary key) partition by range (id) (partition p0 values less than (100));")
tk.MustExec("create table tn (id int primary key);")
tk.MustExec("insert into tp values(1),(2);")
tk.MustExec("insert into tn values(1),(2);")
tk.MustQuery("select * from tp,tn where tp.id=tn.id and tn.id=1 for update;").Check(testkit.Rows("1 1"))
}

func (s *testIntegrationSuite) TestIssue26559(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
Expand Down
4 changes: 4 additions & 0 deletions planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,10 @@ func (b *PlanBuilder) buildSelectLock(src LogicalPlan, lock *ast.SelectLockInfo)
func addExtraPIDColumnToDataSource(p LogicalPlan, info *extraPIDInfo) error {
switch raw := p.(type) {
case *DataSource:
// Fix issue 26250, do not add extra pid column to normal table.
if raw.tableInfo.GetPartitionInfo() == nil {
return nil
}
raw.addExtraPIDColumn(info)
return nil
default:
Expand Down

0 comments on commit 5c561eb

Please sign in to comment.