MySQL 5.7 Reference Manual Including MySQL NDB Cluster 7.5 and NDB Cluster 7.6

28.4 Adding Functions to MySQL

There are three ways to add functions to MySQL:

Each method of creating compiled functions has advantages and disadvantages:

Whichever method you use to add functions, they can be invoked in SQL statements just like native functions such as ABS() or SOUNDEX().

For the rules describing how the server interprets references to different kinds of functionss see Section 9.2.5, “Function Name Parsing and Resolution”.

The following sections describe features of the UDF interface, provide instructions for writing UDFs, discuss security precautions that MySQL takes to prevent UDF misuse, and describe how to add native MySQL functions.

For example source code that illustrates how to write UDFs, take a look at the sql/udf_example.cc file that is provided in MySQL source distributions.