-
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
JSON data type does not support custom types (i.e. MySQL types) #9988
Comments
Others may be tested too: select json_type(cast(127 as json));
select json_type(cast(255 as json));
select json_type(cast(32767 as json));
select json_type(cast(65535 as json));
select json_type(cast(8388607 as json));
select json_type(cast(16777215 as json));
select json_type(cast(2147483647 as json));
select json_type(cast(4294967295 as json));
select json_type(cast(9223372036854775807 as json));
select json_type(cast(18446744073709551615 as json));
select json_type(cast(true as json));
select json_type(cast(b'10101' as json));
select json_type(cast(cast(3.14 as decimal(5,2)) as json));
select json_type(cast(3.14 as json));
select json_type(cast(3.14E30 as json)); |
Confirming this still exists in master. I've noted which values are correct: select json_type(cast(cast('2014-11-25 18:00' as datetime) as json));
select json_type(cast(cast('2014-11-25' as date) as json));
select json_type(cast(cast('18:00:59' as time) as json));
select json_type(cast(127 as json));
select json_type(cast(255 as json));
select json_type(cast(32767 as json));
select json_type(cast(65535 as json));
select json_type(cast(8388607 as json));
select json_type(cast(16777215 as json));
select json_type(cast(2147483647 as json));
select json_type(cast(4294967295 as json));
select json_type(cast(9223372036854775807 as json));
select json_type(cast(18446744073709551615 as json));
select json_type(cast(true as json));
select json_type(cast(b'10101' as json));
select json_type(cast(cast(3.14 as decimal(5,2)) as json));
select json_type(cast(3.14 as json));
select json_type(cast(3.14E30 as json));
select tidb_version()\G
..
mysql> select json_type(cast(cast('2014-11-25 18:00' as datetime) as json));
+---------------------------------------------------------------+
| json_type(cast(cast('2014-11-25 18:00' as datetime) as json)) |
+---------------------------------------------------------------+
| STRING |
+---------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(cast('2014-11-25' as date) as json));
+-----------------------------------------------------+
| json_type(cast(cast('2014-11-25' as date) as json)) |
+-----------------------------------------------------+
| STRING |
+-----------------------------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(cast('18:00:59' as time) as json));
+---------------------------------------------------+
| json_type(cast(cast('18:00:59' as time) as json)) |
+---------------------------------------------------+
| STRING |
+---------------------------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(127 as json)); # correct
+------------------------------+
| json_type(cast(127 as json)) |
+------------------------------+
| INTEGER |
+------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(255 as json)); # correct
+------------------------------+
| json_type(cast(255 as json)) |
+------------------------------+
| INTEGER |
+------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(32767 as json)); # correct
+--------------------------------+
| json_type(cast(32767 as json)) |
+--------------------------------+
| INTEGER |
+--------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(65535 as json)); # correct
+--------------------------------+
| json_type(cast(65535 as json)) |
+--------------------------------+
| INTEGER |
+--------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(8388607 as json)); # correct
+----------------------------------+
| json_type(cast(8388607 as json)) |
+----------------------------------+
| INTEGER |
+----------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(16777215 as json)); # correct
+-----------------------------------+
| json_type(cast(16777215 as json)) |
+-----------------------------------+
| INTEGER |
+-----------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(2147483647 as json)); # correct
+-------------------------------------+
| json_type(cast(2147483647 as json)) |
+-------------------------------------+
| INTEGER |
+-------------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(4294967295 as json)); # correct
+-------------------------------------+
| json_type(cast(4294967295 as json)) |
+-------------------------------------+
| INTEGER |
+-------------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(9223372036854775807 as json)); # correct
+----------------------------------------------+
| json_type(cast(9223372036854775807 as json)) |
+----------------------------------------------+
| INTEGER |
+----------------------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(18446744073709551615 as json)); # correct
+-----------------------------------------------+
| json_type(cast(18446744073709551615 as json)) |
+-----------------------------------------------+
| UNSIGNED INTEGER |
+-----------------------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(true as json)); # correct
+-------------------------------+
| json_type(cast(true as json)) |
+-------------------------------+
| BOOLEAN |
+-------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(b'10101' as json));
ERROR 3140 (22032): Invalid JSON text: The document root must not be followed by other values.
mysql> select json_type(cast(cast(3.14 as decimal(5,2)) as json));
+-----------------------------------------------------+
| json_type(cast(cast(3.14 as decimal(5,2)) as json)) |
+-----------------------------------------------------+
| DOUBLE |
+-----------------------------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(3.14 as json));
+-------------------------------+
| json_type(cast(3.14 as json)) |
+-------------------------------+
| DOUBLE |
+-------------------------------+
1 row in set (0.00 sec)
mysql> select json_type(cast(3.14E30 as json)); # correct
+----------------------------------+
| json_type(cast(3.14E30 as json)) |
+----------------------------------+
| DOUBLE |
+----------------------------------+
1 row in set (0.00 sec)
mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-750-g8a661044c
Edition: Community
Git Commit Hash: 8a661044cedf8daad1de4fbf79a390962b6f6c3b
Git Branch: master
UTC Build Time: 2020-07-10 10:52:37
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) |
We didn't fully support json type. I convert the issue to |
reference: |
I am assigning this to myself. We have an intern looking into it. |
This behavior has further influence:
In TiDB, |
It's quite amazing that it doesn't have the problem for #37443, the |
I'm working on this issue. It can be split into two problems:
|
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
If possible, provide a recipe for reproducing the error.
In MySQL
In TiDB
SIG slack channel
#sig-exec
Score
300
Mentor
The text was updated successfully, but these errors were encountered: