1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-3860 backport --plugin-load-add (and related mysql-test changes)

revno: 3383
  revision-id: georgi.kodinov@oracle.com-20110818083108-qa3h3ufqu4zne80a
  committer: Georgi Kodinov <Georgi.Kodinov@Oracle.com>
  timestamp: Thu 2011-08-18 11:31:08 +0300
  message:

  Bug #11766001: 59026: ALLOW MULTIPLE --PLUGIN-LOAD OPTIONS
  
  Implemented support for a new command line option :
  --plugin-load-add=<comma-separated-name-equals-value-list>
  This option takes the same type of arguments that --plugin-load does
  and complements --plugin-load (that continues to operate as before) by
  appending its argument to the list specified by --plugin-load.
  So --plugin-load can be considered a composite option consisting of 
  resetting the plugin load list and then calling --plugin-load-add to process
  the argument.
  Note that the order in which you specify --plugin-load and --plugin-load-add 
  is important : "--plugin-load=x --plugin-load-add=y" will be equivalent to
  "--plugin-load=x,y" whereas "--plugin-load-add=y --plugin-load=x" will be 
  equivalent to "plugin-load=x".
  
  Incompatible change : the --help --verbose command will no longer print the 
  --plugin-load variable's values (as it doesn't have one). Otherwise both --plugin-load 
  and --plugin-load-add are mentioned in it.
This commit is contained in:
Sergei Golubchik
2012-12-15 18:24:11 +01:00
parent 17d63e5be2
commit 2217717ff6
25 changed files with 126 additions and 85 deletions

View File

@ -1,2 +1,2 @@
--loose-archive --loose-archive
--plugin-load=$HA_ARCHIVE_SO --plugin-load-add=$HA_ARCHIVE_SO

View File

@ -1,2 +1,2 @@
--loose-blackhole --loose-blackhole
--plugin-load=$HA_BLACKHOLE_SO --plugin-load-add=$HA_BLACKHOLE_SO

View File

@ -1,13 +1,13 @@
[innodb_plugin] [innodb_plugin]
ignore-builtin-innodb ignore-builtin-innodb
plugin-load=$HA_INNODB_SO plugin-load-add=$HA_INNODB_SO
innodb innodb
innodb-cmpmem innodb-cmpmem
innodb-trx innodb-trx
[xtradb_plugin] [xtradb_plugin]
ignore-builtin-innodb ignore-builtin-innodb
plugin-load=$HA_XTRADB_SO plugin-load-add=$HA_XTRADB_SO
innodb innodb
innodb-cmpmem innodb-cmpmem
innodb-trx innodb-trx

View File

@ -1 +1 @@
--plugin-load=$AUTH_TEST_PLUGIN_SO --plugin-load-add=$AUTH_TEST_PLUGIN_SO

View File

@ -1,6 +1,6 @@
[xtradb_plugin] [xtradb_plugin]
ignore-builtin-innodb ignore-builtin-innodb
plugin-load=$HA_XTRADB_SO plugin-load-add=$HA_XTRADB_SO
innodb innodb
innodb-cmpmem innodb-cmpmem
innodb-trx innodb-trx

View File

@ -9,6 +9,7 @@
# PLUGVAR_DIR: name of directory where plugin was found # PLUGVAR_DIR: name of directory where plugin was found
# PLUGVAR_OPT: mysqld option --plugin_dir=.... # PLUGVAR_OPT: mysqld option --plugin_dir=....
# PLUGVAR_LOAD: option --plugin_load=.... if the 4th element is present # PLUGVAR_LOAD: option --plugin_load=.... if the 4th element is present
# PLUGVAR_LOAD_ADD: option --plugin_load_add=.... if the 4th element is present
# #
# If a listed plugin is not found, the corresponding variables will be # If a listed plugin is not found, the corresponding variables will be
# set to empty, they will not be unset. # set to empty, they will not be unset.

View File

@ -5264,9 +5264,6 @@ sub mysqld_arguments ($$$) {
} }
my $found_skip_core= 0; my $found_skip_core= 0;
my @plugins;
my %seen;
my $plugin;
foreach my $arg ( @$extra_opts ) foreach my $arg ( @$extra_opts )
{ {
# Skip --defaults-file option since it's handled above. # Skip --defaults-file option since it's handled above.
@ -5286,12 +5283,6 @@ sub mysqld_arguments ($$$) {
{ {
; # Dont add --skip-log-bin when mysqld have --log-slave-updates in config ; # Dont add --skip-log-bin when mysqld have --log-slave-updates in config
} }
elsif ($plugin = mtr_match_prefix($arg, "--plugin-load="))
{
next if $plugin =~ /=$/;
push @plugins, $plugin unless $seen{$plugin};
$seen{$plugin} = 1;
}
else else
{ {
mtr_add_arg($args, "%s", $arg); mtr_add_arg($args, "%s", $arg);
@ -5308,11 +5299,6 @@ sub mysqld_arguments ($$$) {
mtr_add_arg($args, "--loose-debug-sync-timeout=%s", mtr_add_arg($args, "--loose-debug-sync-timeout=%s",
$opt_debug_sync_timeout) unless $opt_user_args; $opt_debug_sync_timeout) unless $opt_user_args;
if (@plugins) {
my $sep = (IS_WINDOWS) ? ';' : ':';
mtr_add_arg($args, "--plugin-load=%s" . join($sep, @plugins));
}
return $args; return $args;
} }

View File

@ -606,6 +606,11 @@ The following options may be given as the first argument:
plugin is specified as ether a plugin_name=library_file plugin is specified as ether a plugin_name=library_file
pair or only a library_file. If the latter case, all pair or only a library_file. If the latter case, all
plugins from a given library_file will be loaded. plugins from a given library_file will be loaded.
--plugin-load-add=name
Optional semicolon-separated list of plugins to load.
This option adds to the list speficied by --plugin-load
in an incremental way. It can be specified many times,
adding more plugins every time.
--plugin-maturity=name --plugin-maturity=name
The lowest desirable plugin maturity (unknown, The lowest desirable plugin maturity (unknown,
experimental, alpha, beta, gamma, or stable). Plugins experimental, alpha, beta, gamma, or stable). Plugins
@ -1115,7 +1120,6 @@ performance-schema-max-thread-instances 1000
performance-schema-setup-actors-size 100 performance-schema-setup-actors-size 100
performance-schema-setup-objects-size 100 performance-schema-setup-objects-size 100
performance-schema-users-size 100 performance-schema-users-size 100
plugin-load (No default value)
plugin-maturity unknown plugin-maturity unknown
port 3306 port 3306
port-open-timeout 0 port-open-timeout 0

View File

@ -1,3 +1,10 @@
SELECT @@global.example_enum_var = 'e2'; SELECT @@global.example_enum_var = 'e2';
@@global.example_enum_var = 'e2' @@global.example_enum_var = 'e2'
1 1
select plugin_name, plugin_status from information_schema.plugins
where plugin_name in ('SIMPLE_PARSER', 'EXAMPLE',
'DAEMON_EXAMPLE', 'TWO_QUESTIONS', 'THREE_ATTEMPTS');
plugin_name plugin_status
EXAMPLE ACTIVE
daemon_example ACTIVE
simple_parser ACTIVE

View File

@ -1,6 +1,6 @@
[old] [old]
plugin-load=$HA_FEDERATED_SO plugin-load-add=$HA_FEDERATED_SO
[X] [X]
plugin-load=$HA_FEDERATEDX_SO plugin-load-add=$HA_FEDERATEDX_SO

View File

@ -1 +1 @@
--plugin-load=$HA_FEDERATEDX_SO --federated --plugin-load-add=$HA_FEDERATEDX_SO --federated

View File

@ -1,2 +1,2 @@
--loose-federated --loose-federated
--plugin-load=$HA_FEDERATEDX_SO --plugin-load-add=$HA_FEDERATEDX_SO

View File

@ -1 +1 @@
--plugin-load=$HA_OQGRAPH_SO --enable-oqgraph --plugin-load-add=$HA_OQGRAPH_SO --enable-oqgraph

View File

@ -1,2 +1,2 @@
--loose-feedback --loose-feedback
--plugin-load=$FEEDBACK_SO --plugin-load-add=$FEEDBACK_SO

View File

@ -1 +1 @@
--plugin-load=$HA_SPHINX_SO --sphinx --plugin-load-add=$HA_SPHINX_SO --sphinx

View File

@ -1 +1 @@
--plugin-load=$QA_AUTH_INTERFACE_SO --plugin-load-add=$QA_AUTH_INTERFACE_SO

View File

@ -1 +1 @@
--plugin-load=$QA_AUTH_SERVER_SO --plugin-load-add=$QA_AUTH_SERVER_SO

View File

@ -1,2 +0,0 @@
--plugin-load=EXAMPLE=$HA_EXAMPLE_SO
--loose-plugin-example-enum-var=e2

View File

@ -0,0 +1,6 @@
--plugin-load-add=$DIALOG_EXAMPLES_SO
--plugin-load=$LIBDAEMON_EXAMPLE_SO
--plugin-load-add=EXAMPLE=$HA_EXAMPLE_SO
--plugin-load-add=$MYPLUGLIB_SO
--plugin-load-add=$HA_EXAMPLE_SO
--loose-plugin-example-enum-var=e2

View File

@ -1,4 +1,18 @@
--source include/not_windows_embedded.inc --source include/not_windows_embedded.inc
--source include/have_example_plugin.inc --source include/have_example_plugin.inc
if (!$MYPLUGLIB_SO) {
--echo needs SIMPLE_PARSER plugin
}
if (!$LIBDAEMON_EXAMPLE_SO) {
--echo needs DAEMON_EXAMPLE plugin
}
if (!$DIALOG_EXAMPLES_SO) {
--echo needs dialog examples plugins
}
SELECT @@global.example_enum_var = 'e2'; SELECT @@global.example_enum_var = 'e2';
--sorted_result
select plugin_name, plugin_status from information_schema.plugins
where plugin_name in ('SIMPLE_PARSER', 'EXAMPLE',
'DAEMON_EXAMPLE', 'TWO_QUESTIONS', 'THREE_ATTEMPTS');

View File

@ -1,2 +1,2 @@
--plugin-load=EXAMPLE=$HA_EXAMPLE_SO --plugin-load-add=EXAMPLE=$HA_EXAMPLE_SO
--loose-plugin-example=FORCE_PLUS_PERMANENT --loose-plugin-example=FORCE_PLUS_PERMANENT

View File

@ -1908,6 +1908,7 @@ void clean_up(bool print_message)
mysql_cond_broadcast(&COND_thread_count); mysql_cond_broadcast(&COND_thread_count);
mysql_mutex_unlock(&LOCK_thread_count); mysql_mutex_unlock(&LOCK_thread_count);
free_list(opt_plugin_load_list_ptr);
/* /*
The following lines may never be executed as the main thread may have The following lines may never be executed as the main thread may have
killed us killed us
@ -6626,12 +6627,18 @@ struct my_option my_long_options[]=
&opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, &opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"plugin-load", 0, {"plugin-load", OPT_PLUGIN_LOAD,
"Semicolon-separated list of plugins to load, where each plugin is " "Semicolon-separated list of plugins to load, where each plugin is "
"specified as ether a plugin_name=library_file pair or only a library_file. " "specified as ether a plugin_name=library_file pair or only a library_file. "
"If the latter case, all plugins from a given library_file will be loaded.", "If the latter case, all plugins from a given library_file will be loaded.",
&opt_plugin_load, &opt_plugin_load, 0, 0, 0, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"plugin-load-add", OPT_PLUGIN_LOAD_ADD,
"Optional semicolon-separated list of plugins to load. This option adds "
"to the list speficied by --plugin-load in an incremental way. "
"It can be specified many times, adding more plugins every time.",
0, 0, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"table_cache", 0, "Deprecated; use --table-open-cache instead.", {"table_cache", 0, "Deprecated; use --table-open-cache instead.",
&table_cache_size, &table_cache_size, 0, GET_ULONG, &table_cache_size, &table_cache_size, 0, GET_ULONG,
REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0}, REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
@ -7989,6 +7996,13 @@ mysqld_get_one_option(int optid,
} }
} }
break; break;
case OPT_PLUGIN_LOAD:
free_list(opt_plugin_load_list_ptr);
/* fall through */
case OPT_PLUGIN_LOAD_ADD:
opt_plugin_load_list_ptr->push_back(new i_string(argument));
break;
case OPT_MAX_LONG_DATA_SIZE: case OPT_MAX_LONG_DATA_SIZE:
max_long_data_size_used= true; max_long_data_size_used= true;
break; break;

View File

@ -514,6 +514,8 @@ enum options_mysqld
OPT_LOG_ERROR, OPT_LOG_ERROR,
OPT_LOWER_CASE_TABLE_NAMES, OPT_LOWER_CASE_TABLE_NAMES,
OPT_MAX_LONG_DATA_SIZE, OPT_MAX_LONG_DATA_SIZE,
OPT_PLUGIN_LOAD,
OPT_PLUGIN_LOAD_ADD,
OPT_ONE_THREAD, OPT_ONE_THREAD,
OPT_PFS_INSTRUMENT, OPT_PFS_INSTRUMENT,
OPT_POOL_OF_THREADS, OPT_POOL_OF_THREADS,

View File

@ -51,8 +51,8 @@ static TYPELIB global_plugin_typelib=
{ array_elements(global_plugin_typelib_names)-1, { array_elements(global_plugin_typelib_names)-1,
"", global_plugin_typelib_names, NULL }; "", global_plugin_typelib_names, NULL };
static I_List<i_string> opt_plugin_load_list;
char *opt_plugin_load= NULL; I_List<i_string> *opt_plugin_load_list_ptr= &opt_plugin_load_list;
char *opt_plugin_dir_ptr; char *opt_plugin_dir_ptr;
char opt_plugin_dir[FN_REFLEN]; char opt_plugin_dir[FN_REFLEN];
ulong plugin_maturity; ulong plugin_maturity;
@ -1040,7 +1040,7 @@ static bool plugin_add(MEM_ROOT *tmp_root,
{ {
struct st_plugin_int tmp; struct st_plugin_int tmp;
struct st_maria_plugin *plugin; struct st_maria_plugin *plugin;
uint oks= 0, errs= 0; uint oks= 0, errs= 0, dupes= 0;
DBUG_ENTER("plugin_add"); DBUG_ENTER("plugin_add");
DBUG_PRINT("enter", ("name: %s dl: %s", name->str, dl->str)); DBUG_PRINT("enter", ("name: %s dl: %s", name->str, dl->str));
@ -1069,51 +1069,54 @@ static bool plugin_add(MEM_ROOT *tmp_root,
continue; // plugin name doesn't match continue; // plugin name doesn't match
if (!name->str && plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN)) if (!name->str && plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN))
{
dupes++;
continue; // already installed continue; // already installed
}
struct st_plugin_int *tmp_plugin_ptr; struct st_plugin_int *tmp_plugin_ptr;
if (*(int*)plugin->info < if (*(int*)plugin->info <
min_plugin_info_interface_version[plugin->type] || min_plugin_info_interface_version[plugin->type] ||
((*(int*)plugin->info) >> 8) > ((*(int*)plugin->info) >> 8) >
(cur_plugin_info_interface_version[plugin->type] >> 8)) (cur_plugin_info_interface_version[plugin->type] >> 8))
{ {
char buf[256]; char buf[256];
strxnmov(buf, sizeof(buf) - 1, "API version for ", strxnmov(buf, sizeof(buf) - 1, "API version for ",
plugin_type_names[plugin->type].str, plugin_type_names[plugin->type].str,
" plugin ", tmp.name.str, " plugin ", tmp.name.str,
" not supported by this version of the server", NullS); " not supported by this version of the server", NullS);
report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, 0, buf); report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, 0, buf);
goto err; goto err;
} }
if (plugin_maturity_map[plugin->maturity] < plugin_maturity) if (plugin_maturity_map[plugin->maturity] < plugin_maturity)
{ {
char buf[256]; char buf[256];
strxnmov(buf, sizeof(buf) - 1, "Loading of ", strxnmov(buf, sizeof(buf) - 1, "Loading of ",
plugin_maturity_names[plugin->maturity], plugin_maturity_names[plugin->maturity],
" plugin ", tmp.name.str, " plugin ", tmp.name.str,
" is prohibited by --plugin-maturity=", " is prohibited by --plugin-maturity=",
plugin_maturity_names[plugin_maturity], plugin_maturity_names[plugin_maturity],
NullS); NullS);
report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, 0, buf); report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, 0, buf);
goto err; goto err;
} }
tmp.plugin= plugin; tmp.plugin= plugin;
tmp.ref_count= 0; tmp.ref_count= 0;
tmp.state= PLUGIN_IS_UNINITIALIZED; tmp.state= PLUGIN_IS_UNINITIALIZED;
tmp.load_option= PLUGIN_ON; tmp.load_option= PLUGIN_ON;
if (test_plugin_options(tmp_root, &tmp, argc, argv)) if (test_plugin_options(tmp_root, &tmp, argc, argv))
tmp.state= PLUGIN_IS_DISABLED; tmp.state= PLUGIN_IS_DISABLED;
if (!(tmp_plugin_ptr= plugin_insert_or_reuse(&tmp))) if (!(tmp_plugin_ptr= plugin_insert_or_reuse(&tmp)))
{ {
mysql_del_sys_var_chain(tmp.system_vars); mysql_del_sys_var_chain(tmp.system_vars);
restore_pluginvar_names(tmp.system_vars); restore_pluginvar_names(tmp.system_vars);
goto err; goto err;
} }
plugin_array_version++; plugin_array_version++;
if (my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr)) if (my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr))
tmp_plugin_ptr->state= PLUGIN_IS_FREED; tmp_plugin_ptr->state= PLUGIN_IS_FREED;
init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096); init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096);
if (name->str) if (name->str)
DBUG_RETURN(FALSE); // all done DBUG_RETURN(FALSE); // all done
@ -1128,11 +1131,13 @@ err:
break; break;
} }
if (errs == 0 && oks == 0) // no plugin was found DBUG_ASSERT(!name->str || !dupes); // dupes is ONLY for name->str == 0
if (errs == 0 && oks == 0 && !dupes) // no plugin was found
report_error(report, ER_CANT_FIND_DL_ENTRY, name->str); report_error(report, ER_CANT_FIND_DL_ENTRY, name->str);
plugin_dl_del(dl); plugin_dl_del(dl);
DBUG_RETURN(errs > 0 || oks == 0); DBUG_RETURN(errs > 0 || oks + dupes == 0);
} }
@ -1625,8 +1630,11 @@ int plugin_init(int *argc, char **argv, int flags)
/* Register all dynamic plugins */ /* Register all dynamic plugins */
if (!(flags & PLUGIN_INIT_SKIP_DYNAMIC_LOADING)) if (!(flags & PLUGIN_INIT_SKIP_DYNAMIC_LOADING))
{ {
if (opt_plugin_load) I_List_iterator<i_string> iter(opt_plugin_load_list);
plugin_load_list(&tmp_root, argc, argv, opt_plugin_load); i_string *item;
while (NULL != (item= iter++))
plugin_load_list(&tmp_root, argc, argv, item->ptr);
if (!(flags & PLUGIN_INIT_SKIP_PLUGIN_TABLE)) if (!(flags & PLUGIN_INIT_SKIP_PLUGIN_TABLE))
plugin_load(&tmp_root, argc, argv); plugin_load(&tmp_root, argc, argv);
} }

View File

@ -40,6 +40,7 @@ enum enum_plugin_load_option { PLUGIN_OFF, PLUGIN_ON, PLUGIN_FORCE,
extern const char *global_plugin_typelib_names[]; extern const char *global_plugin_typelib_names[];
#include <my_sys.h> #include <my_sys.h>
#include "sql_list.h"
#ifdef DBUG_OFF #ifdef DBUG_OFF
#define plugin_ref_to_int(A) A #define plugin_ref_to_int(A) A
@ -137,7 +138,7 @@ typedef struct st_plugin_int **plugin_ref;
typedef int (*plugin_type_init)(struct st_plugin_int *); typedef int (*plugin_type_init)(struct st_plugin_int *);
extern char *opt_plugin_load; extern I_List<i_string> *opt_plugin_load_list_ptr;
extern char *opt_plugin_dir_ptr; extern char *opt_plugin_dir_ptr;
extern char opt_plugin_dir[FN_REFLEN]; extern char opt_plugin_dir[FN_REFLEN];
extern const LEX_STRING plugin_type_names[]; extern const LEX_STRING plugin_type_names[];