Every server plugin must have a general descriptor that
provides information to the plugin API. The general descriptor
has the same structure for all plugin types. The
st_mysql_plugin structure in the
plugin.h file defines this descriptor:
struct st_mysql_plugin
{
int type; /* the plugin type (a MYSQL_XXX_PLUGIN value) */
void *info; /* pointer to type-specific plugin descriptor */
const char *name; /* plugin name */
const char *author; /* plugin author (for SHOW PLUGINS) */
const char *descr; /* general descriptive text (for SHOW PLUGINS ) */
int license; /* the plugin license (PLUGIN_LICENSE_XXX) */
int (*init)(void *); /* the function to invoke when plugin is loaded */
int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
unsigned int version; /* plugin version (for SHOW PLUGINS) */
struct st_mysql_show_var *status_vars;
struct st_mysql_sys_var **system_vars;
void * __reserved1; /* reserved for dependency checking */
};
The st_mysql_plugin descriptor structure
members are used as follows. char * members
should be specified as null-terminated strings.
typeThe plugin type. This must be one of the plugin-type values from
plugin.h:/* The allowable types of plugins */ #define MYSQL_UDF_PLUGIN 0 /* User-defined function */ #define MYSQL_STORAGE_ENGINE_PLUGIN 1 /* Storage Engine */ #define MYSQL_FTPARSER_PLUGIN 2 /* Full-text parser plugin */ #define MYSQL_DAEMON_PLUGIN 3 /* The daemon/raw plugin type */ #define MYSQL_INFORMATION_SCHEMA_PLUGIN 4 /* The I_S plugin type */ #define MYSQL_AUDIT_PLUGIN 5 /* The Audit plugin type */ #define MYSQL_REPLICATION_PLUGIN 6 /* The replication plugin type */ #define MYSQL_AUTHENTICATION_PLUGIN 7 /* The authentication plugin type */ ...
For example, for a full-text parser plugin, the
typevalue isMYSQL_FTPARSER_PLUGIN.infoA pointer to the type-specific descriptor for the plugin. This descriptor's structure depends on the particular type of plugin, unlike that of the general plugin descriptor structure. Each type-specific descriptor has a version number that indicates the API version for that type of plugin, plus any other members needed. See Section 23.2.4.3, “Type-Specific Plugin Data Structures and Functions”.
nameA string that gives the plugin name. This is the name that will be listed in the
mysql.plugintable and by which you refer to the plugin in SQL statements such asINSTALL PLUGINandUNINSTALL PLUGIN, or with the--plugin-loadoption. The name is also visible in theINFORMATION_SCHEMA.PLUGINStable or the output fromSHOW PLUGINS.authorA string naming the plugin author. This can be whatever you like.
descA string that provides a general description of the plugin. This can be whatever you like.
licenseThe plugin license type. The value can be one of
PLUGIN_LICENSE_PROPRIETARY,PLUGIN_LICENSE_GPL, orPLUGIN_LICENSE_BSD.initA once-only initialization function, or
NULLif there is no such function. The server executes this function when it loads the plugin, which happens forINSTALL PLUGINor, for plugins listed in themysql.plugintable, at server startup. The function takes one argument that points to the internal structure used to identify the plugin. It returns zero for success and nonzero for failure.deinitA once-only deinitialization function, or
NULLif there is no such function. The server executes this function when it unloads the plugin, which happens forUNINSTALL PLUGINor, for plugins listed in themysql.plugintable, at server shutdown. The function takes one argument that points to the internal structure used to identify the plugin It returns zero for success and nonzero for failure.versionThe plugin version number. When the plugin is installed, this value can be retrieved from the
INFORMATION_SCHEMA.PLUGINStable. The value includes major and minor numbers. If you write the value as a hex constant, the format is0x, whereMMNNMMandNNare the major and minor numbers, respectively. For example,0x0302represents version 3.2.status_varsA pointer to a structure for status variables associated with the plugin, or
NULLif there are no such variables. When the plugin is installed, these variables are displayed in the output of theSHOW STATUSstatement.The
status_varsmember, if notNULL, points to an array ofst_mysql_show_varstructures that describe status variables. See Section 23.2.4.2, “Plugin Status and System Variables”.system_varsA pointer to a structure for system variables associated with the plugin, or
NULLif there are no such variables. These options and system variables can be used to help initialize variables within the plugin.The
system_varsmember, if notNULL, points to an array ofst_mysql_sys_varstructures that describe sytem variables. See Section 23.2.4.2, “Plugin Status and System Variables”.__reserved1A placeholder for the future. Currently, it should be set to
NULL.
The server invokes the init and
deinit functions in the general plugin
descriptor only when loading and unloading the plugin. They
have nothing to do with use of the plugin such as happens when
an SQL statement causes the plugin to be invoked.