summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorgkodinov/kgeorge@rakia.(none) <>2006-09-19 19:18:52 +0300
committergkodinov/kgeorge@rakia.(none) <>2006-09-19 19:18:52 +0300
commit2da037c7d57688180fe05e4009c24f52ac97c189 (patch)
tree2cdc87f7be2691c8cef45adf2837c61f7570a3ca /sql
parentcf9d1c91529a3e341a25f5643c2565988766965c (diff)
parent5bc16fd9545a92ba2690ab0687e6bdf76d92757a (diff)
downloadmariadb-git-2da037c7d57688180fe05e4009c24f52ac97c189.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
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;
}