A custom Function (UDF) extends MySQL by using a new function like an intrinsic (built-in) function like ABS () or CONCAT ().
CREATE [AGGREGATE] FUNCTION function_name RETURNS {STRING|INTEGER|REAL}
SONAME shared_library_name
DROP FUNCTION function_name
Function_name is the name of the function used in the SQL declaration for invocation. The RETURNS clause describes the type of the function return value. Shared_library_name is the basic name of the shared target file, and the shared target file contains code to implement the function. The file must be located in a directory that can be searched by your system's dynamic connectors.
You must have a MySQL database insert permission to create a function, you must have the MySQL database delete permission to undo a function. This is because the CREATE function adds a row to the MYSQL.FUNC system table that records the function name, type, and share name, and the drop function deletes the row from the list. If you do not have this system table, you should run the Mysql_fix_privilege_tables script to create one.
A valid function is one that is loaded with the CREATE function and is not removed with the drop function. All valid functions are reloaded every time the server starts, unless you use the--skip-grant-tables parameter to start the mysqld. In this case, the initialization of the UDF is skipped and the UDF is not available.
To enable the UDF mechanism to work, you must write functions in C or C + +, your system must support dynamic loading, and you must be dynamically compiled Mysqld (non-static).
A aggregate function works like a MySQL intrinsic set (sum) function, such as the sum or count () function. To make aggregate work, your Mysql.func table must include a type column. If your Mysql.func table does not have this column, you should run the Mysql_fix_privilege_tables script to create this column.