Here is another test case:
--source include/have_innodb.inc SET SESSION optimizer_search_depth=4;
CREATE TABLE t1 ( f6 int) ENGINE=InnoDB;
CREATE TABLE t2 ( f1 int) ;
CREATE TABLE t3 ( f4 int) ;
CREATE TABLE t4 ( f1 int) ENGINE=InnoDB;
CREATE TABLE t5 ( f1 int) ;
CREATE TABLE t6 ( f3 int NOT NULL , PRIMARY KEY (f3)) ;
SELECT t2.f1 FROM t1 RIGHT JOIN t2 JOIN t3 ON t2.f1 RIGHT JOIN t4 LEFT JOIN t5 LEFT JOIN t6 ON t5.f1 = t6.f3 ON t4.f1 ON t3.f4 ON t1.f6 ;
Here is another test case:
--source include/ have_innodb. inc search_ depth=4;
SET SESSION optimizer_
CREATE TABLE t1 ( f6 int) ENGINE=InnoDB;
CREATE TABLE t2 ( f1 int) ;
CREATE TABLE t3 ( f4 int) ;
CREATE TABLE t4 ( f1 int) ENGINE=InnoDB;
CREATE TABLE t5 ( f1 int) ;
CREATE TABLE t6 ( f3 int NOT NULL , PRIMARY KEY (f3)) ;
SELECT t2.f1
FROM t1
RIGHT JOIN t2 JOIN t3 ON t2.f1
RIGHT JOIN t4
LEFT JOIN t5
LEFT JOIN t6 ON t5.f1 = t6.f3 ON t4.f1 ON t3.f4 ON t1.f6 ;