summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2009-12-17 18:09:04 +0300
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2009-12-17 18:09:04 +0300
commit5069a666709a66335ded54c6fab4832e155840c1 (patch)
tree4d0f676967368da9dbb6b7ddde1033a278f2e17c /sql/sql_select.cc
parent7e15d855f1fbc72bae6c0ee75dd2b61477c2eaff (diff)
parent709f49cbf780681bb74707c9ab2438f163747906 (diff)
downloadmariadb-git-5069a666709a66335ded54c6fab4832e155840c1.tar.gz
Automerge from mysql-5.1-bugteam to mysql-trunk-merge.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 47426d28eb5..bdd32718a08 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -7231,7 +7231,19 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
for (order=first_order; order ; order=order->next)
{
table_map order_tables=order->item[0]->used_tables();
- if (order->item[0]->with_sum_func)
+ if (order->item[0]->with_sum_func ||
+ /*
+ If the outer table of an outer join is const (either by itself or
+ after applying WHERE condition), grouping on a field from such a
+ table will be optimized away and filesort without temporary table
+ will be used unless we prevent that now. Filesort is not fit to
+ handle joins and the join condition is not applied. We can't detect
+ the case without an expensive test, however, so we force temporary
+ table for all queries containing more than one table, ROLLUP, and an
+ outer join.
+ */
+ (join->tables > 1 && join->rollup.state == ROLLUP::STATE_INITED &&
+ join->outer_join))
*simple_order=0; // Must do a temp table to sort
else if (!(order_tables & not_const_tables))
{