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

Inconsistent Results with Datetime and Item_cache_temporal

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.2.2
    • 10.11, 11.4, 11.8, 12.3
    • Optimizer
    • None

    Description

      This example illustrates a query optimization bug where two identical queries produce different results depending on whether the table uses the ENGINE=MyISAM. In the first query, the table t0 does not specify the engine, and the result is an empty set. In the second query, with ENGINE=MyISAM, the query returns 1. The difference in results is likely related to how MySQL handles the IFNULL function when combined with time functions such as TIMESTAMP() and SYSDATE(). The optimizer appears to process the IFNULL and time-related expressions differently depending on the storage engine, leading to inconsistent results.

      DROP DATABASE IF EXISTS test2;
      CREATE DATABASE test2;
      USE test2;
       
      --  query1
      CREATE TABLE t0(c0 char(100) ,c1 SMALLINT);
      INSERT INTO t0 VALUES ('', false);
       
      SELECT 1 FROM t0 AS tom0 WHERE ( IFNULL( TIMESTAMP( 'A' ) , SYSDATE( 0 ) ) ) ;
       
      --  query2
      CREATE OR REPLACE TABLE t0(c0 CHAR(100) , c1 SMALLINT  ) engine=MyISAM;
      INSERT INTO t0 VALUES ('', false);
      SELECT 1 FROM t0 AS tom0 WHERE ( IFNULL( TIMESTAMP( 'A' ) , SYSDATE( 0 ) ) ) ;
      

      --  output1
      Empty set, 1 warning (0.00 sec)
       
      --  output2
      +---+
      | 1 |
      +---+
      | 1 |
      +---+
      1 row in set, 1 warning (0.01 sec)
      

      Attachments

        Activity

          People

            serg Sergei Golubchik
            ammmkilo ammmkilo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0d
                0d
                Logged:
                Time Spent - 3h
                3h

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.