diff options
-rw-r--r-- | mysql-test/r/join_nested.result | 14 | ||||
-rw-r--r-- | mysql-test/t/join_nested.test | 8 | ||||
-rw-r--r-- | sql/sql_select.cc | 10 |
3 files changed, 25 insertions, 7 deletions
diff --git a/mysql-test/r/join_nested.result b/mysql-test/r/join_nested.result index 7a205811113..845fceab2f1 100644 --- a/mysql-test/r/join_nested.result +++ b/mysql-test/r/join_nested.result @@ -845,6 +845,20 @@ a b a b a b a b 1 3 5 3 2 2 NULL NULL 2 2 5 3 1 2 NULL NULL 2 2 5 3 2 2 NULL NULL +EXPLAIN EXTENDED +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, t3, t4 +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 +1 SIMPLE t4 ALL NULL NULL NULL NULL 2 +Warnings: +Note 1003 select test.t1.a AS `a`,test.t1.b AS `b`,test.t2.a AS `a`,test.t2.b AS `b`,test.t3.a AS `a`,test.t3.b AS `b`,test.t4.a AS `a`,test.t4.b AS `b` from test.t1 join test.t3 join test.t2 left join test.t4 on(((test.t3.a = 1) and (test.t2.b = test.t4.b))) where (test.t1.a <= 2) CREATE INDEX idx_b ON t2(b); EXPLAIN EXTENDED SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test index f4b6370539d..8247a12fc56 100644 --- a/mysql-test/t/join_nested.test +++ b/mysql-test/t/join_nested.test @@ -458,6 +458,14 @@ SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b ON t3.a=1 AND t2.b=t4.b WHERE t1.a <= 2; +EXPLAIN EXTENDED +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b + FROM t1, t3, t4 + RIGHT JOIN + t2 + ON t3.a=1 AND t2.b=t4.b + WHERE t1.a <= 2; + CREATE INDEX idx_b ON t2(b); EXPLAIN EXTENDED diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a48c5dda6af..6b9a2ae0be0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11201,17 +11201,14 @@ static void print_join(THD *thd, String *str, List<TABLE_LIST> *tables) *t= ti++; DBUG_ASSERT(tables->elements >= 1); - TABLE_LIST *prev= *table; - prev->print(thd, str); + (*table)->print(thd, str); TABLE_LIST **end= table + tables->elements; for(TABLE_LIST **tbl= table + 1; tbl < end; tbl++) { TABLE_LIST *curr= *tbl; - if (prev->outer_join & JOIN_TYPE_RIGHT) - str->append(" right join ", 12); - else if (curr->outer_join & JOIN_TYPE_LEFT) - str->append(" left join ", 11); + if (curr->outer_join) + str->append(" left join ", 11); // MySQL converg right to left joins else if (curr->straight) str->append(" straight_join ", 15); else @@ -11223,7 +11220,6 @@ static void print_join(THD *thd, String *str, List<TABLE_LIST> *tables) curr->on_expr->print(str); str->append(')'); } - prev= curr; } } |