summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorSergey Petrunia <sergefp@mysql.com>2008-10-24 06:16:22 +0400
committerSergey Petrunia <sergefp@mysql.com>2008-10-24 06:16:22 +0400
commit844797c492312a5b0851a6cce3a84994aa4250a0 (patch)
tree8d6c2db966d4879ac8258d645eacc8e425ae1166 /mysql-test
parent9ad8d644392bc9ca23e0212e18c704f7a6520837 (diff)
downloadmariadb-git-844797c492312a5b0851a6cce3a84994aa4250a0.tar.gz
BUG#38072: Wrong result: HAVING not observed in a query with aggregate
- Make send_row_on_empty_set() return FALSE when simplify_cond() has found out that HAVING is always FALSE re-committing to put the fix into 5.0 and 5.1 mysql-test/r/group_by.result: BUG#38072: Wrong result: HAVING not observed in a query with aggregate - Testcase mysql-test/t/group_by.test: BUG#38072: Wrong result: HAVING not observed in a query with aggregate - Testcase sql/sql_select.h: BUG#38072: Wrong result: HAVING not observed in a query with aggregate - Make send_row_on_empty_set() return FALSE when simplify_cond() has found out that HAVING is always FALSE
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/group_by.result30
-rw-r--r--mysql-test/t/group_by.test29
2 files changed, 59 insertions, 0 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 28a9e15d473..ffb7ca667c7 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -1359,4 +1359,34 @@ tt
41
SET sql_mode=@save_sql_mode;
DROP TABLE t1, t2;
+#
+# BUG#38072: Wrong result: HAVING not observed in a query with aggregate
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+int_nokey int(11) NOT NULL,
+int_key int(11) NOT NULL,
+varchar_key varchar(1) NOT NULL,
+varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY int_key (int_key),
+KEY varchar_key (varchar_key)
+);
+INSERT INTO t1 VALUES
+(1,5,5, 'h','h'),
+(2,1,1, '{','{'),
+(3,1,1, 'z','z'),
+(4,8,8, 'x','x'),
+(5,7,7, 'o','o'),
+(6,3,3, 'p','p'),
+(7,9,9, 'c','c'),
+(8,0,0, 'k','k'),
+(9,6,6, 't','t'),
+(10,0,0,'c','c');
+explain SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
+SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+X
+drop table t1;
End of 5.0 tests
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 82bb8a45faa..0e5af0133ca 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1010,4 +1010,33 @@ select (select sum(outr.a + t1.a) from t1 limit 1) as tt from t1 as outr order b
SET sql_mode=@save_sql_mode;
DROP TABLE t1, t2;
+--echo #
+--echo # BUG#38072: Wrong result: HAVING not observed in a query with aggregate
+--echo #
+CREATE TABLE t1 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ int_nokey int(11) NOT NULL,
+ int_key int(11) NOT NULL,
+ varchar_key varchar(1) NOT NULL,
+ varchar_nokey varchar(1) NOT NULL,
+ PRIMARY KEY (pk),
+ KEY int_key (int_key),
+ KEY varchar_key (varchar_key)
+);
+INSERT INTO t1 VALUES
+(1,5,5, 'h','h'),
+(2,1,1, '{','{'),
+(3,1,1, 'z','z'),
+(4,8,8, 'x','x'),
+(5,7,7, 'o','o'),
+(6,3,3, 'p','p'),
+(7,9,9, 'c','c'),
+(8,0,0, 'k','k'),
+(9,6,6, 't','t'),
+(10,0,0,'c','c');
+
+explain SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+drop table t1;
+
--echo End of 5.0 tests