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

Wrong result: INNER JOIN and STRAIGHT_JOIN return different results for mixed REAL/CHAR IN expression

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 12.3.3
    • N/A
    • Optimizer
    • None
    • Not for Release Notes

    Description

      Summary

      MariaDB 12.3.3 returns different results for two semantically equivalent
      inner joins when STRAIGHT_JOIN is used.

      This may be related to MDEV-36249.

      How to reproduce

      DROP DATABASE IF EXISTS mariadb_srs_reduced;
      CREATE DATABASE mariadb_srs_reduced CHARACTER SET utf8mb4;
      USE mariadb_srs_reduced;
       
      CREATE TABLE t0 (
          c0 REAL SIGNED NOT NULL
      ) ENGINE=MyISAM;
       
      CREATE OR REPLACE TABLE t1 (
          c0 CHAR(100) UNIQUE PRIMARY KEY
      ) ENGINE=InnoDB;
       
      INSERT INTO t1 VALUES ('E|');
      INSERT INTO t0 VALUES (-1120782647);
       
      SELECT t1.c0
      FROM t1
      INNER JOIN t0 ON TRUE
      WHERE t0.c0 IN (t1.c0, (t0.c0 ^ ''));
       
      SELECT ALL t1.c0
      FROM t1
      STRAIGHT_JOIN t0 ON TRUE
      WHERE t0.c0 IN (t1.c0, (t0.c0 ^ ''));
      

      Actual result

      The INNER JOIN query returns 1 row:

      E|
      

      The STRAIGHT_JOIN query returns 0 rows.

      Observed cardinalities:

      INNER JOIN:     1
      STRAIGHT_JOIN:  0
      

      The result is stable across repeated executions.

      Expected result

      Both queries should return the same result.

      STRAIGHT_JOIN can constrain the join order, but changing the join order of
      these inner joins must not change the result of the query.

      Additional information

      The predicate contains a mixed REAL/CHAR IN expression and a bitwise XOR
      expression:

      t0.c0 IN (t1.c0, (t0.c0 ^ ''))
      

      Possibly related to MDEV-36249.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Ann C Ann C
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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