From 86f46a3da4a6d82cb510dc4c270d46cfd6a8965b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 23 Mar 2015 09:49:32 +0200 Subject: MDEV-7301: Unknown column quoted with backticks in HAVING clause when using function. Merged upstream fix to Bug#16221433 MYSQL REJECTS QUERY DUE TO BAD RESOLUTION OF NAMES IN HAVING; VIEW UNREADABLE authored by Guilhem Bichot . --- mysql-test/t/having.test | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'mysql-test/t/having.test') diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index a2bbfb80be1..505fb9ad3cf 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -693,3 +693,37 @@ 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; -- cgit v1.2.1