diff --git a/mysql-test/include/plugin.defs b/mysql-test/include/plugin.defs new file mode 100644 index 00000000000..4da03dc2cc9 --- /dev/null +++ b/mysql-test/include/plugin.defs @@ -0,0 +1,41 @@ +# Definition file for plugins. +# +# [,...] +# +# The following variables will be set for a plugin, where PLUGVAR +# represents the variable name given as the 3rd item +# +# PLUGVAR: name of plugin file including extension .so or .dll +# 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 +# +# If a listed plugin is not found, the corresponding variables will be +# set to empty, they will not be unset. +# +# The PLUGVAR variable is not quoted, so you must remember to quote it +# when using it in an INSTALL PLUGIN command. +# +# The envorinment variables can be used in tests. If adding a new plugin, +# you are free to pick your variable name, but please keep it upper +# case for consistency. +# +# The _LOAD variable will have a form +# +# --plugin_load==;=..... +# +# with name1, name2 etc from the comma separated list of plugin names +# in the optional 4th argument. + +auth_test_plugin plugin/auth PLUGIN_AUTH test_plugin_server +qa_auth_interface plugin/auth PLUGIN_AUTH_INTERFACE qa_auth_interface +qa_auth_server plugin/auth PLUGIN_AUTH_SERVER qa_auth_server +qa_auth_client plugin/auth PLUGIN_AUTH_CLIENT qa_auth_client +udf_example sql UDF_EXAMPLE_LIB +ha_example storage/example EXAMPLE_PLUGIN EXAMPLE +semisync_master plugin/semisync SEMISYNC_MASTER_PLUGIN +semisync_slave plugin/semisync SEMISYNC_SLAVE_PLUGIN +ha_archive storage/archive ARCHIVE_PLUGIN +ha_blackhole storage/blackhole BLACKHOLE_PLUGIN +ha_federated storage/federated FEDERATED_PLUGIN +mypluglib plugin/fulltext SIMPLE_PARSER diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a7683b8d807..e2bb5d24205 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -131,10 +131,6 @@ my $opt_start_dirty; my $opt_start_exit; my $start_only; -my $auth_interface_fn; # the name of qa_auth_interface plugin -my $auth_server_fn; # the name of qa_auth_server plugin -my $auth_client_fn; # the name of qa_auth_client plugin -my $auth_filename; # the name of the authentication test plugin my $auth_plugin; # the path to the authentication test plugin END { @@ -1124,27 +1120,7 @@ sub command_line_setup { "$basedir/sql/share/charsets", "$basedir/share/charsets"); - # Look for auth test plugins - if (IS_WINDOWS) - { - $auth_filename = "auth_test_plugin.dll"; - $auth_interface_fn = "qa_auth_interface.dll"; - $auth_server_fn = "qa_auth_server.dll"; - $auth_client_fn = "qa_auth_client.dll"; - } - else - { - $auth_filename = "auth_test_plugin.so"; - $auth_interface_fn = "qa_auth_interface.so"; - $auth_server_fn = "qa_auth_server.so"; - $auth_client_fn = "qa_auth_client.so"; - } - $auth_plugin= - mtr_file_exists(vs_config_dirs('plugin/auth/',$auth_filename), - "$basedir/plugin/auth/.libs/" . $auth_filename, - "$basedir/lib/mysql/plugin/" . $auth_filename, - "$basedir/lib/plugin/" . $auth_filename); - + ($auth_plugin)= find_plugin("auth_test_plugin", "plugin/auth"); if (using_extern()) { @@ -1983,6 +1959,53 @@ sub find_plugin($$) return $lib_example_plugin; } +# +# Read plugin defintions file +# + +sub read_plugin_defs($) +{ + my ($defs_file)= @_; + + open(PLUGDEF, '<', $defs_file) + or mtr_error("Can't read plugin defintions file $defs_file"); + + while () { + next if /^#/; + my ($plug_file, $plug_loc, $plug_var, $plug_names)= split; + # Allow empty lines + next unless $plug_file; + mtr_error("Lines in $defs_file must have 3 or 4 items") unless $plug_var; + + my ($plugin)= find_plugin($plug_file, $plug_loc); + + # Set env. variables that tests may use, set to empty if plugin + # listed in def. file but not found. + + if ($plugin) { + $ENV{$plug_var}= basename($plugin); + $ENV{$plug_var.'_DIR'}= dirname($plugin); + $ENV{$plug_var.'_OPT'}= "--plugin-dir=".dirname($plugin); + if ($plug_names) { + my $lib_name= basename($plugin); + my $load_var= "--plugin_load="; + my $semi= ''; + foreach my $plug_name (split (',', $plug_names)) { + $load_var .= $semi . "$plug_name=$lib_name"; + $semi= ';'; + } + $ENV{$plug_var.'_LOAD'}= $load_var; + } + } else { + $ENV{$plug_var}= ""; + $ENV{$plug_var.'_DIR'}= ""; + $ENV{$plug_var.'_OPT'}= ""; + $ENV{$plug_var.'_LOAD'}= "" if $plug_names; + } + } + close PLUGDEF; +} + sub environment_setup { umask(022); @@ -2019,127 +2042,19 @@ sub environment_setup { } # -------------------------------------------------------------------------- - # Add the path where mysqld will find udf_example.so + # Read definitions from include/plugin.defs + # + # Plugin settings should no longer be added here, instead + # place definitions in include/plugin.defs. + # See comment in that file for details. # -------------------------------------------------------------------------- - my $udf_example_filename; - if (IS_WINDOWS) + read_plugin_defs("include/plugin.defs"); + + # Simplify reference to semisync plugins + if ($ENV{'SEMISYNC_MASTER_PLUGIN'}) { - $udf_example_filename = "udf_example.dll"; + $ENV{'SEMISYNC_PLUGIN_OPT'}= $ENV{'SEMISYNC_MASTER_PLUGIN_OPT'}; } - else - { - $udf_example_filename = "udf_example.so"; - } - my $lib_udf_example= - mtr_file_exists(vs_config_dirs('sql', $udf_example_filename), - "$basedir/sql/.libs/$udf_example_filename",); - - if ( $lib_udf_example ) - { - push(@ld_library_paths, dirname($lib_udf_example)); - } - - $ENV{'UDF_EXAMPLE_LIB'}= - ($lib_udf_example ? basename($lib_udf_example) : ""); - $ENV{'UDF_EXAMPLE_LIB_OPT'}= "--plugin-dir=". - ($lib_udf_example ? dirname($lib_udf_example) : ""); - - # -------------------------------------------------------------------------- - # Add the path where mysqld will find the auth test plugin (dialog.so/dll) - # -------------------------------------------------------------------------- - if ($auth_plugin) - { - $ENV{'PLUGIN_AUTH'}= basename($auth_plugin); - $ENV{'PLUGIN_AUTH_OPT'}= "--plugin-dir=".dirname($auth_plugin); - - $ENV{'PLUGIN_AUTH_LOAD'}="--plugin_load=test_plugin_server=".$auth_filename; - $ENV{'PLUGIN_AUTH_INTERFACE'}="--plugin_load=qa_auth_interface=".$auth_interface_fn; - $ENV{'PLUGIN_AUTH_SERVER'}="--plugin_load=qa_auth_server=".$auth_server_fn; - $ENV{'PLUGIN_AUTH_CLIENT'}="--plugin_load=qa_auth_client=".$auth_client_fn; - } - else - { - $ENV{'PLUGIN_AUTH'}= ""; - $ENV{'PLUGIN_AUTH_OPT'}="--plugin-dir="; - $ENV{'PLUGIN_AUTH_LOAD'}=""; - $ENV{'PLUGIN_AUTH_INTERFACE'}=""; - $ENV{'PLUGIN_AUTH_SERVER'}=""; - $ENV{'PLUGIN_AUTH_CLIENT'}=""; - } - - - # -------------------------------------------------------------------------- - # Add the path where mysqld will find ha_example.so - # -------------------------------------------------------------------------- - if ($mysql_version_id >= 50100) { - my ($lib_example_plugin) = find_plugin("ha_example", "storage/example"); - - if($lib_example_plugin) - { - $ENV{'EXAMPLE_PLUGIN'}= - ($lib_example_plugin ? basename($lib_example_plugin) : ""); - $ENV{'EXAMPLE_PLUGIN_OPT'}= "--plugin-dir=". - ($lib_example_plugin ? dirname($lib_example_plugin) : ""); - - $ENV{'HA_EXAMPLE_SO'}="'".basename($lib_example_plugin)."'"; - $ENV{'EXAMPLE_PLUGIN_LOAD'}="--plugin_load=EXAMPLE=".basename($lib_example_plugin); - } - else - { - # Some ".opt" files use some of these variables, so they must be defined - $ENV{'EXAMPLE_PLUGIN'}= ""; - $ENV{'EXAMPLE_PLUGIN_OPT'}= ""; - $ENV{'HA_EXAMPLE_SO'}= ""; - $ENV{'EXAMPLE_PLUGIN_LOAD'}= ""; - } - } - - - # -------------------------------------------------------------------------- - # Add the path where mysqld will find semisync plugins - # -------------------------------------------------------------------------- - if (!$opt_embedded_server) { - - - my ($lib_semisync_master_plugin) = find_plugin("semisync_master", "plugin/semisync"); - my ($lib_semisync_slave_plugin) = find_plugin("semisync_slave", "plugin/semisync"); - - - if ($lib_semisync_master_plugin && $lib_semisync_slave_plugin) - { - $ENV{'SEMISYNC_MASTER_PLUGIN'}= basename($lib_semisync_master_plugin); - $ENV{'SEMISYNC_SLAVE_PLUGIN'}= basename($lib_semisync_slave_plugin); - $ENV{'SEMISYNC_PLUGIN_OPT'}= "--plugin-dir=".dirname($lib_semisync_master_plugin); - } - else - { - $ENV{'SEMISYNC_MASTER_PLUGIN'}= ""; - $ENV{'SEMISYNC_SLAVE_PLUGIN'}= ""; - $ENV{'SEMISYNC_PLUGIN_OPT'}="--plugin-dir="; - } - } - - # ---------------------------------------------------- - # Add the paths where mysqld will find archive/blackhole/federated plugins. - # ---------------------------------------------------- - $ENV{'ARCHIVE_PLUGIN_DIR'} = - dirname(find_plugin("ha_archive", "storage/archive")); - $ENV{'BLACKHOLE_PLUGIN_DIR'} = - dirname(find_plugin("ha_blackhole", "storage/blackhole")); - $ENV{'FEDERATED_PLUGIN_DIR'} = - dirname(find_plugin("ha_federated", "storage/federated")); - - # ---------------------------------------------------- - # Add the path where mysqld will find mypluglib.so - # ---------------------------------------------------- - - my ($lib_simple_parser) = find_plugin("mypluglib", "plugin/fulltext"); - - $ENV{'MYPLUGLIB_SO'}="'".basename($lib_simple_parser)."'"; - $ENV{'SIMPLE_PARSER'}= - ($lib_simple_parser ? basename($lib_simple_parser) : ""); - $ENV{'SIMPLE_PARSER_OPT'}= "--plugin-dir=". - ($lib_simple_parser ? dirname($lib_simple_parser) : ""); # -------------------------------------------------------------------------- # Valgrind need to be run with debug libraries otherwise it's almost diff --git a/mysql-test/suite/bugs/t/bug57108.test b/mysql-test/suite/bugs/t/bug57108.test index 1006a7b30f1..56acd7fe7bd 100644 --- a/mysql-test/suite/bugs/t/bug57108.test +++ b/mysql-test/suite/bugs/t/bug57108.test @@ -5,7 +5,7 @@ # switched directory after starting the server and am using a relative # --defaults-file. --replace_regex /\.dll/.so/ -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'; --query_vertical SELECT @@global.connect_timeout AS connect_timeout, @@global.local_infile AS local_infile diff --git a/mysql-test/t/bug46261.test b/mysql-test/t/bug46261.test index 67bdc995850..e0eae9b86fb 100644 --- a/mysql-test/t/bug46261.test +++ b/mysql-test/t/bug46261.test @@ -7,7 +7,7 @@ --replace_regex /\.dll/.so/ --error ER_OPTION_PREVENTS_STATEMENT -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'; --replace_regex /\.dll/.so/ --error ER_OPTION_PREVENTS_STATEMENT diff --git a/mysql-test/t/fulltext_plugin.test b/mysql-test/t/fulltext_plugin.test index 25e4302ef0d..b591a7949e5 100644 --- a/mysql-test/t/fulltext_plugin.test +++ b/mysql-test/t/fulltext_plugin.test @@ -4,7 +4,7 @@ # BUG#39746 - Debug flag breaks struct definition (server crash) # --replace_regex /\.dll/.so/ -eval INSTALL PLUGIN simple_parser SONAME $MYPLUGLIB_SO; +eval INSTALL PLUGIN simple_parser SONAME '$SIMPLE_PARSER'; CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a) WITH PARSER simple_parser); ALTER TABLE t1 ADD FULLTEXT(b) WITH PARSER simple_parser; DROP TABLE t1; diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test index 0bf86b47dd7..117eaf1e19b 100644 --- a/mysql-test/t/plugin.test +++ b/mysql-test/t/plugin.test @@ -5,15 +5,15 @@ CREATE TABLE t1(a int) ENGINE=EXAMPLE; DROP TABLE t1; --replace_regex /\.dll/.so/ -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'; --replace_regex /\.dll/.so/ --error 1125 -eval INSTALL PLUGIN EXAMPLE SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN EXAMPLE SONAME '$EXAMPLE_PLUGIN'; UNINSTALL PLUGIN example; --replace_regex /\.dll/.so/ -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'; CREATE TABLE t1(a int) ENGINE=EXAMPLE; @@ -41,7 +41,7 @@ UNINSTALL PLUGIN non_exist; --echo # to impossible int val --echo # --replace_regex /\.dll/.so/ -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'; SET GLOBAL example_enum_var= e1; SET GLOBAL example_enum_var= e2; @@ -56,7 +56,7 @@ UNINSTALL PLUGIN example; # Bug #32757 hang with sql_mode set when setting some global variables # --replace_regex /\.dll/.so/ -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'; select @@session.sql_mode into @old_sql_mode; diff --git a/mysql-test/t/plugin_auth_qa_2-master.opt b/mysql-test/t/plugin_auth_qa_2-master.opt index c29153ac95b..354907b9366 100644 --- a/mysql-test/t/plugin_auth_qa_2-master.opt +++ b/mysql-test/t/plugin_auth_qa_2-master.opt @@ -1,2 +1,2 @@ -$PLUGIN_AUTH_OPT -$PLUGIN_AUTH_INTERFACE +$PLUGIN_AUTH_INTERFACE_OPT +$PLUGIN_AUTH_INTERFACE_LOAD diff --git a/mysql-test/t/plugin_auth_qa_3-master.opt b/mysql-test/t/plugin_auth_qa_3-master.opt index 5cc2af0a358..e1754862a4d 100644 --- a/mysql-test/t/plugin_auth_qa_3-master.opt +++ b/mysql-test/t/plugin_auth_qa_3-master.opt @@ -1,2 +1,2 @@ -$PLUGIN_AUTH_OPT -$PLUGIN_AUTH_SERVER +$PLUGIN_AUTH_SERVER_OPT +$PLUGIN_AUTH_SERVER_LOAD diff --git a/mysql-test/t/plugin_not_embedded.test b/mysql-test/t/plugin_not_embedded.test index 40024efcaad..a2b7b8a0fe4 100644 --- a/mysql-test/t/plugin_not_embedded.test +++ b/mysql-test/t/plugin_not_embedded.test @@ -8,7 +8,7 @@ GRANT INSERT ON mysql.plugin TO bug51770@localhost; connect(con1,localhost,bug51770,,); --replace_regex /\.dll/.so/ -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'; --error ER_TABLEACCESS_DENIED_ERROR UNINSTALL PLUGIN example; connection default; @@ -25,7 +25,7 @@ DROP USER bug51770@localhost; # The bug consisted of not recognizing / on Windows, so checking / on # all platforms should cover this case. -let $path = `select CONCAT_WS('/', '..', $HA_EXAMPLE_SO)`; +let $path = `select CONCAT_WS('/', '..', '$EXAMPLE_PLUGIN')`; --replace_regex /\.dll/.so/ --error ER_UDF_NO_PATHS eval INSTALL PLUGIN example SONAME '$path';