summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2013-10-14 13:39:18 -0700
committerIgor Babaev <igor@askmonty.org>2013-10-14 13:39:18 -0700
commiteb2c6f451392396ef2ca74f1dba761fc4459d171 (patch)
tree4b9e6c400215cd74a81c65b1fa8a0200ea7249c3 /sql
parentddc46740a56bf3885ae33dc21e281c063d189abf (diff)
parenteae0a45f4e5ed4f1e382e53be74dd8082d4d797a (diff)
downloadmariadb-git-eb2c6f451392396ef2ca74f1dba761fc4459d171.tar.gz
Merge 5.5->10.0-base
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_select.cc34
1 files changed, 28 insertions, 6 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index fdc52cb454a..a40b7b217f9 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4980,6 +4980,33 @@ static void add_key_fields_for_nj(JOIN *join, TABLE_LIST *nested_join_table,
}
+void count_cond_for_nj(SELECT_LEX *sel, TABLE_LIST *nested_join_table)
+{
+ List_iterator<TABLE_LIST> li(nested_join_table->nested_join->join_list);
+ List_iterator<TABLE_LIST> li2(nested_join_table->nested_join->join_list);
+ bool have_another = FALSE;
+ TABLE_LIST *table;
+
+ while ((table= li++) || (have_another && (li=li2, have_another=FALSE,
+ (table= li++))))
+ if (table->nested_join)
+ {
+ if (!table->on_expr)
+ {
+ /* It's a semi-join nest. Walk into it as if it wasn't a nest */
+ have_another= TRUE;
+ li2= li;
+ li= List_iterator<TABLE_LIST>(table->nested_join->join_list);
+ }
+ else
+ count_cond_for_nj(sel, table);
+ }
+ if (nested_join_table->on_expr)
+ nested_join_table->on_expr->walk(&Item::count_sargable_conds,
+ 0, (uchar*) sel);
+
+}
+
/**
Update keyuse array with all possible keys we can use to fetch rows.
@@ -5028,12 +5055,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
while ((table= li++))
{
if (table->nested_join)
- {
- if (table->on_expr)
- table->on_expr->walk(&Item::count_sargable_conds, 0, (uchar*) sel);
- if (table->sj_on_expr)
- table->sj_on_expr->walk(&Item::count_sargable_conds, 0, (uchar*) sel);
- }
+ count_cond_for_nj(sel, table);
}
}