summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-02-07 18:14:31 +0200
committerunknown <monty@mysql.com>2005-02-07 18:14:31 +0200
commitedae64f4cb319562bc9f6ea0a20b6cfe174fdaff (patch)
tree52bd15591cacd4fcb417957f538bc26953ef3025 /mysql-test
parent4a196cc4d3ef589d5d2aa1b39e31ff6ab82ac271 (diff)
parentd6ed8cd7097391b55936a1dfec248da65e7f64f9 (diff)
downloadmariadb-git-edae64f4cb319562bc9f6ea0a20b6cfe174fdaff.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/my/mysql-4.1 sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/group_by.result45
-rw-r--r--mysql-test/r/user_var.result4
-rw-r--r--mysql-test/t/group_by.test28
3 files changed, 59 insertions, 18 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index f92b3ea4f4d..17b1bb03d1d 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -629,15 +629,6 @@ explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
DROP TABLE t1;
-create table t1 ( col1 int, col2 int );
-insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2);
-select group_concat( distinct col1 ) as alias from t1
-group by col2 having alias like '%';
-alias
-1,2
-1,2
-1
-drop table t1;
create table t1 (a int);
insert into t1 values(null);
select min(a) is null from t1;
@@ -650,3 +641,39 @@ select 1 and min(a) is null from t1;
1 and min(a) is null
1
drop table t1;
+create table t1 ( col1 int, col2 int );
+insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2);
+select group_concat( distinct col1 ) as alias from t1
+group by col2 having alias like '%';
+alias
+1,2
+1,2
+1
+drop table t1;
+create table t1 (a integer, b integer, c integer);
+insert into t1 (a,b) values (1,2),(1,3),(2,5);
+select a, 0.1*0+1 r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2=1;
+a r2 r1
+1 1.0 2
+select a, rand()*0+1 r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2=1;
+a r2 r1
+1 1 2
+select a,sum(b) from t1 where a=1 group by c;
+a sum(b)
+1 5
+select a*sum(b) from t1 where a=1 group by c;
+a*sum(b)
+5
+select sum(a)*sum(b) from t1 where a=1 group by c;
+sum(a)*sum(b)
+10
+select a,sum(b) from t1 where a=1 group by c having a=1;
+a sum(b)
+1 5
+select a as d,sum(b) from t1 where a=1 group by c having d=1;
+d sum(b)
+1 5
+select sum(a)*sum(b) as d from t1 where a=1 group by c having d > 0;
+d
+10
+drop table t1;
diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index 81846391795..041d1b836b7 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -109,8 +109,8 @@ select @a:=0;
select @a, @a:=@a+count(*), count(*), @a from t1 group by i;
@a @a:=@a+count(*) count(*) @a
0 1 1 0
-0 2 2 0
-0 3 3 0
+0 3 2 0
+0 6 3 0
select @a:=0;
@a:=0
0
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index c0447b06303..379f668df1a 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -457,6 +457,14 @@ SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
DROP TABLE t1;
+#Test for BUG#6976: Aggregate functions have incorrect NULL-ness
+create table t1 (a int);
+insert into t1 values(null);
+select min(a) is null from t1;
+select min(a) is null or null from t1;
+select 1 and min(a) is null from t1;
+drop table t1;
+
# Test for BUG#5400: GROUP_CONCAT returns everything twice.
create table t1 ( col1 int, col2 int );
insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2);
@@ -465,12 +473,18 @@ select group_concat( distinct col1 ) as alias from t1
drop table t1;
+#
+# Test BUG#8216 when referring in HAVING to n alias which is rand() function
+#
-#Test for BUG#6976: Aggregate functions have incorrect NULL-ness
-create table t1 (a int);
-insert into t1 values(null);
-select min(a) is null from t1;
-select min(a) is null or null from t1;
-select 1 and min(a) is null from t1;
+create table t1 (a integer, b integer, c integer);
+insert into t1 (a,b) values (1,2),(1,3),(2,5);
+select a, 0.1*0+1 r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2=1;
+select a, rand()*0+1 r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2=1;
+select a,sum(b) from t1 where a=1 group by c;
+select a*sum(b) from t1 where a=1 group by c;
+select sum(a)*sum(b) from t1 where a=1 group by c;
+select a,sum(b) from t1 where a=1 group by c having a=1;
+select a as d,sum(b) from t1 where a=1 group by c having d=1;
+select sum(a)*sum(b) as d from t1 where a=1 group by c having d > 0;
drop table t1;
-