summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-09-30 09:04:43 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-09-30 09:04:43 +0300
commit064cb58efea063595e336e4cd0feccb12d26f8cf (patch)
treef140b96c8a20172cbb484375e38a7aa481ab660b /sql/item_sum.cc
parente5a9dcfda20e174525ad63a30e12f592aa9c96d3 (diff)
parent57fdd016ce6167c15ba9cd41048b8a42ba582447 (diff)
downloadmariadb-git-064cb58efea063595e336e4cd0feccb12d26f8cf.tar.gz
Merge 10.4 into 10.5
FIXME: Part of the MDEV-20699 test is disabled due to nonderterministic result.
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 537eaaf8dcd..a674cfe8ff9 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -73,6 +73,7 @@ size_t Item_sum::ram_limitation(THD *thd)
bool Item_sum::init_sum_func_check(THD *thd)
{
SELECT_LEX *curr_sel= thd->lex->current_select;
+ LEX *lex_s= (curr_sel ? curr_sel->parent_lex : thd->lex);
if (curr_sel && curr_sel->name_visibility_map.is_clear_all())
{
for (SELECT_LEX *sl= curr_sel; sl; sl= sl->context.outer_select())
@@ -88,9 +89,9 @@ bool Item_sum::init_sum_func_check(THD *thd)
return TRUE;
}
/* Set a reference to the nesting set function if there is any */
- in_sum_func= thd->lex->in_sum_func;
+ in_sum_func= lex_s->in_sum_func;
/* Save a pointer to object to be used in items for nested set functions */
- thd->lex->in_sum_func= this;
+ lex_s->in_sum_func= this;
nest_level= thd->lex->current_select->nest_level;
ref_by= 0;
aggr_level= -1;
@@ -157,6 +158,7 @@ bool Item_sum::init_sum_func_check(THD *thd)
bool Item_sum::check_sum_func(THD *thd, Item **ref)
{
SELECT_LEX *curr_sel= thd->lex->current_select;
+ LEX *lex_s= curr_sel->parent_lex;
nesting_map allow_sum_func(thd->lex->allow_sum_func);
allow_sum_func.intersect(curr_sel->name_visibility_map);
bool invalid= FALSE;
@@ -319,7 +321,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
if (sum_func() == SP_AGGREGATE_FUNC)
aggr_sel->set_custom_agg_func_used(true);
update_used_tables();
- thd->lex->in_sum_func= in_sum_func;
+ lex_s->in_sum_func= in_sum_func;
return FALSE;
}