There are two ways to add a new function for MySQL: you can add a function through the UDF interface. The custom function is compiled as the target file, and then dynamically added to and removed from the server using the CREATEFUNCTION and DROPFUNCTION statements. You can add functions as built-in MySQL functions. Inherent functions are compiled into m
There are two ways to add a new function for MySQL: you can add a function through the UDF interface. The custom FUNCTION is compiled as the target file, and then dynamically added to and removed from the server using the create function and drop function declaration. You can add functions as built-in MySQL functions. Inherent functions are compiled into m
There are two ways to add a new function for MySQL:
You can use the UDF to add functions. The custom FUNCTION is compiled as the target file, and then dynamically added to and removed from the server using the create function and drop function declaration.
You can add functions as built-in MySQL functions. Inherent functions are compiled into the mysqld server and become permanently available.
Each method has its advantages and disadvantages:
If you write a UDF, you must install the target file in addition to the server itself. If you compile your function into the server, you do not need to do so.
You can add a UDF to the MySQL distribution edition of the binary version. The inherent function requires you to correct the source code distribution version ..
If you upgrade your MySQL distribution edition, you can continue to use the previously installed UDF unless you upgrade to a new version that has been changed by a UDF interface. For inherent functions, you must repeat the correction for each update.
No matter which method you use to add new functions, they can be declared and called by SQL statements, just like inherent functions such as ABS () or SOUNDEX.
Create a storage function when you add another function. These functions are written in SQL statements instead of compiling the target code. The syntax for writing storage functions is described in Chapter 20th: storage programs and functions.
The following section describes the features of the UDF interface, provides UDF instructions, and discusses the security prevention measures taken by MySQL to prevent UDF misuse.
The source code example is provided to illustrate how to write a UDF. You can take a look at the SQL/udf_example.cc file provided in the MySQL source code distribution version.
Note: For more exciting tutorials, please pay attention to the Sanlian graphic tutorial channel,