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

Index causes incorrect result when comparing float-point number with INT

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.4.11, 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
    • 10.4(EOL)
    • None
    • None
    • Ubuntu 19.04

    Description

      Hi everyone,

      On the latest trunk version (0308de9), I could observe a bug, as demonstrated by the following test case:

      CREATE TABLE t0(c0 INT);
      INSERT INTO t0 VALUES (1);
      CREATE INDEX i0 ON t0(c0);
      SELECT * FROM t0 WHERE 0.5 = c0; -- unexpected: row is fetched
      

      Only when the index is created does MariaDB compute an incorrect result set, containing the row. As demonstrated below, the expression should evaluate to FALSE:

      SELECT 0.5 = c0 FROM t0; -- evaluates to FALSE
      

      Attachments

        Activity

          alice Alice Sherepa added a comment -

          Thanks! I repeated on MariaDB 5.5-10.4, Mysql 5.6-5.7, works as expected on Mysql 8.0.16

          MariaDB [test]> CREATE TABLE t0(c0 INT, index(c0));
          Query OK, 0 rows affected (0.030 sec)
           
          MariaDB [test]> INSERT INTO t0 VALUES (1),(2),(3);
          Query OK, 3 rows affected (0.001 sec)
          Records: 3  Duplicates: 0  Warnings: 0
           
          MariaDB [test]> SELECT * FROM t0 WHERE 0.5 = c0;
          +------+
          | c0   |
          +------+
          |    1 |
          +------+
          1 row in set (0.001 sec)
          
          

          alice Alice Sherepa added a comment - Thanks! I repeated on MariaDB 5.5-10.4, Mysql 5.6-5.7, works as expected on Mysql 8.0.16 MariaDB [test]> CREATE TABLE t0(c0 INT, index(c0)); Query OK, 0 rows affected (0.030 sec)   MariaDB [test]> INSERT INTO t0 VALUES (1),(2),(3); Query OK, 3 rows affected (0.001 sec) Records: 3 Duplicates: 0 Warnings: 0   MariaDB [test]> SELECT * FROM t0 WHERE 0.5 = c0; +------+ | c0 | +------+ | 1 | +------+ 1 row in set (0.001 sec)

          People

            psergei Sergei Petrunia
            mrigger Manuel Rigger
            Votes:
            0 Vote for this issue
            Watchers:
            5 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.