Bug #109179 unique key with null value acts abnormally in select statements
Submitted: 23 Nov 2022 9:47 Modified: 23 Nov 2022 10:37
Reporter: shuang chen Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S2 (Serious)
Version:8.0.31, 5.7.40 OS:Linux
Assigned to: CPU Architecture:Any

[23 Nov 2022 9:47] shuang chen
Description:
add unique key on a table。The query result set is inconsistent before and after adding the index

How to repeat:
create table t1(id int key,c1 int);
insert into t1 values(1,NULL),(2,NULL),(3,3),(4,NULL);
select * from t1 where (INET_ATON('452683762'))<=>c1;

+----+------+
| id | c1   |
+----+------+
|  1 | NULL |
|  2 | NULL |
|  4 | NULL |
+----+------+
3 rows in set, 1 warning (0.01 sec)

mysql> show warnings;
+---------+------+--------------------------------------------------------------+
| Level   | Code | Message                                                      |
+---------+------+--------------------------------------------------------------+
| Warning | 1411 | Incorrect string value: ''452683762'' for function inet_aton |
+---------+------+--------------------------------------------------------------+
1 row in set (0.01 sec)

alter table t1 add unique index c1(c1);

select * from t1 where (INET_ATON('452683762'))<=>c1;

+----+------+
| id | c1   |
+----+------+
|  1 | NULL |
+----+------+
1 row in set, 3 warnings (0.00 sec)

mysql> show warnings;
+---------+------+--------------------------------------------------------------+
| Level   | Code | Message                                                      |
+---------+------+--------------------------------------------------------------+
| Warning | 1411 | Incorrect string value: ''452683762'' for function inet_aton |
| Warning | 1411 | Incorrect string value: ''452683762'' for function inet_aton |
| Warning | 1411 | Incorrect string value: ''452683762'' for function inet_aton |
+---------+------+--------------------------------------------------------------+
3 rows in set (0.00 sec)
[23 Nov 2022 10:37] MySQL Verification Team
Hello shuang chen,

Thank you for the report and test case.

regards,
Umesh
[25 Nov 2022 6:49] MySQL Verification Team
Bug #109192 marked as duplicate of this one