diff options
author | Georgi Kodinov <Georgi.Kodinov@Oracle.com> | 2010-12-08 14:28:06 +0200 |
---|---|---|
committer | Georgi Kodinov <Georgi.Kodinov@Oracle.com> | 2010-12-08 14:28:06 +0200 |
commit | 352ce1b596758403ab9d439b06267fec4d191a58 (patch) | |
tree | 843cd564016bb7ea84119c7bbc818afe1b4cd412 /sql/item_sum.h | |
parent | 9588e1ba53fa91463c4ad5695c46f821aa2ade7b (diff) | |
download | mariadb-git-352ce1b596758403ab9d439b06267fec4d191a58.tar.gz |
Bug #57954: BIT_AND function returns incorrect results
when semijoin=on
When setting the aggregate function as having no rows to report
the function no_rows_in_result() was calling Item_sum::reset().
However this function in addition to cleaning up the aggregate
value by calling aggregator_clear() was also adding the current
value to the aggregate value by calling aggregator_add().
Fixed by making no_rows_in_result() to call aggregator_clear()
directly.
Renamed Item_sum::reset to Item_sum::reset_and_add() to
and added a comment to avoid misinterpretation of what the
function does.
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r-- | sql/item_sum.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h index c7159568c40..3ea79fb8cee 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -406,14 +406,22 @@ public: Item_sum(THD *thd, Item_sum *item); enum Type type() const { return SUM_FUNC_ITEM; } virtual enum Sumfunctype sum_func () const=0; - inline bool reset() { aggregator_clear(); return aggregator_add(); }; + /** + Resets the aggregate value to its default and aggregates the current + value of its attribute(s). + */ + inline bool reset_and_add() + { + aggregator_clear(); + return aggregator_add(); + }; /* Called when new group is started and results are being saved in - a temporary table. Similar to reset(), but must also store value in - result_field. Like reset() it is supposed to reset start value to - default. - This set of methods (reult_field(), reset_field, update_field()) of + a temporary table. Similarly to reset_and_add() it resets the + value to its default and aggregates the value of its + attribute(s), but must also store it in result_field. + This set of methods (result_item(), reset_field, update_field()) of Item_sum is used only if quick_group is not null. Otherwise copy_or_same() is used to obtain a copy of this item. */ @@ -456,7 +464,7 @@ public: set_aggregator(with_distinct ? Aggregator::DISTINCT_AGGREGATOR : Aggregator::SIMPLE_AGGREGATOR); - reset(); + aggregator_clear(); } virtual void make_unique() { force_copy_fields= TRUE; } Item *get_tmp_table_item(THD *thd); |