diff --git a/pkg/planner/core/point_get_plan.go b/pkg/planner/core/point_get_plan.go index 546c97340e342..8f89c11d75900 100644 --- a/pkg/planner/core/point_get_plan.go +++ b/pkg/planner/core/point_get_plan.go @@ -817,8 +817,8 @@ func newBatchPointGetPlan( if dval == nil { return nil } - values[permIndex] = innerX.Datum - pairs = append(pairs, nameValuePair{colName: whereColNames[index], value: innerX.Datum}) + values[permIndex] = *dval + pairs = append(pairs, nameValuePair{colName: whereColNames[index], value: *dval}) case *driver.ParamMarkerExpr: con, err := expression.ParamMarkerExpression(ctx, innerX, true) if err != nil { @@ -832,12 +832,12 @@ func newBatchPointGetPlan( if dval == nil { return nil } - values[permIndex] = innerX.Datum + values[permIndex] = *dval valuesParams[permIndex] = con if initTypes { indexTypes[permIndex] = &colInfos[index].FieldType } - pairs = append(pairs, nameValuePair{colName: whereColNames[index], value: innerX.Datum}) + pairs = append(pairs, nameValuePair{colName: whereColNames[index], value: *dval}) default: return nil } diff --git a/tests/integrationtest/r/planner/core/casetest/partition/integration_partition.result b/tests/integrationtest/r/planner/core/casetest/partition/integration_partition.result index 44ef24389322b..8d4e7d48d0b65 100644 --- a/tests/integrationtest/r/planner/core/casetest/partition/integration_partition.result +++ b/tests/integrationtest/r/planner/core/casetest/partition/integration_partition.result @@ -750,3 +750,19 @@ id estRows task access object operator info TableReader 10.00 root data:Selection └─Selection 10.00 cop[tikv] eq(list_partition_pruning.t.col, "LINPIN") └─TableFullScan 10000.00 cop[tikv] table:t, partition:p4 keep order:false, stats:pseudo +drop table if exists t; +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; +INSERT INTO t(tenant_id, order_id) VALUES (123, 456); +select * from t where (tenant_id, order_id) in (('123','456')); +tenant_id order_id +123 456 +select * from t where (tenant_id, order_id) in (('0123','456')); +tenant_id order_id +123 456 +alter table t remove partitioning; +select * from t where (tenant_id, order_id) in (('123','456')); +tenant_id order_id +123 456 +select * from t where (tenant_id, order_id) in (('0123','456')); +tenant_id order_id +123 456 diff --git a/tests/integrationtest/t/planner/core/casetest/partition/integration_partition.test b/tests/integrationtest/t/planner/core/casetest/partition/integration_partition.test index a19c49b78cfbe..5645deb754db5 100644 --- a/tests/integrationtest/t/planner/core/casetest/partition/integration_partition.test +++ b/tests/integrationtest/t/planner/core/casetest/partition/integration_partition.test @@ -185,3 +185,13 @@ drop table if exists t; create table t(col varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL) PARTITION BY KEY (`col`) PARTITIONS 7; explain format = brief select * from t where col = 'linpin'; explain format = brief select * from t where col = 'LINPIN'; + +# TestIssue54746 +drop table if exists t; +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; +INSERT INTO t(tenant_id, order_id) VALUES (123, 456); +select * from t where (tenant_id, order_id) in (('123','456')); +select * from t where (tenant_id, order_id) in (('0123','456')); +alter table t remove partitioning; +select * from t where (tenant_id, order_id) in (('123','456')); +select * from t where (tenant_id, order_id) in (('0123','456'));