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

IS TRUE incorrectly converts outer join to inner

    XMLWordPrintable

Details

    • Unexpected results

    Description

      Hi,

      I found a logic bug in MariaDB when using a Boolean value as the parameter of a prepared statement. In the following test case, the where condition should return false, but the query still return one row:

      CREATE TABLE t0(c0 REAL);
      CREATE TABLE t1 LIKE t0;
      INSERT INTO t1 VALUES (1);
      INSERT INTO t0 VALUES (1);
      SET @a = false;
      PREPARE prepare_query FROM "SELECT t1.c0, t0.c0 FROM t1 LEFT JOIN t0 ON 'J' WHERE (? OR ((t0.c0 IS TRUE) IN ('*_')))";
      EXECUTE prepare_query USING @a;
      --- c0      c0
      --- 1       NULL
      

      The equivalent normal query returns an empty result, which is incorrect:

      SELECT t1.c0, t0.c0 FROM t1 LEFT JOIN t0 ON FALSE WHERE (FALSE OR ((t0.c0 IS TRUE) IN (FALSE)));
      

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              ChiZhang Chi Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.