Commit 2eb8437d authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.1-arch

into  janus.mylan:/usr/home/serg/Abk/mysql-5.1-arch

parents 984983f8 5babf500
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
Plugin API. Common for all plugin types. Plugin API. Common for all plugin types.
*/ */
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0001 #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0002
/* /*
The allowable types of plugins The allowable types of plugins
...@@ -31,10 +31,6 @@ ...@@ -31,10 +31,6 @@
#define MYSQL_FTPARSER_PLUGIN 2 /* Full-text parser plugin */ #define MYSQL_FTPARSER_PLUGIN 2 /* Full-text parser plugin */
#define MYSQL_MAX_PLUGIN_TYPE_NUM 3 /* The number of plugin types */ #define MYSQL_MAX_PLUGIN_TYPE_NUM 3 /* The number of plugin types */
#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
#define __attribute__(A)
#endif
/* /*
Macros for beginning and ending plugin declarations. Between Macros for beginning and ending plugin declarations. Between
mysql_declare_plugin and mysql_declare_plugin_end there should mysql_declare_plugin and mysql_declare_plugin_end there should
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
#include <ctype.h> #include <ctype.h>
#include <mysql/plugin.h> #include <mysql/plugin.h>
#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
#define __attribute__(A)
#endif
static long number_of_calls= 0; /* for SHOW STATUS, see below */ static long number_of_calls= 0; /* for SHOW STATUS, see below */
/* /*
......
...@@ -35,12 +35,17 @@ plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]= ...@@ -35,12 +35,17 @@ plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
0,ha_initialize_handlerton,0 0,ha_initialize_handlerton,0
}; };
plugin_type_init plugin_type_deinitialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
{
0,ha_finalize_handlerton,0
};
static const char *plugin_interface_version_sym= static const char *plugin_interface_version_sym=
"_mysql_plugin_interface_version_"; "_mysql_plugin_interface_version_";
static const char *sizeof_st_plugin_sym= static const char *sizeof_st_plugin_sym=
"_mysql_sizeof_struct_st_plugin_"; "_mysql_sizeof_struct_st_plugin_";
static const char *plugin_declarations_sym= "_mysql_plugin_declarations_"; static const char *plugin_declarations_sym= "_mysql_plugin_declarations_";
static int min_plugin_interface_version= 0x0000; static int min_plugin_interface_version= MYSQL_PLUGIN_INTERFACE_VERSION & ~0xFF;
/* Note that 'int version' must be the first field of every plugin /* Note that 'int version' must be the first field of every plugin
sub-structure (plugin->info). sub-structure (plugin->info).
*/ */
...@@ -469,19 +474,36 @@ static my_bool plugin_add(const LEX_STRING *name, const LEX_STRING *dl, int repo ...@@ -469,19 +474,36 @@ static my_bool plugin_add(const LEX_STRING *name, const LEX_STRING *dl, int repo
} }
void plugin_deinitializer(struct st_plugin_int *plugin) void plugin_deinitialize(struct st_plugin_int *plugin)
{ {
if (plugin_type_deinitialize[plugin->plugin->type] &&
(*plugin_type_deinitialize[plugin->plugin->type])(plugin))
{
sql_print_error("Plugin '%s' of type %s failed deinitialization",
plugin->name.str, plugin_type_names[plugin->plugin->type]);
}
if (plugin->plugin->status_vars) if (plugin->plugin->status_vars)
{ {
#ifdef FIX_LATER
/*
We have a problem right now where we can not prepend without
breaking backwards compatibility. We will fix this shortly so
that engines have "use names" and we wil use those for
CREATE TABLE, and use the plugin name then for adding automatic
variable names.
*/
SHOW_VAR array[2]= { SHOW_VAR array[2]= {
{plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY}, {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY},
{0, 0, SHOW_UNDEF} {0, 0, SHOW_UNDEF}
}; };
remove_status_vars(array); remove_status_vars(array);
#else
remove_status_vars(plugin->plugin->status_vars);
#endif /* FIX_LATER */
} }
if (plugin->state == PLUGIN_IS_READY)
{
if (plugin->plugin->deinit) if (plugin->plugin->deinit)
{ {
DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str)); DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str));
...@@ -492,26 +514,27 @@ void plugin_deinitializer(struct st_plugin_int *plugin) ...@@ -492,26 +514,27 @@ void plugin_deinitializer(struct st_plugin_int *plugin)
} }
} }
plugin->state= PLUGIN_IS_UNINITIALIZED; plugin->state= PLUGIN_IS_UNINITIALIZED;
}
} }
static void plugin_del(const LEX_STRING *name) static void plugin_del(struct st_plugin_int *plugin)
{ {
uint i; DBUG_ENTER("plugin_del(plugin)");
struct st_plugin_int *plugin;
DBUG_ENTER("plugin_del");
if ((plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN)))
{
plugin_deinitializer(plugin);
hash_delete(&plugin_hash[plugin->plugin->type], (byte*)plugin); hash_delete(&plugin_hash[plugin->plugin->type], (byte*)plugin);
plugin_dl_del(&plugin->plugin_dl->dl); plugin_dl_del(&plugin->plugin_dl->dl);
plugin->state= PLUGIN_IS_FREED; plugin->state= PLUGIN_IS_FREED;
plugin_array_version++; plugin_array_version++;
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
static void plugin_del(const LEX_STRING *name)
{
struct st_plugin_int *plugin;
DBUG_ENTER("plugin_del(name)");
if ((plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN)))
plugin_del(plugin);
DBUG_VOID_RETURN;
}
void plugin_unlock(struct st_plugin_int *plugin) void plugin_unlock(struct st_plugin_int *plugin)
{ {
...@@ -521,9 +544,8 @@ void plugin_unlock(struct st_plugin_int *plugin) ...@@ -521,9 +544,8 @@ void plugin_unlock(struct st_plugin_int *plugin)
plugin->ref_count--; plugin->ref_count--;
if (plugin->state == PLUGIN_IS_DELETED && ! plugin->ref_count) if (plugin->state == PLUGIN_IS_DELETED && ! plugin->ref_count)
{ {
if (plugin->plugin->deinit) plugin_deinitialize(plugin);
plugin->plugin->deinit(); plugin_del(plugin);
plugin_del(&plugin->name);
} }
rw_unlock(&THR_LOCK_plugin); rw_unlock(&THR_LOCK_plugin);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -545,7 +567,7 @@ static int plugin_initialize(struct st_plugin_int *plugin) ...@@ -545,7 +567,7 @@ static int plugin_initialize(struct st_plugin_int *plugin)
variable names. variable names.
*/ */
SHOW_VAR array[2]= { SHOW_VAR array[2]= {
{plugin->name, (char*)plugin->status_vars, SHOW_ARRAY}, {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY},
{0, 0, SHOW_UNDEF} {0, 0, SHOW_UNDEF}
}; };
if (add_status_vars(array)) // add_status_vars makes a copy if (add_status_vars(array)) // add_status_vars makes a copy
...@@ -578,53 +600,6 @@ static int plugin_initialize(struct st_plugin_int *plugin) ...@@ -578,53 +600,6 @@ static int plugin_initialize(struct st_plugin_int *plugin)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
static int plugin_finalize(THD *thd, struct st_plugin_int *plugin)
{
int rc;
DBUG_ENTER("plugin_finalize");
if (plugin->ref_count)
{
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
"Plugin is busy and will be uninstalled on shutdown");
goto err;
}
switch (plugin->plugin->type)
{
case MYSQL_STORAGE_ENGINE_PLUGIN:
if (ha_finalize_handlerton(plugin))
{
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
"Storage engine shutdown failed. "
"It will be uninstalled on shutdown");
sql_print_warning("Storage engine '%s' shutdown failed. "
"It will be uninstalled on shutdown", plugin->name.str);
goto err;
}
break;
default:
break;
}
if (plugin->plugin->deinit)
{
if ((rc= plugin->plugin->deinit()))
{
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
"Plugin deinit failed. "
"It will be uninstalled on shutdown");
sql_print_warning("Plugin '%s' deinit failed. "
"It will be uninstalled on shutdown", plugin->name.str);
goto err;
}
}
DBUG_RETURN(0);
err:
DBUG_RETURN(1);
}
static byte *get_hash_key(const byte *buff, uint *length, static byte *get_hash_key(const byte *buff, uint *length,
my_bool not_used __attribute__((unused))) my_bool not_used __attribute__((unused)))
{ {
...@@ -702,7 +677,10 @@ int plugin_init(int skip_dynamic_loading) ...@@ -702,7 +677,10 @@ int plugin_init(int skip_dynamic_loading)
if (tmp->state == PLUGIN_IS_UNINITIALIZED) if (tmp->state == PLUGIN_IS_UNINITIALIZED)
{ {
if (plugin_initialize(tmp)) if (plugin_initialize(tmp))
plugin_del(&tmp->name); {
plugin_deinitialize(tmp);
plugin_del(tmp);
}
} }
} }
...@@ -812,7 +790,7 @@ void plugin_shutdown(void) ...@@ -812,7 +790,7 @@ void plugin_shutdown(void)
{ {
struct st_plugin_int *tmp= dynamic_element(&plugin_array, i, struct st_plugin_int *tmp= dynamic_element(&plugin_array, i,
struct st_plugin_int *); struct st_plugin_int *);
plugin_deinitializer(tmp); plugin_deinitialize(tmp);
} }
...@@ -862,7 +840,7 @@ my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING ...@@ -862,7 +840,7 @@ my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING
{ {
my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str, my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str,
"Plugin initialization function failed."); "Plugin initialization function failed.");
goto err; goto deinit;
} }
table->use_all_columns(); table->use_all_columns();
...@@ -879,10 +857,9 @@ my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING ...@@ -879,10 +857,9 @@ my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING
rw_unlock(&THR_LOCK_plugin); rw_unlock(&THR_LOCK_plugin);
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
deinit: deinit:
if (tmp->plugin->deinit) plugin_deinitialize(tmp);
tmp->plugin->deinit();
err: err:
plugin_del(name); plugin_del(tmp);
rw_unlock(&THR_LOCK_plugin); rw_unlock(&THR_LOCK_plugin);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
...@@ -917,10 +894,17 @@ my_bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name) ...@@ -917,10 +894,17 @@ my_bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name)
goto err; goto err;
} }
if (!plugin_finalize(thd, plugin)) if (plugin->ref_count)
plugin_del(name); {
else push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
"Plugin is busy and will be uninstalled on shutdown");
plugin->state= PLUGIN_IS_DELETED; plugin->state= PLUGIN_IS_DELETED;
}
else
{
plugin_deinitialize(plugin);
plugin_del(plugin);
}
table->use_all_columns(); table->use_all_columns();
table->field[0]->store(name->str, name->length, system_charset_info); table->field[0]->store(name->str, name->length, system_charset_info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment