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

JSON_UNQUOTE returns incorrect results depending on the collation

    XMLWordPrintable

Details

    • Can result in unexpected behaviour
    • Hide
      That problem is already fixed in 10.11.
      Also these character set issues don't appear differently there so if not correct should be different issue.
      Show
      That problem is already fixed in 10.11. Also these character set issues don't appear differently there so if not correct should be different issue.
    • 10.2.12, Q1/2026 Server Maintenance

    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:
                Resolved:

                Git Integration

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