summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2005-09-15 22:21:30 +0400
committerunknown <evgen@moonbone.local>2005-09-15 22:21:30 +0400
commitc5f78752aada25162a9cc0c7d2989a77952fcba6 (patch)
tree0bd7ef985a5f212f7a3fa4cd9bd2c619a4b2d5b6
parentbb20af75f7a915a232e27d3eca229050e9cfe3b7 (diff)
parent4805236e2f04c5acf60bac87fb446e5df16133e0 (diff)
downloadmariadb-git-c5f78752aada25162a9cc0c7d2989a77952fcba6.tar.gz
Manual merge
BitKeeper/etc/ignore: auto-union mysql-test/t/bool.test: Auto merged mysql-test/t/cast.test: Auto merged mysql-test/t/func_concat.test: Auto merged mysql-test/t/grant.test: Auto merged mysql-test/t/grant_cache.test: Auto merged mysql-test/t/innodb-deadlock.test: Auto merged mysql-test/t/loaddata.test: Auto merged mysql-test/t/lowercase_table.test: Auto merged mysql-test/t/lowercase_table3.test: Auto merged mysql-test/t/mix_innodb_myisam_binlog.test: Auto merged mysql-test/t/mysqlbinlog.test: Auto merged mysql-test/t/mysqldump.test: Auto merged mysql-test/t/query_cache.test: Auto merged mysql-test/t/rpl_EE_error.test: Auto merged mysql-test/t/rpl_change_master.test: Auto merged mysql-test/t/rpl_empty_master_crash.test: Auto merged BitKeeper/deleted/.del-isam.test~834fb0ee8196c445: Auto merged BitKeeper/deleted/.del-rpl_trunc_binlog.test~961b1f6ac73d37c8: Auto merged mysql-test/r/flush_block_commit.result: Auto merged mysql-test/r/flush_table.result: Auto merged mysql-test/r/lock_multi.result: Auto merged mysql-test/r/rpl_server_id1.result: Auto merged mysql-test/r/rpl_server_id2.result: Auto merged mysql-test/r/rpl_start_stop_slave.result: Auto merged mysql-test/t/create_select_tmp.test: Auto merged mysql-test/t/ctype_latin1_de.test: Auto merged mysql-test/t/flush_block_commit.test: Auto merged mysql-test/t/func_if.test: Auto merged mysql-test/t/innodb-lock.test: Auto merged mysql-test/t/lock_multi.test: Auto merged mysql-test/t/rpl_drop.test: Auto merged mysql-test/t/rpl_error_ignored_table.test: Auto merged mysql-test/t/rpl_flush_log_loop.test: Auto merged mysql-test/t/rpl_get_lock.test: Auto merged mysql-test/t/rpl_heap.test: Auto merged mysql-test/t/rpl_insert_id.test: Auto merged mysql-test/t/rpl_loaddata.test: Auto merged mysql-test/t/rpl_loaddata_rule_m.test: Auto merged mysql-test/t/rpl_loaddata_rule_s.test: Auto merged mysql-test/t/rpl_loaddatalocal.test: Auto merged mysql-test/t/rpl_max_relay_size.test: Auto merged mysql-test/t/rpl_reset_slave.test: Auto merged mysql-test/t/system_mysql_db.test: Auto merged mysql-test/t/system_mysql_db_fix.test: Auto merged sql/sql_select.cc: Auto merged mysql-test/t/rpl_server_id2.test: Auto merged
-rw-r--r--mysql-test/r/olap.result12
-rw-r--r--mysql-test/t/olap.test10
-rw-r--r--sql/sql_select.cc2
3 files changed, 23 insertions, 1 deletions
diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result
index df0ee09ea8e..225e306b3cf 100644
--- a/mysql-test/r/olap.result
+++ b/mysql-test/r/olap.result
@@ -580,6 +580,18 @@ 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;
CREATE TABLE t1(id int, type char(1));
INSERT INTO t1 VALUES
(1,"A"),(2,"C"),(3,"A"),(4,"A"),(5,"B"),
diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test
index adaf6883d43..e34ac6a865c 100644
--- a/mysql-test/t/olap.test
+++ b/mysql-test/t/olap.test
@@ -274,6 +274,15 @@ 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
#
@@ -309,3 +318,4 @@ SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
+# End of 4.1 tests
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 74c9b793886..3916509db69 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -755,7 +755,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)