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

JSON_UNQUOTE returns incorrect results depending on the collation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: In Progress (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.2, 10.3, 10.4, 10.5
    • Fix Version/s: 10.2, 10.3, 10.4, 10.5
    • Component/s: JSON
    • Labels:
      None
    • Sprint:
      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

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

                Dates

                Created:
                Updated: