summaryrefslogtreecommitdiff
path: root/mysql-test/main/having.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/main/having.test')
-rw-r--r--mysql-test/main/having.test28
1 files changed, 14 insertions, 14 deletions
diff --git a/mysql-test/main/having.test b/mysql-test/main/having.test
index 7e0a0439f8e..3f4e8a8e710 100644
--- a/mysql-test/main/having.test
+++ b/mysql-test/main/having.test
@@ -1,10 +1,6 @@
# test of problems with having (Reported by Mark Rogers)
#
---disable_warnings
-drop table if exists t1,t2,t3;
---enable_warnings
-
create table t1 (a int);
select count(a) as b from t1 where a=0 having b > 0;
insert into t1 values (null);
@@ -207,7 +203,7 @@ select count(*) from t1 group by col1 having col1 = 10;
select count(*) as count_col1 from t1 group by col1 having col1 = 10;
select count(*) as count_col1 from t1 as tmp1 group by col1 having col1 = 10;
select count(*) from t1 group by col2 having col2 = 'hello';
---error 1054
+--error ER_BAD_FIELD_ERROR
select count(*) from t1 group by col2 having col1 = 10;
select col1 as count_col1 from t1 as tmp1 group by col1 having col1 = 10;
select col1 as count_col1 from t1 as tmp1 group by col1 having count_col1 = 10;
@@ -221,10 +217,10 @@ select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col1 =
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having count_col1 = 10;
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col2 = 'hello';
select col1 as count_col1,col2 as group_col2 from t1 as tmp1 group by col1,col2 having group_col2 = 'hello';
---error 1064
+--error ER_PARSE_ERROR
select sum(col1) as co12 from t1 group by col2 having col2 10;
select sum(col1) as co2, count(col2) as cc from t1 group by col1 having col1 =10;
---error 1054
+--error ER_BAD_FIELD_ERROR
select t2.col2 from t2 group by t2.col1, t2.col2 having t1.col1 <= 10;
@@ -253,7 +249,8 @@ where t1.col2 in
group by t2.col1, t2.col2 having t1.col1 <= 10);
# the having column is resolved in the SELECT clause of the outer query -
-# error in ANSI, works with MySQL extension
+# error in ANSI
+--error ER_BAD_FIELD_ERROR
select t1.col1 as tmp_col from t1
where t1.col2 in
(select t2.col2 from t2
@@ -273,7 +270,7 @@ having (select col_t1 from t2 where col_t1 = col_t2 order by col_t2 limit 1);
# nested queries with HAVING, inner having column resolved in outer FROM clause
# the outer having column is not referenced in GROUP BY which results in an error
---error 1054
+--error ER_BAD_FIELD_ERROR
select t1.col1 from t1
where t1.col2 in
(select t2.col2 from t2
@@ -302,7 +299,7 @@ having col_t1 > 10 and
# correlated subqueries - inner having column 't1.col2' resolves to
# the outer FROM clause, which cannot be used because the outer query
# is grouped
---error 1054
+--error ER_BAD_FIELD_ERROR
select sum(col1) from t1
group by col_t1
having col_t1 in (select sum(t2.col1) from t2
@@ -318,11 +315,11 @@ having col_t1 in (select sum(t2.col1) from t2
#
# queries with joins and ambiguous column names
#
---error 1052
+--error ER_NON_UNIQ_ERROR
select t1.col1, t2.col1 from t1, t2 where t1.col1 = t2.col1
group by t1.col1, t2.col1 having col1 = 2;
---error 1052
+--error ER_NON_UNIQ_ERROR
select t1.col1*10+t2.col1 from t1,t2 where t1.col1=t2.col1
group by t1.col1, t2.col1 having col1 = 2;
@@ -352,7 +349,7 @@ select count(s1) from t1 group by s1 having count(1+1)=2;
select count(s1) from t1 group by s1 having s1*0=0;
--- error 1052
+-- error ER_NON_UNIQ_ERROR
select * from t1 a, t1 b group by a.s1 having s1 is null;
# ANSI requires: 0 rows
# MySQL returns:
@@ -912,7 +909,9 @@ alter table t1 add column b int default (rand()+1+3);
select default(b) AS h FROM t1 HAVING h > "2";
drop table t1;
+--echo #
--echo # End of 10.3 tests
+--echo #
--echo #
--echo # MDEV-18681: AND formula in HAVING with several occurances
@@ -930,7 +929,6 @@ HAVING t.f != 112 AND t.f = 'x' AND t.f != 'a';
DROP TABLE t1,t2;
-
--echo #
--echo # MDEV-20200: AddressSanitizer: use-after-poison in
--echo # Item_direct_view_ref::get_null_ref_table
@@ -943,4 +941,6 @@ SELECT * FROM t HAVING f = 'foo';
# Cleanup
DROP TABLE t;
+--echo #
--echo # End of 10.4 tests
+--echo #