Open wjhuang2016 opened 8 months ago
This problem is more frightening than I have thought. The auto-conversion between types (string <-> date <-> datetime
) can cause very confusing behavior. For example:
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 SELECT
statements will have different behaviors on MySQL:
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)
As TiDB has a more strict type restriction, we will not trigger this problem. I prefer to leave this issue open and not fix it for a while, as solving it in the most straight forward way will cause more serious issue.
I've also submitted a bug report to MySQL: https://bugs.mysql.com/bug.php?id=113641 . Let's wait for the response of MySQL team and see how they will fix it :thinking: .
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
No error
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
56c619f1f5ea8e3f9970fe664729074b5123683a