diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index 3d4ade1776e54..9b864309f1e8c 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -3018,3 +3018,13 @@ PARTITION BY RANGE (a) ( s.testData.GetTestCases(c, &input, &output) s.verifyPartitionResult(tk, input, output) } + +func (s *partitionTableSuite) TestIssue25528(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("set @@tidb_partition_prune_mode = 'static'") + tk.MustExec("use test") + tk.MustExec("create table issue25528 (id int primary key, balance DECIMAL(10, 2), balance2 DECIMAL(10, 2) GENERATED ALWAYS AS (-balance) VIRTUAL, created_at TIMESTAMP) PARTITION BY HASH(id) PARTITIONS 8") + tk.MustExec("insert into issue25528 (id, balance, created_at) values(1, 100, '2021-06-17 22:35:20')") + tk.MustExec("begin pessimistic") + tk.MustQuery("select * from issue25528 where id = 1 for update").Check(testkit.Rows("1 100.00 -100.00 2021-06-17 22:35:20")) +} diff --git a/planner/core/find_best_task.go b/planner/core/find_best_task.go index 8a2e41ec85a02..8802e1456021a 100644 --- a/planner/core/find_best_task.go +++ b/planner/core/find_best_task.go @@ -732,6 +732,15 @@ func (ds *DataSource) findBestTask(prop *property.PhysicalProperty, planCounter if hashPartColName == nil { canConvertPointGet = false } + } else { + // If the schema contains ExtraPidColID, do not convert to point get. + // Because the point get executor can not handle the extra partition ID column now. + for _, col := range ds.schema.Columns { + if col.ID == model.ExtraPidColID { + canConvertPointGet = false + break + } + } } } if canConvertPointGet {