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

Incorrect COUNT result with correlated subquery containing LOCATE and (t0.c0 IS FALSE)

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 12.2.2
    • None
    • None
    • None

    Description

      Hi, I found a logic bug in MariaDB 12.2.2. A query using a correlated subquery with LOCATE and a logical expression (t0.c0 IS FALSE) returns an incorrect count of 2 instead of the expected 0. Reducing the number of rows in either table makes the bug disappear.

      CREATE TABLE t0(c0 REAL UNSIGNED, PRIMARY KEY(c0));
      CREATE TABLE t1(c0 REAL ZEROFILL);
      INSERT INTO t0 SELECT seq FROM seq_0_to_40;   -- 41 rows
      INSERT INTO t1 SELECT seq FROM seq_0_to_2;    -- 3 rows
      SELECT COUNT(CASE WHEN NOT EXISTS (SELECT 1 FROM t1 WHERE LOCATE((t0.c0 IS FALSE), t0.c0, true) AND t0.c0 = t1.c0) THEN 1 END) FROM t0  WHERE EXISTS (SELECT 1 FROM t1 WHERE LOCATE((t0.c0 IS FALSE), t0.c0, true) AND t0.c0 = t1.c0); -- expect 0, actually return 2
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            jinhui lai jinhui lai
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.