Documentation Home
MySQL 5.6 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 29.5Mb
PDF (A4) - 29.5Mb
PDF (RPM) - 28.1Mb
HTML Download (TGZ) - 7.1Mb
HTML Download (Zip) - 7.1Mb
HTML Download (RPM) - 6.1Mb
Man Pages (TGZ) - 190.3Kb
Man Pages (Zip) - 305.1Kb
Info (Gzip) - 2.8Mb
Info (Zip) - 2.8Mb
Excerpts from this Manual

MySQL 5.6 Reference Manual  /  ...  /  Installing and Uninstalling Loadable Functions

5.6.1 Installing and Uninstalling Loadable Functions

Loadable functions, as the name implies, must be loaded into the server before they can be used. MySQL supports automatic function loading during server startup and manual loading thereafter.

While a loadable function is loaded, information about it is available as described in Section 5.6.2, “Obtaining Information About Loadable Functions”.

Installing Loadable Functions

To load a loadable function manually, use the CREATE FUNCTION statement. For example:

CREATE FUNCTION metaphon
  RETURNS STRING
  SONAME 'udf_example.so';

The file base name depends on your platform. Common suffixes are .so for Unix and Unix-like systems, .dll for Windows.

CREATE FUNCTION has these effects:

  • It loads the function into the server to make it available immediately.

  • It registers the function in the mysql.func system table to make it persistent across server restarts. For this reason, CREATE FUNCTION requires the INSERT privilege for the mysql system database.

Automatic loading of loadable functions occurs during the normal server startup sequence. The server loads functions registered in the mysql.func table. If the server is started with the --skip-grant-tables option, functions registered in the table are not loaded and are unavailable.

Uninstalling Loadable Functions

To remove a loadable function, use the DROP FUNCTION statement. For example:

DROP FUNCTION metaphon;

DROP FUNCTION has these effects:

  • It unloads the function to make it unavailable.

  • It removes the function from the mysql.func system table. For this reason, DROP FUNCTION requires the DELETE privilege for the mysql system database. With the function no longer registered in the mysql.func table, the server does not load the function during subsequent restarts.

While a loadable function is loaded, information about it is available from the mysql.func system table. See Section 5.6.2, “Obtaining Information About Loadable Functions”. CREATE FUNCTION adds the function to the table and DROP FUNCTION removes it.

Reinstalling or Upgrading Loadable Functions

To reinstall or upgrade the shared library associated with a loadable function, issue a DROP FUNCTION statement, upgrade the shared library, and then issue a CREATE FUNCTION statement. If you upgrade the shared library first and then use DROP FUNCTION, the server may unexpectedly shut down.