From 9ca76cbca958aca7fbcbc3735bf73b2900103e1f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Sep 2005 21:34:11 +0400 Subject: Fix bug#12887 Distinct is not always applied after rollup For queries with GROUP BY and without hidden GROUP BY fields DISTINCT is optimized away becuase such queries produce result set without duplicates. But ROLLUP can add rows which may be same to some rows and this fact was ignored. Added check so if ROLLUP is present DISTINCT can't be optimized away. sql/sql_select.cc: Fix bug #12887 Distinct is not always applied after rollup mysql-test/r/olap.result: Test case for bug #12887 Distinct is not always applied after rollup mysql-test/t/olap.test: Test case for bug #12887 Distinct is not always applied after rollup --- mysql-test/r/olap.result | 12 ++++++++++++ mysql-test/t/olap.test | 9 +++++++++ 2 files changed, 21 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 65f7c649624..fef990297d9 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -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; diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 76c62d14621..4f9790b0de6 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -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 -- cgit v1.2.1