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

Unexpected end of JSON text when working with JSON_EXTRACT from derived table

    XMLWordPrintable

Details

    • Unexpected results
    • Correct JSON_EXTRACT to return the correct results when its input is from a derived table. It previously incorrectly returned NULL.

    Description

      This is a perfectly valid query, which should produce the ["a",1] JSON document:

      select
        json_extract(t.j, '$')
      from (
        select json_extract('["a",1]', '$') as j
      ) as t;
      

      Yet it produces NULL and a warning:

      > Unexpected end of JSON text in argument 1 to function 'json_extract'

      A workaround appears to be to "format" the JSON value:

      select
        json_extract(t.j, '$')
      from (
        select json_extract('["a", 1]', '$') as j -- There's a whitespace in ["a", 1]
      ) as t;
      

      Now, I'm getting the document as expected:

      > ["a", 1]

      Attachments

        Activity

          People

            rucha174 Rucha Deodhar
            lukas.eder Lukas Eder
            Rucha Deodhar Rucha Deodhar
            Votes:
            0 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.