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

JSON_EXTRACT has inconsistent behavior with '0' value in json path (when range is used)

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 10.9.1
    • JSON
    • None

    Description

      Test:

      SET @json= '[ 11, 22 , 33]';
      SELECT JSON_EXTRACT(@json, '$[-2 to 1]');
      SELECT JSON_EXTRACT(@json, '$[-1 to 1]');
      SELECT JSON_EXTRACT(@json, '$[-1 to 0]');
      SELECT JSON_EXTRACT(@json, '$[0 to 0]');
      SELECT JSON_EXTRACT(@json, '$[-0 to 0]');
      SELECT JSON_EXTRACT(@json, '$[-0 to 1]');
      SELECT JSON_EXTRACT(@json, '$[0 to -0]');
      

      Actual result:

      SET @json= '[ 11, 22 , 33]';
      SELECT JSON_EXTRACT(@json, '$[-2 to 1]');
      JSON_EXTRACT(@json, '$[-2 to 1]')
      [22]
      SELECT JSON_EXTRACT(@json, '$[-1 to 1]');
      JSON_EXTRACT(@json, '$[-1 to 1]')
      NULL
      SELECT JSON_EXTRACT(@json, '$[-1 to 0]');
      JSON_EXTRACT(@json, '$[-1 to 0]')
      NULL
      Warnings:
      Warning	4042	Syntax error in JSON path in argument 2 to function 'json_extract' at position 9
      SELECT JSON_EXTRACT(@json, '$[0 to 0]');
      JSON_EXTRACT(@json, '$[0 to 0]')
      NULL
      Warnings:
      Warning	4042	Syntax error in JSON path in argument 2 to function 'json_extract' at position 8
      SELECT JSON_EXTRACT(@json, '$[-0 to 0]');
      JSON_EXTRACT(@json, '$[-0 to 0]')
      NULL
      Warnings:
      Warning	4042	Syntax error in JSON path in argument 2 to function 'json_extract' at position 9
      SELECT JSON_EXTRACT(@json, '$[-0 to 1]');
      JSON_EXTRACT(@json, '$[-0 to 1]')
      [11, 22]
      SELECT JSON_EXTRACT(@json, '$[0 to -0]');
      JSON_EXTRACT(@json, '$[0 to -0]')
      [11]
      

      Look like '0' on the right side of range is bad value, but '-0' - is good value. Why?

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              lstartseva Lena Startseva
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.