Loading mysql-test/r/olap.result +12 −0 Original line number Diff line number Diff line Loading @@ -529,3 +529,15 @@ a LENGTH(a) COUNT(*) 2 1 1 NULL NULL 2 DROP TABLE t1; create table t1 ( a varchar(9), b int ); insert into t1 values('a',1),(null,2); select a, max(b) from t1 group by a with rollup; a max(b) NULL 2 a 1 NULL 2 select distinct a, max(b) from t1 group by a with rollup; a max(b) NULL 2 a 1 drop table t1; mysql-test/t/olap.test +9 −0 Original line number Diff line number Diff line Loading @@ -263,4 +263,13 @@ SELECT * FROM (SELECT a, LENGTH(a), COUNT(*) FROM t1 GROUP BY a WITH ROLLUP) t; DROP TABLE t1; # # Bug #12887 Distinct is not always applied after rollup # create table t1 ( a varchar(9), b int ); insert into t1 values('a',1),(null,2); select a, max(b) from t1 group by a with rollup; select distinct a, max(b) from t1 group by a with rollup; drop table t1; # End of 4.1 tests sql/sql_select.cc +1 −1 Original line number Diff line number Diff line Loading @@ -618,7 +618,7 @@ JOIN::optimize() } if (group_list || tmp_table_param.sum_func_count) { if (! hidden_group_fields) if (! hidden_group_fields && rollup.state == ROLLUP::STATE_NONE) select_distinct=0; } else if (select_distinct && tables - const_tables == 1) Loading Loading
mysql-test/r/olap.result +12 −0 Original line number Diff line number Diff line Loading @@ -529,3 +529,15 @@ a LENGTH(a) COUNT(*) 2 1 1 NULL NULL 2 DROP TABLE t1; create table t1 ( a varchar(9), b int ); insert into t1 values('a',1),(null,2); select a, max(b) from t1 group by a with rollup; a max(b) NULL 2 a 1 NULL 2 select distinct a, max(b) from t1 group by a with rollup; a max(b) NULL 2 a 1 drop table t1;
mysql-test/t/olap.test +9 −0 Original line number Diff line number Diff line Loading @@ -263,4 +263,13 @@ SELECT * FROM (SELECT a, LENGTH(a), COUNT(*) FROM t1 GROUP BY a WITH ROLLUP) t; DROP TABLE t1; # # Bug #12887 Distinct is not always applied after rollup # create table t1 ( a varchar(9), b int ); insert into t1 values('a',1),(null,2); select a, max(b) from t1 group by a with rollup; select distinct a, max(b) from t1 group by a with rollup; drop table t1; # End of 4.1 tests
sql/sql_select.cc +1 −1 Original line number Diff line number Diff line Loading @@ -618,7 +618,7 @@ JOIN::optimize() } if (group_list || tmp_table_param.sum_func_count) { if (! hidden_group_fields) if (! hidden_group_fields && rollup.state == ROLLUP::STATE_NONE) select_distinct=0; } else if (select_distinct && tables - const_tables == 1) Loading