[Commits] 0f9efd5: MDEV-16359 wrong result (extra rows) on the query with UNION and brackets
revision-id: 0f9efd54ceb0e2b42841f5eb15d30072d210bac2 (mariadb-10.3.6-67-g0f9efd5) parent(s): 980aa3e71dfe0284ae8acb3e22852f29aaebd0bd author: Igor Babaev committer: Igor Babaev timestamp: 2018-08-03 23:27:24 -0700 message: 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 (). --- mysql-test/main/brackets.result | 12 ++++++++++++ mysql-test/main/brackets.test | 8 ++++++++ sql/sql_lex.cc | 1 - 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/brackets.result b/mysql-test/main/brackets.result index 1948072..479b74b 100644 --- a/mysql-test/main/brackets.result +++ b/mysql-test/main/brackets.result @@ -207,4 +207,16 @@ a b 1 100 3 30 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 diff --git a/mysql-test/main/brackets.test b/mysql-test/main/brackets.test index ac22770..699c70a 100644 --- a/mysql-test/main/brackets.test +++ b/mysql-test/main/brackets.test @@ -80,5 +80,13 @@ select a,b from t1 order by 1 limit 3; 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 diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index fa81555..20b1eb4 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -8763,7 +8763,6 @@ void st_select_lex_unit::reset_distinct() if (sl->distinct) { union_distinct= sl; - return; } } }
participants (1)
-
IgorBabaev