These conditions apply to plugin writing:
MySQL header files used by plugins contain C++ code, so plugins must be compiled as C++ code.
You must compile plugins with the entire server source code present, not just the libraries and header files.
Compiled plugins are not compatible across server versions. For a plugin compiled against MySQL 8.0.
X, there is no guarantee it will work with a MySQL 8.0.
Yserver without recompiling for MySQL 8.0.
Plugins are loaded and unloaded dynamically, so your operating system must support dynamic loading and you must have compiled the calling application dynamically (not statically). For server plugins, this means that mysqld must be linked dynamically.
The following procedure provides an overview of the steps needed to create a plugin library. The next sections provide additional details on setting plugin data structures and writing specific types of plugins.
In the plugin source file, include the header files that the plugin library needs. The
plugin.hfile is required, and the library might require other files as well. For example:
#include <stdlib.h> #include <ctype.h> #include <mysql/plugin.h>
Set up the descriptor information for the plugin library file. For server plugins, write the library descriptor, which must contain the general plugin descriptor for each server plugin in the file. For more information, see Section 22.214.171.124.1, “Server Plugin Library and Plugin Descriptors”. In addition, set up the type-specific descriptor for each server plugin in the library. Each plugin's general descriptor points to its type-specific descriptor.
For client plugins, write the client descriptor. For more information, see Section 126.96.36.199.3, “Client Plugin Descriptors”.
Write the plugin interface functions for each plugin. For example, each plugin's general plugin descriptor points to the initialization and deinitialization functions that the server should invoke when it loads and unloads the plugin. The plugin's type-specific description may also point to interface functions.
For server plugins, set up the status and system variables, if there are any.
Compile the plugin library as a shared library and install it in the plugin directory. For more information, see Section 188.8.131.52, “Compiling and Installing Plugin Libraries”.
For server plugins, register the plugin with the server. For more information, see Section 5.6.1, “Installing and Uninstalling Plugins”.
Test the plugin to verify that it works properly.