summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
authormonty@mashka.mysql.fi <>2003-02-08 01:12:58 +0200
committermonty@mashka.mysql.fi <>2003-02-08 01:12:58 +0200
commit7388c5f1618380f5ac29c3ab40d48da0372a3d57 (patch)
treed54b65dfc052978dab95842c84f1a39745ef0d0c /sql/opt_sum.cc
parent60556efaca57f2db6a9c6484e788623b5591e1e3 (diff)
parentd92022f7f018fb1b19efa8a04ed06217600c16f7 (diff)
downloadmariadb-git-7388c5f1618380f5ac29c3ab40d48da0372a3d57.tar.gz
merge
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r--sql/opt_sum.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 2ca6ddbab10..d8c61fa1a1d 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -245,8 +245,15 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
const_result=0;
}
}
- if (used_tables != removed_tables)
- const_result=0; // We didn't remove all tables
+ /*
+ If we have a where clause, we can only ignore searching in the
+ tables if MIN/MAX optimisation replaced all used tables
+ This is to not to use replaced values in case of:
+ SELECT MIN(key) FROM table_1, empty_table
+ removed_tables is != 0 if we have used MIN() or MAX().
+ */
+ if (removed_tables && used_tables != removed_tables)
+ const_result= 0; // We didn't remove all tables
return const_result;
}