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

JSON_QUOTE function does not quote and uses wrong character set

    XMLWordPrintable

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

            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.