diff options
author | unknown <gkodinov/kgeorge@magare.gmz> | 2007-11-01 18:36:24 +0200 |
---|---|---|
committer | unknown <gkodinov/kgeorge@magare.gmz> | 2007-11-01 18:36:24 +0200 |
commit | 660eb5bb40314d37b2f6e0f4f84a6936285ffc8a (patch) | |
tree | fd9d624da48f83ed21986fe60fa425a02248b9ab /mysql-test/t/func_group.test | |
parent | 95acd426ebda2030f7cfc04cf7d5abba5a7d231e (diff) | |
download | mariadb-git-660eb5bb40314d37b2f6e0f4f84a6936285ffc8a.tar.gz |
Bug #31794: no syntax error on SELECT id FROM t HAVING count(*)>2
The HAVING clause is subject to the same rules as the SELECT list
about using aggregated and non-aggregated columns.
But this was not enforced when processing implicit grouping from
using aggregate functions.
Fixed by performing the same checks for HAVING as for SELECT.
mysql-test/r/func_group.result:
Bug #31794: test case
mysql-test/t/func_group.test:
Bug #31794: test case
sql/sql_select.cc:
Bug #31794: Check HAVING in addition to SELECT list
Diffstat (limited to 'mysql-test/t/func_group.test')
-rw-r--r-- | mysql-test/t/func_group.test | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 7e115707625..25cb13a2f75 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -882,5 +882,24 @@ CREATE TABLE t1 (a int, b date NOT NULL, KEY k1 (a,b)); SELECT MIN(b) FROM t1 WHERE a=1 AND b>'2007-08-01'; DROP TABLE t1; +# +# Bug #31794: no syntax error on SELECT id FROM t HAVING count(*)>2; +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); + +SET SQL_MODE=ONLY_FULL_GROUP_BY; +--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS +SELECT a FROM t1 HAVING COUNT(*)>2; +--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS +SELECT COUNT(*), a FROM t1; + +SET SQL_MODE=DEFAULT; +SELECT a FROM t1 HAVING COUNT(*)>2; +SELECT COUNT(*), a FROM t1; + +DROP TABLE t1; + ### --echo End of 5.0 tests |