7.7.1 Installing and Uninstalling Loadable Functions (original) (raw)

7.7.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 inSection 7.7.2, “Obtaining Information About Loadable Functions”.

Installing Loadable Functions

To load a loadable function manually, use theCREATE 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:

Automatic loading of loadable functions occurs during the normal server startup sequence:

If the server is started with the--skip-grant-tables option, functions registered in the mysql.func table are not loaded and are unavailable. This does not apply to functions installed automatically by a component or plugin.

Uninstalling Loadable Functions

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

DROP FUNCTION metaphon;

DROP FUNCTION has these effects:

DROP FUNCTION cannot be used to drop a loadable function that is installed automatically by components or plugins rather than by usingCREATE FUNCTION. Such a function is also dropped automatically, when the component or plugin that installed it is uninstalled.

Reinstalling or Upgrading Loadable Functions

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