Bug #113641 Multi-valued index can lead to incorrect result with implicit conversion
Submitted: 15 Jan 5:42 Modified: 15 Jan 5:49
Reporter: Yang Keao Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: JSON Severity:S2 (Serious)
Version:8.0.28 OS:Any
Assigned to: CPU Architecture:Any
Tags: json;multi-valued index

[15 Jan 5:42] Yang Keao
Description:
The implicit conversion can happen in multi-valued index. For example, a string json value can be converted to date/datetime, a datetime json value can be converted to date. When this kind of conversion happened, select using or not using the multi-valued index can give different results, even when the WHERE clause is the same.

How to repeat:
Execute the following statements:

```sql
create table t2(j json, key mvi((cast(j as date array))) );
insert into t2 values ('["2024-01-15 13:19:00"]');
insert into t2 values ('["2024-01-15"]');
select * from t2 ignore index(mvi) where '2024-01-15' member of(j);
select * from t2 use index(mvi) where '2024-01-15' member of(j);
```

The last two selection will return different results:

```
mysql> select * from t2 ignore index(mvi) where '2024-01-15' member of(j);
+----------------+
| j              |
+----------------+
| ["2024-01-15"] |
+----------------+
1 row in set (0.00 sec)

mysql> select * from t2 use index(mvi) where '2024-01-15' member of(j);
+-------------------------+
| j                       |
+-------------------------+
| ["2024-01-15 13:19:00"] |
| ["2024-01-15"]          |
+-------------------------+
2 rows in set (0.00 sec)
```
[15 Jan 5:49] MySQL Verification Team
Hello Yang Keao,

Thank you for the report and test case.

regards,
Umesh