Skip to content

Commit badb901

Browse files
authored
planner: Using converted value in newBatchPointGetPlan, fix for partitioned table and IN (#57011) (#59325)
close #54746
1 parent ea34b0b commit badb901

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
drop table if exists t;
2+
CREATE TABLE `t` (`tenant_id` bigint(20) NOT NULL DEFAULT '0',`order_id` bigint(20) NOT NULL DEFAULT '0',UNIQUE KEY `uk_ten_ord` (`order_id`, `tenant_id`)) PARTITION BY HASH(`tenant_id`) PARTITIONS 32;
3+
INSERT INTO t(tenant_id, order_id) VALUES (123, 456);
4+
select * from t where (tenant_id, order_id) in (('123','456'));
5+
tenant_id order_id
6+
123 456
7+
select * from t where (tenant_id, order_id) in (('0123','456'));
8+
tenant_id order_id
9+
123 456
10+
drop table t;
11+
CREATE TABLE `t` (`tenant_id` bigint(20) NOT NULL DEFAULT '0',`order_id` bigint(20) NOT NULL DEFAULT '0',UNIQUE KEY `uk_ten_ord` (`order_id`, `tenant_id`));
12+
INSERT INTO t(tenant_id, order_id) VALUES (123, 456);
13+
select * from t where (tenant_id, order_id) in (('123','456'));
14+
tenant_id order_id
15+
123 456
16+
select * from t where (tenant_id, order_id) in (('0123','456'));
17+
tenant_id order_id
18+
123 456
19+
drop table t;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# TestIssue54746
2+
drop table if exists t;
3+
CREATE TABLE `t` (`tenant_id` bigint(20) NOT NULL DEFAULT '0',`order_id` bigint(20) NOT NULL DEFAULT '0',UNIQUE KEY `uk_ten_ord` (`order_id`, `tenant_id`)) PARTITION BY HASH(`tenant_id`) PARTITIONS 32;
4+
INSERT INTO t(tenant_id, order_id) VALUES (123, 456);
5+
select * from t where (tenant_id, order_id) in (('123','456'));
6+
select * from t where (tenant_id, order_id) in (('0123','456'));
7+
8+
drop table t;
9+
CREATE TABLE `t` (`tenant_id` bigint(20) NOT NULL DEFAULT '0',`order_id` bigint(20) NOT NULL DEFAULT '0',UNIQUE KEY `uk_ten_ord` (`order_id`, `tenant_id`));
10+
INSERT INTO t(tenant_id, order_id) VALUES (123, 456);
11+
select * from t where (tenant_id, order_id) in (('123','456'));
12+
select * from t where (tenant_id, order_id) in (('0123','456'));
13+
14+
drop table t;

planner/core/point_get_plan.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,8 @@ func newBatchPointGetPlan(
808808
if dval == nil {
809809
return nil
810810
}
811-
values[permIndex] = innerX.Datum
812-
pairs = append(pairs, nameValuePair{colName: whereColNames[index], value: innerX.Datum})
811+
values[permIndex] = *dval
812+
pairs = append(pairs, nameValuePair{colName: whereColNames[index], value: *dval})
813813
case *driver.ParamMarkerExpr:
814814
con, err := expression.ParamMarkerExpression(ctx, innerX, true)
815815
if err != nil {
@@ -823,12 +823,12 @@ func newBatchPointGetPlan(
823823
if dval == nil {
824824
return nil
825825
}
826-
values[permIndex] = innerX.Datum
826+
values[permIndex] = *dval
827827
valuesParams[permIndex] = con
828828
if initTypes {
829829
indexTypes[permIndex] = &colInfos[index].FieldType
830830
}
831-
pairs = append(pairs, nameValuePair{colName: whereColNames[index], value: innerX.Datum})
831+
pairs = append(pairs, nameValuePair{colName: whereColNames[index], value: *dval})
832832
default:
833833
return nil
834834
}

0 commit comments

Comments
 (0)