summaryrefslogtreecommitdiff
path: root/sql/opt_subselect.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2017-06-07 12:45:09 -0700
committerIgor Babaev <igor@askmonty.org>2017-06-07 12:45:32 -0700
commitc258ca2463947fcc3d69bb50a8b5cf6906778508 (patch)
tree67109ac2bccfda94c8b2cad15eed21e3003275fa /sql/opt_subselect.cc
parent2cb94aa1b70fa01d9e5c1d8a7625415a0220a3d9 (diff)
downloadmariadb-git-c258ca2463947fcc3d69bb50a8b5cf6906778508.tar.gz
Fixed the bug mdev-12838.
If the optimizer chose an execution plan where a semi-join nest were materialized and the result of materialization was scanned to access other tables by ref access it could build a key over columns of the tables from the nest that were actually inaccessible. The patch performs a proper check whether a key that uses columns of the tables from a materialized semi-join nest can be employed to access outer tables.
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r--sql/opt_subselect.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index d8b4de29f47..af1abb2001e 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -3429,6 +3429,7 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
table_map remaining_tables= 0;
table_map handled_tabs= 0;
join->sjm_lookup_tables= 0;
+ join->sjm_scan_tables= 0;
for (tablenr= table_count - 1 ; tablenr != join->const_tables - 1; tablenr--)
{
POSITION *pos= join->best_positions + tablenr;
@@ -3487,6 +3488,9 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
for (i= tablenr; i != (first + sjm->tables - 1); i--)
rem_tables |= join->best_positions[i].table->table->map;
+ for (i= first; i < first+ sjm->tables; i++)
+ join->sjm_scan_tables |= join->best_positions[i].table->table->map;
+
POSITION dummy;
join->cur_sj_inner_tables= 0;
for (i= first + sjm->tables; i <= tablenr; i++)