Commit f048032c authored by unknown's avatar unknown

removed wrong distinct UNION detection (BUG#6565)


mysql-test/r/derived.result:
  test of union subquery in the FROM clause with complex distinct/all
mysql-test/t/derived.test:
  test of union subquery in the FROM clause with complex distinct/all
sql/sql_derived.cc:
  removed wrong distinct UNION detection
parent 0d578714
...@@ -339,3 +339,22 @@ select distinct sum(b) from (select a,b from t1) y group by a; ...@@ -339,3 +339,22 @@ select distinct sum(b) from (select a,b from t1) y group by a;
sum(b) sum(b)
4 4
drop table t1; drop table t1;
create table t1(a int);
create table t2(a int);
create table t3(a int);
insert into t1 values(1),(1);
insert into t2 values(2),(2);
insert into t3 values(3),(3);
select * from t1 union distinct select * from t2 union all select * from t3;
a
1
2
3
3
select * from (select * from t1 union distinct select * from t2 union all select * from t3) X;
a
1
2
3
3
drop table t1, t2, t3;
...@@ -224,3 +224,15 @@ select distinct sum(b) from t1 group by a; ...@@ -224,3 +224,15 @@ select distinct sum(b) from t1 group by a;
select distinct sum(b) from (select a,b from t1) y group by a; select distinct sum(b) from (select a,b from t1) y group by a;
drop table t1; drop table t1;
#
# test of union subquery in the FROM clause with complex distinct/all (BUG#6565)
#
create table t1(a int);
create table t2(a int);
create table t3(a int);
insert into t1 values(1),(1);
insert into t2 values(2),(2);
insert into t3 values(3),(3);
select * from t1 union distinct select * from t2 union all select * from t3;
select * from (select * from t1 union distinct select * from t2 union all select * from t3) X;
drop table t1, t2, t3;
...@@ -132,10 +132,16 @@ static int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, ...@@ -132,10 +132,16 @@ static int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
/* /*
Temp table is created so that it hounours if UNION without ALL is to be Temp table is created so that it hounours if UNION without ALL is to be
processed processed
As 'distinct' parameter we always pass FALSE (0), because underlying
query will control distinct condition by itself. Correct test of
distinct underlying query will be is_union &&
!unit->union_distinct->next_select() (i.e. it is union and last distinct
SELECT is last SELECT of UNION).
*/ */
if (!(table= create_tmp_table(thd, &derived_result->tmp_table_param, if (!(table= create_tmp_table(thd, &derived_result->tmp_table_param,
unit->types, (ORDER*) 0, unit->types, (ORDER*) 0,
is_union && unit->union_distinct, 1, FALSE, 1,
(first_select->options | thd->options | (first_select->options | thd->options |
TMP_TABLE_ALL_COLUMNS), TMP_TABLE_ALL_COLUMNS),
HA_POS_ERROR, HA_POS_ERROR,
......
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