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

JSON_QUOTE function does not quote and uses wrong character set

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.2(EOL)
    • 10.2.3
    • JSON

    Description

      Function JSON_QUOTE is specified in MySQL manual as

      Quotes a string as a JSON value by wrapping it with double quote characters and escaping interior quote and other characters, then returning the result as a utf8mb4 string.

      It works in MySQL according to this specification:

      +-------------------+
      | JSON_QUOTE('foo') |
      +-------------------+
      | "foo"             |
      +-------------------+
      1 row in set (0.00 sec)
       
      MySQL [test]> CREATE TABLE t AS SELECT JSON_QUOTE('foo');
      Query OK, 1 row affected (0.48 sec)
      Records: 1  Duplicates: 0  Warnings: 0
       
      MySQL [test]> SHOW CREATE TABLE t \G
      *************************** 1. row ***************************
             Table: t
      Create Table: CREATE TABLE `t` (
        `JSON_QUOTE('foo')` varchar(56) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1
      1 row in set (0.00 sec)
      

      However, in MariaDB it neither wraps the value in double quote marks, nor does it return result in utf8mb4

      +-------------------+
      | JSON_QUOTE('foo') |
      +-------------------+
      | foo               |
      +-------------------+
      1 row in set (0.00 sec)
       
      MariaDB [test]> CREATE TABLE t SELECT JSON_QUOTE('foo');
      Query OK, 1 row affected (0.49 sec)
      Records: 1  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> SHOW CREATE TABLE t \G
      *************************** 1. row ***************************
             Table: t
      Create Table: CREATE TABLE `t` (
        `JSON_QUOTE('foo')` varchar(36) CHARACTER SET utf8 NOT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1
      1 row in set (0.00 sec)
      

      Attachments

        Issue Links

          Activity

            elenst Elena Stepanova created issue -
            elenst Elena Stepanova made changes -
            Field Original Value New Value
            elenst Elena Stepanova made changes -
            Labels json-10.2
            elenst Elena Stepanova made changes -
            Component/s JSON [ 13908 ]
            Component/s OTHER [ 10125 ]
            elenst Elena Stepanova made changes -
            holyfoot Alexey Botchkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            holyfoot Alexey Botchkov made changes -
            Fix Version/s 10.2.3 [ 22115 ]
            Fix Version/s 10.2 [ 14601 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 78571 ] MariaDB v4 [ 151280 ]

            People

              holyfoot Alexey Botchkov
              elenst Elena Stepanova
              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.