Bug #113316 When the bit type has an index, the query result is incorrect.
Submitted: 4 Dec 2023 3:32 Modified: 4 Dec 2023 7:21
Reporter: Sakurajima Mai Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.35, 8.1.0, 8.2.0 OS:Any
Assigned to: CPU Architecture:Any

[4 Dec 2023 3:32] Sakurajima Mai
Description:
In the partition table, when the bit type has an index, the query result is incorrect.

mysql> drop table t0;
Query OK, 0 rows affected (0.03 sec)

mysql> create table t0 (`int_col` int,`bit_col` bit(8) DEFAULT b'0', KEY `ndx_bit_col` (`bit_col` DESC)) partition by hash(int_col) partitions 3;
Query OK, 0 rows affected (0.06 sec)

mysql> insert into t0(int_col) values(1);
Query OK, 1 row affected (0.01 sec)

mysql> SELECT bit_col, int_col FROM t0 A WHERE bit_col = '0x00';
Empty set (0.00 sec)

mysql> alter table t0 drop key ndx_bit_col;
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> SELECT bit_col, int_col FROM t0 A WHERE bit_col = '0x00';
+------------------+---------+
| bit_col          | int_col |
+------------------+---------+
| 0x00             |       1 |
+------------------+---------+
1 row in set, 1 warning (0.00 sec)

How to repeat:
create table t0 (`int_col` int,`bit_col` bit(8) DEFAULT b'0', KEY `ndx_bit_col` (`bit_col` DESC)) partition by hash(int_col) partitions 3;

insert into t0(int_col) values(1);

SELECT bit_col, int_col FROM t0 A WHERE bit_col = '0x00';

alter table t0 drop key ndx_bit_col;

SELECT bit_col, int_col FROM t0 A WHERE bit_col = '0x00';

Suggested fix:
In the partition table.The query results must be consistent regardless of whether a column of the bit type has an index.
[4 Dec 2023 7:21] MySQL Verification Team
Hello Sakurajima Mai,

Thank you for the report and test case.
Verified as described.

regards,
Umesh