Skip to content

Commit 1ee3c45

Browse files
authored
planner: fix PointGet working with list columns partition table with only one partition (#61141)
close #61134
1 parent dfc4eee commit 1ee3c45

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

pkg/planner/core/casetest/partition/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ go_test(
1010
],
1111
data = glob(["testdata/**"]),
1212
flaky = True,
13-
shard_count = 13,
13+
shard_count = 14,
1414
deps = [
1515
"//pkg/config",
1616
"//pkg/planner/util/coretestsdk",

pkg/planner/core/casetest/partition/partition_pruner_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,18 @@ func TestIssue59827RangeColumns(t *testing.T) {
634634
tk.MustQuery("explain select * from t where a = 'a' and b = '2'").CheckContain("partition:p2")
635635
tk.MustQuery("explain select * from t where a = 'a' and (b = '2')").CheckContain("partition:p2")
636636
}
637+
638+
func TestIssue61134(t *testing.T) {
639+
store := testkit.CreateMockStore(t)
640+
tk := testkit.NewTestKit(t, store)
641+
tk.MustExec("use test")
642+
tk.MustExec("create table t (" +
643+
"a varchar(291)," +
644+
"b int," +
645+
"primary key(a)) partition by list columns (a)" +
646+
"(partition p0 values in ('', '1'))")
647+
648+
tk.MustExec("insert into t values ('', 1)")
649+
tk.MustQuery("explain select * from t where a in ('')").CheckContain("Point_Get")
650+
tk.MustQuery("select * from t where a in ('')").Check(testkit.Rows(" 1"))
651+
}

pkg/planner/core/point_get_plan.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,16 @@ func needsPartitionPruning(sctx sessionctx.Context, tblInfo *model.TableInfo, pt
388388
}
389389

390390
partIdx, err := PartitionPruning(sctx.GetPlanCtx(), pt, conds, partitionNames, tblCols, partNameSlice)
391-
if err != nil || len(partIdx) != 1 {
391+
if err != nil {
392392
return nil, true, err
393393
}
394+
if len(partIdx) == 1 && partIdx[0] == FullRange {
395+
ret := make([]int, len(tblInfo.Partition.Definitions))
396+
for i := range len(tblInfo.Partition.Definitions) {
397+
ret[i] = i
398+
}
399+
return ret, true, nil
400+
}
394401
return partIdx, true, nil
395402
}
396403

0 commit comments

Comments
 (0)