Databases Reference
In-Depth Information
The role of a version
As we have seen, there are three two-component version numbers in the
INFORMATION_SCHEMA.PLUGINS table. One of them, PLUGIN_VERSION , is purely
informational. It is a number that a plugin author can specify arbitrarily, and MySQL
itself does not do anything with it. The other two are very important though. They
are used to protect the API, to make sure that if a plugin is loaded it uses the same
API version that the server provides. This is one of the main differences to UDFs.
UDF API is not versioned. Hence, it was not developed and still has only those
features that it did in 3.21.24. Extending UDF API is risky; any change and old UDFs
may start crashing the server.
Plugin API, on the other hand, is safe. It is protected by a version, and this version is
part of every plugin library, the API version that the plugin was compiled against.
When a plugin is loaded the server verifies that the version is supported by the
server and refuses to load a plugin otherwise. That is, the server can guarantee that
all loaded plugins are fully compatible with the server, and no crash can happen
because of API mismatch.
The API is protected with two version numbers, as it contains two parts—one is
common to all plugin types. It is version 1.0, as can be seen in the PLUGIN_LIBRARY_
VERSION column above. The other one is specific to each plugin type. For Daemon
plugins this version is 50147.0, as seen in the PLUGIN_TYPE_VERSION column, and it
is derived from the MySQL server version (which was 5.1.47 in my examples).
Defining Daemon plugins
The most basic of Daemon plugins needs no code at all; only a declaration is
required. A plugin declaration is an instance of a st_mysql_plugin structure:
struct st_mysql_plugin
{
int type;
void *info;
const char *name;
const char *author;
const char *descr;
int license;
int (*init)(void *);
int (*deinit)(void *);
unsigned int version;
struct st_mysql_show_var *status_vars;
struct st_mysql_sys_var **system_vars;
void *__reserved1
};
 
Search WWH ::




Custom Search