How to add new functions to MySQL

Source: Internet
Author: User
Tags mysql functions
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,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.