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

Json Range only affects first row of the result set

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 10.9.4, 10.10.2, 10.9(EOL), 10.10(EOL), 10.11
    • 10.9.5, 10.10.3
    • JSON
    • None

    Description

      To reproduce:

      CREATE TABLE t3 (
        j JSON 
      );
       
      INSERT INTO t3 (j) VALUES ('[{"id": 1, "name": "Monty"},{"id": 2, "name": "Widenius"}]');
      INSERT INTO t3 (j) VALUES ('[{"id": 1, "name": "Monty"},{"id": 2, "name": "Widenius"}]');
       
      SELECT JSON_EXTRACT(j, '$[0 to 1]')  FROM t3 ;
      

      Expected result:

      [{"id": 1, "name": "Monty"}, {"id": 2, "name": "Widenius"}]
      [{"id": 1, "name": "Monty"}, {"id": 2, "name": "Widenius"}]
      

      Current result

      [{"id": 1, "name": "Monty"}, {"id": 2, "name": "Widenius"}]
      {"id": 1, "name": "Monty"}
      

      Attachments

        Issue Links

          Activity

            alice Alice Sherepa added a comment -

            Also when using * instead of json range (MDEV-30308):

            MariaDB [test]> SELECT JSON_EXTRACT(j, '$[*]')  FROM t3 ;
            +-------------------------------------------------------------+
            | JSON_EXTRACT(j, '$[*]')                                     |
            +-------------------------------------------------------------+
            | [{"id": 1, "name": "Monty"}, {"id": 2, "name": "Widenius"}] |
            | {"id": 1, "name": "Monty"}                                  |
            +-------------------------------------------------------------+
            2 rows in set (0,001 sec)
            

            alice Alice Sherepa added a comment - Also when using * instead of json range ( MDEV-30308 ): MariaDB [test]> SELECT JSON_EXTRACT(j, '$[*]') FROM t3 ; +-------------------------------------------------------------+ | JSON_EXTRACT(j, '$[*]') | +-------------------------------------------------------------+ | [{"id": 1, "name": "Monty"}, {"id": 2, "name": "Widenius"}] | | {"id": 1, "name": "Monty"} | +-------------------------------------------------------------+ 2 rows in set (0,001 sec)
            rucha174 Rucha Deodhar added a comment - Patch: https://github.com/MariaDB/server/commit/57c685950c019f6c8c73eea9e1edae3db732d6af

            ok to push.

            holyfoot Alexey Botchkov added a comment - ok to push.

            People

              rucha174 Rucha Deodhar
              Richard Richard Stracke
              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.