From 444dbfaf174d5148ecc46df5a72dc304a7c20ccd Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Thu, 15 Sep 2005 17:14:39 +0300 Subject: [PATCH 1/3] Turn off EOLN_NATIVE flag for all test files Ignored some generated files --- .bzrignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index 9f57a7ad7de..1d5a2dcebdb 100644 --- a/.bzrignore +++ b/.bzrignore @@ -547,3 +547,5 @@ scripts/make_win_binary_distribution EXCEPTIONS-CLIENT support-files/my-innodb-heavy-4G.cnf ac_available_languages_fragment +support-files/MacOSX/postflight +support-files/MacOSX/preflight From 10a4a16654c3acd4e7b7447612a638737ba47d43 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Thu, 15 Sep 2005 17:59:01 +0300 Subject: [PATCH 2/3] Turn off EOLN_NATIVE flag of some test files From 1685040e2b56b914ef7513d2f372114d4b651c99 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Thu, 15 Sep 2005 21:34:11 +0400 Subject: [PATCH 3/3] 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. --- mysql-test/r/olap.result | 12 ++++++++++++ mysql-test/t/olap.test | 9 +++++++++ sql/sql_select.cc | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) 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 diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f702e531a4d..59b82b53b32 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -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)