Bug #58494 | Assertion !check_interleaving_with_nj(s) failed in optimize_straight_join() | ||
---|---|---|---|
Submitted: | 25 Nov 2010 13:50 | Modified: | 13 Jan 2011 21:22 |
Reporter: | John Embretsen | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S1 (Critical) |
Version: | 5.6.1-m5 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | straight_join |
[25 Nov 2010 13:50]
John Embretsen
[25 Nov 2010 14:12]
Guilhem Bichot
I added this assertion recently to the STRAIGHT_JOIN code path (optimize_straight_join()) (it was already present in the non-STRAIGHT_JOIN code path). I did it as a follow-up on BUG#52005. This assertion is supposed to check for correctness of the chosen execution plan (sometimes even with STRAIGHT_JOIN the server cannot use the user-provided plan and switches to something else, so this assertion makes sense even with STRAIGHT_JOIN).
[25 Nov 2010 15:02]
John Embretsen
The following MTR-style test case reproduces this bug (for this test case InnoDB is required): --source include/have_innodb.inc --disable_warnings DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t2; DROP TABLE IF EXISTS t3; DROP TABLE IF EXISTS t4; DROP TABLE IF EXISTS t5; DROP TABLE IF EXISTS t6; --enable_warnings CREATE TABLE t1 ( pk INT NOT NULL AUTO_INCREMENT, col_varchar_10_latin1_key VARCHAR(10), PRIMARY KEY (pk), KEY col_varchar_10_latin1_key (col_varchar_10_latin1_key) ) ENGINE=MyISAM; CREATE TABLE t2 ( pk INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (pk) ) ENGINE=InnoDB; CREATE TABLE t3 ( pk INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (pk) ) ENGINE=InnoDB; CREATE TABLE t4 ( pk INT NOT NULL AUTO_INCREMENT, col_int INT, col_int_key INT, col_varchar_10_latin1_key VARCHAR(10), PRIMARY KEY (pk), KEY col_int_key (col_int_key), KEY col_varchar_10_latin1_key (col_varchar_10_latin1_key) ) ENGINE=MyISAM; CREATE TABLE t5 ( col_int INT, col_varchar_10_utf8_key VARCHAR(10) CHARACTER SET utf8 ) ENGINE=MyISAM; CREATE TABLE t6 ( col_int_key INT, col_varchar_10_latin1_key VARCHAR(10), pk INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (pk), KEY col_varchar_10_latin1_key (col_varchar_10_latin1_key), KEY col_int_key (col_int_key) ) ENGINE=InnoDB; SELECT STRAIGHT_JOIN t6a.pk FROM t6 AS t6a LEFT JOIN t2 RIGHT JOIN t4 JOIN t3 ON t4.col_int RIGHT JOIN t1 ON t4.col_int_key = t1.pk LEFT JOIN t5 JOIN t6 AS t6b ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key ON t1.pk = t5.col_int ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key ON t6a.pk IS TRUE WHERE t6b.col_int_key IS TRUE ; DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t2; DROP TABLE IF EXISTS t3; DROP TABLE IF EXISTS t4; DROP TABLE IF EXISTS t5; DROP TABLE IF EXISTS t6;
[13 Jan 2011 12:55]
Guilhem Bichot
Summary: I had added an assertion in 5.6 only, and this bug report is about a case where this assertion fires. If I remove the assertion there is no _visible_ problem anymore. And if I add this assertion to 5.1 it fires as well. This assertion is supposed to be correct, so I will investigate why it fires (in 5.6).
[13 Jan 2011 21:21]
Guilhem Bichot
Though the testcase's query triggers an assertion failure in 5.6 and gives good results in 5.1/5.5, this is not a regression. The failed assertion, added to 5.6, points out that ordering of tables in the plan is incorrect and can theoretically lead to wrong results, and indeed a small modification of the testcase leads to wrong results in 5.1 and 5.5 too. So this is a bug which exists since 5.1: filed as BUG#59487. Fixing 59487 will fix the assertion failure (58494). So 58494 is marked as duplicate of 59487.
[13 Jan 2011 21:22]
Guilhem Bichot
Duplicate of BUG#59487