Bug #102912 filter result different on a index bit column with no-index bit column
Submitted: 11 Mar 2021 2:07 Modified: 11 Mar 2021 11:35
Reporter: jiangtao guo Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0, 8.0.23, 5.7.33 OS:Any
Assigned to: CPU Architecture:Any

[11 Mar 2021 2:07] jiangtao guo
Description:
version: Server version: 8.0.23 MySQL Community Server - GPL

drop table t1_no_idx;
create table t1_no_idx(id int, col_bit bit(16));
insert into t1_no_idx values(1, 0x3135);
insert into t1_no_idx values(2, 0x0f);
prepare stmt from 'select * from t1_no_idx where col_bit = ?';                                                                                                                                                                                                                set @a = 0x3135;
execute stmt using @a;
prepare stmt1 from 'select * from t2 where col_bit in (?)';
execute stmt1 using @a;
mysql> execute stmt1 using @a;
+------+------------------+
| id   | col_bit          |
+------+------------------+
|    2 | 0x000F           |
+------+------------------+
1 row in set (0.00 sec)

drop table t2_idx;
create table t2_idx(id int, col_bit bit(16), key(col_bit));
insert into t2_idx values(1, 0x3135);
insert into t2_idx values(2, 0x0f);
prepare stmt from 'select * from t2_idx where col_bit = ?';
set @a = 0x3135;
execute stmt using @a;
+------+------------------+
| id   | col_bit          |
+------+------------------+
|    1 | 0x3135           |
+------+------------------+
1 row in set (0.00 sec)

t1_no_idx is same with t2_idx expect t2_idx got idx on col_bit. But same execute got different result.

How to repeat:
drop table t1_no_idx;
create table t1_no_idx(id int, col_bit bit(16));
insert into t1_no_idx values(1, 0x3135);
insert into t1_no_idx values(2, 0x0f);
prepare stmt from 'select * from t1_no_idx where col_bit = ?';                                                                                                                                                                                                                set @a = 0x3135;
execute stmt using @a;
prepare stmt1 from 'select * from t2 where col_bit in (?)';
execute stmt1 using @a;

drop table t2_idx;
create table t2_idx(id int, col_bit bit(16), key(col_bit));
insert into t2_idx values(1, 0x3135);
insert into t2_idx values(2, 0x0f);
prepare stmt from 'select * from t2_idx where col_bit = ?';
set @a = 0x3135;
execute stmt using @a;
[11 Mar 2021 11:35] MySQL Verification Team
Hello jiangtao,

Thank you for the report and test case.

regards,
Umesh