summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2003-12-10 15:37:50 +0300
committerunknown <konstantin@mysql.com>2003-12-10 15:37:50 +0300
commit06d008c69d8695ce28dc14f27bee483e21eb7b64 (patch)
tree4531c773da7a45d47807cee8a888d5b326893561
parent39177af1f31d04d5c2f2cfbe817d9d1049d4789f (diff)
parent02f56e77e0f71197679ea8784f07be98fb17ce27 (diff)
downloadmariadb-git-06d008c69d8695ce28dc14f27bee483e21eb7b64.tar.gz
Merge mysql.com:/home/kostja/mysql/mysql-4.0-root
into mysql.com:/home/kostja/mysql/mysql-4.0-1790
-rw-r--r--mysql-test/r/func_group.result23
-rw-r--r--mysql-test/t/func_group.test8
-rw-r--r--sql/item_sum.cc9
3 files changed, 30 insertions, 10 deletions
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index f6a30813bb0..99c42bb83cf 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -207,13 +207,13 @@ drop table t1,t2;
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;
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;
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);
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
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;
@@ -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
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
-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
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)
@@ -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
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
+1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
2 1 1 1.0000 0.0000 1 1 1 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;
@@ -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
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
+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
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;
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index 40d829d3e70..d03e4b9b629 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -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 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;
+#
+# 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;
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 5a5934db0cd..e18fa83e49d 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -104,12 +104,13 @@ Item_sum_num::val_str(String *str)
String *
Item_sum_int::val_str(String *str)
{
- longlong nr=val_int();
+ longlong nr= val_int();
if (null_value)
return 0;
- char buff[21];
- uint length= (uint) (longlong10_to_str(nr,buff,-10)-buff);
- str->copy(buff,length);
+ if (unsigned_flag)
+ str->set((ulonglong) nr);
+ else
+ str->set(nr);
return str;
}