summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@rakia.(none)>2006-09-19 19:18:52 +0300
committerunknown <gkodinov/kgeorge@rakia.(none)>2006-09-19 19:18:52 +0300
commitde5b4eba916e0c2a547e91235f492388e14177fe (patch)
tree2cdc87f7be2691c8cef45adf2837c61f7570a3ca /sql
parent665ebc05d07d39eccedd754d2625e2651c23888a (diff)
parent2a00a073c2c07f2d73d60a6c74c538874f05158b (diff)
downloadmariadb-git-de5b4eba916e0c2a547e91235f492388e14177fe.tar.gz
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into rakia.(none):/home/kgeorge/mysql/autopush/B21540-5.0-opt mysql-test/r/func_group.result: Auto merged sql/item_sum.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/item_sum.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index bcd8270e52f..5ca1dbba94b 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -246,7 +246,27 @@ bool Item_sum::register_sum_func(THD *thd, Item **ref)
aggr_sl->inner_sum_func_list->next= this;
}
aggr_sl->inner_sum_func_list= this;
-
+ aggr_sl->with_sum_func= 1;
+
+ /*
+ Mark Item_subselect(s) as containing aggregate function all the way up
+ to aggregate function's calculation context.
+ Note that we must not mark the Item of calculation context itself
+ because with_sum_func on the calculation context st_select_lex is
+ already set above.
+
+ with_sum_func being set for an Item means that this Item refers
+ (somewhere in it, e.g. one of its arguments if it's a function) directly
+ or through intermediate items to an aggregate function that is calculated
+ in a context "outside" of the Item (e.g. in the current or outer select).
+
+ with_sum_func being set for an st_select_lex means that this st_select_lex
+ has aggregate functions directly referenced (i.e. not through a sub-select).
+ */
+ for (sl= thd->lex->current_select;
+ sl && sl != aggr_sl && sl->master_unit()->item;
+ sl= sl->master_unit()->outer_select() )
+ sl->master_unit()->item->with_sum_func= 1;
}
return FALSE;
}