Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong IndexRangeScan for bit column #33067

Closed
ChenPeng2013 opened this issue Mar 15, 2022 · 1 comment · Fixed by #33090
Closed

wrong IndexRangeScan for bit column #33067

ChenPeng2013 opened this issue Mar 15, 2022 · 1 comment · Fixed by #33090
Assignees
Labels
affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 epic/plan-cache severity/critical sig/planner SIG: Planner type/bug This issue is a bug.

Comments

@ChenPeng2013
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

use test;
drop table if exists IDT_MULTI22970;
source [test.txt](https://github.com/pingcap/tidb/files/8250040/test.txt)

prepare stmt from 'select * from IDT_MULTI22970 where col1 is not null and col2 not in (?, ?, ?) and col3 in (?, ?, ?);';
set @a=-21188, @b=26824, @c=31855, @d="5597-1-4", @e="5755-12-6", @f="1253-7-12";
execute stmt using @a,@b,@c,@d,@e,@f;
set @a=-5360, @b=-11715, @c=9399, @d="9213-09-13", @e="4705-12-24", @f="9901-06-17";
execute stmt using @a,@b,@c,@d,@e,@f;
select * from IDT_MULTI22970 where col1 is not null and col2 not in (-5360, -11715, 9399) and col3 in ("9213-09-13", "4705-12-24", "9901-06-17");

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

MySQL [test]> execute stmt using @a,@b,@c,@d,@e,@f;
+--------------------------------------------------------------+------+------------+------------+
| COL1                                                         | COL2 | COL3       | COL4       |
+--------------------------------------------------------------+------+------------+------------+
| 皪禆簤笳鏽殷雁譹缪偸荸粵綃篺伾嗯覲竬莃坽 | y�   | 9213-09-13 |  654993671 |
| 嶔Ė戙纚业锈痰啵满迂撖阂蘻飮韚齳ò柹吟圳   |  �   | 4705-12-24 |  893651658 |
| 贛翆饏粢惿苧栶掹哽旴菄慉諠俄锞ņƈ姹瓩點   | >d   | 9901-06-17 | 1952622619 |
+--------------------------------------------------------------+------+------------+------------+
3 rows in set (0.00 sec)

MySQL [test]> select * from IDT_MULTI22970 where col1 is not null and col2 not in (-5360, -11715, 9399) and col3 in ("9213-09-13", "4705-12-24", "9901-06-17");
+--------------------------------------------------------------+------+------------+------------+
| COL1                                                         | COL2 | COL3       | COL4       |
+--------------------------------------------------------------+------+------------+------------+
| 皪禆簤笳鏽殷雁譹缪偸荸粵綃篺伾嗯覲竬莃坽 | y�   | 9213-09-13 |  654993671 |
| 嶔Ė戙纚业锈痰啵满迂撖阂蘻飮韚齳ò柹吟圳   |  �   | 4705-12-24 |  893651658 |
| 贛翆饏粢惿苧栶掹哽旴菄慉諠俄锞ņƈ姹瓩點   | >d   | 9901-06-17 | 1952622619 |
+--------------------------------------------------------------+------+------------+------------+
3 rows in set (0.00 sec)

3. What did you see instead (Required)

MySQL [test]> execute stmt using @a,@b,@c,@d,@e,@f;
+--------------------------------------------------------------+------+------------+------------+
| COL1                                                         | COL2 | COL3       | COL4       |
+--------------------------------------------------------------+------+------------+------------+
| 皪禆簤笳鏽殷雁譹缪偸荸粵綃篺伾嗯覲竬莃坽 | y�   | 9213-09-13 |  654993671 |
| 皪禆簤笳鏽殷雁譹缪偸荸粵綃篺伾嗯覲竬莃坽 | y�   | 9213-09-13 |  654993671 |
| 嶔Ė戙纚业锈痰啵满迂撖阂蘻飮韚齳ò柹吟圳   |  �   | 4705-12-24 |  893651658 |
| 贛翆饏粢惿苧栶掹哽旴菄慉諠俄锞ņƈ姹瓩點   | >d   | 9901-06-17 | 1952622619 |
| 贛翆饏粢惿苧栶掹哽旴菄慉諠俄锞ņƈ姹瓩點   | >d   | 9901-06-17 | 1952622619 |
+--------------------------------------------------------------+------+------------+------------+
5 rows in set (0.00 sec)

MySQL [test]> select * from IDT_MULTI22970 where col1 is not null and col2 not in (-5360, -11715, 9399) and col3 in ("9213-09-13", "4705-12-24", "9901-06-17");
+--------------------------------------------------------------+------+------------+------------+
| COL1                                                         | COL2 | COL3       | COL4       |
+--------------------------------------------------------------+------+------------+------------+
| 皪禆簤笳鏽殷雁譹缪偸荸粵綃篺伾嗯覲竬莃坽 | y�   | 9213-09-13 |  654993671 |
| 嶔Ė戙纚业锈痰啵满迂撖阂蘻飮韚齳ò柹吟圳   |  �   | 4705-12-24 |  893651658 |
| 贛翆饏粢惿苧栶掹哽旴菄慉諠俄锞ņƈ姹瓩點   | >d   | 9901-06-17 | 1952622619 |
+--------------------------------------------------------------+------+------------+------------+
3 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

Release Version: v6.0.0-alpha-82-g7ca9aff
Edition: Community
Git Commit Hash: 7ca9affabb3e1ba05bb3a3b357c2bf491d9ed330
Git Branch: master
UTC Build Time: 2022-03-15 01:02:37
GoVersion: go1.17.6
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. labels Mar 15, 2022
@qw4990 qw4990 self-assigned this Mar 15, 2022
@qw4990
Copy link
Contributor

qw4990 commented Mar 15, 2022

It uses a wrong range for the bit column:
image

@qw4990 qw4990 added affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 and removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. labels Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 epic/plan-cache severity/critical sig/planner SIG: Planner type/bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants