From a01d48f92e9c2eebe91e92962b5fdb075978c712 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 Mar 2006 12:34:28 +0300 Subject: Fix for BUG#16710. The bug was due to a missed case in the detection of whether an index can be used for loose scan. More precisely, the range optimizer chose to use loose index scan for queries for which the condition(s) over an index key part could not be pushed to the index together with the loose scan. As a result, loose index scan was selecting the first row in the index with a given GROUP BY prefix, and was applying the WHERE clause after that, while it should have inspected all rows with the given prefix, and apply the WHERE clause to all of them. The fix detects and skips such cases. mysql-test/r/group_min_max.result: Added test for BUG#16710. mysql-test/t/group_min_max.test: Added test for BUG#16710. sql/item.cc: Added new method [Item | Item_field]::find_item_in_field_list_processor. sql/item.h: Added new method [Item | Item_field]::find_item_in_field_list_processor. sql/opt_range.cc: Handle the case when there is no MIN/MAX aggregate function, and a keypart of the index being considered, that is after the GROUP BY prefix, is used in the WHERE clause and the condition where it is used cannot be pushed to the index. If this is the case, we rule out this index. --- mysql-test/t/group_min_max.test | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mysql-test/t/group_min_max.test') diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index 8dc55532bbf..69c5d58b409 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -641,6 +641,14 @@ explain select a1,a2,count(a2) from t1 group by a1,a2,b; explain select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; explain select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; + +# +# Bug #16710: select distinct doesn't return all it should +# + +explain select distinct(a1) from t1 where ord(a2) = 98; +select distinct(a1) from t1 where ord(a2) = 98; + # # BUG#11044: DISTINCT or GROUP BY queries with equality predicates instead of MIN/MAX. # -- cgit v1.2.1