diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-10 17:57:14 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-10 17:57:14 +0300 |
commit | 3b6dadb5ebedab71bf1870579745ff3cd05e498a (patch) | |
tree | 045f7347d2dde8ca4f7cddce0b91b7625cb9cf13 /sql/sql_union.cc | |
parent | 0460d42b949b1dd90117808919d7cc97b8ab16ae (diff) | |
parent | 7f67ef14852afebf90aaafdfc7295acbf0ad340f (diff) | |
download | mariadb-git-3b6dadb5ebedab71bf1870579745ff3cd05e498a.tar.gz |
Merge 10.1 into 10.2
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r-- | sql/sql_union.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc index b2198eb2b31..8b1719c60cb 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -514,6 +514,25 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, found_rows_for_union= first_sl->options & OPTION_FOUND_ROWS; is_union_select= is_union() || fake_select_lex; + /* + If we are reading UNION output and the UNION is in the + IN/ANY/ALL/EXISTS subquery, then ORDER BY is redundant and hence should + be removed. + Example: + select ... col IN (select col2 FROM t1 union select col3 from t2 ORDER BY 1) + + (as for ORDER BY ... LIMIT, it currently not supported inside + IN/ALL/ANY subqueries) + (For non-UNION this removal of ORDER BY clause is done in + check_and_do_in_subquery_rewrites()) + */ + if (is_union() && item && + (item->is_in_predicate() || item->is_exists_predicate())) + { + global_parameters()->order_list.first= NULL; + global_parameters()->order_list.elements= 0; + } + /* Global option */ if (is_union_select || is_recursive) |