mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
plugin version changes
include/plugin.h: relocate version sql/handler.cc: no version checks here sql/handler.h: version is kinda short sql/sql_show.cc: version is a short, rearrange and show all storage/csv/ha_tina.cc: rearrange version storage/example/ha_example.cc: rearrange version
This commit is contained in:
@ -21,7 +21,7 @@
|
||||
Plugin API. Common for all plugin types.
|
||||
*/
|
||||
|
||||
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0000
|
||||
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0001
|
||||
|
||||
/*
|
||||
The allowable types of plugins
|
||||
@ -51,11 +51,11 @@ struct st_mysql_plugin
|
||||
int type; /* the plugin type (a MYSQL_XXX_PLUGIN value) */
|
||||
void *info; /* pointer to type-specific plugin descriptor */
|
||||
const char *name; /* plugin name */
|
||||
uint version; /* plugin version */
|
||||
const char *author; /* plugin author (for SHOW PLUGINS) */
|
||||
const char *descr; /* general descriptive text (for SHOW PLUGINS ) */
|
||||
int (*init)(void); /* the function to invoke when plugin is loaded */
|
||||
int (*deinit)(void); /* the function to invoke when plugin is unloaded */
|
||||
uint version; /* plugin version (for SHOW PLUGINS) */
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
|
@ -401,23 +401,6 @@ int ha_initialize_handlerton(handlerton *hton)
|
||||
if (hton == NULL)
|
||||
DBUG_RETURN(1);
|
||||
|
||||
/* check major version */
|
||||
if ((hton->interface_version>>24) != (MYSQL_HANDLERTON_INTERFACE_VERSION>>24))
|
||||
{
|
||||
sql_print_error("handlerton major version incompatible");
|
||||
DBUG_PRINT("warning", ("handlerton major version incompatible"));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
/* check minor version */
|
||||
if ((hton->interface_version>>16)&0xff <
|
||||
(MYSQL_HANDLERTON_INTERFACE_VERSION>>16)&0xff)
|
||||
{
|
||||
sql_print_error("handlerton minor version incompatible");
|
||||
DBUG_PRINT("warning", ("handlerton minor version incompatible"));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
switch (hton->state)
|
||||
{
|
||||
case SHOW_OPTION_NO:
|
||||
|
@ -337,7 +337,7 @@ typedef struct
|
||||
handlerton structure version
|
||||
*/
|
||||
const int interface_version;
|
||||
#define MYSQL_HANDLERTON_INTERFACE_VERSION 0x00000000
|
||||
#define MYSQL_HANDLERTON_INTERFACE_VERSION 0x0000
|
||||
|
||||
|
||||
/*
|
||||
|
@ -101,8 +101,7 @@ bool mysqld_show_storage_engines(THD *thd)
|
||||
|
||||
static int make_version_string(char *buf, int buf_length, uint version)
|
||||
{
|
||||
return my_snprintf(buf, buf_length, "%d.%d.%d",
|
||||
(version>>24)&0xff, (version>>16)&0xff,version&0xffff);
|
||||
return my_snprintf(buf, buf_length, "%d.%d", version>>8,version&0xff);
|
||||
}
|
||||
|
||||
static my_bool show_plugins(THD *thd, st_plugin_int *plugin,
|
||||
@ -118,17 +117,22 @@ static my_bool show_plugins(THD *thd, st_plugin_int *plugin,
|
||||
|
||||
table->field[0]->store(plugin->name.str, plugin->name.length, cs);
|
||||
|
||||
table->field[1]->store(version_buf,
|
||||
make_version_string(version_buf, sizeof(version_buf), plug->version),
|
||||
cs);
|
||||
|
||||
|
||||
switch (plugin->state)
|
||||
{
|
||||
/* case PLUGIN_IS_FREED: does not happen */
|
||||
case PLUGIN_IS_DELETED:
|
||||
table->field[1]->store(STRING_WITH_LEN("DELETED"), cs);
|
||||
table->field[2]->store(STRING_WITH_LEN("DELETED"), cs);
|
||||
break;
|
||||
case PLUGIN_IS_UNINITIALIZED:
|
||||
table->field[1]->store(STRING_WITH_LEN("INACTIVE"), cs);
|
||||
table->field[2]->store(STRING_WITH_LEN("INACTIVE"), cs);
|
||||
break;
|
||||
case PLUGIN_IS_READY:
|
||||
table->field[1]->store(STRING_WITH_LEN("ACTIVE"), cs);
|
||||
table->field[2]->store(STRING_WITH_LEN("ACTIVE"), cs);
|
||||
break;
|
||||
default:
|
||||
DBUG_ASSERT(0);
|
||||
@ -137,64 +141,57 @@ static my_bool show_plugins(THD *thd, st_plugin_int *plugin,
|
||||
switch (plug->type)
|
||||
{
|
||||
case MYSQL_UDF_PLUGIN:
|
||||
table->field[2]->store(STRING_WITH_LEN("UDF"), cs);
|
||||
table->field[3]->store(STRING_WITH_LEN("UDF"), cs);
|
||||
break;
|
||||
case MYSQL_STORAGE_ENGINE_PLUGIN:
|
||||
table->field[2]->store(STRING_WITH_LEN("STORAGE"), cs);
|
||||
table->field[3]->store(STRING_WITH_LEN("STORAGE"), cs);
|
||||
break;
|
||||
case MYSQL_FTPARSER_PLUGIN:
|
||||
table->field[2]->store(STRING_WITH_LEN("FTPARSER"), cs);
|
||||
table->field[3]->store(STRING_WITH_LEN("FTPARSER"), cs);
|
||||
break;
|
||||
default:
|
||||
table->field[2]->store(STRING_WITH_LEN("UNKNOWN"), cs);
|
||||
table->field[3]->store(STRING_WITH_LEN("UNKNOWN"), cs);
|
||||
break;
|
||||
}
|
||||
|
||||
if (plug->version)
|
||||
{
|
||||
table->field[3]->store(version_buf,
|
||||
make_version_string(version_buf, sizeof(version_buf), plug->version),
|
||||
cs);
|
||||
table->field[3]->set_notnull();
|
||||
}
|
||||
else
|
||||
table->field[3]->set_null();
|
||||
|
||||
if (plug->info)
|
||||
{
|
||||
table->field[4]->store(version_buf,
|
||||
make_version_string(version_buf, sizeof(version_buf),
|
||||
*(uint *)plug->info), cs);
|
||||
table->field[4]->set_notnull();
|
||||
}
|
||||
else
|
||||
table->field[4]->set_null();
|
||||
|
||||
if (plugin->plugin_dl)
|
||||
{
|
||||
table->field[5]->store(plugin->plugin_dl->dl.str,
|
||||
plugin->plugin_dl->dl.length, cs);
|
||||
table->field[5]->set_notnull();
|
||||
}
|
||||
else
|
||||
table->field[5]->set_null();
|
||||
|
||||
if (plug->author)
|
||||
{
|
||||
table->field[6]->store(plug->author, strlen(plug->author), cs);
|
||||
table->field[6]->store(version_buf,
|
||||
make_version_string(version_buf, sizeof(version_buf),
|
||||
plugin->plugin_dl->version),
|
||||
cs);
|
||||
table->field[6]->set_notnull();
|
||||
}
|
||||
else
|
||||
table->field[6]->set_null();
|
||||
|
||||
if (plug->descr)
|
||||
{
|
||||
table->field[7]->store(plug->descr, strlen(plug->descr), cs);
|
||||
table->field[5]->set_null();
|
||||
table->field[6]->set_null();
|
||||
}
|
||||
|
||||
|
||||
if (plug->author)
|
||||
{
|
||||
table->field[7]->store(plug->author, strlen(plug->author), cs);
|
||||
table->field[7]->set_notnull();
|
||||
}
|
||||
else
|
||||
table->field[7]->set_null();
|
||||
|
||||
if (plug->descr)
|
||||
{
|
||||
table->field[8]->store(plug->descr, strlen(plug->descr), cs);
|
||||
table->field[8]->set_notnull();
|
||||
}
|
||||
else
|
||||
table->field[8]->set_null();
|
||||
|
||||
return schema_table_store_record(thd, table);
|
||||
}
|
||||
|
||||
@ -4293,11 +4290,12 @@ ST_FIELD_INFO variables_fields_info[]=
|
||||
ST_FIELD_INFO plugin_fields_info[]=
|
||||
{
|
||||
{"PLUGIN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"},
|
||||
{"PLUGIN_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0},
|
||||
{"PLUGIN_STATUS", 10, MYSQL_TYPE_STRING, 0, 0, "Status"},
|
||||
{"PLUGIN_TYPE", 10, MYSQL_TYPE_STRING, 0, 0, "Type"},
|
||||
{"PLUGIN_VERSION", 20, MYSQL_TYPE_STRING, 0, 1, 0},
|
||||
{"PLUGIN_TYPE_VERSION", 20, MYSQL_TYPE_STRING, 0, 1, 0},
|
||||
{"PLUGIN_TYPE_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0},
|
||||
{"PLUGIN_LIBRARY", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Library"},
|
||||
{"PLUGIN_LIBRARY_VERSION", 20, MYSQL_TYPE_STRING, 0, 1, 0},
|
||||
{"PLUGIN_AUTHOR", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
|
||||
{"PLUGIN_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0},
|
||||
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
|
||||
|
@ -949,11 +949,11 @@ mysql_declare_plugin
|
||||
MYSQL_STORAGE_ENGINE_PLUGIN,
|
||||
&tina_hton,
|
||||
tina_hton.name,
|
||||
0x00010000 /* 0.1.0 */,
|
||||
"Brian Aker, MySQL AB",
|
||||
"CSV Storage Engine",
|
||||
tina_init_func, /* Plugin Init */
|
||||
tina_done_func /* Plugin Deinit */
|
||||
tina_done_func, /* Plugin Deinit */
|
||||
0x0100 /* 1.0 */,
|
||||
}
|
||||
mysql_declare_plugin_end;
|
||||
|
||||
|
@ -730,11 +730,11 @@ mysql_declare_plugin
|
||||
MYSQL_STORAGE_ENGINE_PLUGIN,
|
||||
&example_hton,
|
||||
example_hton.name,
|
||||
0x01000000 /* 1.0.0 */,
|
||||
"Brian Aker, MySQL AB",
|
||||
"Example Storage Engine",
|
||||
tina_init_func, /* Plugin Init */
|
||||
tina_done_func /* Plugin Deinit */
|
||||
tina_done_func, /* Plugin Deinit */
|
||||
0x0001 /* 0.1 */,
|
||||
}
|
||||
mysql_declare_plugin_end;
|
||||
|
||||
|
Reference in New Issue
Block a user