1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Fixed bug #36632: SELECT DISTINCT from a simple view on an

InnoDB table, where all selected columns
                  belong to the same unique index key, returns
                  incorrect results

Server executes some queries via QUICK_GROUP_MIN_MAX_SELECT
(MIN/MAX optimization for queries with GROUP BY or DISTINCT
clause) and that optimization implies loose index scan, so all
grouping is done by the QUICK_GROUP_MIN_MAX_SELECT::get_next
method.

The server does not set the precomputed_group_by flag for some
QUICK_GROUP_MIN_MAX_SELECT queries and duplicates grouping by
call to the end_send_group function.

Fix: when the test_if_skip_sort_order function selects loose 
index scan as a best way to satisfy an ORDER BY/GROUP BY type
of query, the precomputed_group_by flag has been set to use 
end_send/end_write functions instead of end_send_group/
end_write_group functions.


mysql-test/r/group_min_max_innodb.result:
  Fixed bug #36632: SELECT DISTINCT from a simple view on an
                    InnoDB table, where all selected columns
                    belong to the same unique index key, returns
                    incorrect results
mysql-test/t/group_min_max_innodb.test:
  Fixed bug #36632: SELECT DISTINCT from a simple view on an
                    InnoDB table, where all selected columns
                    belong to the same unique index key, returns
                    incorrect results
sql/sql_select.cc:
  Fixed bug #36632: SELECT DISTINCT from a simple view on an
                    InnoDB table, where all selected columns
                    belong to the same unique index key, returns
                    incorrect results
This commit is contained in:
Gleb Shchepa
2008-06-27 23:50:53 +05:00
parent fb8f32d077
commit a8067140e8
3 changed files with 50 additions and 0 deletions

View File

@ -6,6 +6,11 @@
--source include/have_innodb.inc
--disable_warnings
drop view if exists v1;
drop table if exists t1,t4;
--enable_warnings
#
# Bug #12672: primary key implcitly included in every innodb index
#
@ -93,3 +98,22 @@ alter table t1 drop primary key, add primary key (f2, f1);
explain select distinct f1 a, f1 b from t1;
explain select distinct f1, f2 from t1;
drop table t1;
#
# Bug #36632: Select distinct from a simple view on an InnoDB table
# returns incorrect results
#
create table t1(pk int primary key) engine=innodb;
create view v1 as select pk from t1 where pk < 20;
insert into t1 values (1), (2), (3), (4);
select distinct pk from v1;
insert into t1 values (5), (6), (7);
select distinct pk from v1;
drop view v1;
drop table t1;
--echo End of 5.1 tests