-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unexpect invalid json text error when query with json_extract
#11883
Comments
json_extract
json_extract
https://dev.mysql.com/doc/refman/8.0/en/json.html#json-comparison |
MySQL support json comparison in in clause now, in 8.0.18 |
I have to say, the MySQL handling of just throwing a warning here is very unsafe. It should be an error (as it is in TiDB). Having said that, this works as expected in MySQL 8.0. Here is a testcase showing the behavior of MySQL 5.7/8.0 and TiDB: DROP TABLE IF EXISTS t1;
create table t1(f1 json);
insert into t1(f1) values ('"asd"'),('"asdf"'),('"asasas"');
select f1 from t1 where json_extract(f1,"$") in ("asd","asasas","asdf");
..
mysql [localhost:5731] {root} (test) > select f1 from t1 where json_extract(f1,"$") in ("asd","asasas","asdf");
Empty set, 1 warning (0.00 sec)
mysql [localhost:5731] {root} (test) > show warnings;
+---------+------+-----------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------------------------------------------+
| Warning | 1235 | This version of MySQL doesn't yet support 'comparison of JSON in the IN operator' |
+---------+------+-----------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql [localhost:8021] {msandbox} (test) > select f1 from t1 where json_extract(f1,"$") in ("asd","asasas","asdf");
+----------+
| f1 |
+----------+
| "asd" |
| "asdf" |
| "asasas" |
+----------+
3 rows in set (0.00 sec)
mysql> select f1 from t1 where json_extract(f1,"$") in ("asd","asasas","asdf");
ERROR 1105 (HY000): invalid data type: Illegal Json text: Error("expected value", line: 1, column: 1)
mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-807-g824df7675
Edition: Community
Git Commit Hash: 824df767559b8544af0cb71509135d322de1cd47
Git Branch: master
UTC Build Time: 2020-07-20 04:47:45
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec) |
Please edit this comment or add a new comment to complete the following informationNot a bug
Duplicate bug
BugNote: Make Sure that 'component', and 'severity' labels are added 1. Root Cause Analysis (RCA) (optional)2. Symptom (optional)3. All Trigger Conditions (optional)4. Workaround (optional)5. Affected versions6. Fixed versions |
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
If possible, provide a recipe for reproducing the error.
tidb-server -V
or runselect tidb_version();
on TiDB)?SIG slack channel
#sig-exec
Score
Mentor
The text was updated successfully, but these errors were encountered: