Skip to content

return wrong results when using plan-cache and dynamic-mode #33031

@ChenPeng2013

Description

@ChenPeng2013

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

prepared-plan-cache.enabled = true

use test;
drop table if exists UK_RP17396;
CREATE TABLE `UK_RP17396` (
  `COL1` int(16) DEFAULT '29' COMMENT 'NUMERIC UNIQUE INDEX',
  `COL2` varchar(20) DEFAULT NULL,
  `COL4` datetime DEFAULT NULL,
  `COL3` bigint(20) DEFAULT NULL,
  `COL5` float DEFAULT NULL,
  UNIQUE KEY `UK_COL1` (`COL1`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE (`COL1`)
(PARTITION `P0` VALUES LESS THAN (-1964648596),
 PARTITION `P1` VALUES LESS THAN (-1798171365),
 PARTITION `P2` VALUES LESS THAN (-224353317),
 PARTITION `P3` VALUES LESS THAN (74739562),
 PARTITION `P4` VALUES LESS THAN (330180811),
 PARTITION `P5` VALUES LESS THAN (1267470870));

insert into UK_RP17396 values(-556906299, "竂揿蜓锌璸籾珵岄浑祿恺鮘茷拦没盬饎醱僛橉", "9269-08-13 18:36:02", 363208857940760420, -1.28355e38);


set tidb_partition_prune_mode=static;
prepare stmt from 'select * from UK_RP17396 where col3 < ? and col1 in (?, ?, ?) and col2 != ?;';
set @a=4020185825752602279, @b=-4331, @c=-29749, @d=-13306, @e="AgHVfFsnfEO";
execute stmt using @a,@b,@c,@d,@e;
set @a=2972768264503339938, @b=5150, @c=-556906299, @d=1232847360, @e="=姵犵駘鏤ⱴȴ褋韨窷晢镸辈夁沶蚩皭兩隧撬";
execute stmt using @a,@b,@c,@d,@e;


set tidb_partition_prune_mode=dynamic;
prepare stmt from 'select * from UK_RP17396 where col3 < ? and col1 in (?, ?, ?) and col2 != ?;';
set @a=4020185825752602279, @b=-4331, @c=-29749, @d=-13306, @e="AgHVfFsnfEO";
execute stmt using @a,@b,@c,@d,@e;
set @a=2972768264503339938, @b=5150, @c=-556906299, @d=1232847360, @e="=姵犵駘鏤ⱴȴ褋韨窷晢镸辈夁沶蚩皭兩隧撬";
execute stmt using @a,@b,@c,@d,@e;

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

MySQL [test]> execute stmt using @a,@b,@c,@d,@e;
+------------+--------------------------------------------------------------+---------------------+--------------------+-------------+
| COL1       | COL2                                                         | COL4                | COL3               | COL5        |
+------------+--------------------------------------------------------------+---------------------+--------------------+-------------+
| -556906299 | 竂揿蜓锌璸籾珵岄浑祿恺鮘茷拦没盬饎醱僛橉 | 9269-08-13 18:36:02 | 363208857940760420 | -1.28355e38 |
+------------+--------------------------------------------------------------+---------------------+--------------------+-------------+
1 row in set (0.00 sec)

MySQL [test]>
MySQL [test]>
MySQL [test]> set tidb_partition_prune_mode=dynamic;
Query OK, 0 rows affected (0.00 sec)

MySQL [test]> prepare stmt from 'select * from UK_RP17396 where col3 < ? and col1 in (?, ?, ?) and col2 != ?;';
Query OK, 0 rows affected (0.00 sec)

MySQL [test]> set @a=4020185825752602279, @b=-4331, @c=-29749, @d=-13306, @e="AgHVfFsnfEO";
Query OK, 0 rows affected (0.00 sec)

MySQL [test]> execute stmt using @a,@b,@c,@d,@e;
Empty set (0.01 sec)

;ySQL [test]> set @a=2972768264503339938, @b=5150, @c=-556906299, @d=1232847360, @e="=姵犵駘鏤ⱴȴ褋韨窷晢镸辈夁沶蚩皭兩隧撬"
Query OK, 0 rows affected (0.00 sec)

MySQL [test]> execute stmt using @a,@b,@c,@d,@e;
+------------+--------------------------------------------------------------+---------------------+--------------------+-------------+
| COL1       | COL2                                                         | COL4                | COL3               | COL5        |
+------------+--------------------------------------------------------------+---------------------+--------------------+-------------+
| -556906299 | 竂揿蜓锌璸籾珵岄浑祿恺鮘茷拦没盬饎醱僛橉 | 9269-08-13 18:36:02 | 363208857940760420 | -1.28355e38 |
+------------+--------------------------------------------------------------+---------------------+--------------------+-------------+

1 row in set (0.00 sec)

3. What did you see instead (Required)

MySQL [test]> execute stmt using @a,@b,@c,@d,@e;
+------------+--------------------------------------------------------------+---------------------+--------------------+-------------+
| COL1       | COL2                                                         | COL4                | COL3               | COL5        |
+------------+--------------------------------------------------------------+---------------------+--------------------+-------------+
| -556906299 | 竂揿蜓锌璸籾珵岄浑祿恺鮘茷拦没盬饎醱僛橉 | 9269-08-13 18:36:02 | 363208857940760420 | -1.28355e38 |
+------------+--------------------------------------------------------------+---------------------+--------------------+-------------+
1 row in set (0.00 sec)

MySQL [test]>
MySQL [test]>
MySQL [test]> set tidb_partition_prune_mode=dynamic;
Query OK, 0 rows affected (0.00 sec)

MySQL [test]> prepare stmt from 'select * from UK_RP17396 where col3 < ? and col1 in (?, ?, ?) and col2 != ?;';
Query OK, 0 rows affected (0.00 sec)

MySQL [test]> set @a=4020185825752602279, @b=-4331, @c=-29749, @d=-13306, @e="AgHVfFsnfEO";
Query OK, 0 rows affected (0.00 sec)

MySQL [test]> execute stmt using @a,@b,@c,@d,@e;
Empty set (0.01 sec)

;ySQL [test]> set @a=2972768264503339938, @b=5150, @c=-556906299, @d=1232847360, @e="=姵犵駘鏤ⱴȴ褋韨窷晢镸辈夁沶蚩皭兩隧撬"
Query OK, 0 rows affected (0.00 sec)

MySQL [test]> execute stmt using @a,@b,@c,@d,@e;
Empty set (0.00 sec)

4. What is your TiDB version? (Required)

Release Version: v6.0.0-alpha-56-g9a4ca3c
Edition: Community
Git Commit Hash: 9a4ca3ca6919699fb4f0da72edd7151c56f84edd
Git Branch: master
UTC Build Time: 2022-03-11 01:02:55
GoVersion: go1.17.6
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions