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

Different results of query with 'derived_merge=on';

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.5, 10.0, 10.1, 10.2, 10.3
    • 10.4
    • None
    • None

    Description

      CREATE TABLE t1 (pk int, i1 int NOT NULL);
      INSERT INTO t1 VALUES (1, 4),(2, 6);
       
      CREATE TABLE t2 (i2 int NOT NULL, d2 DATE NOT NULL);
      #INSERT IGNORE INTO t2 VALUES (4, NULL);
      INSERT INTO t2 VALUES (4, '0000-00-00');  ##the same case, there NULL was truncated to '0000-00-00'
       
      SELECT t1.i1 FROM t1 JOIN (t2 JOIN (SELECT t1.* FROM t1) AS a1 ON a1.i1 = t2.i2) ON a1.pk = t2.d2;
      SET SESSION optimizer_switch = 'derived_merge=off';
      SELECT t1.i1 FROM t1 JOIN (t2 JOIN (SELECT t1.* FROM t1) AS a1 ON a1.i1 = t2.i2) ON a1.pk = t2.d2;
       
      drop table t1, t2;
      

      Repeatable on 5.5-10.3, not on 10.4

      10.3 37d6d3b661315617953

      MariaDB [test]> SELECT t1.i1 FROM t1 JOIN (t2 JOIN (SELECT t1.* FROM t1) AS a1 ON a1.i1 = t2.i2) ON a1.pk = t2.d2;
      Empty set, 2 warnings (0.000 sec)
       
      Warning (Code 1292): Incorrect datetime value: '1' for column 'pk' at row 2
      Warning (Code 1292): Incorrect datetime value: '1' for column 'pk' at row 2
      MariaDB [test]> SET SESSION optimizer_switch = 'derived_merge=off';
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [test]> SELECT t1.i1 FROM t1 JOIN (t2 JOIN (SELECT t1.* FROM t1) AS a1 ON a1.i1 = t2.i2) ON a1.pk = t2.d2;
      +----+
      | i1 |
      +----+
      |  4 |
      |  6 |
      +----+
      2 rows in set, 2 warnings (0.000 sec)
       
      Warning (Code 1292): Incorrect datetime value: '1' for column 'pk' at row 3
      Warning (Code 1292): Incorrect datetime value: '1' for column 'pk' at row 3
      

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              alice Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.