Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26448

CAST as JSON is not supported

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 10.6.3, 10.6.5
    • N/A
    • N/A
    • 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.

      Attachments

        Activity

          People

            serg Sergei Golubchik
            valerii Valerii Kravchuk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.