Skip to content

Commit

Permalink
planner,executor: fix point get for update read panic on partition ta…
Browse files Browse the repository at this point in the history
…ble (pingcap#25537)
  • Loading branch information
tiancaiamao authored and Yisaer committed Jun 18, 2021
1 parent ded9b88 commit 81493a7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions executor/partition_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
9 changes: 9 additions & 0 deletions planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 81493a7

Please sign in to comment.