summaryrefslogtreecommitdiff
path: root/mysql-test/t/having.test
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2011-07-20 21:55:55 -0700
committerIgor Babaev <igor@askmonty.org>2011-07-20 21:55:55 -0700
commit2e8542f4620fd64e65eb6e41122bbe166c242a01 (patch)
tree1b19d7e54e2415fd9aba043b07c1b5d698d6bc3c /mysql-test/t/having.test
parent6dc1cdc2057121d8a10782fc5261e4ea9650a7ab (diff)
downloadmariadb-git-2e8542f4620fd64e65eb6e41122bbe166c242a01.tar.gz
Fixed LP bug #791761.
An aggregating query over an empty set of a join of two tables with a rejecting HAVING clause erroneously could return a row. It could happen in the cases when the optimizer made a conclusion that the aggregating set was empty. Wrong results were produced because the server missed initial setting for aggregation functions in the mentioned cases.
Diffstat (limited to 'mysql-test/t/having.test')
-rw-r--r--mysql-test/t/having.test25
1 files changed, 25 insertions, 0 deletions
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index 2ed8b40b858..01342fdf5fa 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -591,3 +591,28 @@ DROP TABLE t1,t2;
--echo End of 5.1 tests
+
+--echo #
+--echo # LP bug #791761: MAX over an empty join + HAVING
+--echo #
+
+CREATE TABLE t1 (a int, b int , KEY (b)) ;
+INSERT INTO t1 VALUES (3,1);
+
+CREATE TABLE t2 (a int NOT NULL ) ;
+INSERT INTO t2 VALUES (29);
+
+SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a > 0 HAVING MAX(t1.b) <> 6;
+SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a > 0 HAVING MAX(t1.b) IS NULL;
+
+EXPLAIN
+SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a < 0 HAVING MAX(t1.b) <> 6;
+SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a < 0 HAVING MAX(t1.b) <> 6;
+
+CREATE TABLE t3 ( f3 int) ;
+INSERT INTO t3 VALUES (NULL);
+
+SELECT MAX(t1.b) AS f FROM t1 JOIN t2 ON t2.a != 0
+ WHERE (SELECT f3 FROM t3) <> 0 HAVING f <> 6 ;
+
+DROP TABLE t1,t2,t3;