summaryrefslogtreecommitdiff
path: root/mysql-test/t/having.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/having.test')
-rw-r--r--mysql-test/t/having.test36
1 files changed, 35 insertions, 1 deletions
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index cd6a4c9d328..0f6be0b0ec6 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -694,6 +694,41 @@ DROP TABLE t1;
--echo End of 5.3 tests
--echo #
+--echo # Bug MDEV-7301: Unknown column quoted with backticks in HAVING clause when using function.
+--echo # Bug#16221433 MYSQL REJECTS QUERY DUE TO BAD RESOLUTION OF NAMES IN HAVING; VIEW UNREADABLE
+--echo #
+
+CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ `title` varchar(45) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) DEFAULT CHARSET=utf8;
+
+INSERT INTO `t1` VALUES ('1', 'Just for fun');
+INSERT INTO `t1` VALUES ('2', 'Wait until a sunhine');
+INSERT INTO `t1` VALUES ('3', 'Take a new turn');
+
+SELECT `id`, SHA1(`title`) AS `column_1`
+FROM `t1`
+HAVING `column_1` LIKE '8%';
+
+--echo expected 1 row(s) returned
+
+SELECT `id`, SHA1(`title`) AS `column_1`
+FROM `t1`
+HAVING UPPER(column_1) LIKE '8%';
+
+--echo expected -- 1 row(s) returned
+
+SELECT `id`, SHA1(`title`) AS `column_1`
+FROM `t1`
+HAVING UPPER(`column_1`) LIKE '8%';
+
+--echo expected -- 1 row(s) returned not ER_BAD_FIELD_ERROR
+
+drop table t1;
+
+--echo #
--echo # Bug mdev-5160: two-way join with HAVING over the second table
--echo #
@@ -708,4 +743,3 @@ SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1;
DROP TABLE t1,t2;
--echo End of 10.0 tests
-