MySQL 8.0.39
Source Code Documentation
|
A "plugin service" is in its core a C struct containing one or more function pointers.
If you want to export C++ class you need to provide an extern "C" function that will create a new instance of your class, and put it in a service. But be careful to also provide a destructor method since the heaps of the server and the plugin may be different.
Data structures are not part of the service structure, but they are part of the API you create and usually need to be declared in the same service_*.h file.
To turn a pre-existing set of functions (foo_func1, foo_func2) into a service "foo" you need to:
Create a new file include/mysql/service_foo.h
The template is:
The service_foo.h file should be self-contained, if it needs system headers - include them in it, e.g. if you use size_t
It should also declare all the accompanying data structures, as necessary (e.g. thd_alloc_service declares MYSQL_LEX_STRING).
libservices/foo_service.c
using the following template: Add it to the list_of_services