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

JSON_VALUE and JSON_EXTRACT doesn't handle special characters

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 10.9, 10.10, 10.9.3
    • Fix Version/s: 10.9.5
    • Component/s: JSON
    • Labels:
    • Environment:
      Ubuntu Server 22.04.1 LTS, MariaDB 10.9 installed from official MariaDB repositories.

      Description

      10.9 doesn't seem to be handling special characters in JSON keys in JSON_VALUE and JSON_EXTRACT functions - it returns NULL even when the key is quoted according to the documentation:

      ."memberName" - the same as above but allows one to select a member with a name that's not a valid identifier (that is, has space, dot, and/or other characters)

      This has changed in 10.9 - 10.8 works as expected (I don't have any earlier version to test against.)

      In 10.8.4:

      Welcome to the MariaDB monitor.  Commands end with ; or \g.
      Server version: 10.8.4-MariaDB-1:10.8.4+maria~ubu2004-log mariadb.org binary distribution
       
      MariaDB [(none)]> SET @test = '{"NetworkManager":"1:1.36.0-7.el8_6","NetworkManager-initscripts-updown":"1:1.36.0-7.el8_6"}';
      Query OK, 0 rows affected (0.000 sec)
       
       
      MariaDB [(none)]> SELECT JSON_VALUE(@test, '$."NetworkManager"');
      +-----------------------------------------+
      | JSON_VALUE(@test, '$."NetworkManager"') |
      +-----------------------------------------+
      | 1:1.36.0-7.el8_6                        |
      +-----------------------------------------+
      1 row in set (0.003 sec)
       
       
      MariaDB [(none)]> SELECT JSON_VALUE(@test, '$."NetworkManager-initscripts-updown"');
      +------------------------------------------------------------+
      | JSON_VALUE(@test, '$."NetworkManager-initscripts-updown"') |
      +------------------------------------------------------------+
      | 1:1.36.0-7.el8_6                                           |
      +------------------------------------------------------------+
      1 row in set (0.000 sec)
      

      In 10.9.2 and 10.9.3, the final query returns NULL:

      Welcome to the MariaDB monitor.  Commands end with ; or \g.
      Server version: 10.9.3-MariaDB-1:10.9.3+maria~ubu2204-log mariadb.org binary distribution
       
      MariaDB [(none)]> SET @test = '{"NetworkManager":"1:1.36.0-7.el8_6","NetworkManager-initscripts-updown":"1:1.36.0-7.el8_6"}';
      Query OK, 0 rows affected (0.000 sec)
       
       
      MariaDB [(none)]> SELECT JSON_VALUE(@test, '$."NetworkManager"');
      +-----------------------------------------+
      | JSON_VALUE(@test, '$."NetworkManager"') |
      +-----------------------------------------+
      | 1:1.36.0-7.el8_6                        |
      +-----------------------------------------+
      1 row in set (0.000 sec)
       
       
      MariaDB [(none)]> SELECT JSON_VALUE(@test, '$."NetworkManager-initscripts-updown"');
      +------------------------------------------------------------+
      | JSON_VALUE(@test, '$."NetworkManager-initscripts-updown"') |
      +------------------------------------------------------------+
      | NULL                                                       |
      +------------------------------------------------------------+
      1 row in set (0.000 sec)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rucha174 Rucha Deodhar
              Reporter:
              aheathershaw Andy Heathershaw
              Votes:
              2 Vote for this issue
              Watchers:
              7 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.