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

JSON_TABLE doesn't properly unquote strings

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.6.5
    • Fix Version/s: 10.6, 10.7
    • Component/s: JSON
    • Labels:
      None
    • Environment:
      Ubuntu 20.04

      Description

      I have trouble with the `JSON_TABLE` function in *MariaDB 10.6.5*. This is my query:

      SET @data = '[{"Data": "<root language=\\"de\\"></root>"}]';
       
      SELECT
        data
      FROM JSON_TABLE (@data, '$[*]' COLUMNS (data text PATH '$.Data')) AS t;}}
      

      What I get back is the XML string, but not properly unescaped:

      <root language=\"de\"></root>
      

      When I use then `JSON_VALUE` instead:

      SET @data = '[{"Data": "<root language=\\"de\\"></root>"}]';
       
      SELECT
        JSON_VALUE(@DATA, '$[0].Data');
      

      then I get back the correctly unescaped string:

      <root language="de"></root>
      

      When I do the same on a MySQL *8.0.26* server, it works as expected:

      SET @data = '[{"Data": "<root language=\\"de\\"></root>"}]';
       
      SELECT
        data
      FROM JSON_TABLE (@data, '$[*]' COLUMNS (data text PATH '$.Data')) AS t;
       
      -- correct:
      -- <root language="de"></root>
       
      SELECT
        JSON_VALUE(@data, '$[0].Data');
       
      -- correct:
      -- <root language="de"></root>
      

      It looks to me that this difference in behaviour is a bug in MariaDB's side.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rucha174 Rucha Deodhar
              Reporter:
              louis77 Louis Brauer
              Votes:
              1 Vote for this issue
              Watchers:
              4 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.