summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2003-12-02 18:04:00 +0300
committerunknown <konstantin@mysql.com>2003-12-02 18:04:00 +0300
commit363c4e8a81af1ff8a08072dd18a62fb431e70f1b (patch)
treeff20ffde8d7c450baef8362b8ab5394935f69e6b /sql
parentf0bc11177de9160ecfc0086ec9373537f7b47830 (diff)
parent3f355523ba3e9eb814bbd37c0092755330fd2db9 (diff)
downloadmariadb-git-363c4e8a81af1ff8a08072dd18a62fb431e70f1b.tar.gz
Merge mysql.com:/home/kostja/mysql/mysql-4.0-root
into mysql.com:/home/kostja/mysql/mysql-4.0-1790
Diffstat (limited to 'sql')
-rw-r--r--sql/item_sum.cc36
-rw-r--r--sql/item_sum.h22
2 files changed, 29 insertions, 29 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;
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 5189566fdfb..c91abbded28 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -55,7 +55,18 @@ public:
virtual enum Sumfunctype sum_func () const=0;
virtual void reset()=0;
virtual bool add()=0;
+ /*
+ 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.
+ */
virtual void reset_field()=0;
+ /*
+ Called for each new value in the group, when temporary table is in use.
+ Similar to add(), but uses temporary table field to obtain current value,
+ Updated value is then saved in the field.
+ */
virtual void update_field()=0;
virtual bool keep_field_type(void) const { return 0; }
virtual void fix_length_and_dec() { maybe_null=1; null_value=1; }
@@ -360,20 +371,20 @@ class Item_sum_bit :public Item_sum_int
void reset();
longlong val_int();
void reset_field();
+ void update_field();
unsigned int size_of() { return sizeof(*this);}
- void fix_length_and_dec()
- { decimals=0; max_length=21; unsigned_flag=1; maybe_null=null_value=0; }
};
class Item_sum_or :public Item_sum_bit
{
- public:
+public:
Item_sum_or(Item *item_par) :Item_sum_bit(item_par,LL(0)) {}
bool add();
- void update_field();
const char *func_name() const { return "bit_or"; }
unsigned int size_of() { return sizeof(*this);}
+ void fix_length_and_dec()
+ { decimals=0; max_length=21; unsigned_flag=1; maybe_null=null_value=0; }
};
@@ -382,9 +393,10 @@ class Item_sum_and :public Item_sum_bit
public:
Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ~(ulonglong) LL(0)) {}
bool add();
- void update_field();
const char *func_name() const { return "bit_and"; }
unsigned int size_of() { return sizeof(*this);}
+ void fix_length_and_dec()
+ { decimals=0; max_length=21; unsigned_flag=0; maybe_null=null_value=0; }
};
/*