Description:
MySQL does not support aggregate stored functions, however the parser
allows AGGREGATE-clause in CREATE FUNCTION statement. This clause
is meaningless, i.e. it does not affect the definition.
How to repeat:
mysql> CREATE AGGREGATE FUNCTION f1() RETURNS INT RETURN 1;
Query OK, 0 rows affected (0.01 sec)
mysql> SELECT * FROM mysql.proc;
+------+------+----------+---------------+----------+-----------------+------------------+---------------+------------+---------+----------+----------------+---------------------+---------------------+----------+---------+
| db | name | type | specific_name | language | sql_data_access | is_deterministic | security_type | param_list | returns | body | definer | created | modified | sql_mode | comment |
+------+------+----------+---------------+----------+-----------------+------------------+---------------+------------+---------+----------+----------------+---------------------+---------------------+----------+---------+
| test | f1 | FUNCTION | f1 | SQL | CONTAINS_SQL | NO | DEFINER | | int(11) | RETURN 1 | root@localhost | 2006-01-30 14:39:00 | 2006-01-30 14:39:00 | | |
+------+------+----------+---------------+----------+-----------------+------------------+---------------+------------+---------+----------+----------------+---------------------+---------------------+----------+---------+
1 row in set (0.00 sec)
mysql> SHOW CREATE FUNCTION f1;
+----------+----------+-------------------------------------------------+
| Function | sql_mode | Create Function |
+----------+----------+-------------------------------------------------+
| f1 | | CREATE FUNCTION `f1`() RETURNS int(11)
RETURN 1 |
+----------+----------+-------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT * FROM information_schema.routines;
+---------------+-----------------+----------------+--------------+--------------+----------------+--------------+--------------------+---------------+-------------------+-----------------+------------------+-----------------+----------+---------------+---------------------+---------------------+----------+-----------------+----------------+
| SPECIFIC_NAME | ROUTINE_CATALOG | ROUTINE_SCHEMA | ROUTINE_NAME | ROUTINE_TYPE | DTD_IDENTIFIER | ROUTINE_BODY | ROUTINE_DEFINITION | EXTERNAL_NAME | EXTERNAL_LANGUAGE | PARAMETER_STYLE | IS_DETERMINISTIC | SQL_DATA_ACCESS | SQL_PATH | SECURITY_TYPE | CREATED | LAST_ALTERED | SQL_MODE | ROUTINE_COMMENT | DEFINER |
+---------------+-----------------+----------------+--------------+--------------+----------------+--------------+--------------------+---------------+-------------------+-----------------+------------------+-----------------+----------+---------------+---------------------+---------------------+----------+-----------------+----------------+
| f1 | NULL | test | f1 | FUNCTION | int(11) | SQL | RETURN 1 | NULL | NULL | SQL | NO | CONTAINS SQL | NULL | DEFINER | 2006-01-30 14:39:00 | 2006-01-30 14:39:00 | | | root@localhost |
+---------------+-----------------+----------------+--------------+--------------+----------------+--------------+--------------------+---------------+-------------------+-----------------+------------------+-----------------+----------+---------------+---------------------+---------------------+----------+-----------------+----------------+
1 row in set (0.01 sec)
Suggested fix:
Prohibit AGGREGATE-clause in CREATE FUNCTION statement.