diff options
author | unknown <timour@askmonty.org> | 2013-02-07 15:33:24 +0200 |
---|---|---|
committer | unknown <timour@askmonty.org> | 2013-02-07 15:33:24 +0200 |
commit | e648ff111a1d3fe79b6bd4ff0a25e85d1b949fb2 (patch) | |
tree | b6bbc11cf7e2408fe0f18a33540bc35050ffb1e6 /sql | |
parent | c7fa9fa72b2df857dac33a76ea79d66e37918acb (diff) | |
download | mariadb-git-e648ff111a1d3fe79b6bd4ff0a25e85d1b949fb2.tar.gz |
MDEV-537 Make multi-column non-top level subqueries to be executed via index (index/unique subquery)
instead of single_select_engine
This task changes the IN-EXISTS rewrite for multi-column subqueries
"(a, b) IN (select b, c ...)" to work in the same way as for
single-column subqueries "a IN (select b ...) with respect to the
injection of NULL-rejecting predicates.
More specifically, the method
Item_in_subselect::create_row_in_to_exists_cond()
adds Item_is_not_null_test and Item_func_trig_cond only if the left
IN operand can be NULL. Not having these predicates when not necessary,
makes it possible to rewrite the subquery into a "unique_subquery" or
"index_subquery" when there is a suitable index on the only
subquery table.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_subselect.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 8b3ce257642..0bde4a7926f 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -2306,7 +2306,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, ref_pointer_array+i, (char *)"<no matter>", (char *)"<list ref>")); - if (!abort_on_null) + if (!abort_on_null && select_lex->ref_pointer_array[i]->maybe_null) { Item *having_col_item= new Item_is_not_null_test(this, @@ -2325,10 +2325,6 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, (char *)"<no matter>", (char *)"<list ref>")); item= new Item_cond_or(item, item_isnull); - /* - TODO: why we create the above for cases where the right part - cant be NULL? - */ if (left_expr->element_index(i)->maybe_null) { if (!(item= new Item_func_trig_cond(item, get_cond_guard(i)))) @@ -2339,6 +2335,11 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, } *having_item= and_items(*having_item, having_col_item); } + if (!abort_on_null && left_expr->element_index(i)->maybe_null) + { + if (!(item= new Item_func_trig_cond(item, get_cond_guard(i)))) + DBUG_RETURN(true); + } *where_item= and_items(*where_item, item); } } |