[MDEV-31719] Wrong result of: WHERE inet6_column IN ('','::1') Created: 2023-07-17  Updated: 2023-08-18  Resolved: 2023-08-18

Status: Closed
Project: MariaDB Server
Component/s: Data types, Plugin - INET6
Affects Version/s: 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0
Fix Version/s: 10.6.16, 10.10.7, 10.11.6, 11.0.4, 11.1.2, 11.2.1

Type: Bug Priority: Critical
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-27207 Assertion `!m_null_value' failed in i... Closed

 Description   

This script erroneously treats '' as a correct INET6 value of '::' and returns one row:

CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('::');
SELECT * FROM t1 WHERE a IN ('','::1');

+------+
| a    |
+------+
| ::   |
+------+
1 row in set, 1 warning (0.000 sec)

The comparison operator works as expected on the contrary:

SELECT * FROM t1 WHERE a='';

Empty set, 2 warnings (0.001 sec)



 Comments   
Comment by Alexander Barkov [ 2023-07-17 ]

The same problem is repeatable with UUID stating from 10.9.

The IN operator returns a wrong row:

CREATE OR REPLACE TABLE t1 (a UUID);
INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000000');
SELECT * FROM t1 WHERE a IN ('','00000000-0000-0000-0000-000000000001');

+--------------------------------------+
| a                                    |
+--------------------------------------+
| 00000000-0000-0000-0000-000000000000 |
+--------------------------------------+

The comparison operator works fine:

SELECT * FROM t1 WHERE a='';

Empty set, 2 warnings (0.001 sec)

Comment by Alexander Barkov [ 2023-07-20 ]

Pushed to 10.5 in a single patch with MDEV-27207.
Waiting for a merge to 10.9 to add UUID tests.

Comment by Alexander Barkov [ 2023-08-16 ]

The merge 10.5->10.6 for this patch went wrong.
Pushed an after-merge cleanup:
https://github.com/MariaDB/server/commit/88dd50b80ad9624d05b72751fd6e4a2cfdb6a3fe

Waiting for it to propagate to 10.9.

Generated at Thu Feb 08 10:25:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.