summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2019-05-14 23:58:56 -0700
committerIgor Babaev <igor@askmonty.org>2019-05-23 21:54:17 -0700
commite57bb1f76cd0f8eac587a5fede01ba19bd54677a (patch)
tree912dde4c886de29b827db839e2fc4e9221cc357b /sql/sql_select.cc
parentaad4e5637daf52c2b27a355e0c2f9038d940209d (diff)
downloadmariadb-git-e57bb1f76cd0f8eac587a5fede01ba19bd54677a.tar.gz
MDEV-19258 RIGHT JOIN hangs in MariaDB
This patch corrects the patch for the bug 10006. The latter incorrectly calculates the attribute TABLE_LIST::dep_tables for inner tables of outer joins that are to be converted into inner joins. As a result after the patch some valid join orders were not evaluated and the optimizer could choose an execution plan that was far from being optimal.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7426540c8d7..02f1623a878 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -14635,8 +14635,20 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
table->table->maybe_null= FALSE;
table->outer_join= 0;
if (!(straight_join || table->straight))
- table->dep_tables= table->embedding && !table->embedding->sj_subq_pred ?
- table->embedding->dep_tables : 0;
+ {
+ table->dep_tables= 0;
+ TABLE_LIST *embedding= table->embedding;
+ while (embedding)
+ {
+ if (embedding->nested_join->join_list.head()->outer_join)
+ {
+ if (!embedding->sj_subq_pred)
+ table->dep_tables= embedding->dep_tables;
+ break;
+ }
+ embedding= embedding->embedding;
+ }
+ }
if (table->on_expr)
{
/* Add ON expression to the WHERE or upper-level ON condition. */