mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
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.
This commit is contained in:
@@ -603,11 +603,25 @@ extern double my_atof(const char*);
|
|||||||
#define HAVE_LONG_LONG 1
|
#define HAVE_LONG_LONG 1
|
||||||
#endif
|
#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)
|
#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
|
||||||
#define LONGLONG_MIN ((long long) 0x8000000000000000LL)
|
#define LONGLONG_MIN ((long long) 0x8000000000000000LL)
|
||||||
#define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL)
|
#define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL)
|
||||||
#endif
|
#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
|
#if SIZEOF_LONG == 4
|
||||||
#define INT_MIN32 (long) 0x80000000L
|
#define INT_MIN32 (long) 0x80000000L
|
||||||
#define INT_MAX32 (long) 0x7FFFFFFFL
|
#define INT_MAX32 (long) 0x7FFFFFFFL
|
||||||
|
@@ -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
|
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;
|
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)
|
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
|
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
|
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
|
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);
|
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;
|
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)
|
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 0 NULL NULL NULL NULL NULL -1 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;
|
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)
|
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 -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);
|
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;
|
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)
|
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
|
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;
|
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)
|
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);
|
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;
|
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)
|
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
|
2 1 1 1.0000 0.0000 1 1 1 1
|
||||||
3 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;
|
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;
|
||||||
|
@@ -615,10 +615,8 @@ void Item_sum_avg::reset_field()
|
|||||||
|
|
||||||
void Item_sum_bit::reset_field()
|
void Item_sum_bit::reset_field()
|
||||||
{
|
{
|
||||||
char *res= result_field->ptr;
|
reset();
|
||||||
bits= reset_bits;
|
int8store(result_field->ptr, bits);
|
||||||
add();
|
|
||||||
int8store(res, bits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Item_sum_bit::update_field()
|
void Item_sum_bit::update_field()
|
||||||
|
@@ -373,6 +373,8 @@ class Item_sum_bit :public Item_sum_int
|
|||||||
void reset_field();
|
void reset_field();
|
||||||
void update_field();
|
void update_field();
|
||||||
unsigned int size_of() { return sizeof(*this);}
|
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();
|
bool add();
|
||||||
const char *func_name() const { return "bit_or"; }
|
const char *func_name() const { return "bit_or"; }
|
||||||
unsigned int size_of() { return sizeof(*this);}
|
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
|
class Item_sum_and :public Item_sum_bit
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ~(ulonglong) LL(0)) {}
|
Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ULONGLONG_MAX) {}
|
||||||
bool add();
|
bool add();
|
||||||
const char *func_name() const { return "bit_and"; }
|
const char *func_name() const { return "bit_and"; }
|
||||||
unsigned int size_of() { return sizeof(*this);}
|
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; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user