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.
[9 Feb 2006 11:59]
Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:
http://lists.mysql.com/commits/2359
[9 Feb 2006 19:59]
Konstantin Osipov
Approved by email (ok to push).
[22 Feb 2006 13:35]
Per-Erik Martin
Pushed to bk 5.0.19.
"CREATE AGGREGATE FUNCTION p(...) ..." (i.e. not an UDF), now gives the error message:
"ERROR 42000: AGGREGATE is not supported for stored functions"
[28 Feb 2006 0:46]
Paul DuBois
Noted in 5.0.19 changelog.
The parser allowed <literal>CREATE AGGREGATE
FUNCTION</literal> for creating stored functions, even though
<literal>AGGREGATE</literal> does not apply. (It is used only
for <literal>CREATE FUNCTION</literal> only when creating
user-defined functions.) (Bug #16896)
Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders. It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.