Description:
When debug build is done with "-DCMAKE_BUILD_TYPE=Debug" option and the binaries are installed into mysqld-debug install directory
which can be set with "-DCMAKE_INSTALL_PREFIX=" option there is no way to run mtr tests from this install directory if the
tests use any plugin.
How to repeat:
1) Create test file mysql-test/t/mpd.test in source tree with the following content:
select count(*) from information_schema.plugins where plugin_name='EXAMPLE';
2) Create options file in source tree for the above test file mysql-test/t/mpd.opt with the following content:
$EXAMPLE_PLUGIN_OPT $EXAMPLE_PLUGIN_LOAD_ADD
This options file tries to load plugins described in mysql-test/include/plugin.defs:
ha_example storage/example EXAMPLE_PLUGIN EXAMPLE
3) Build and install debug version with -DCMAKE_BUILD_TYPE=Debug and -DCMAKE_INSTALL_PREFIX=some_path/mysqld-debug
4) Go to install dir and try to start our empty mtr test
cd some_path/mysqld-debug/mysql-test
./mtr --debug-server mpd
The result should be the following:
select count(*) from information_schema.plugins where plugin_name='EXAMPLE';
count(*)
0
main.mpd [ pass ] 2
What means ha_example plugin was not loaded as there is no correspondent record in I_S.
Why the plugin was not loaded?
Lets look into mysql-test-run.pl:read_plugin_defs():
...
# Need to check if we will be running mysqld-debug
if ($opt_debug_server) {
$running_debug= 1 if find_mysqld($basedir) =~ /mysqld-debug/;
}
while (<PLUGDEF>) {
...
# If running debug server, plugins will be in 'debug' subdirectory
$plug_file= "debug/$plug_file" if $running_debug && !$source_dist;
my ($plugin)= find_plugin($plug_file, $plug_loc);
if (!$plugin) {
($plugin)= find_plugin($plug_file, "rapid/$plug_loc");
}
...
}
mtr expects the plugin is pushed on 'plugin_dir/debug' under some conditions. But there is no 'debug' subdir in 'plugin_dir'.
Why plugin was not installed to expected location? Let's look at MYSQL_ADD_PLUGIN macros in cmake/plugin.cmake.
It uses INSTALL_DEBUG_TARGET macros for installing plugins into 'plugin_dir/debug' directory. The macros is defined in cmake/install_macros.cmake.
If we jump into this macro definition we will see the following lines responsible for forming source path for the file to install:
IF(CMAKE_GENERATOR MATCHES "Makefiles")
STRING(REPLACE "${CMAKE_BINARY_DIR}" "${DEBUGBUILDDIR}" debug_target_location "${target_location}")
ELSE()
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "Debug" debug_target_location "${target_location}" )
ENDIF()
The source patch for file to install is malformed, we can see this if we insert debug output like this:
IF(CMAKE_GENERATOR MATCHES "Makefiles")
+ MESSAGE(status "====>>> ${CMAKE_BINARY_DIR} ${DEBUGBUILDDIR} ${target_location}")
STRING(REPLACE "${CMAKE_BINARY_DIR}" "${DEBUGBUILDDIR}" debug_target_location "${target_location}")
ELSE()
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "Debug" debug_target_location "${target_location}" )
ENDIF()
Plugin can't be found on malformed path and that's why it's not installed into 'plugin_dir/debug' directory.
Suggested fix:
I don't fully understand the reason of installing plugins into "plugin_dir/debug" directory for debug builds and why mtr expects plugins to be installed in such strange location under such strange conditions, so I don't have suggestions about fixing now.