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

JSON_UNQUOTE returns incorrect results depending on the collation

    XMLWordPrintable

Details

    • Bug
    • Status: Stalled (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5
    • 10.5, 10.6, 10.11, 11.4
    • JSON
    • None
    • 10.2.12

    Description

      MariaDB

      MariaDB [(none)]> SELECT VERSION();
      +-----------------+
      | VERSION()       |
      +-----------------+
      | 10.2.10-MariaDB |
      +-----------------+
      1 row in set (0.00 sec)
       
      MariaDB [(none)]> SET @`json` := '{"sv":"Börk"}';
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [(none)]> SELECT
          ->   JSON_UNQUOTE(
          ->     JSON_EXTRACT(CAST(@`json` AS CHAR CHARACTER SET latin1), '$.sv')
          ->   ) `latin1`,
          ->   JSON_UNQUOTE(
          ->     JSON_EXTRACT(CAST(@`json` AS CHAR CHARACTER SET utf8mb4), '$.sv')
          -> ) `utf8mb4`;
      +---------+---------+
      | latin1  | utf8mb4 |
      +---------+---------+
      | "Börk"  | Börk    |
      +---------+---------+
      1 row in set (0.00 sec)
      

      MySQL

      mysql> SELECT VERSION();
      +-----------+
      | VERSION() |
      +-----------+
      | 5.7.20    |
      +-----------+
      1 row in set (0.00 sec)
       
      mysql> SET @`json` := '{"sv":"Börk"}';
      Query OK, 0 rows affected (0.00 sec)
       
      mysql> SELECT
          ->   JSON_UNQUOTE(
          ->     JSON_EXTRACT(CAST(@`json` AS CHAR CHARACTER SET latin1), '$.sv')
          ->   ) `latin1`,
          ->   JSON_UNQUOTE(
          ->     JSON_EXTRACT(CAST(@`json` AS CHAR CHARACTER SET utf8mb4), '$.sv')
          ->   ) `utf8mb4`;
      +--------+---------+
      | latin1 | utf8mb4 |
      +--------+---------+
      | Börk   | Börk    |
      +--------+---------+
      1 row in set (0.00 sec)
      

      Attachments

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              wchiquito William Chiquito
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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