Commit 97d610d6 authored by Sergei Golubchik's avatar Sergei Golubchik

--plugin_maturity command-line option

parent 9b48499d
INSTALL PLUGIN example SONAME 'ha_example.so';
ERROR HY000: Can't open shared library 'ha_example.so' (errno: 0 Loading of experimental plugins is prohibited by --plugin-maturity=stable)
# test for --plugin_maturity
--replace_regex /\.dll/.so/
--error 1126
eval INSTALL PLUGIN example SONAME '$HA_EXAMPLE_SO';
......@@ -2052,6 +2052,7 @@ extern bool volatile abort_loop, shutdown_in_progress;
extern bool in_bootstrap;
extern uint volatile thread_count, thread_running, global_read_lock;
extern ulong thread_created;
extern uint thread_handling;
extern uint connection_count, extra_connection_count;
extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap;
......
......@@ -348,6 +348,16 @@ TYPELIB thread_handling_typelib=
thread_handling_names, NULL
};
const char *plugin_maturity_names[]=
{ "unknown", "experimental", "alpha", "beta", "gamma", "stable", 0 };
TYPELIB plugin_maturity_values=
{
array_elements(plugin_maturity_names) - 1, "", plugin_maturity_names, 0
};
const int server_maturity= MariaDB_PLUGIN_MATURITY_UNKNOWN;
const char *first_keyword= "first", *binary_keyword= "BINARY";
const char *my_localhost= "localhost", *delayed_user= "DELAYED";
#if SIZEOF_OFF_T > 4 && defined(BIG_TABLES)
......@@ -387,6 +397,7 @@ static my_bool opt_short_log_format= 0;
static my_bool opt_ignore_wrong_options= 0, opt_expect_abort= 0;
static uint kill_cached_threads, wake_thread;
ulong thread_created;
uint thread_handling;
static ulong max_used_connections;
static ulong my_bind_addr; /**< the address we bind to */
static volatile ulong cached_thread_count= 0;
......@@ -5924,6 +5935,7 @@ enum options_mysqld
OPT_TABLE_LOCK_WAIT_TIMEOUT,
OPT_PLUGIN_LOAD,
OPT_PLUGIN_DIR,
OPT_PLUGIN_MATURITY,
OPT_SYMBOLIC_LINKS,
OPT_WARNINGS,
OPT_RECORD_BUFFER_OLD,
......@@ -7208,7 +7220,7 @@ The minimum value for this variable is 4096.",
(uchar**) &optimizer_switch_str, (uchar**) &optimizer_switch_str, 0, GET_STR, REQUIRED_ARG,
/*OPTIMIZER_SWITCH_DEFAULT*/0,
0, 0, 0, 0, 0},
{"plugin_dir", OPT_PLUGIN_DIR,
{"plugin-dir", OPT_PLUGIN_DIR,
"Directory for plugins.",
(uchar**) &opt_plugin_dir_ptr, (uchar**) &opt_plugin_dir_ptr, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
......@@ -7218,6 +7230,10 @@ The minimum value for this variable is 4096.",
"is the plugin library in plugin_dir.",
(uchar**) &opt_plugin_load, (uchar**) &opt_plugin_load, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"plugin-maturity", OPT_PLUGIN_MATURITY,
"The lowest desirable plugin maturity. Plugins less mature than that will not be installed or loaded.",
(uchar**) &plugin_maturity, (uchar**) &plugin_maturity, &plugin_maturity_values,
GET_ENUM, REQUIRED_ARG, server_maturity, 0, 0, 0, 0, 0},
{"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
"The size of the buffer that is allocated when preloading indexes.",
(uchar**) &global_system_variables.preload_buff_size,
......@@ -8907,16 +8923,16 @@ mysqld_get_one_option(int optid,
break;
}
case OPT_ONE_THREAD:
global_system_variables.thread_handling= SCHEDULER_NO_THREADS;
opt_thread_handling= thread_handling_typelib.type_names[global_system_variables.thread_handling];
thread_handling= SCHEDULER_NO_THREADS;
opt_thread_handling= thread_handling_typelib.type_names[thread_handling];
break;
case OPT_THREAD_HANDLING:
{
int id;
LINT_INIT(id);
if (!find_opt_type(argument, &thread_handling_typelib, opt->name, &id))
global_system_variables.thread_handling= id - 1;
opt_thread_handling= thread_handling_typelib.type_names[global_system_variables.thread_handling];
thread_handling= id - 1;
opt_thread_handling= thread_handling_typelib.type_names[thread_handling];
break;
}
case OPT_FT_BOOLEAN_SYNTAX:
......@@ -9078,7 +9094,7 @@ static int get_options(int *argc,char **argv)
if (mysqld_chroot)
set_root(mysqld_chroot);
#else
global_system_variables.thread_handling = SCHEDULER_NO_THREADS;
thread_handling = SCHEDULER_NO_THREADS;
max_allowed_packet= global_system_variables.max_allowed_packet;
net_buffer_length= global_system_variables.net_buffer_length;
#endif
......@@ -9117,11 +9133,10 @@ static int get_options(int *argc,char **argv)
one_thread_scheduler(&thread_scheduler);
one_thread_scheduler(&extra_thread_scheduler);
#else
if (global_system_variables.thread_handling <=
SCHEDULER_ONE_THREAD_PER_CONNECTION)
if (thread_handling <= SCHEDULER_ONE_THREAD_PER_CONNECTION)
one_thread_per_connection_scheduler(&thread_scheduler, &max_connections,
&connection_count);
else if (global_system_variables.thread_handling == SCHEDULER_NO_THREADS)
else if (thread_handling == SCHEDULER_NO_THREADS)
one_thread_scheduler(&thread_scheduler);
else
pool_of_threads_scheduler(&thread_scheduler); /* purecov: tested */
......
......@@ -592,9 +592,8 @@ static sys_var_thd_ulong sys_trans_prealloc_size(&vars, "transaction_prealloc_si
&SV::trans_prealloc_size,
0, fix_trans_mem_root);
sys_var_enum_const sys_thread_handling(&vars, "thread_handling",
&SV::thread_handling,
&thread_handling_typelib,
NULL);
&thread_handling,
&thread_handling_typelib);
#ifdef HAVE_QUERY_CACHE
static sys_var_long_ptr sys_query_cache_limit(&vars, "query_cache_limit",
......@@ -957,6 +956,9 @@ static sys_var_readonly sys_myisam_mmap_size(&vars, "myisam_mmap_size",
SHOW_LONGLONG,
get_myisam_mmap_size);
static sys_var_enum_const sys_plugin_maturity(&vars, "plugin_maturity",
&plugin_maturity,
&plugin_maturity_values);
bool sys_var::check(THD *thd, set_var *var)
{
......@@ -1689,12 +1691,6 @@ uchar *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
return (uchar*) enum_names->type_names[*value];
}
uchar *sys_var_enum_const::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
return (uchar*) enum_names->type_names[global_system_variables.*offset];
}
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
{
if (get_unsigned(thd, var, max_system_variables.*offset, GET_ULONG))
......
......@@ -376,21 +376,14 @@ public:
};
class sys_var_enum_const :public sys_var
class sys_var_enum_const :public sys_var_enum
{
ulong SV::*offset;
TYPELIB *enum_names;
public:
sys_var_enum_const(sys_var_chain *chain, const char *name_arg, ulong SV::*offset_arg,
TYPELIB *typelib, sys_after_update_func func)
:sys_var(name_arg,func), offset(offset_arg), enum_names(typelib)
{ chain_sys_var(chain); }
bool check(THD *thd, set_var *var) { return 1; }
bool update(THD *thd, set_var *var) { return 1; }
SHOW_TYPE show_type() { return SHOW_CHAR; }
bool check_update_type(Item_result type) { return 1; }
sys_var_enum_const(sys_var_chain *chain, const char *name_arg,
uint *value_arg, TYPELIB *typelib)
:sys_var_enum(chain, name_arg, value_arg, typelib, 0)
{ }
bool is_readonly() const { return 1; }
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
};
......
......@@ -339,7 +339,6 @@ struct system_variables
ulong read_rnd_buff_size;
ulong div_precincrement;
ulong sortbuff_size;
ulong thread_handling;
ulong tx_isolation;
ulong completion_type;
/* Determines which non-standard SQL behaviour should be enabled */
......
......@@ -37,6 +37,18 @@ static TYPELIB global_plugin_typelib=
char *opt_plugin_load= NULL;
char *opt_plugin_dir_ptr;
char opt_plugin_dir[FN_REFLEN];
uint plugin_maturity;
/*
not really needed now, this map will become essential when we add more
maturity levels. We cannot change existing maturity constants,
so the next value - even if it will be MariaDB_PLUGIN_MATURITY_VERY_BUGGY -
will inevitably be larger than MariaDB_PLUGIN_MATURITY_STABLE.
To be able to compare them we use this mapping array
*/
uint plugin_maturity_map[]=
{ 0, 1, 2, 3, 4, 5, 6 };
/*
When you ad a new plugin type, add both a string and make sure that the
init and deinit array are correctly updated.
......@@ -953,6 +965,17 @@ static bool plugin_add(MEM_ROOT *tmp_root,
report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, 0, buf);
goto err;
}
if (plugin_maturity_map[plugin->maturity] < plugin_maturity)
{
char buf[256];
strxnmov(buf, sizeof(buf) - 1, "Loading of ",
plugin_maturity_names[plugin->maturity],
" plugins is prohibited by --plugin-maturity=",
plugin_maturity_names[plugin_maturity],
NullS);
report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, 0, buf);
goto err;
}
tmp.plugin= plugin;
tmp.name.str= (char *)plugin->name;
tmp.name.length= name_len;
......
......@@ -107,6 +107,9 @@ extern char *opt_plugin_load;
extern char *opt_plugin_dir_ptr;
extern char opt_plugin_dir[FN_REFLEN];
extern const LEX_STRING plugin_type_names[];
extern uint plugin_maturity;
extern TYPELIB plugin_maturity_values;
extern const char *plugin_maturity_names[];
extern int plugin_init(int *argc, char **argv, int init_flags);
extern void plugin_shutdown(void);
......
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