summaryrefslogtreecommitdiff
path: root/sql/opt_subselect.cc
diff options
context:
space:
mode:
authorVarun Gupta <varun.gupta@mariadb.com>2020-12-14 21:03:07 +0530
committerVarun Gupta <varun.gupta@mariadb.com>2020-12-18 12:54:33 +0530
commitdc1f28e78c22fde6a6446445a6574ab0dd7fcf93 (patch)
tree44493f3c88404faa4925660ca5a8ee1769d52eb4 /sql/opt_subselect.cc
parentcc16977aa84edcca540fdef0db8af67479165aef (diff)
downloadmariadb-git-10.2-wf.tar.gz
MDEV-15296: wrong result with window function inside a subquery10.2-wf
Window Functions were treated as a constant in a dependent tables less subquery. Made sure that the behaviour of window functions is same as the aggregate function for dependent tables less subquery. Also propagted Item::with_window_func for few missing cases.
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r--sql/opt_subselect.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index fec4e8b2828..68d4977bac4 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -651,7 +651,7 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
1. Subquery predicate is an IN/=ANY subq predicate
2. Subquery is a single SELECT (not a UNION)
3. Subquery does not have GROUP BY or ORDER BY
- 4. Subquery does not use aggregate functions or HAVING
+ 4. Subquery does not use aggregate functions or HAVING or window functions
5. Subquery predicate is at the AND-top-level of ON/WHERE clause
6. We are not in a subquery of a single table UPDATE/DELETE that
doesn't have a JOIN (TODO: We should handle this at some
@@ -669,6 +669,7 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
!select_lex->is_part_of_union() && // 2
!select_lex->group_list.elements && !join->order && // 3
!join->having && !select_lex->with_sum_func && // 4
+ !select_lex->have_window_funcs() && // 4
in_subs->emb_on_expr_nest && // 5
select_lex->outer_select()->join && // 6
parent_unit->first_select()->leaf_tables.elements && // 7