Commit 0812385d authored by unknown's avatar unknown

group_by.result, group_by.test:

  Added a test case for bug #8614.
sql_select.cc:
  Fixed bug #8614.
  SELECT DISTINCT ... GROUP BY 'const' must be equivalent to
  SELECT ... GROUP BY 'const'.


sql/sql_select.cc:
  Fixed bug #8614.
  SELECT DISTINCT ... GROUP BY 'const' must be equivalent to
  SELECT ... GROUP BY 'const'.
mysql-test/t/group_by.test:
  Added a test case for bug #8614.
mysql-test/r/group_by.result:
  Added a test case for bug #8614.
parent c23524c7
......@@ -722,3 +722,13 @@ WHERE hostname LIKE '%aol%'
GROUP BY hostname;
hostname no
cache-dtc-af05.proxy.aol.com 1
DROP TABLE t1;
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (1,2), (1,3);
SELECT a, b FROM t1 GROUP BY 'const';
a b
1 2
SELECT DISTINCT a, b FROM t1 GROUP BY 'const';
a b
1 2
DROP TABLE t1;
# Initialise
--disable_warnings
drop table if exists t1,t2,t3;
......@@ -524,7 +525,7 @@ select min(b) from t1;
drop table t1;
#
# Test for bug #11088: GROUP BY a BLOB colimn with COUNT(DISTINCT column1)
# Test for bug #11088: GROUP BY a BLOB column with COUNT(DISTINCT column1)
#
CREATE TABLE t1 (id int PRIMARY KEY, user_id int, hostname longtext);
......@@ -539,3 +540,15 @@ SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1
WHERE hostname LIKE '%aol%'
GROUP BY hostname;
DROP TABLE t1;
#
# Test for bug #8614: GROUP BY 'const with DISTINCT
#
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (1,2), (1,3);
SELECT a, b FROM t1 GROUP BY 'const';
SELECT DISTINCT a, b FROM t1 GROUP BY 'const';
DROP TABLE t1;
......@@ -676,9 +676,14 @@ JOIN::optimize()
DBUG_RETURN(1);
}
simple_group= 0;
group_list= remove_const(this, group_list, conds,
rollup.state == ROLLUP::STATE_NONE,
&simple_group);
{
ORDER *old_group_list;
group_list= remove_const(this, (old_group_list= group_list), conds,
rollup.state == ROLLUP::STATE_NONE,
&simple_group);
if (old_group_list && !group_list)
select_distinct= 0;
}
if (!group_list && group)
{
order=0; // The output has only one row
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment