Commit 4101abf3 authored by unknown's avatar unknown

followup to fix for bug #1790 BIT_AND() result in GROUP BY different when

SQL_BIG_RESULT used": now BIT_AND() always returns 18446744073709551615
if no rows were found.
This patch also fixes bug #1972: "BIT_AND() and BIT_OR() still return 
a *signed* 64bit value"


mysql-test/r/func_group.result:
  followup to fix for bug #1790 BIT_AND() result in GROUP BY different when 
  SQL_BIG_RESULT used": test results fixed
  bug #1972 "BIT_AND() and BIT_OR() still return a *signed* 64bit value":
  results of new tests
mysql-test/t/func_group.test:
  added tests for bug #1972 "BIT_AND() and BIT_OR() still return a 
  *signed* 64bit value"
parent 59a5f98f
...@@ -207,13 +207,13 @@ drop table t1,t2; ...@@ -207,13 +207,13 @@ drop table t1,t2;
CREATE TABLE t1 (a int, b int); CREATE TABLE t1 (a int, b int);
select count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1; select count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1;
count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
0 NULL NULL NULL NULL NULL -1 0 0 NULL NULL NULL NULL NULL 18446744073709551615 0
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)
insert into t1 values (1,null); insert into t1 values (1,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
insert into t1 values (1,null); 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;
...@@ -222,8 +222,8 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) ...@@ -222,8 +222,8 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
2 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; 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 18446744073709551615 0
2 0 NULL NULL NULL NULL NULL -1 0 2 0 NULL NULL NULL NULL NULL 18446744073709551615 0
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)
...@@ -231,7 +231,7 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) ...@@ -231,7 +231,7 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
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)
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
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;
...@@ -241,7 +241,18 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) ...@@ -241,7 +241,18 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
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;
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
drop table t1; drop table t1;
create table t1 (col int);
insert into t1 values (-1), (-2), (-3);
select bit_and(col), bit_or(col) from t1;
bit_and(col) bit_or(col)
18446744073709551612 18446744073709551615
select SQL_BIG_RESULT bit_and(col), bit_or(col) from t1 group by col;
bit_and(col) bit_or(col)
18446744073709551613 18446744073709551613
18446744073709551614 18446744073709551614
18446744073709551615 18446744073709551615
drop table t1;
...@@ -147,3 +147,11 @@ insert into t1 values (3,1); ...@@ -147,3 +147,11 @@ 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;
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;
drop table t1; drop table t1;
#
# Bug #1972: test for bit_and(), bit_or() and negative values
#
create table t1 (col int);
insert into t1 values (-1), (-2), (-3);
select bit_and(col), bit_or(col) from t1;
select SQL_BIG_RESULT bit_and(col), bit_or(col) from t1 group by col;
drop table t1;
...@@ -104,12 +104,13 @@ Item_sum_num::val_str(String *str) ...@@ -104,12 +104,13 @@ Item_sum_num::val_str(String *str)
String * String *
Item_sum_int::val_str(String *str) Item_sum_int::val_str(String *str)
{ {
longlong nr=val_int(); longlong nr= val_int();
if (null_value) if (null_value)
return 0; return 0;
char buff[21]; if (unsigned_flag)
uint length= (uint) (longlong10_to_str(nr,buff,-10)-buff); str->set((ulonglong) nr);
str->copy(buff,length); else
str->set(nr);
return str; return str;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment