summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_group.test
diff options
context:
space:
mode:
authorGeorgi Kodinov <kgeorge@mysql.com>2008-11-24 17:30:47 +0200
committerGeorgi Kodinov <kgeorge@mysql.com>2008-11-24 17:30:47 +0200
commitd795963cba42fefd57a788eb1112bfc4cc13f6d3 (patch)
tree2a8f7f159454647868e51a2c60a0c657b62c8c8c /mysql-test/t/func_group.test
parent60d5e900891bc849d7a6180b708290fe7a3e93ab (diff)
downloadmariadb-git-d795963cba42fefd57a788eb1112bfc4cc13f6d3.tar.gz
Bug #39656: Behaviour different for agg functions with & without where -
ONLY_FULL_GROUP_BY The check for non-aggregated columns in queries with aggregate function, but without GROUP BY was treating all the parts of the query as if they are in the SELECT list. Fixed by ignoring the non-aggregated fields in the WHERE clause. mysql-test/r/func_group.result: Bug #39656: test case mysql-test/t/func_group.test: Bug #39656: test case sql/sql_select.cc: Bug #39656: ignore the new non-aggregated column refs in a WHERE by saving the state so far and then adding only the new values of the other parts of the bitmask.
Diffstat (limited to 'mysql-test/t/func_group.test')
-rw-r--r--mysql-test/t/func_group.test29
1 files changed, 29 insertions, 0 deletions
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index dbe6d3113d5..38779ac1a2f 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -926,5 +926,34 @@ SELECT AVG(a), CAST(AVG(a) AS DECIMAL) FROM t1;
DROP TABLE t1;
+#
+# Bug #39656: Behaviour different for agg functions with & without where -
+# ONLY_FULL_GROUP_BY
+#
+
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,1), (1,2), (1,3);
+
+SET SQL_MODE='ONLY_FULL_GROUP_BY';
+
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t1 where a=1;
+
+--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS
+SELECT COUNT(*),a FROM t1;
+
+SELECT COUNT(*) FROM t1 a JOIN t1 b ON a.a= b.a;
+
+--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS
+SELECT COUNT(*), (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a)
+ FROM t1 outr;
+
+SELECT COUNT(*) FROM t1 a JOIN t1 outr
+ ON a.a= (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a);
+
+SET SQL_MODE=default;
+DROP TABLE t1;
+
+
###
--echo End of 5.0 tests