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

A BOOLEAN != NOT NOT BOOLEAN predicate evaluates true in projection but false in filtering

    XMLWordPrintable

Details

    • Not for Release Notes

    Description

      `BOOLEAN` is `TINYINT(1)`, and inserting `127` preserves that non-canonical non-zero value. Therefore `NOT (NOT t1.c0)` is `1`, so `t1.c0 != (NOT (NOT t1.c0))` is `127 != 1`, i.e. true. MariaDB's projection evaluation reports that value as true, so the `WHERE` clause that builds `join_temp_0` should keep the row. Instead, MariaDB filters it away, and the final query incorrectly becomes empty.

      How to repeat:

      CREATE TABLE t0(c0 INT);
      CREATE TABLE t1(c0 BOOLEAN PRIMARY KEY);

      INSERT INTO t0 VALUES (0);
      INSERT INTO t1 VALUES (127);

      CREATE TEMPORARY TABLE join_temp_0 (c0 TINYINT(1) NOT NULL);
      INSERT INTO join_temp_0 SELECT * FROM t1 WHERE (t1.c0 != (NOT (NOT t1.c0)));

      SELECT MIN(t1.c0)
      FROM t0 INNER JOIN join_temp_0 AS t1
      ON ((t0.c0 < t1.c0) AND (t1.c0 != true))
      HAVING (MIN(t1.c0) != true); – Expected correct result: 127 – actual Wrong result: <empty>

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              yx yx
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.