Commit 0f9efd54 authored by Igor Babaev's avatar Igor Babaev

MDEV-16359 wrong result (extra rows) on the query with UNION and brackets

Due to an obvious bug in st_select_lex_unit::reset_distinct() a union
without duplicates of more than 2 selects could return a result set
containing duplicate rows if this union was enclosed in ().
parent 980aa3e7
...@@ -207,4 +207,16 @@ a b ...@@ -207,4 +207,16 @@ a b
1 100 1 100
3 30 3 30
drop table t1; drop table t1;
#
# MDEV-16359: union with 3 selects in brackets
#
select 1 union select 1 union select 1;
1
1
(select 1 union select 1 union select 1);
1
1
((select 1) union (select 1) union (select 1));
1
1
# End of 10.4 tests # End of 10.4 tests
...@@ -80,5 +80,13 @@ select a,b from t1 order by 1 limit 3; ...@@ -80,5 +80,13 @@ select a,b from t1 order by 1 limit 3;
drop table t1; drop table t1;
--echo #
--echo # MDEV-16359: union with 3 selects in brackets
--echo #
select 1 union select 1 union select 1;
(select 1 union select 1 union select 1);
((select 1) union (select 1) union (select 1));
--echo # End of 10.4 tests --echo # End of 10.4 tests
...@@ -8763,7 +8763,6 @@ void st_select_lex_unit::reset_distinct() ...@@ -8763,7 +8763,6 @@ void st_select_lex_unit::reset_distinct()
if (sl->distinct) if (sl->distinct)
{ {
union_distinct= sl; union_distinct= sl;
return;
} }
} }
} }
......
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