diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2019-10-07 22:05:09 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2019-10-07 22:05:09 +0530 |
commit | a5ffaa05ae7d6e55c3fbcbc976e7c455a85f7e51 (patch) | |
tree | 8b24d014e814ac38b247e83339f98ff4c266ee75 | |
parent | ac3bc3c87797cc4535a20eda25f3655bc0d1b339 (diff) | |
download | mariadb-git-a5ffaa05ae7d6e55c3fbcbc976e7c455a85f7e51.tar.gz |
Minor fix for duplicate weedout
-rw-r--r-- | sql/opt_subselect.cc | 30 | ||||
-rw-r--r-- | sql/sql_sort_nest.cc | 3 |
2 files changed, 27 insertions, 6 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 6df06c508b4..822240dcfac 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -3930,10 +3930,8 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join) for (uint i= first; i < i_end; i++) { if (i != first) - { join->best_positions[i].sj_strategy= SJ_OPT_NONE; - DBUG_ASSERT(!join->best_positions[i].sort_nest_operation_here); - } + handled_tabs |= join->best_positions[i].table->table->map; } @@ -5123,8 +5121,28 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options, } } - init_dups_weedout(join, first_table, i, i + pos->n_sj_tables - first_table); - i+= pos->n_sj_tables; + bool sort_nest_present= FALSE; + /* + Walk through the range and remember + - tables that need their rowids to be put into temptable + - the last outer table + */ + if (join->sort_nest_needed()) + { + for (JOIN_TAB *j= tab; j < tab + pos->n_sj_tables; j++) + { + if (j->is_sort_nest) + { + sort_nest_present= TRUE; + break; + } + } + } + + init_dups_weedout(join, first_table, i, + i + pos->n_sj_tables + MY_TEST(sort_nest_present)- + first_table); + i+= pos->n_sj_tables + MY_TEST(sort_nest_present); pos+= pos->n_sj_tables; break; } @@ -5279,6 +5297,8 @@ static bool sj_table_is_included(JOIN *join, JOIN_TAB *join_tab) { if (join_tab->emb_sj_nest) return FALSE; + if (join_tab->is_sort_nest) + return FALSE; /* Check if this table is functionally dependent on the tables that are within the same outer join nest diff --git a/sql/sql_sort_nest.cc b/sql/sql_sort_nest.cc index de0f6ea0f52..7cce22e2644 100644 --- a/sql/sql_sort_nest.cc +++ b/sql/sql_sort_nest.cc @@ -1418,7 +1418,8 @@ bool JOIN::sort_nest_allowed() select_lex->agg_func_used() || select_limit == HA_POS_ERROR || thd->lex->sql_command != SQLCOM_SELECT || - select_lex->uncacheable & UNCACHEABLE_DEPENDENT); + select_lex->uncacheable & UNCACHEABLE_DEPENDENT || + MY_TEST(select_options & SELECT_STRAIGHT_JOIN)); } |