Loading mysql-test/r/olap.result +15 −0 Original line number Diff line number Diff line Loading @@ -592,6 +592,21 @@ a max(b) NULL 2 a 1 drop table t1; create table t1 (a varchar(22) not null , b int); insert into t1 values ("2006-07-01 21:30", 1), ("2006-07-01 23:30", 10); select left(a,10), a, sum(b) from t1 group by 1,2 with rollup; left(a,10) a sum(b) 2006-07-01 2006-07-01 21:30 1 2006-07-01 2006-07-01 23:30 10 2006-07-01 NULL 11 NULL NULL 11 select left(a,10) x, a, sum(b) from t1 group by x,a with rollup; x a sum(b) 2006-07-01 2006-07-01 21:30 1 2006-07-01 2006-07-01 23:30 10 2006-07-01 NULL 11 NULL NULL 11 drop table t1; CREATE TABLE t1(id int, type char(1)); INSERT INTO t1 VALUES (1,"A"),(2,"C"),(3,"A"),(4,"A"),(5,"B"), Loading mysql-test/t/olap.test +9 −1 Original line number Diff line number Diff line Loading @@ -283,6 +283,15 @@ 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; # # Bug #20825: rollup puts non-equal values together # create table t1 (a varchar(22) not null , b int); insert into t1 values ("2006-07-01 21:30", 1), ("2006-07-01 23:30", 10); select left(a,10), a, sum(b) from t1 group by 1,2 with rollup; select left(a,10) x, a, sum(b) from t1 group by x,a with rollup; drop table t1; # End of 4.1 tests # Loading Loading @@ -318,4 +327,3 @@ SELECT * FROM v1; DROP VIEW v1; DROP TABLE t1; # End of 4.1 tests sql/sql_select.cc +6 −1 Original line number Diff line number Diff line Loading @@ -14156,12 +14156,17 @@ bool JOIN::rollup_init() while ((item= it++)) { ORDER *group_tmp; bool found_in_group= 0; for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next) { if (*group_tmp->item == item) { item->maybe_null= 1; found_in_group= 1; } } if (item->type() == Item::FUNC_ITEM) if (item->type() == Item::FUNC_ITEM && !found_in_group) { bool changed= FALSE; if (change_group_ref(thd, (Item_func *) item, group_list, &changed)) Loading Loading
mysql-test/r/olap.result +15 −0 Original line number Diff line number Diff line Loading @@ -592,6 +592,21 @@ a max(b) NULL 2 a 1 drop table t1; create table t1 (a varchar(22) not null , b int); insert into t1 values ("2006-07-01 21:30", 1), ("2006-07-01 23:30", 10); select left(a,10), a, sum(b) from t1 group by 1,2 with rollup; left(a,10) a sum(b) 2006-07-01 2006-07-01 21:30 1 2006-07-01 2006-07-01 23:30 10 2006-07-01 NULL 11 NULL NULL 11 select left(a,10) x, a, sum(b) from t1 group by x,a with rollup; x a sum(b) 2006-07-01 2006-07-01 21:30 1 2006-07-01 2006-07-01 23:30 10 2006-07-01 NULL 11 NULL NULL 11 drop table t1; CREATE TABLE t1(id int, type char(1)); INSERT INTO t1 VALUES (1,"A"),(2,"C"),(3,"A"),(4,"A"),(5,"B"), Loading
mysql-test/t/olap.test +9 −1 Original line number Diff line number Diff line Loading @@ -283,6 +283,15 @@ 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; # # Bug #20825: rollup puts non-equal values together # create table t1 (a varchar(22) not null , b int); insert into t1 values ("2006-07-01 21:30", 1), ("2006-07-01 23:30", 10); select left(a,10), a, sum(b) from t1 group by 1,2 with rollup; select left(a,10) x, a, sum(b) from t1 group by x,a with rollup; drop table t1; # End of 4.1 tests # Loading Loading @@ -318,4 +327,3 @@ SELECT * FROM v1; DROP VIEW v1; DROP TABLE t1; # End of 4.1 tests
sql/sql_select.cc +6 −1 Original line number Diff line number Diff line Loading @@ -14156,12 +14156,17 @@ bool JOIN::rollup_init() while ((item= it++)) { ORDER *group_tmp; bool found_in_group= 0; for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next) { if (*group_tmp->item == item) { item->maybe_null= 1; found_in_group= 1; } } if (item->type() == Item::FUNC_ITEM) if (item->type() == Item::FUNC_ITEM && !found_in_group) { bool changed= FALSE; if (change_group_ref(thd, (Item_func *) item, group_list, &changed)) Loading