Details
-
Task
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
Description
Since we introduced a few incompatible SE API changes and we'll have to bump SE API version anyway, we could try implementing this in 10.5.
Originally plugins were intended to use declarative approach, e.g. plugin/fulltext/plugin_example.c is an example of such approach. It fills in simple_parser_descriptor and passes it via plugin descriptor to the server.
However SE API implements dynamic approach for no apparent reason. That is server (ha_initialize_handlerton()) allocates handlerton and then passes it to a plugin for further initialisation via plugin->init() call.
We should attempt switching it to declarative approach, which means 1. extending st_mysql_storage_engine like:
struct st_mysql_storage_engine
|
{
|
int interface_version;
|
handlerton *hton;
|
};
|
or even
struct st_mysql_storage_engine: public handlerton
|
{
|
st_mysql_storage_engine(...): handlerton(...) {}
|
int interface_version;
|
};
|
2. removing hton argument from SE plugin->init(hton)
3. making use of plugin_decl(plugin)->info->hton rather than hton
Not necessarily. If designated initializers are not acceptable yet, we can do something else. I had this macro workaround that almost looks like designated initializers
#define init_ht(...) \
[]{ \
st_mysql_storage_engine _; \
_.version = MYSQL_HANDLERTON_INTERFACE_VERSION; \
__VA_ARGS__; \
}()
and
_.db_type= DB_TYPE_PARTITION_DB,
_.create= partition_create_handler,
_.partition_flags= partition_flags,
_.alter_table_flags= alter_table_flags,
_.flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN |
HTON_TEMPORARY_NOT_SUPPORTED,
_.tablefile_extensions= ha_partition_ext
);
which is fairly close to the true designated initializers syntax three comments above.
But designated initializers, that trick, or something else — the point is to let storage engine authors to write as little code as possible, to reduce the amount of boilerplate code.
But this robertbindar's commit just moves code around, from init() function into constructors. Same amount of code, slightly different boilerplate decoration.