diff options
author | unknown <timour@mysql.com> | 2005-06-14 12:52:44 +0300 |
---|---|---|
committer | unknown <timour@mysql.com> | 2005-06-14 12:52:44 +0300 |
commit | d87c2dd6bf6e6660c52fc64389b03568695ae903 (patch) | |
tree | 628bf5c4aebb640cea79c6eb61fd623de4578f45 /mysql-test/t/group_min_max.test | |
parent | d0db70270c59c8def10980c76173b3072263ef25 (diff) | |
download | mariadb-git-d87c2dd6bf6e6660c52fc64389b03568695ae903.tar.gz |
Fix for BUG#11044 - "SELECT DISTINCT on indexed column returns inconsistent results"
The problem was that when there was no MIN or MAX function, after finding the
group prefix based on the DISTINCT or GROUP BY attributes we did not search further
for a key in the group that satisfies the equi-join conditions on attributes that
follow the group attributes. Thus we ended up with the wrong rows, and subsequent
calls to select_cond->val_int() in evaluate_join_record() were filtering those
rows. Hence - the query result set was empty.
The problem occured both for GROUP BY queries without MIN/MAX and for queries
with DISTINCT (which were internally executed as GROUP BY queries).
mysql-test/r/group_min_max.result:
Added test result for BUG#11044. Notice that the group by query is
equivalent to the distinct query and both are executed via the same
algorithm.
mysql-test/t/group_min_max.test:
Added test for BUG#11044. Notice that the group by query is
equivalent to the distinct query and both are executed via the
same algorithm.
sql/opt_range.cc:
* Use the extended prefix in QUICK_GROUP_MIN_MAX_SELECT::get_next()
to find keys that satisfy equality conditions in the case when there is
no MIN or MAX function.
* Corrected some method comments.
* Corrected debug printout of cost information.
Diffstat (limited to 'mysql-test/t/group_min_max.test')
-rw-r--r-- | mysql-test/t/group_min_max.test | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index 76f959b983b..6731be615fd 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -482,7 +482,6 @@ select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; - -- -- DISTINCT queries -- @@ -526,6 +525,7 @@ select distinct a1,a1 from t1; select distinct a2,a1,a2,a1 from t1; select distinct t1.a1,t2.a1 from t1,t2; + -- -- DISTINCT queries with GROUP-BY -- @@ -641,6 +641,17 @@ 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#11044: DISTINCT or GROUP BY queries with equality predicates instead of MIN/MAX. +# + +explain select a1 from t1 where a2 = 'b' group by a1; +select a1 from t1 where a2 = 'b' group by a1; + +explain select distinct a1 from t1 where a2 = 'b'; +select distinct a1 from t1 where a2 = 'b'; + + drop table t1; drop table t2; drop table t3; |