summaryrefslogtreecommitdiff
path: root/sql/sql_derived.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2011-06-06 12:19:35 -0700
committerIgor Babaev <igor@askmonty.org>2011-06-06 12:19:35 -0700
commitdb0c3406011d9a6d6fdb98c1c1f7925d243bd1f9 (patch)
tree7288647c4e707fffc4362f4c71198c99be828231 /sql/sql_derived.cc
parent3bf08e549a78ad12191f6b1ca49719bc667664ef (diff)
downloadmariadb-git-db0c3406011d9a6d6fdb98c1c1f7925d243bd1f9.tar.gz
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.
Diffstat (limited to 'sql/sql_derived.cc')
-rw-r--r--sql/sql_derived.cc5
1 files changed, 4 insertions, 1 deletions
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;
}
}
/*