summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2003-11-21 00:03:04 +0300
committerunknown <konstantin@mysql.com>2003-11-21 00:03:04 +0300
commit3f355523ba3e9eb814bbd37c0092755330fd2db9 (patch)
treef492e1c63239a18718072c5d05c72fe393e1f205 /sql/item_sum.cc
parent24bdf9560396936bcdb540d785bcaf981b68d457 (diff)
downloadmariadb-git-3f355523ba3e9eb814bbd37c0092755330fd2db9.tar.gz
fix for bug #1790:
"BIT_AND() result in GROUP BY different when SQL_BIG_RESULT used" return value of BIT_AND changed to BIGINT SIGNED Also the patch fixes another bug: when temporary table is in use and one of values in group is NULL, BIT_AND always returns zero. Fixed it to always skip null values. mysql-test/r/func_group.result: bug #1790: test results fixed sql/item_sum.cc: fix for bug #1790: update_field() rewritten to use add() and thus was moved to Item_sum_bit::update_field() Item_sum_bit::reset_field() was rewritten to take into account reset_bits. sql/item_sum.h: fix for bug #1790: Item_sum::update_field() and Item_sum::reset_field() commented Item_sum_and changed to return BIGINT SIGNED Item_sum_and::update_field() and Item_sum_or::update_field) were replaced with generic Item_sum_bit::update_field()
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc36
1 files changed, 12 insertions, 24 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 835278ae262..36a3c6b009b 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -615,9 +615,18 @@ void Item_sum_avg::reset_field()
void Item_sum_bit::reset_field()
{
+ char *res= result_field->ptr;
+ bits= reset_bits;
+ add();
+ int8store(res, bits);
+}
+
+void Item_sum_bit::update_field()
+{
char *res=result_field->ptr;
- ulonglong nr=(ulonglong) args[0]->val_int();
- int8store(res,nr);
+ bits= uint8korr(res);
+ add();
+ int8store(res, bits);
}
/*
@@ -756,28 +765,6 @@ Item_sum_hybrid::min_max_update_int_field()
}
-void Item_sum_or::update_field()
-{
- ulonglong nr;
- char *res=result_field->ptr;
-
- nr=uint8korr(res);
- nr|= (ulonglong) args[0]->val_int();
- int8store(res,nr);
-}
-
-
-void Item_sum_and::update_field()
-{
- ulonglong nr;
- char *res=result_field->ptr;
-
- nr=uint8korr(res);
- nr&= (ulonglong) args[0]->val_int();
- int8store(res,nr);
-}
-
-
Item_avg_field::Item_avg_field(Item_sum_avg *item)
{
name=item->name;
@@ -787,6 +774,7 @@ Item_avg_field::Item_avg_field(Item_sum_avg *item)
maybe_null=1;
}
+
double Item_avg_field::val()
{
double nr;