diff options
author | Igor Babaev <igor@askmonty.org> | 2017-08-10 14:25:19 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2017-08-10 14:26:29 -0700 |
commit | bf75dcac89d1496032015526dc6ce78d327e329f (patch) | |
tree | 98ca05164f4a2bf2fce6e1644bc6335193e69bbd /sql/sql_derived.cc | |
parent | b14e2b044b6483f22d9c33e6697479fbd859f747 (diff) | |
download | mariadb-git-bf75dcac89d1496032015526dc6ce78d327e329f.tar.gz |
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".
Diffstat (limited to 'sql/sql_derived.cc')
-rw-r--r-- | sql/sql_derived.cc | 13 |
1 files changed, 11 insertions, 2 deletions
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) |