diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index 642233ea04f16..beaa960ee999b 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -3970,3 +3970,13 @@ func (s *testIntegrationSerialSuite) TestSelectIgnoreTemporaryTableInView(c *C) tk.MustQuery("select * from v5").Check(testkit.Rows("1 2", "3 4")) } + +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")) +} diff --git a/planner/core/planbuilder.go b/planner/core/planbuilder.go index 335951a1b5307..2fcdd6fc19c85 100644 --- a/planner/core/planbuilder.go +++ b/planner/core/planbuilder.go @@ -1236,6 +1236,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: