diff options
25 files changed, 127 insertions, 86 deletions
diff --git a/mysql-test/include/have_archive.opt b/mysql-test/include/have_archive.opt index cf9309d9fb0..39da455d917 100644 --- a/mysql-test/include/have_archive.opt +++ b/mysql-test/include/have_archive.opt @@ -1,2 +1,2 @@ --loose-archive ---plugin-load=$HA_ARCHIVE_SO +--plugin-load-add=$HA_ARCHIVE_SO diff --git a/mysql-test/include/have_blackhole.opt b/mysql-test/include/have_blackhole.opt index b600b468390..980dc27e328 100644 --- a/mysql-test/include/have_blackhole.opt +++ b/mysql-test/include/have_blackhole.opt @@ -1,2 +1,2 @@ --loose-blackhole ---plugin-load=$HA_BLACKHOLE_SO +--plugin-load-add=$HA_BLACKHOLE_SO diff --git a/mysql-test/include/have_innodb.combinations b/mysql-test/include/have_innodb.combinations index 6ce075b4cc2..d47d2c81a71 100644 --- a/mysql-test/include/have_innodb.combinations +++ b/mysql-test/include/have_innodb.combinations @@ -1,13 +1,13 @@ [innodb_plugin] ignore-builtin-innodb -plugin-load=$HA_INNODB_SO +plugin-load-add=$HA_INNODB_SO innodb innodb-cmpmem innodb-trx [xtradb_plugin] ignore-builtin-innodb -plugin-load=$HA_XTRADB_SO +plugin-load-add=$HA_XTRADB_SO innodb innodb-cmpmem innodb-trx diff --git a/mysql-test/include/have_plugin_auth.opt b/mysql-test/include/have_plugin_auth.opt index ff91abb1bef..0204e148656 100644 --- a/mysql-test/include/have_plugin_auth.opt +++ b/mysql-test/include/have_plugin_auth.opt @@ -1 +1 @@ ---plugin-load=$AUTH_TEST_PLUGIN_SO +--plugin-load-add=$AUTH_TEST_PLUGIN_SO diff --git a/mysql-test/include/have_xtradb.combinations b/mysql-test/include/have_xtradb.combinations index e05e8f53508..13d8ab915f5 100644 --- a/mysql-test/include/have_xtradb.combinations +++ b/mysql-test/include/have_xtradb.combinations @@ -1,6 +1,6 @@ [xtradb_plugin] ignore-builtin-innodb -plugin-load=$HA_XTRADB_SO +plugin-load-add=$HA_XTRADB_SO innodb innodb-cmpmem innodb-trx diff --git a/mysql-test/include/plugin.defs b/mysql-test/include/plugin.defs index 6fbe4f68328..d0dbfd35bee 100644 --- a/mysql-test/include/plugin.defs +++ b/mysql-test/include/plugin.defs @@ -9,6 +9,7 @@ # PLUGVAR_DIR: name of directory where plugin was found # PLUGVAR_OPT: mysqld option --plugin_dir=.... # 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 # set to empty, they will not be unset. diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ce964d6856d..b0dca9426ac 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -5264,9 +5264,6 @@ sub mysqld_arguments ($$$) { } my $found_skip_core= 0; - my @plugins; - my %seen; - my $plugin; foreach my $arg ( @$extra_opts ) { # 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 } - elsif ($plugin = mtr_match_prefix($arg, "--plugin-load=")) - { - next if $plugin =~ /=$/; - push @plugins, $plugin unless $seen{$plugin}; - $seen{$plugin} = 1; - } else { mtr_add_arg($args, "%s", $arg); @@ -5308,11 +5299,6 @@ sub mysqld_arguments ($$$) { mtr_add_arg($args, "--loose-debug-sync-timeout=%s", $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; } diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index c065f949802..9fb3502c5c5 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -606,6 +606,11 @@ The following options may be given as the first argument: plugin is 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. + --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 The lowest desirable plugin maturity (unknown, 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-objects-size 100 performance-schema-users-size 100 -plugin-load (No default value) plugin-maturity unknown port 3306 port-open-timeout 0 diff --git a/mysql-test/r/plugin_load.result b/mysql-test/r/plugin_load.result index 33116cc20ab..35bacf670a5 100644 --- a/mysql-test/r/plugin_load.result +++ b/mysql-test/r/plugin_load.result @@ -1,3 +1,10 @@ SELECT @@global.example_enum_var = 'e2'; @@global.example_enum_var = 'e2' 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 diff --git a/mysql-test/suite/federated/combinations b/mysql-test/suite/federated/combinations index 668c1c05c50..6379074896d 100644 --- a/mysql-test/suite/federated/combinations +++ b/mysql-test/suite/federated/combinations @@ -1,6 +1,6 @@ [old] -plugin-load=$HA_FEDERATED_SO +plugin-load-add=$HA_FEDERATED_SO [X] -plugin-load=$HA_FEDERATEDX_SO +plugin-load-add=$HA_FEDERATEDX_SO diff --git a/mysql-test/suite/federated/have_federatedx.opt b/mysql-test/suite/federated/have_federatedx.opt index 21f6f149f09..05d01b26b29 100644 --- a/mysql-test/suite/federated/have_federatedx.opt +++ b/mysql-test/suite/federated/have_federatedx.opt @@ -1 +1 @@ ---plugin-load=$HA_FEDERATEDX_SO --federated +--plugin-load-add=$HA_FEDERATEDX_SO --federated diff --git a/mysql-test/suite/funcs_1/t/is_engines_federated.opt b/mysql-test/suite/funcs_1/t/is_engines_federated.opt index e3c507f518d..198144ce5ac 100644 --- a/mysql-test/suite/funcs_1/t/is_engines_federated.opt +++ b/mysql-test/suite/funcs_1/t/is_engines_federated.opt @@ -1,2 +1,2 @@ --loose-federated ---plugin-load=$HA_FEDERATEDX_SO +--plugin-load-add=$HA_FEDERATEDX_SO diff --git a/mysql-test/suite/oqgraph/suite.opt b/mysql-test/suite/oqgraph/suite.opt index c41e40b894d..9f10d4e06ef 100644 --- a/mysql-test/suite/oqgraph/suite.opt +++ b/mysql-test/suite/oqgraph/suite.opt @@ -1 +1 @@ ---plugin-load=$HA_OQGRAPH_SO --enable-oqgraph +--plugin-load-add=$HA_OQGRAPH_SO --enable-oqgraph diff --git a/mysql-test/suite/plugins/t/feedback_plugin_load.opt b/mysql-test/suite/plugins/t/feedback_plugin_load.opt index 5fbb2f83954..6bf7594ce09 100644 --- a/mysql-test/suite/plugins/t/feedback_plugin_load.opt +++ b/mysql-test/suite/plugins/t/feedback_plugin_load.opt @@ -1,2 +1,2 @@ --loose-feedback ---plugin-load=$FEEDBACK_SO +--plugin-load-add=$FEEDBACK_SO diff --git a/mysql-test/suite/sphinx/suite.opt b/mysql-test/suite/sphinx/suite.opt index 6a0a190f67a..7b425b045f7 100644 --- a/mysql-test/suite/sphinx/suite.opt +++ b/mysql-test/suite/sphinx/suite.opt @@ -1 +1 @@ ---plugin-load=$HA_SPHINX_SO --sphinx +--plugin-load-add=$HA_SPHINX_SO --sphinx diff --git a/mysql-test/t/plugin_auth_qa_2-master.opt b/mysql-test/t/plugin_auth_qa_2-master.opt index 1a023ad271c..6429a4458aa 100644 --- a/mysql-test/t/plugin_auth_qa_2-master.opt +++ b/mysql-test/t/plugin_auth_qa_2-master.opt @@ -1 +1 @@ ---plugin-load=$QA_AUTH_INTERFACE_SO +--plugin-load-add=$QA_AUTH_INTERFACE_SO diff --git a/mysql-test/t/plugin_auth_qa_3-master.opt b/mysql-test/t/plugin_auth_qa_3-master.opt index 5d53a9dbe04..db4629aa09d 100644 --- a/mysql-test/t/plugin_auth_qa_3-master.opt +++ b/mysql-test/t/plugin_auth_qa_3-master.opt @@ -1 +1 @@ ---plugin-load=$QA_AUTH_SERVER_SO +--plugin-load-add=$QA_AUTH_SERVER_SO diff --git a/mysql-test/t/plugin_load-master.opt b/mysql-test/t/plugin_load-master.opt deleted file mode 100644 index aadeef2fb66..00000000000 --- a/mysql-test/t/plugin_load-master.opt +++ /dev/null @@ -1,2 +0,0 @@ ---plugin-load=EXAMPLE=$HA_EXAMPLE_SO ---loose-plugin-example-enum-var=e2 diff --git a/mysql-test/t/plugin_load.opt b/mysql-test/t/plugin_load.opt new file mode 100644 index 00000000000..aeeb2e4eb7d --- /dev/null +++ b/mysql-test/t/plugin_load.opt @@ -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 diff --git a/mysql-test/t/plugin_load.test b/mysql-test/t/plugin_load.test index 97b2afbe219..fdae622645a 100644 --- a/mysql-test/t/plugin_load.test +++ b/mysql-test/t/plugin_load.test @@ -1,4 +1,18 @@ --source include/not_windows_embedded.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'; + +--sorted_result +select plugin_name, plugin_status from information_schema.plugins + where plugin_name in ('SIMPLE_PARSER', 'EXAMPLE', + 'DAEMON_EXAMPLE', 'TWO_QUESTIONS', 'THREE_ATTEMPTS'); diff --git a/mysql-test/t/plugin_load_option-master.opt b/mysql-test/t/plugin_load_option-master.opt index a5a12e7b0d6..be9bc9d5487 100644 --- a/mysql-test/t/plugin_load_option-master.opt +++ b/mysql-test/t/plugin_load_option-master.opt @@ -1,2 +1,2 @@ ---plugin-load=EXAMPLE=$HA_EXAMPLE_SO +--plugin-load-add=EXAMPLE=$HA_EXAMPLE_SO --loose-plugin-example=FORCE_PLUS_PERMANENT diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d02d9194f3f..28e2c43ca43 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1908,6 +1908,7 @@ void clean_up(bool print_message) mysql_cond_broadcast(&COND_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 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}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, 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 " "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.", - &opt_plugin_load, &opt_plugin_load, 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_size, &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0}, @@ -7989,6 +7996,13 @@ mysqld_get_one_option(int optid, } } 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: max_long_data_size_used= true; break; diff --git a/sql/mysqld.h b/sql/mysqld.h index eaf22954cc4..7da96ca932e 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -514,6 +514,8 @@ enum options_mysqld OPT_LOG_ERROR, OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_LONG_DATA_SIZE, + OPT_PLUGIN_LOAD, + OPT_PLUGIN_LOAD_ADD, OPT_ONE_THREAD, OPT_PFS_INSTRUMENT, OPT_POOL_OF_THREADS, diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index e15f6339847..73539f70762 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -51,8 +51,8 @@ static TYPELIB global_plugin_typelib= { array_elements(global_plugin_typelib_names)-1, "", global_plugin_typelib_names, NULL }; - -char *opt_plugin_load= NULL; +static I_List<i_string> opt_plugin_load_list; +I_List<i_string> *opt_plugin_load_list_ptr= &opt_plugin_load_list; char *opt_plugin_dir_ptr; char opt_plugin_dir[FN_REFLEN]; ulong plugin_maturity; @@ -1040,7 +1040,7 @@ static bool plugin_add(MEM_ROOT *tmp_root, { struct st_plugin_int tmp; struct st_maria_plugin *plugin; - uint oks= 0, errs= 0; + uint oks= 0, errs= 0, dupes= 0; DBUG_ENTER("plugin_add"); 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 if (!name->str && plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN)) + { + dupes++; continue; // already installed + } - struct st_plugin_int *tmp_plugin_ptr; - if (*(int*)plugin->info < - min_plugin_info_interface_version[plugin->type] || - ((*(int*)plugin->info) >> 8) > - (cur_plugin_info_interface_version[plugin->type] >> 8)) - { - char buf[256]; - strxnmov(buf, sizeof(buf) - 1, "API version for ", - plugin_type_names[plugin->type].str, - " plugin ", tmp.name.str, - " not supported by this version of the server", NullS); - 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], - " plugin ", tmp.name.str, - " 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.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; - - if (!(tmp_plugin_ptr= plugin_insert_or_reuse(&tmp))) - { - mysql_del_sys_var_chain(tmp.system_vars); - restore_pluginvar_names(tmp.system_vars); - goto err; - } - plugin_array_version++; - if (my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr)) - tmp_plugin_ptr->state= PLUGIN_IS_FREED; - init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096); + struct st_plugin_int *tmp_plugin_ptr; + if (*(int*)plugin->info < + min_plugin_info_interface_version[plugin->type] || + ((*(int*)plugin->info) >> 8) > + (cur_plugin_info_interface_version[plugin->type] >> 8)) + { + char buf[256]; + strxnmov(buf, sizeof(buf) - 1, "API version for ", + plugin_type_names[plugin->type].str, + " plugin ", tmp.name.str, + " not supported by this version of the server", NullS); + 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], + " plugin ", tmp.name.str, + " 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.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; + + if (!(tmp_plugin_ptr= plugin_insert_or_reuse(&tmp))) + { + mysql_del_sys_var_chain(tmp.system_vars); + restore_pluginvar_names(tmp.system_vars); + goto err; + } + plugin_array_version++; + if (my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr)) + tmp_plugin_ptr->state= PLUGIN_IS_FREED; + init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096); if (name->str) DBUG_RETURN(FALSE); // all done @@ -1128,11 +1131,13 @@ err: 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); 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 */ if (!(flags & PLUGIN_INIT_SKIP_DYNAMIC_LOADING)) { - if (opt_plugin_load) - plugin_load_list(&tmp_root, argc, argv, opt_plugin_load); + I_List_iterator<i_string> iter(opt_plugin_load_list); + i_string *item; + while (NULL != (item= iter++)) + plugin_load_list(&tmp_root, argc, argv, item->ptr); + if (!(flags & PLUGIN_INIT_SKIP_PLUGIN_TABLE)) plugin_load(&tmp_root, argc, argv); } diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index be1cfcdcc4f..dc713826fe2 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -40,6 +40,7 @@ enum enum_plugin_load_option { PLUGIN_OFF, PLUGIN_ON, PLUGIN_FORCE, extern const char *global_plugin_typelib_names[]; #include <my_sys.h> +#include "sql_list.h" #ifdef DBUG_OFF #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 *); -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[FN_REFLEN]; extern const LEX_STRING plugin_type_names[]; |