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

Unexpected result when casting decimal in WHERE clause

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 11.3.2, 11.4.1, 10.4(EOL), 10.5, 10.6, 10.11, 11.0(EOL), 11.1(EOL), 11.2(EOL), 11.3(EOL)
    • 10.5, 10.6, 10.11, 11.4
    • None
    • None
    • Run on Docker container mariadb:latest and mariadb:11.4-rc

    Description

      Consider the below queries, it is unexpected that the last query returns an empty results.

      The predicate `t0.c1/4` should be evaluated to `0.25`, and `0.25!=0`. Thus, the WHERE predicate should be evaluated to true and the query should fetch the row from `t0`.

      Besides, the query `SELECT t0.c1 FROM t0 WHERE 0.25;` and `SELECT t0.c1 FROM t0 WHERE 1/4;` both return `1`. If the result for the last query is expected, then these two queries should also return an empty set.

      MySQL could return 1 as expected.

      DROP DATABASE db0;
      CREATE DATABASE db0;
      USE db0;
       
      CREATE TABLE t0(c1 INTEGER);
      INSERT INTO t0 (c1) VALUES (1);
       
      SELECT t0.c1 FROM t0;
      SELECT t0.c1/4 FROM t0; -- 0.25
      SELECT t0.c1 FROM t0 WHERE 0.25; -- 1
      SELECT t0.c1 FROM t0 WHERE 1/4; -- 1
       
      SELECT t0.c1 FROM t0 WHERE t0.c1/4; 
      -- Expected: 1
      -- Actual: Empty set
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              suyzhong Suyang Zhong
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.