diff options
author | gkodinov/kgeorge@magare.gmz <> | 2007-06-29 10:39:17 +0300 |
---|---|---|
committer | gkodinov/kgeorge@magare.gmz <> | 2007-06-29 10:39:17 +0300 |
commit | 38172240e3d5736d7d55fa2296facd2fcf84f3f6 (patch) | |
tree | d3ed38e7e41e1f719e4a866004003c2244ea12ac /sql/item_sum.h | |
parent | a90ff73738281029abf2bb75dfb2fdfa6e041985 (diff) | |
download | mariadb-git-38172240e3d5736d7d55fa2296facd2fcf84f3f6.tar.gz |
Bug#27333: subquery grouped for aggregate of outer
query / no aggregate of subquery
The optimizer counts the aggregate functions that
appear as top level expressions (in all_fields) in
the current subquery. Later it makes a list of these
that it uses to actually execute the aggregates in
end_send_group().
That count is used in several places as a flag whether
there are aggregates functions.
While collecting the above info it must not consider
aggregates that are not aggregated in the current
context. It must treat them as normal expressions
instead. Not doing that leads to incorrect data about
the query, e.g. running a query that actually has no
aggregate functions as if it has some (and hence is
expected to return only one row).
Fixed by ignoring the aggregates that are not aggregated
in the current context.
One other smaller omission discovered and fixed in the
process : the place of aggregation was not calculated for
user defined functions. Fixed by calling
Item_sum::init_sum_func_check() and
Item_sum::check_sum_func() as it's done for the rest of
the aggregate functions.
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r-- | sql/item_sum.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h index 66c73e1d416..d18454cc3b8 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -966,8 +966,15 @@ public: bool fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); + + if (init_sum_func_check(thd)) + return TRUE; + fixed= 1; - return udf.fix_fields(thd, this, this->arg_count, this->args); + if (udf.fix_fields(thd, this, this->arg_count, this->args)) + return TRUE; + + return check_sum_func(thd, ref); } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } virtual bool have_field_update(void) const { return 0; } |