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

JSON_ARRAY_INTERSECT returns an incorrect result

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 13.1
    • N/A
    • JSON
    • None
    • Not for Release Notes

    Description

      Hi,

      In the following test case, the second row of the table t_arr has two json: '[1,2]' and '[2]', which should has intersection, however, JSON_ARRAY_INTERSECT returns NULL on this row.

      CREATE TABLE t_arr (
        id INT PRIMARY KEY,
        a LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin CHECK (JSON_VALID(a)),
        b LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin CHECK (JSON_VALID(b))
      );
       
      INSERT INTO t_arr VALUES
        (1, '[1,2]', '[9]'),
        (2, '[1,2]', '[2]');
       
      SELECT id, JSON_ARRAY_INTERSECT(a, b) AS actual FROM t_arr ORDER BY id;
      -- 1	NULL
      -- 2	NULL
       
      SELECT JSON_ARRAY_INTERSECT('[1,2]', '[9]') AS expected_row1; -- NULL
      SELECT JSON_ARRAY_INTERSECT('[1,2]', '[2]') AS expected_row2; -- [2]
      

      Attachments

        Issue Links

          Activity

            People

              danblack Daniel Black
              ChiZhang Chi Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.