diff options
author | unknown <konstantin@mysql.com> | 2003-12-02 19:39:51 +0300 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2003-12-02 19:39:51 +0300 |
commit | a2bdd6218c7ed36bf245eb378fa3b128ebf266ce (patch) | |
tree | cbf6200a23df5fb40c74eb1e8e0cdde88a34063f | |
parent | 363c4e8a81af1ff8a08072dd18a62fb431e70f1b (diff) | |
download | mariadb-git-a2bdd6218c7ed36bf245eb378fa3b128ebf266ce.tar.gz |
Post-review fixes for bug #1790 'BIT_AND() result in GROUP BY different when
SQL_BIG_RESULT used':
- BIT_AND now returns BIGINT UNSIGNED
- in case there were no matching rows BIT_AND returns 18446744073709551615
(but not NULL), BIT_OR returns 0 (but not NULL). That's how Monty wants it
and how is described in our docs.
include/my_global.h:
Added definition for ULONGLONG_MAX.
This is also a check that ULL type specifier
can be used on all supported platforms.
mysql-test/r/func_group.result:
bug #1790, post-review work: test results fixed
sql/item_sum.cc:
small cleanup
sql/item_sum.h:
few style fixes.
BIT_AND and BIT_OR now are both BIGINT UNSIGNED
-rw-r--r-- | include/my_global.h | 14 | ||||
-rw-r--r-- | mysql-test/r/func_group.result | 10 | ||||
-rw-r--r-- | sql/item_sum.cc | 6 | ||||
-rw-r--r-- | sql/item_sum.h | 14 |
4 files changed, 27 insertions, 17 deletions
diff --git a/include/my_global.h b/include/my_global.h index 349ac8ac82e..68c331aa414 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -603,11 +603,25 @@ extern double my_atof(const char*); #define HAVE_LONG_LONG 1 #endif +/* + Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define + ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined. +*/ + #if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN) #define LONGLONG_MIN ((long long) 0x8000000000000000LL) #define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL) #endif +#if defined(HAVE_LONG_LONG) && !defined(ULONLONG_MAX) +/* First check for ANSI C99 definition: */ +#ifdef ULLONG_MAX +#define ULONGLONG_MAX ULLONG_MAX +#else +#define ULONGLONG_MAX ((unsigned long long)(~0ULL)) +#endif +#endif /* defined (HAVE_LONG_LONG) && !defined(ULONLONG_MAX)*/ + #if SIZEOF_LONG == 4 #define INT_MIN32 (long) 0x80000000L #define INT_MAX32 (long) 0x7FFFFFFFL diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index a1563271917..f6a30813bb0 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -47,7 +47,7 @@ sum(all a) count(all a) avg(all a) std(all a) bit_or(all a) bit_and(all a) min(a 21 6 3.5000 1.7078 7 0 1 6 E select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp; grp sum(a) count(a) avg(a) std(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c) -NULL NULL 0 NULL NULL 0 -1 NULL NULL +NULL NULL 0 NULL NULL 0 18446744073709551615 NULL NULL 1 1 1 1.0000 0.0000 1 1 1 1 a a 2 5 2 2.5000 0.5000 3 2 2 3 b c 3 15 3 5.0000 0.8165 7 4 4 6 C E @@ -218,8 +218,8 @@ insert into t1 values (1,null); insert into t1 values (2,null); select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) -1 0 NULL NULL NULL NULL NULL -1 0 -2 0 NULL NULL NULL NULL NULL -1 0 +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 +2 0 NULL NULL NULL NULL NULL 18446744073709551615 0 select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) 1 0 NULL NULL NULL NULL NULL -1 0 @@ -227,7 +227,7 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) insert into t1 values (2,1); select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) -1 0 NULL NULL NULL NULL NULL -1 0 +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 2 1 1 1.0000 0.0000 1 1 1 1 select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) @@ -236,7 +236,7 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) insert into t1 values (3,1); select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) -1 0 NULL NULL NULL NULL NULL -1 0 +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 2 1 1 1.0000 0.0000 1 1 1 1 3 1 1 1.0000 0.0000 1 1 1 1 select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 36a3c6b009b..5a5934db0cd 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -615,10 +615,8 @@ void Item_sum_avg::reset_field() void Item_sum_bit::reset_field() { - char *res= result_field->ptr; - bits= reset_bits; - add(); - int8store(res, bits); + reset(); + int8store(result_field->ptr, bits); } void Item_sum_bit::update_field() diff --git a/sql/item_sum.h b/sql/item_sum.h index c91abbded28..d3a328be032 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -361,10 +361,10 @@ public: class Item_sum_bit :public Item_sum_int { - protected: +protected: ulonglong reset_bits,bits; - public: +public: Item_sum_bit(Item *item_par,ulonglong reset_arg) :Item_sum_int(item_par),reset_bits(reset_arg),bits(reset_arg) {} enum Sumfunctype sum_func () const {return SUM_BIT_FUNC;} @@ -373,6 +373,8 @@ class Item_sum_bit :public Item_sum_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; } }; @@ -383,20 +385,16 @@ public: bool add(); 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; } }; class Item_sum_and :public Item_sum_bit { - public: - Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ~(ulonglong) LL(0)) {} +public: + Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ULONGLONG_MAX) {} bool add(); 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; } }; /* |