planner,executor: fix point get for update read panic on partition table (#25537)

This commit is contained in:
tiancaiamao
2021-06-18 12:22:38 +08:00
committed by GitHub
parent fce508702f
commit 5645edeec6
2 changed files with 19 additions and 0 deletions

View File

@ -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"))
}

View File

@ -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 {