Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
10.6.3, 10.6.5
-
None
Description
MariaDB does have a JSON data type implemented, with a lot of features added over time, but unlike MySQL 8.0.x it does not support casting to JSON (since MDEV-11439 is fixed, probably). Consider this:
openxs@ao756:~/dbs/8.0$ bin/mysql --socket=/tmp/maysql8.sock -uroot
|
Welcome to the MySQL monitor. Commands end with ; or \g.
|
Your MySQL connection id is 9
|
Server version: 8.0.26 Source distribution
|
|
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
|
|
Oracle is a registered trademark of Oracle Corporation and/or its
|
affiliates. Other names may be trademarks of their respective
|
owners.
|
|
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
|
mysql> select cast(true as json);
|
+--------------------+
|
| cast(true as json) |
|
+--------------------+
|
| true |
|
+--------------------+
|
1 row in set (0,00 sec)
|
and compare to the following MariaDB behavior:
openxs@ao756:~/dbs/8.0$ bin/mysql --socket=/tmp/mariadb.sock
|
Welcome to the MySQL monitor. Commands end with ; or \g.
|
Your MySQL connection id is 6
|
Server version: 5.5.5-10.6.5-MariaDB MariaDB Server
|
|
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
|
|
Oracle is a registered trademark of Oracle Corporation and/or its
|
affiliates. Other names may be trademarks of their respective
|
owners.
|
|
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
|
mysql> select cast(true as json);
|
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json)' at line 1
|
mysql> select cast(true as text);
|
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'text)' at line 1
|
mysql> select cast(true as unsigned);
|
+------------------------+
|
| cast(true as unsigned) |
|
+------------------------+
|
| 1 |
|
+------------------------+
|
1 row in set (0,00 sec)
|
|
mysql> select cast(true as char);
|
+--------------------+
|
| cast(true as char) |
|
+--------------------+
|
| 1 |
|
+--------------------+
|
1 row in set (0,00 sec)
|
It is unexpected I'd say to have no way to cast to JSON (or, for that matter, TEXT) type when cast to CHAR is supported.