Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: Disable dynamic partition prune mode for all non-autocommit (#27532) #30505

Merged
merged 3 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions planner/core/integration_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1160,3 +1160,22 @@ func genListPartition(begin, end int) string {
buf.WriteString(fmt.Sprintf("%v)", end-1))
return buf.String()
}

func TestIssue27532(t *testing.T) {
t.Parallel()
store, clean := testkit.CreateMockStore(t)
defer clean()

tk := testkit.NewTestKit(t, store)
tk.MustExec("create database issue_27532")
defer tk.MustExec(`drop database issue_27532`)
tk.MustExec("use issue_27532")
tk.MustExec(`set tidb_enable_list_partition = 1`)
tk.MustExec(`create table t2 (c1 int primary key, c2 int, c3 int, c4 int, key k2 (c2), key k3 (c3)) partition by hash(c1) partitions 10`)
tk.MustExec(`insert into t2 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4)`)
tk.MustExec(`set @@tidb_partition_prune_mode="dynamic"`)
tk.MustExec(`set autocommit = 0`)
tk.MustQuery(`select * from t2`).Sort().Check(testkit.Rows("1 1 1 1", "2 2 2 2", "3 3 3 3", "4 4 4 4"))
tk.MustQuery(`select * from t2`).Sort().Check(testkit.Rows("1 1 1 1", "2 2 2 2", "3 3 3 3", "4 4 4 4"))
tk.MustExec(`drop table t2`)
}
2 changes: 1 addition & 1 deletion sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ func (s *SessionVars) CheckAndGetTxnScope() string {

// UseDynamicPartitionPrune indicates whether use new dynamic partition prune.
func (s *SessionVars) UseDynamicPartitionPrune() bool {
if s.InTxn() {
if s.InTxn() || !s.GetStatusFlag(mysql.ServerStatusAutocommit) {
// UnionScan cannot get partition table IDs in dynamic-mode, this is a quick-fix for issues/26719,
// please see it for more details.
return false
Expand Down