From bf75dcac89d1496032015526dc6ce78d327e329f Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 10 Aug 2017 14:25:19 -0700 Subject: This is a modification of the first patch committed for mdev-13369 developed to cover the case of mdev-13389: "Optimization for equi-joins of derived tables with window functions". --- sql/sql_derived.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'sql/sql_derived.cc') diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index e274e20d7e1..56909364f2a 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -1055,11 +1055,20 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived) select_unit *derived_result= derived->derived_result; SELECT_LEX *save_current_select= lex->current_select; - if (!derived_is_recursive && (unit->uncacheable & UNCACHEABLE_DEPENDENT)) + if (unit->executed && !derived_is_recursive && + (unit->uncacheable & UNCACHEABLE_DEPENDENT)) { if ((res= derived->table->file->ha_delete_all_rows())) goto err; - unit->first_select()->join->first_record= false; + JOIN *join= unit->first_select()->join; + join->first_record= false; + for (uint i= join->top_join_tab_count; + i < join->top_join_tab_count + join->aggr_tables; + i++) + { + if ((res= join->join_tab[i].table->file->ha_delete_all_rows())) + goto err; + } } if (derived_is_recursive) -- cgit v1.2.1