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

x NOT IN (<set-operation subquery>) drops rows

    XMLWordPrintable

Details

    • Bug
    • Status: In Review (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 12.1.2
    • 11.4, 11.8, 12.3
    • None
    • Unexpected results

    Description

      `x NOT IN (<set-operation subquery>)` drops rows when the set operation's result is empty but its input contains NULL.

      The following demonstrates the wrong result:

      CREATE TABLE b (id BIGINT);
      INSERT INTO b VALUES (NULL),(1);
       
      SELECT id FROM b
      WHERE id NOT IN ((SELECT t5.id FROM b AS t5) EXCEPT (SELECT t6.id FROM b AS t6));
       
      -- expected: {NULL, 1} -- actual: {NULL}
      

      When the table doesn't contain NULL, the result is correct.

      CREATE TABLE b (id BIGINT);
      INSERT INTO b VALUES (1),(2);
       
      SELECT id FROM b
      WHERE id NOT IN ((SELECT t5.id FROM b AS t5) EXCEPT (SELECT t6.id FROM b AS t6));
       
      -- expected: {1, 2} -- actual: {1, 2}
      

      Reproducible on MySQL as well

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              jesse0623 Junwen An
              Sergei Petrunia Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0d
                  0d
                  Remaining:
                  Remaining Estimate - 2.5d
                  2.5d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.