summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2006-04-04 12:55:02 -0700
committerunknown <igor@rurik.mysql.com>2006-04-04 12:55:02 -0700
commite77888f53075d283d1e8d2c719ef91896b93e15e (patch)
treee4198c98922180bdcb6779316d4b88e2ad4887db /sql/opt_sum.cc
parent8eb2b474b335973dcd2a2aa8c1fa5c097d46cc50 (diff)
downloadmariadb-git-e77888f53075d283d1e8d2c719ef91896b93e15e.tar.gz
Fixed bug #18237.
The code in opt_sum_query that prevented the COUNT/MIN/MAX optimization from being applied to outer joins was not adjusted after introducing nested joins. As a result if an outer join contained a reference to a view as an inner table the code of opt_sum_query missed the presence of an on expressions and erroneously applied the mentioned optimization. mysql-test/r/view.result: Added a test case for bug #18237. mysql-test/t/view.test: Added a test case for bug #18237.
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r--sql/opt_sum.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index ed8e694dcb7..8a5a5875d47 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -96,8 +96,14 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
*/
for (TABLE_LIST *tl= tables; tl; tl= tl->next_leaf)
{
+ TABLE_LIST *embedded;
+ for (embedded= tl ; embedded; embedded= embedded->embedding)
+ {
+ if (embedded->on_expr)
+ break;
+ }
+ if (embedded)
/* Don't replace expression on a table that is part of an outer join */
- if (tl->on_expr)
{
outer_tables|= tl->table->map;