Databases Reference
In-Depth Information
Both variables are recognized on the command line too, as
--static-text-text
and
--static-text-rows
accordingly. Note that we have specified variable
names simply as
text
and
rows
because MySQL will add the plugin name
as a prefix automatically.
Similar to other plugin types, when defining a storage engine plugin, we need the
following incantation:
struct st_mysql_storage_engine static_text_storage_engine =
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
mysql_declare_plugin(static_text)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&static_text_storage_engine,
"STATIC_TEXT",
"Andrew Hutchings (Andrew.Hutchings@Sun.COM)",
"An example static text storage engine",
PLUGIN_LICENSE_GPL,"
static_text_init,
NULL,
0x0001,
NULL,
static_text_sys_var,
NULL
}
mysql_declare_plugin_end;
The main job of the plugin initialization function is to set up the
handlerton
structure. For an engine as simple as ours, we only need to provide the
create()
method. This is a
handlerton
method that creates a new
handler
object, more
precisely, a new instance of our
ha_static_text
class that inherits from the
handler
class:
static int static_text_init(void *p)
{
handlerton *static_text_hton = (handlerton *)p;
static_text_hton->create = static_text_create_handler;
return 0;
}
static handler* static_text_create_handler(handlerton *hton,
TABLE_SHARE *table, MEM_ROOT *mem_root)
{
return new (mem_root) ha_static_text(hton, table);
}