Syntax:
CREATE [AGGREGATE] FUNCTION function_name
    RETURNS {STRING|INTEGER|REAL|DECIMAL}
    SONAME shared_library_name

A user-defined function (UDF) is a way to extend MySQL with a new
function that works like a native (built-in) MySQL function such as
ABS() or CONCAT().

function_name is the name that should be used in SQL statements to
invoke the function. The RETURNS clause indicates the type of the
function's return value. DECIMAL is a legal value after RETURNS, but
currently DECIMAL functions return string values and should be written
like STRING functions.

shared_library_name is the base name of the shared library file that
contains the code that implements the function. The file must be
located in the plugin directory. This directory is given by the value
of the plugin_dir system variable. For more information, see
https://dev.mysql.com/doc/refman/8.0/en/udf-loading.html.

To create a function, you must have the INSERT privilege for the mysql
system schema. This is necessary because CREATE FUNCTION adds a row to
the mysql.func system table that records the function's name, type, and
shared library name.

UDFs registered using CREATE FUNCTION are listed in the Performance
Schema user_defined_functions table; see
https://dev.mysql.com/doc/refman/8.0/en/user-defined-functions-table.ht
ml.

URL: https://dev.mysql.com/doc/refman/8.0/en/create-function-udf.html

