pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
36.91k stars 5.81k forks source link

Batch Point Get doesn't use converted datum #54746

Open Ryan-Git opened 2 months ago

Ryan-Git commented 2 months ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

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);

DELETE FROM t where (tenant_id, order_id) in (('123','456'));

2. What did you expect to see? (Required)

affected rows 1

3. What did you see instead (Required)

affected rows 0

4. What is your TiDB version? (Required)

up to 7.5.0, master the same I think

in https://github.com/pingcap/tidb/pull/26713, cases of ValueExpr and ParamMarkerExpr are handled(use converted int datum instead of origin string one), but the RowExpr is left unchanged, which causes this problem.

Is it intentional?

Defined2014 commented 2 months ago

It's been fixed by https://github.com/pingcap/tidb/pull/49161 and only affects v7.5.x and previous version.

Ryan-Git commented 1 month ago

It's been fixed by #49161 and only affects v7.5.x and previous version.

u mean plan cache re-evaluates it? It seems the value still uses innerX.Datum instead of dval on main. https://github.com/mjonss/tidb/blame/cc616f9ba19d9c8a9dc31ae9b95fe54077069454/pkg/planner/core/point_get_plan.go#L1124