summaryrefslogtreecommitdiff
path: root/mysql-test/r/having.result
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2017-11-11 11:45:59 -0800
committerIgor Babaev <igor@askmonty.org>2017-11-11 11:45:59 -0800
commitb5cb4ae470c80e21cc340c2fa13683d7d31b3da6 (patch)
tree962f53b8fde85aa2ab1848e68e6c25561e94e96c /mysql-test/r/having.result
parent36f84744031430747d27bfb2087c7ae51019a70a (diff)
downloadmariadb-git-b5cb4ae470c80e21cc340c2fa13683d7d31b3da6.tar.gz
Fixed bug MDEV-14368 Improper error for a grouping query that
uses alias in HAVING when sql_mode = 'ONLY_FULL_GROUP_BY' This patch corrects the patch for bug#18739: non-standard HAVING extension was allowed in strict ANSI sql mode added in 2006 by commit 4b7c4cd27f68b9aac1970b9f21c50d4eee35df7d. As a result of incompleteness of the fix in the above commit if a query with GROUP BY contained an aggregate function with an alias and this alias was used in the HAVING clause of the query the server reported an error when sql_mode was set to 'ONLY_FULL_GROUP_BY'.
Diffstat (limited to 'mysql-test/r/having.result')
-rw-r--r--mysql-test/r/having.result15
1 files changed, 15 insertions, 0 deletions
diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result
index 514abbf5522..18915da1a09 100644
--- a/mysql-test/r/having.result
+++ b/mysql-test/r/having.result
@@ -697,3 +697,18 @@ id column_1
1 80a12660d24a72460e5e292fe33f870276d7f40a
expected -- 1 row(s) returned not ER_BAD_FIELD_ERROR
drop table t1;
+#
+# mdev-14368: grouping query with alias for aggregate function in HAVING
+# when sql_mode = 'ONLY_FULL_GROUP_BY'
+set @save_sql_mode= @@sql_mode;
+set sql_mode = 'ONLY_FULL_GROUP_BY';
+create table t1(a int);
+insert t1 values (4),(1),(2),(1), (3),(4);
+SELECT a, COUNT(a) as ct FROM t1 GROUP BY a HAVING ct>0;
+a ct
+1 2
+2 1
+3 1
+4 2
+set sql_mode=@save_sql_mode;
+drop table t1;