From db0c3406011d9a6d6fdb98c1c1f7925d243bd1f9 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 6 Jun 2011 12:19:35 -0700 Subject: Fixed LP bug #793436. When looking for the execution plan of a derived table to be materialized JOIN::optimize finds out that all joined tables of the derived table contain not more than one row then the derived table should be maretialized at the optimization stage. Added a test case for the bug. Adjusted results in other test cases. --- sql/sql_derived.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sql/sql_derived.cc') diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 021f7ccc636..ca56f0fa0a6 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -761,9 +761,12 @@ bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived) { if (!derived->is_merged_derived()) { + JOIN *join= first_select->join; unit->optimized= TRUE; - if ((res= first_select->join->optimize())) + if ((res= join->optimize())) goto err; + if (join->table_count == join->const_tables) + derived->fill_me= TRUE; } } /* -- cgit v1.2.1