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

INTERSECT of EXISTS / NOT EXISTS returns wrong result when UNCOMPRESSED_LENGTH is used

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.6, 12.3, 12.2.2
    • 10.11, 11.4, 11.8, 12.3
    • Optimizer
    • None

    Description

      Hi, I found a bug in MariaDB 12.2.2. A query using `INTERSECT` between two contradictory `WHERE` clauses—one with `NOT EXISTS` and the other with `EXISTS` on identical correlated conditions—should logically yield an empty set. However, MariaDB 12.2.2 returns a row instead.

      CREATE TABLE t0(c0 REAL UNSIGNED);
      CREATE TABLE t1(c0 REAL ZEROFILL UNIQUE);
      INSERT INTO t0 VALUES (1),(2);
      INSERT INTO t1 VALUES (1);
      -- expect "empty set", actually return 1
      SELECT t0.c0 FROM t0 WHERE NOT EXISTS (SELECT 1 FROM t1 WHERE UNCOMPRESSED_LENGTH(t0.c0) AND t0.c0 = t1.c0) INTERSECT SELECT t0.c0 FROM t0  WHERE EXISTS (SELECT 1 FROM t1 WHERE UNCOMPRESSED_LENGTH(t0.c0) AND t0.c0 = t1.c0);
      +------+
      | c0   |
      +------+
      |    1 |
      +------+
      SELECT t0.c0 FROM t0 WHERE NOT EXISTS (SELECT 1 FROM t1 WHERE UNCOMPRESSED_LENGTH(t0.c0) AND t0.c0 = t1.c0);
      +------+
      | c0   |
      +------+
      |    1 |
      |    2 |
      +------+
      SELECT t0.c0 FROM t0 WHERE EXISTS (SELECT 1 FROM t1 WHERE UNCOMPRESSED_LENGTH(t0.c0) AND t0.c0 = t1.c0);
      +------+
      | c0   |
      +------+
      |    1 |
      +------+
      

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            jinhui lai jinhui lai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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