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

Wrong result for CROSS JOIN query with NOT BETWEEN and equality predicate

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 12.2.2
    • None
    • Server
    • None
    • Docker: mariadb:12.2.2
      Server version: 12.2.2-MariaDB-ubu2404
      Source revision: d26a6f44c1f2119377e79a9540886c6d8c01472f

    Description

      Hi, I found a logic bug in MariaDB 12.2.2.
      The query returns incorrect results.

      Expected results:

      +------+------+------+
      | c0   | c1   | c2   |
      +------+------+------+
      |    0 |    0 |    0 |
      |    0 |    0 |    0 |
      |    0 |    0 |    0 |
      |    0 |    0 |    0 |
      |    0 |    0 |    0 |
      |    0 |    0 |    0 |
      +------+------+------+
      

      Actual Results:

      Empty set (0.00 sec)
      

      How to repeat:

      -- create table
      DROP TABLE IF EXISTS `t1`;
      CREATE TABLE `t1` ( `c0` float   DEFAULT NULL COMMENT 'asdf', `c1` mediumint DEFAULT NULL, `c2` int  DEFAULT NULL COMMENT 'asdf', UNIQUE KEY `c0` (`c0`), UNIQUE KEY `c2` (`c2`), KEY `i0` (`c2`,`c1`,`c0`) , KEY `i1` (`c2`), KEY `i2` (`c1`) ) CHARSET=utf8mb4;
      INSERT INTO `t1` VALUES (567621000,-8388608,NULL),(0.363988,0,-1643936528),(-422810000,0,NULL),(0,0,0),(NULL,0,NULL),(NULL,8388607,NULL),(NULL,-8388608,NULL);
      DROP TABLE IF EXISTS `t2`;
      CREATE TABLE `t2` ( `c0` decimal(10,0) unsigned   DEFAULT NULL COMMENT 'asdf', UNIQUE KEY `c0` (`c0`) ) CHARSET=utf8mb4;
      INSERT INTO `t2` VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
       
       
      -- query
      SELECT
        t1.c0,
        t1.c1,
        t1.c2
      FROM t2
      CROSS JOIN t1
      WHERE NOT (1 BETWEEN t1.c0 AND t1.c2)
        AND t1.c1 = t1.c2;
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            Yuxiao Guo Yuxiao Guo
            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.