summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/having.result16
-rw-r--r--mysql-test/t/having.test21
2 files changed, 37 insertions, 0 deletions
diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result
index c69de0f307b..daf043860a4 100644
--- a/mysql-test/r/having.result
+++ b/mysql-test/r/having.result
@@ -532,3 +532,19 @@ Warnings:
Warning 1292 Truncated incorrect INTEGER value: 'd'
DROP TABLE t1,t2;
End of 5.0 tests
+#
+# Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set
+#
+CREATE TABLE t1 (f1 INT(11), f2 VARCHAR(1), PRIMARY KEY (f1));
+INSERT INTO t1 VALUES (1,'f');
+CREATE TABLE t2 (f1 INT(11), f2 VARCHAR(1));
+INSERT INTO t2 VALUES (2,'m');
+INSERT INTO t2 VALUES (3,'m');
+INSERT INTO t2 VALUES (11,NULL);
+INSERT INTO t2 VALUES (12,'k');
+SELECT MAX(t1.f1) field1
+FROM t1 JOIN t2 ON t2.f2 LIKE 'x'
+HAVING field1 < 7;
+field1
+DROP TABLE t1,t2;
+End of 5.1 tests
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index 65bf9518a5c..c808e747523 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -544,3 +544,24 @@ ORDER BY t1.f2;
DROP TABLE t1,t2;
--echo End of 5.0 tests
+
+--echo #
+--echo # Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set
+--echo #
+
+CREATE TABLE t1 (f1 INT(11), f2 VARCHAR(1), PRIMARY KEY (f1));
+INSERT INTO t1 VALUES (1,'f');
+
+CREATE TABLE t2 (f1 INT(11), f2 VARCHAR(1));
+INSERT INTO t2 VALUES (2,'m');
+INSERT INTO t2 VALUES (3,'m');
+INSERT INTO t2 VALUES (11,NULL);
+INSERT INTO t2 VALUES (12,'k');
+
+SELECT MAX(t1.f1) field1
+FROM t1 JOIN t2 ON t2.f2 LIKE 'x'
+HAVING field1 < 7;
+
+DROP TABLE t1,t2;
+
+--echo End of 5.1 tests