diff options
Diffstat (limited to 'mysql-test/t/having.test')
-rw-r--r-- | mysql-test/t/having.test | 25 |
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; |