#At file:///home/svoj/mysql/server/mysql-next-mr-wl5341/ based on revid:alik@stripped
3193 Sergey Vojtovich 2010-09-07
WL#5341 - Sticky plugins
This patch implements "permanent" load option for
plugins as specified by WL#5341.
@ mysql-test/r/plugin_load_option.result
A test case for WL#5341.
@ mysql-test/t/plugin_load_option-master.opt
A test case for WL#5341.
@ mysql-test/t/plugin_load_option.test
A test case for WL#5341.
@ sql/share/errmsg-utf8.txt
An error message for WL#5341.
@ sql/sql_plugin.cc
Added FORCE_PLUS_PERMANENT plugin load option.
@ sql/sql_plugin.h
Expose and use plugin load option instead of
is_mandatory flag. This is a requirement for
to-be-implemented WL5496.
added:
mysql-test/r/plugin_load_option.result
mysql-test/t/plugin_load_option-master.opt
mysql-test/t/plugin_load_option.test
modified:
sql/share/errmsg-utf8.txt
sql/sql_plugin.cc
sql/sql_plugin.h
=== added file 'mysql-test/r/plugin_load_option.result'
--- a/mysql-test/r/plugin_load_option.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/plugin_load_option.result 2010-09-07 10:49:09 +0000
@@ -0,0 +1,2 @@
+UNINSTALL PLUGIN example;
+ERROR HY000: Plugin 'example' is force_plus_permanent and can not be unloaded
=== added file 'mysql-test/t/plugin_load_option-master.opt'
--- a/mysql-test/t/plugin_load_option-master.opt 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/plugin_load_option-master.opt 2010-09-07 10:49:09 +0000
@@ -0,0 +1,3 @@
+$EXAMPLE_PLUGIN_OPT
+$EXAMPLE_PLUGIN_LOAD
+--plugin-example=FORCE_PLUS_PERMANENT
=== added file 'mysql-test/t/plugin_load_option.test'
--- a/mysql-test/t/plugin_load_option.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/plugin_load_option.test 2010-09-07 10:49:09 +0000
@@ -0,0 +1,5 @@
+--source include/not_windows_embedded.inc
+--source include/have_example_plugin.inc
+
+--error ER_PLUGIN_IS_PERMANENT
+UNINSTALL PLUGIN example;
=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt 2010-07-29 14:15:38 +0000
+++ b/sql/share/errmsg-utf8.txt 2010-09-07 10:49:09 +0000
@@ -6387,3 +6387,5 @@ ER_TABLES_DIFFERENT_METADATA
ER_ROW_DOES_NOT_MATCH_PARTITION
eng "Found row that does not match the partition"
swe "Hittade rad som inte passar i partitionen"
+ER_PLUGIN_IS_PERMANENT
+ eng "Plugin '%s' is force_plus_permanent and can not be unloaded"
=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc 2010-08-23 17:43:34 +0000
+++ b/sql/sql_plugin.cc 2010-09-07 10:49:09 +0000
@@ -41,9 +41,8 @@ extern struct st_mysql_plugin *mysql_man
@note The order of the enumeration is critical.
@see construct_options
*/
-static const char *global_plugin_typelib_names[]=
- { "OFF", "ON", "FORCE", NULL };
-enum enum_plugin_load_policy {PLUGIN_OFF, PLUGIN_ON, PLUGIN_FORCE};
+const char *global_plugin_typelib_names[]=
+ { "OFF", "ON", "FORCE", "FORCE_PLUS_PERMANENT", NULL };
static TYPELIB global_plugin_typelib=
{ array_elements(global_plugin_typelib_names)-1,
"", global_plugin_typelib_names, NULL };
@@ -796,6 +795,7 @@ static bool plugin_add(MEM_ROOT *tmp_roo
tmp.name.length= name_len;
tmp.ref_count= 0;
tmp.state= PLUGIN_IS_UNINITIALIZED;
+ tmp.load_option= PLUGIN_ON;
if (test_plugin_options(tmp_root, &tmp, argc, argv))
tmp.state= PLUGIN_IS_DISABLED;
@@ -1237,7 +1237,7 @@ int plugin_init(int *argc, char **argv,
tmp.name.str= (char *)plugin->name;
tmp.name.length= strlen(plugin->name);
tmp.state= 0;
- tmp.is_mandatory= mandatory;
+ tmp.load_option= mandatory ? PLUGIN_FORCE : PLUGIN_ON;
/*
If the performance schema is compiled in,
@@ -1256,7 +1256,7 @@ int plugin_init(int *argc, char **argv,
to work, by using '--skip-performance-schema' (the plugin)
*/
if (!my_strcasecmp(&my_charset_latin1, plugin->name, "PERFORMANCE_SCHEMA"))
- tmp.is_mandatory= true;
+ tmp.load_option= PLUGIN_FORCE;
free_root(&tmp_root, MYF(MY_MARK_BLOCKS_FREE));
if (test_plugin_options(&tmp_root, &tmp, argc, argv))
@@ -1334,7 +1334,8 @@ int plugin_init(int *argc, char **argv,
while ((plugin_ptr= *(--reap)))
{
mysql_mutex_unlock(&LOCK_plugin);
- if (plugin_ptr->is_mandatory)
+ if (plugin_ptr->load_option == PLUGIN_FORCE ||
+ plugin_ptr->load_option == PLUGIN_FORCE_PLUS_PERMANENT)
reaped_mandatory_plugin= TRUE;
plugin_deinitialize(plugin_ptr, true);
mysql_mutex_lock(&LOCK_plugin);
@@ -1844,6 +1845,11 @@ bool mysql_uninstall_plugin(THD *thd, co
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str);
goto err;
}
+ if (plugin->load_option == PLUGIN_FORCE_PLUS_PERMANENT)
+ {
+ my_error(ER_PLUGIN_IS_PERMANENT, MYF(0), name->str);
+ goto err;
+ }
plugin->state= PLUGIN_IS_DELETED;
if (plugin->ref_count)
@@ -3054,7 +3060,8 @@ static int construct_options(MEM_ROOT *m
plugin_dash.length + 1);
strxmov(plugin_name_with_prefix_ptr, plugin_dash.str, plugin_name_ptr, NullS);
- if (!tmp->is_mandatory)
+ if (tmp->load_option != PLUGIN_FORCE &&
+ tmp->load_option != PLUGIN_FORCE_PLUS_PERMANENT)
{
/* support --skip-plugin-foo syntax */
options[0].name= plugin_name_ptr;
@@ -3314,7 +3321,7 @@ static int test_plugin_options(MEM_ROOT
{
struct sys_var_chain chain= { NULL, NULL };
bool disable_plugin;
- enum_plugin_load_policy plugin_load_policy= tmp->is_mandatory ? PLUGIN_FORCE : PLUGIN_ON;
+ enum_plugin_load_option plugin_load_option= tmp->load_option;
MEM_ROOT *mem_root= alloc_root_inited(&tmp->mem_root) ?
&tmp->mem_root : &plugin_mem_root;
@@ -3335,7 +3342,7 @@ static int test_plugin_options(MEM_ROOT
*/
if (!(my_strcasecmp(&my_charset_latin1, tmp->name.str, "federated") &&
my_strcasecmp(&my_charset_latin1, tmp->name.str, "ndbcluster")))
- plugin_load_policy= PLUGIN_OFF;
+ plugin_load_option= PLUGIN_OFF;
for (opt= tmp->plugin->system_vars; opt && *opt; opt++)
count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */
@@ -3359,8 +3366,9 @@ static int test_plugin_options(MEM_ROOT
We adjust the default value to account for the hardcoded exceptions
we have set for the federated and ndbcluster storage engines.
*/
- if (!tmp->is_mandatory)
- opts[0].def_value= opts[1].def_value= plugin_load_policy;
+ if (tmp->load_option != PLUGIN_FORCE &&
+ tmp->load_option != PLUGIN_FORCE_PLUS_PERMANENT)
+ opts[0].def_value= opts[1].def_value= plugin_load_option;
error= handle_options(argc, &argv, opts, NULL);
(*argc)++; /* add back one for the program name */
@@ -3375,12 +3383,13 @@ static int test_plugin_options(MEM_ROOT
Set plugin loading policy from option value. First element in the option
list is always the <plugin name> option value.
*/
- if (!tmp->is_mandatory)
- plugin_load_policy= (enum_plugin_load_policy)*(ulong*)opts[0].value;
+ if (tmp->load_option != PLUGIN_FORCE &&
+ tmp->load_option != PLUGIN_FORCE_PLUS_PERMANENT)
+ plugin_load_option= (enum_plugin_load_option)*(ulong*)opts[0].value;
}
- disable_plugin= (plugin_load_policy == PLUGIN_OFF);
- tmp->is_mandatory= (plugin_load_policy == PLUGIN_FORCE);
+ disable_plugin= (plugin_load_option == PLUGIN_OFF);
+ tmp->load_option= plugin_load_option;
/*
If the plugin is disabled it should not be initialized.
=== modified file 'sql/sql_plugin.h'
--- a/sql/sql_plugin.h 2010-07-08 21:42:23 +0000
+++ b/sql/sql_plugin.h 2010-09-07 10:49:09 +0000
@@ -32,6 +32,9 @@
class sys_var;
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
+enum enum_plugin_load_option { PLUGIN_OFF, PLUGIN_ON, PLUGIN_FORCE,
+ PLUGIN_FORCE_PLUS_PERMANENT };
+extern const char *global_plugin_typelib_names[];
#include <my_sys.h>
@@ -95,7 +98,7 @@ struct st_plugin_int
void *data; /* plugin type specific, e.g. handlerton */
MEM_ROOT mem_root; /* memory for dynamic plugin structures */
sys_var *system_vars; /* server variables for this plugin */
- bool is_mandatory; /* If true then plugin must not fail to load */
+ enum enum_plugin_load_option load_option;
};
@@ -110,6 +113,7 @@ typedef struct st_plugin_int *plugin_ref
#define plugin_data(pi,cast) ((cast)((pi)->data))
#define plugin_name(pi) (&((pi)->name))
#define plugin_state(pi) ((pi)->state)
+#define plugin_load_option(pi) ((pi)->load_option)
#define plugin_equals(p1,p2) ((p1) == (p2))
#else
typedef struct st_plugin_int **plugin_ref;
@@ -118,6 +122,7 @@ typedef struct st_plugin_int **plugin_re
#define plugin_data(pi,cast) ((cast)((pi)[0]->data))
#define plugin_name(pi) (&((pi)[0]->name))
#define plugin_state(pi) ((pi)[0]->state)
+#define plugin_load_option(pi) ((pi)[0]->load_option)
#define plugin_equals(p1,p2) ((p1) && (p2) && (p1)[0] == (p2)[0])
#endif
Attachment: [text/bzr-bundle] bzr/svoj@sun.com-20100907104909-3l3jsmn17h87h34z.bundle
| Thread |
|---|
| • bzr commit into mysql-next-mr branch (svoj:3193) WL#5341 | Sergey Vojtovich | 7 Sep |