4.3 Plugin API Components

The server plugin implementation comprises several components.

SQL statements:

  • INSTALL PLUGINregisters a plugin in themysql.plugintable and loads the plugin code.

  • UNINSTALL PLUGINunregisters a plugin from themysql.plugintable and unloads the plugin code.

  • TheWITH PARSERclause for full-text index creation associates a full-text parser plugin with a givenFULLTEXTindex.

  • SHOW PLUGINSdisplays information about server plugins.

Command-line options and system variables:

  • The--plugin-loadoption enables plugins to be loaded at server startup time.

  • Theplugin_dirsystem variable indicates the location of the directory where all plugins must be installed. The value of this variable can be specified at server startup with a--plugin_dir=dir_nameoption.mysql_config --plugindirdisplays the default plugin directory path name.

For additional information about plugin loading, seeInstalling and Uninstalling Plugins.

Plugin-related表:

  • TheINFORMATION_SCHEMA.PLUGINStable contains plugin information.

  • Themysql.plugintable lists each plugin that was installed withINSTALL PLUGINand is required for plugin use. For new MySQL installations, this table is created during the installation process.

The client plugin implementation is simpler:

  • For themysql_options()C API function, theMYSQL_DEFAULT_AUTHandMYSQL_PLUGIN_DIRoptions enable client programs to load authentication plugins.

  • There are C API functions that enable management of client plugins.

To examine how MySQL implements plugins, consult the following source files in a MySQL source distribution:

  • In theinclude/mysqldirectory,plugin.hexposes the public plugin API. This file should be examined by anyone who wants to write a plugin library.plugin_xxx.hfiles provide additional information that pertains to specific types of plugins.client_plugin.hcontains information specific to client plugins.

  • In thesqldirectory,sql_plugin.handsql_plugin.cccomprise the internal plugin implementation.sql_acl.cc是where the server uses authentication plugins. These files need not be consulted by plugin developers. They may be of interest for those who want to know more about how the server handles plugins.

  • In thesql-commondirectory,client_plugin.himplements the C API client plugin functions, andclient.cimplements client authentication support. These files need not be consulted by plugin developers. They may be of interest for those who want to know more about how the server handles plugins.