2007-12-12 18:19:24 +01:00
|
|
|
# -*- cperl -*-
|
2011-11-21 19:13:14 +02:00
|
|
|
# Copyright (c) 2007, 2011, Oracle and/or its affiliates
|
2011-01-18 11:03:44 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Library General Public
|
|
|
|
# License as published by the Free Software Foundation; version 2
|
|
|
|
# of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Library General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
package My::ConfigFactory;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Carp;
|
|
|
|
|
|
|
|
use My::Config;
|
|
|
|
use My::Find;
|
2009-11-03 01:19:37 +01:00
|
|
|
use My::Platform;
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
use File::Basename;
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Rules to run first of all
|
|
|
|
#
|
|
|
|
my @pre_rules=
|
|
|
|
(
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2009-10-08 00:57:43 +02:00
|
|
|
my @share_locations= ("share/mariadb", "share/mysql", "sql/share", "share");
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
sub get_basedir {
|
|
|
|
my ($self, $group)= @_;
|
|
|
|
my $basedir= $group->if_exist('basedir') ||
|
|
|
|
$self->{ARGS}->{basedir};
|
|
|
|
return $basedir;
|
|
|
|
}
|
|
|
|
|
2010-06-15 11:16:38 +02:00
|
|
|
sub get_testdir {
|
|
|
|
my ($self, $group)= @_;
|
|
|
|
my $testdir= $group->if_exist('testdir') ||
|
|
|
|
$self->{ARGS}->{testdir};
|
|
|
|
return $testdir;
|
|
|
|
}
|
|
|
|
|
WL#5161 : Cross-platform build with CMake
BUILD-CMAKE:
WL#5161 : Documentation on how to build with CMake on Unix/Windows
BUILD/Makefile.am:
Add new file
BUILD/autorun.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
BUILD/choose_configure.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
CMakeLists.txt:
WL#5161 : Rewrite top-level CMakeLists.txt.
Remove Windows specifics
- compiler flags handling moved to configure.cmake
- storage engine/plugin stuff moved into cmake/plugin.cmake
- copy docs
Makefile.am:
Added new files
client/CMakeLists.txt:
WL#5161 : Rewrite CMakeLists.txt to be platform-independent
Handle packagng (add INSTALL commands)
cmake/Makefile.am:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
cmake/abi_check.cmake:
Custom targets for abi_check (for cmake)
cmake/bison.cmake:
- Check bison availability
- Add RUN_BISON macro (used to create sql_yacc.cc and sql_yacc.h)
cmake/cat.cmake:
Add helper script to concatenate files.
cmake/character_sets.cmake:
Handle configuration parameters WITH_EXTRA_CHARSETS
cmake/check_minimal_version.cmake:
Helper script to check the minimum required version of cmake
cmake/configure.pl:
Add perl script to convert ./configure parameters for cmake
cmake/create_initial_db.cmake.in:
Add script helper to create initial database.
(on Windows, we pack initial db with the redistribution
package)
cmake/do_abi_check.cmake:
Perform abi check
cmake/dtrace.cmake:
Handle dtrace in CMake Build.
Check for dtrace availablility,
run dtrace -G on solaris in prelink step
cmake/dtrace_prelink.cmake:
Run dtrace -G on Solaris in pre-link step,
link the object it creates together with library or
executable
cmake/install_macros.cmake:
Helper macros for packaging
(install pdb on Windows, install symlinks on Unix)
cmake/make_dist.cmake.in:
"make dist" -
- pack autotools ./configure script with the source
(renamed to configure.am)
- pack bison output
cmake/merge_archives_unix.cmake.in:
script to merge static libraries on Unix
cmake/misc.cmake:
Build helper macros
- MERGE_STATIC_LIBS
We use it when building client library and embedded
(avoid recompilation)
- Convert source file paths to absolute names.
We use it in to locate files of a different project,
when the files need to be recompiled (e.g in embedded
several storage engines are recompiled with
-DEMBEDDED_LIBRARY)
cmake/mysql_version.cmake:
Extract version info from configure.in
Handle package names.
cmake/plugin.cmake:
Rewrote storage/mysql_storage_engine.cmake to handle
other types of plugins and do it in OS-independent manner.
cmake/readline.cmake:
Macros to handle WITH_READLINE/WITH_LIBEDIT parameters
cmake/ssl.cmake:
Add macros to handle WITH_SSL parameter.
cmake/stack_direction.c:
Helper to check stack direction.
cmake/zlib.cmake:
Add macros to handle WITH_ZLIB parameter
cmd-line-utils/libedit/CMakeLists.txt:
Build libedit with cmake.
cmd-line-utils/libedit/Makefile.am:
Add new file
cmd-line-utils/readline/CMakeLists.txt:
Build readline with CMake.
cmd-line-utils/readline/Makefile.am:
Add new file
config.h.cmake:
WL#5161 : Add config.h template for cmake
configure.cmake:
WL#5161 : Add platform tests ( for cmake)
configure.in:
Added new subdirectories
dbug/CMakeLists.txt:
WL#5161
extra/CMakeLists.txt:
WL#5161
extra/yassl/CMakeLists.txt:
WL#5161
extra/yassl/taocrypt/CMakeLists.txt:
WL#5161
include/Makefile.am:
Add new file
include/keycache.h:
remove configure-win.h and remove HUGE_PTR defined there.
include/my_global.h:
use my_config.h for Windows, not config-win.h anymore
include/my_pthread.h:
- Move thread_safe_increment from config-win.h to other headers
(config-win.h is not used anymore)
- Declare pthread_cancel on Windows (it is used in daemon_example)
include/my_sys.h:
Add malloc.h on Windows (we use -D_WIN32_LEAN_AND_MEAN now, and
with this define malloc.h is not included automatically via windows.h)
include/mysql/plugin.h:
Handle pure-C plugins with Microsoft compiler.
include/thr_alarm.h:
remove rf_SetTimer that used to be defined in config-win.h
Replace with UINT_PTR (we do not use config-win.h anymore
and typedef was needed in this single place only)
libmysql/CMakeLists.txt:
Avoid pointless recompilation of source files
in client library if possible. Merge static
libs (dbug, mysys) to create static client
library.
libmysqld/CMakeLists.txt:
Avoid pointless recompilation of source files
when building embedded. Instead, merge dbug and
mysys (and some other static libs) into embedded.
libmysqld/examples/CMakeLists.txt:
Embedded compilation on Unix
libmysqld/lib_sql.cc:
Do not define THD::clear_error() in lib_sql.cc
for embedded. Instead, use the same inline
definition from sql_class.h as in none-embedded
case (fixes duplicate symbol errors on Windows
and removes pointless #ifdef EMBEDDED)
man/CMakeLists.txt:
Install man files.
man/Makefile.am:
Add new file.
mysql-test/CMakeLists.txt:
Install mysql-test files
mysql-test/Makefile.am:
Add new files
mysql-test/lib/My/ConfigFactory.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/Find.pm:
the build configurations are now also available on Unix
Xcode on Mac uses the Release, RelwithDebinfo and Debug
subdirectories for executables. Earlier, build configurations
were available only on Windows.
mysql-test/lib/My/SafeProcess.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/SafeProcess/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysql-test/lib/My/SafeProcess/safe_kill_win.cc:
add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
mysql-test/lib/My/SafeProcess/safe_process_win.cc:
Add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE if not defined
(can happen using MinGW compiler that comes with old SDK)
mysql-test/mtr.out-of-source:
Allow testing with mtr in out-of-source builds.
mysql-test/mysql-test-run.pl:
Allow testing with mtr in out-of-source builds.
Use common find_plugin macro for Windows and unix.
mysql-test/t/fulltext_plugin.test:
This test can now run on Windows as well.
mysys/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysys/my_create.c:
config-win.h is dead => NO_OPEN_3 is never defined.
mysys/my_getsystime.c:
config-win.h is dead => define OFFSET_TO_EPOCH where it is used.
mysys/my_winthread.c:
Add win32 pthread_cancel - used by daemon_example
mysys/mysys_priv.h:
config-win.h is dead => include <sys/stat.h> where it is used
fix prototype of my_win_(f)stat
plugin/daemon_example/CMakeLists.txt:
Compile daemon_example with CMake
plugin/daemon_example/Makefile.am:
Add new file
plugin/fulltext/CMakeLists.txt:
Compile full-text example with CMake
plugin/fulltext/Makefile.am:
Add new file.
plugin/semisync/CMakeLists.txt:
Fix semisync to use common macro for plugins.
regex/CMakeLists.txt:
Use absolute filenames, when adding regex library
(we recompile files in embedded, and want to locate
sources via GET_TARGET_PROPERTY( ... SOURCES ..))
regex/regex2.h:
Remove pointless typedef (produces error with MinGW compiler)
scripts/CMakeLists.txt:
Add configure/install for scripts
sql-bench/CMakeLists.txt:
install sql-bench files
sql-bench/Makefile.am:
Add new file
sql/CMakeLists.txt:
Port CmakeLists.txt to Unix
sql/nt_servc.cc:
compile server with -DWIN32_LEAN_AND_MEAN
sql/share/CMakeLists.txt:
Install charsets
sql/share/Makefile.am:
Add new file
sql/sql_builtin.cc.in:
Handle pure-C plugins on Windows.
sql/sql_class.h:
Use the same clear_error macro in embedded and not embedded.
Fixes pointless #ifdef and avoids duplicate symbols when linking
on Windows.
storage/Makefile.am:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
storage/archive/CMakeLists.txt:
Add names for static and dynamic plugin libraries.
Link archive with zlib
storage/blackhole/CMakeLists.txt:
Add names for static and dynamic storage
engine libraries
storage/csv/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/example/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/federated/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/heap/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/ibmdb2i/CMakeLists.txt:
Better port for ibmdb2i plugin
storage/innobase/CMakeLists.txt:
Run system checks.
Add names for static and dynamic storage engine
libraries.
storage/innobase/include/page0page.ic:
Fix compile error on OpenSolaris.
storage/myisam/CMakeLists.txt:
Port CmakeLists.txt to Unix
storage/myisammrg/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/mysql_storage_engine.cmake:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
support-files/CMakeLists.txt:
Configure and install some files from support-files.
support-files/Makefile.am:
Add new file
tests/CMakeLists.txt:
In general case, mysqlclient library can be dependent
on C++ runtime(if it includes yassl and is not compiled
with gcc or MSVC)
unittest/mysys/CMakeLists.txt:
Add unit tests
unittest/mysys/Makefile.am:
Add new file
unittest/mytap/CMakeLists.txt:
Add library for unit tests
unittest/mytap/Makefile.am:
Add new file
unittest/mytap/tap.c:
fix function definitions to match declarations
win/create_def_file.js:
Fix link error with intel compiler (icl
defines of special label for exception handler)
2009-11-09 12:32:48 +01:00
|
|
|
# Retrive build directory (which is different from basedir in out-of-source build)
|
|
|
|
sub get_bindir {
|
|
|
|
if (defined $ENV{MTR_BINDIR})
|
|
|
|
{
|
|
|
|
return $ENV{MTR_BINDIR};
|
|
|
|
}
|
|
|
|
my ($self, $group)= @_;
|
|
|
|
return $self->get_basedir($group);
|
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
sub fix_charset_dir {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
|
|
|
return my_find_dir($self->get_basedir($group),
|
|
|
|
\@share_locations, "charsets");
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_language {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
WL#5161 : Cross-platform build with CMake
BUILD-CMAKE:
WL#5161 : Documentation on how to build with CMake on Unix/Windows
BUILD/Makefile.am:
Add new file
BUILD/autorun.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
BUILD/choose_configure.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
CMakeLists.txt:
WL#5161 : Rewrite top-level CMakeLists.txt.
Remove Windows specifics
- compiler flags handling moved to configure.cmake
- storage engine/plugin stuff moved into cmake/plugin.cmake
- copy docs
Makefile.am:
Added new files
client/CMakeLists.txt:
WL#5161 : Rewrite CMakeLists.txt to be platform-independent
Handle packagng (add INSTALL commands)
cmake/Makefile.am:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
cmake/abi_check.cmake:
Custom targets for abi_check (for cmake)
cmake/bison.cmake:
- Check bison availability
- Add RUN_BISON macro (used to create sql_yacc.cc and sql_yacc.h)
cmake/cat.cmake:
Add helper script to concatenate files.
cmake/character_sets.cmake:
Handle configuration parameters WITH_EXTRA_CHARSETS
cmake/check_minimal_version.cmake:
Helper script to check the minimum required version of cmake
cmake/configure.pl:
Add perl script to convert ./configure parameters for cmake
cmake/create_initial_db.cmake.in:
Add script helper to create initial database.
(on Windows, we pack initial db with the redistribution
package)
cmake/do_abi_check.cmake:
Perform abi check
cmake/dtrace.cmake:
Handle dtrace in CMake Build.
Check for dtrace availablility,
run dtrace -G on solaris in prelink step
cmake/dtrace_prelink.cmake:
Run dtrace -G on Solaris in pre-link step,
link the object it creates together with library or
executable
cmake/install_macros.cmake:
Helper macros for packaging
(install pdb on Windows, install symlinks on Unix)
cmake/make_dist.cmake.in:
"make dist" -
- pack autotools ./configure script with the source
(renamed to configure.am)
- pack bison output
cmake/merge_archives_unix.cmake.in:
script to merge static libraries on Unix
cmake/misc.cmake:
Build helper macros
- MERGE_STATIC_LIBS
We use it when building client library and embedded
(avoid recompilation)
- Convert source file paths to absolute names.
We use it in to locate files of a different project,
when the files need to be recompiled (e.g in embedded
several storage engines are recompiled with
-DEMBEDDED_LIBRARY)
cmake/mysql_version.cmake:
Extract version info from configure.in
Handle package names.
cmake/plugin.cmake:
Rewrote storage/mysql_storage_engine.cmake to handle
other types of plugins and do it in OS-independent manner.
cmake/readline.cmake:
Macros to handle WITH_READLINE/WITH_LIBEDIT parameters
cmake/ssl.cmake:
Add macros to handle WITH_SSL parameter.
cmake/stack_direction.c:
Helper to check stack direction.
cmake/zlib.cmake:
Add macros to handle WITH_ZLIB parameter
cmd-line-utils/libedit/CMakeLists.txt:
Build libedit with cmake.
cmd-line-utils/libedit/Makefile.am:
Add new file
cmd-line-utils/readline/CMakeLists.txt:
Build readline with CMake.
cmd-line-utils/readline/Makefile.am:
Add new file
config.h.cmake:
WL#5161 : Add config.h template for cmake
configure.cmake:
WL#5161 : Add platform tests ( for cmake)
configure.in:
Added new subdirectories
dbug/CMakeLists.txt:
WL#5161
extra/CMakeLists.txt:
WL#5161
extra/yassl/CMakeLists.txt:
WL#5161
extra/yassl/taocrypt/CMakeLists.txt:
WL#5161
include/Makefile.am:
Add new file
include/keycache.h:
remove configure-win.h and remove HUGE_PTR defined there.
include/my_global.h:
use my_config.h for Windows, not config-win.h anymore
include/my_pthread.h:
- Move thread_safe_increment from config-win.h to other headers
(config-win.h is not used anymore)
- Declare pthread_cancel on Windows (it is used in daemon_example)
include/my_sys.h:
Add malloc.h on Windows (we use -D_WIN32_LEAN_AND_MEAN now, and
with this define malloc.h is not included automatically via windows.h)
include/mysql/plugin.h:
Handle pure-C plugins with Microsoft compiler.
include/thr_alarm.h:
remove rf_SetTimer that used to be defined in config-win.h
Replace with UINT_PTR (we do not use config-win.h anymore
and typedef was needed in this single place only)
libmysql/CMakeLists.txt:
Avoid pointless recompilation of source files
in client library if possible. Merge static
libs (dbug, mysys) to create static client
library.
libmysqld/CMakeLists.txt:
Avoid pointless recompilation of source files
when building embedded. Instead, merge dbug and
mysys (and some other static libs) into embedded.
libmysqld/examples/CMakeLists.txt:
Embedded compilation on Unix
libmysqld/lib_sql.cc:
Do not define THD::clear_error() in lib_sql.cc
for embedded. Instead, use the same inline
definition from sql_class.h as in none-embedded
case (fixes duplicate symbol errors on Windows
and removes pointless #ifdef EMBEDDED)
man/CMakeLists.txt:
Install man files.
man/Makefile.am:
Add new file.
mysql-test/CMakeLists.txt:
Install mysql-test files
mysql-test/Makefile.am:
Add new files
mysql-test/lib/My/ConfigFactory.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/Find.pm:
the build configurations are now also available on Unix
Xcode on Mac uses the Release, RelwithDebinfo and Debug
subdirectories for executables. Earlier, build configurations
were available only on Windows.
mysql-test/lib/My/SafeProcess.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/SafeProcess/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysql-test/lib/My/SafeProcess/safe_kill_win.cc:
add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
mysql-test/lib/My/SafeProcess/safe_process_win.cc:
Add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE if not defined
(can happen using MinGW compiler that comes with old SDK)
mysql-test/mtr.out-of-source:
Allow testing with mtr in out-of-source builds.
mysql-test/mysql-test-run.pl:
Allow testing with mtr in out-of-source builds.
Use common find_plugin macro for Windows and unix.
mysql-test/t/fulltext_plugin.test:
This test can now run on Windows as well.
mysys/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysys/my_create.c:
config-win.h is dead => NO_OPEN_3 is never defined.
mysys/my_getsystime.c:
config-win.h is dead => define OFFSET_TO_EPOCH where it is used.
mysys/my_winthread.c:
Add win32 pthread_cancel - used by daemon_example
mysys/mysys_priv.h:
config-win.h is dead => include <sys/stat.h> where it is used
fix prototype of my_win_(f)stat
plugin/daemon_example/CMakeLists.txt:
Compile daemon_example with CMake
plugin/daemon_example/Makefile.am:
Add new file
plugin/fulltext/CMakeLists.txt:
Compile full-text example with CMake
plugin/fulltext/Makefile.am:
Add new file.
plugin/semisync/CMakeLists.txt:
Fix semisync to use common macro for plugins.
regex/CMakeLists.txt:
Use absolute filenames, when adding regex library
(we recompile files in embedded, and want to locate
sources via GET_TARGET_PROPERTY( ... SOURCES ..))
regex/regex2.h:
Remove pointless typedef (produces error with MinGW compiler)
scripts/CMakeLists.txt:
Add configure/install for scripts
sql-bench/CMakeLists.txt:
install sql-bench files
sql-bench/Makefile.am:
Add new file
sql/CMakeLists.txt:
Port CmakeLists.txt to Unix
sql/nt_servc.cc:
compile server with -DWIN32_LEAN_AND_MEAN
sql/share/CMakeLists.txt:
Install charsets
sql/share/Makefile.am:
Add new file
sql/sql_builtin.cc.in:
Handle pure-C plugins on Windows.
sql/sql_class.h:
Use the same clear_error macro in embedded and not embedded.
Fixes pointless #ifdef and avoids duplicate symbols when linking
on Windows.
storage/Makefile.am:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
storage/archive/CMakeLists.txt:
Add names for static and dynamic plugin libraries.
Link archive with zlib
storage/blackhole/CMakeLists.txt:
Add names for static and dynamic storage
engine libraries
storage/csv/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/example/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/federated/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/heap/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/ibmdb2i/CMakeLists.txt:
Better port for ibmdb2i plugin
storage/innobase/CMakeLists.txt:
Run system checks.
Add names for static and dynamic storage engine
libraries.
storage/innobase/include/page0page.ic:
Fix compile error on OpenSolaris.
storage/myisam/CMakeLists.txt:
Port CmakeLists.txt to Unix
storage/myisammrg/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/mysql_storage_engine.cmake:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
support-files/CMakeLists.txt:
Configure and install some files from support-files.
support-files/Makefile.am:
Add new file
tests/CMakeLists.txt:
In general case, mysqlclient library can be dependent
on C++ runtime(if it includes yassl and is not compiled
with gcc or MSVC)
unittest/mysys/CMakeLists.txt:
Add unit tests
unittest/mysys/Makefile.am:
Add new file
unittest/mytap/CMakeLists.txt:
Add library for unit tests
unittest/mytap/Makefile.am:
Add new file
unittest/mytap/tap.c:
fix function definitions to match declarations
win/create_def_file.js:
Fix link error with intel compiler (icl
defines of special label for exception handler)
2009-11-09 12:32:48 +01:00
|
|
|
return my_find_dir($self->get_bindir($group),
|
2009-10-15 17:23:43 +05:00
|
|
|
\@share_locations);
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_datadir {
|
|
|
|
my ($self, $config, $group_name)= @_;
|
|
|
|
my $vardir= $self->{ARGS}->{vardir};
|
|
|
|
return "$vardir/$group_name/data";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_pidfile {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
|
|
|
my $vardir= $self->{ARGS}->{vardir};
|
|
|
|
return "$vardir/run/$group_name.pid";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_port {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
2010-08-17 11:14:46 +04:00
|
|
|
return $self->{PORT}++;
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_host {
|
|
|
|
my ($self)= @_;
|
2010-08-17 11:14:46 +04:00
|
|
|
'localhost'
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub is_unique {
|
|
|
|
my ($config, $name, $value)= @_;
|
|
|
|
|
|
|
|
foreach my $group ( $config->groups() ) {
|
|
|
|
if ($group->option($name)) {
|
|
|
|
if ($group->value($name) eq $value){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_server_id {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
|
|
|
#define in the order that mysqlds are listed in my.cnf
|
|
|
|
|
|
|
|
my $server_id= $group->if_exist('server-id');
|
|
|
|
if (defined $server_id){
|
|
|
|
if (!is_unique($config, 'server-id', $server_id)) {
|
|
|
|
croak "The server-id($server_id) for '$group_name' is not unique";
|
|
|
|
}
|
|
|
|
return $server_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
$server_id= $self->{SERVER_ID}++;
|
|
|
|
} while(!is_unique($config, 'server-id', $server_id));
|
|
|
|
|
|
|
|
#print "$group_name: server_id: $server_id\n";
|
|
|
|
return $server_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_socket {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
|
|
|
# Put socket file in tmpdir
|
2008-05-06 17:11:09 +02:00
|
|
|
my $dir= $self->{ARGS}->{tmpdir};
|
2007-12-12 18:19:24 +01:00
|
|
|
return "$dir/$group_name.sock";
|
|
|
|
}
|
|
|
|
|
2008-05-06 17:11:09 +02:00
|
|
|
sub fix_tmpdir {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
|
|
|
my $dir= $self->{ARGS}->{tmpdir};
|
|
|
|
return "$dir/$group_name";
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub fix_log_error {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
2009-03-02 13:48:35 +01:00
|
|
|
my $dir= $self->{ARGS}->{vardir};
|
2011-04-18 11:47:14 +02:00
|
|
|
if ( $::opt_valgrind and $::opt_debug ) {
|
|
|
|
return "$dir/log/$group_name.trace";
|
|
|
|
} else {
|
|
|
|
return "$dir/log/$group_name.err";
|
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_log {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
|
|
|
my $dir= dirname($group->value('datadir'));
|
|
|
|
return "$dir/mysqld.log";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_log_slow_queries {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
|
|
|
my $dir= dirname($group->value('datadir'));
|
|
|
|
return "$dir/mysqld-slow.log";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_std_data {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
2010-06-15 11:16:38 +02:00
|
|
|
my $testdir= $self->get_testdir($group);
|
|
|
|
return "$testdir/std_data";
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
|
2007-12-13 15:02:50 +01:00
|
|
|
sub ssl_supported {
|
|
|
|
my ($self)= @_;
|
|
|
|
return $self->{ARGS}->{ssl};
|
|
|
|
}
|
|
|
|
|
2009-01-27 14:21:18 +01:00
|
|
|
sub fix_skip_ssl {
|
|
|
|
return if !ssl_supported(@_);
|
|
|
|
# Add skip-ssl if ssl is supported to avoid
|
|
|
|
# that mysqltest connects with SSL by default
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub fix_ssl_ca {
|
2007-12-13 15:02:50 +01:00
|
|
|
return if !ssl_supported(@_);
|
2007-12-12 18:19:24 +01:00
|
|
|
my $std_data= fix_std_data(@_);
|
|
|
|
return "$std_data/cacert.pem"
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_ssl_server_cert {
|
2007-12-13 15:02:50 +01:00
|
|
|
return if !ssl_supported(@_);
|
2007-12-12 18:19:24 +01:00
|
|
|
my $std_data= fix_std_data(@_);
|
|
|
|
return "$std_data/server-cert.pem"
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_ssl_client_cert {
|
2007-12-13 15:02:50 +01:00
|
|
|
return if !ssl_supported(@_);
|
2007-12-12 18:19:24 +01:00
|
|
|
my $std_data= fix_std_data(@_);
|
|
|
|
return "$std_data/client-cert.pem"
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_ssl_server_key {
|
2007-12-13 15:02:50 +01:00
|
|
|
return if !ssl_supported(@_);
|
2007-12-12 18:19:24 +01:00
|
|
|
my $std_data= fix_std_data(@_);
|
|
|
|
return "$std_data/server-key.pem"
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fix_ssl_client_key {
|
2007-12-13 15:02:50 +01:00
|
|
|
return if !ssl_supported(@_);
|
2007-12-12 18:19:24 +01:00
|
|
|
my $std_data= fix_std_data(@_);
|
|
|
|
return "$std_data/client-key.pem"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Rules to run for each mysqld in the config
|
|
|
|
# - will be run in order listed here
|
|
|
|
#
|
|
|
|
my @mysqld_rules=
|
|
|
|
(
|
|
|
|
{ 'basedir' => sub { return shift->{ARGS}->{basedir}; } },
|
2008-05-06 17:11:09 +02:00
|
|
|
{ 'tmpdir' => \&fix_tmpdir },
|
2007-12-12 18:19:24 +01:00
|
|
|
{ 'character-sets-dir' => \&fix_charset_dir },
|
2009-10-15 17:23:43 +05:00
|
|
|
{ 'lc-messages-dir' => \&fix_language },
|
2007-12-12 18:19:24 +01:00
|
|
|
{ 'datadir' => \&fix_datadir },
|
|
|
|
{ 'pid-file' => \&fix_pidfile },
|
|
|
|
{ '#host' => \&fix_host },
|
|
|
|
{ 'port' => \&fix_port },
|
|
|
|
{ 'socket' => \&fix_socket },
|
2009-03-02 13:48:35 +01:00
|
|
|
{ '#log-error' => \&fix_log_error },
|
2009-02-15 12:58:34 +02:00
|
|
|
{ 'general-log' => sub { return 1; } },
|
|
|
|
{ 'general-log-file' => \&fix_log },
|
|
|
|
{ 'slow-query-log' => sub { return 1; } },
|
2009-11-16 21:49:51 +01:00
|
|
|
{ 'slow-query-log-file' => \&fix_log_slow_queries },
|
2007-12-12 18:19:24 +01:00
|
|
|
{ '#user' => sub { return shift->{ARGS}->{user} || ""; } },
|
|
|
|
{ '#password' => sub { return shift->{ARGS}->{password} || ""; } },
|
|
|
|
{ 'server-id' => \&fix_server_id, },
|
2007-12-13 15:02:50 +01:00
|
|
|
{ 'ssl-ca' => \&fix_ssl_ca },
|
|
|
|
{ 'ssl-cert' => \&fix_ssl_server_cert },
|
|
|
|
{ 'ssl-key' => \&fix_ssl_server_key },
|
2007-12-12 18:19:24 +01:00
|
|
|
);
|
|
|
|
|
2009-11-03 01:19:37 +01:00
|
|
|
if (IS_WINDOWS)
|
|
|
|
{
|
|
|
|
# For simplicity, we use the same names for shared memory and
|
|
|
|
# named pipes.
|
|
|
|
push(@mysqld_rules, {'shared-memory-base-name' => \&fix_socket});
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub fix_ndb_mgmd_port {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
|
|
|
my $hostname= $group->value('HostName');
|
2010-08-17 11:14:46 +04:00
|
|
|
return $self->{PORT}++;
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub fix_cluster_dir {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
|
|
|
my $vardir= $self->{ARGS}->{vardir};
|
|
|
|
my (undef, $process_type, $idx, $suffix)= split(/\./, $group_name);
|
|
|
|
return "$vardir/mysql_cluster.$suffix/$process_type.$idx";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub fix_cluster_backup_dir {
|
|
|
|
my ($self, $config, $group_name, $group)= @_;
|
|
|
|
my $vardir= $self->{ARGS}->{vardir};
|
|
|
|
my (undef, $process_type, $idx, $suffix)= split(/\./, $group_name);
|
|
|
|
return "$vardir/mysql_cluster.$suffix/";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Rules to run for each ndb_mgmd in the config
|
|
|
|
# - will be run in order listed here
|
|
|
|
#
|
|
|
|
my @ndb_mgmd_rules=
|
|
|
|
(
|
|
|
|
{ 'PortNumber' => \&fix_ndb_mgmd_port },
|
|
|
|
{ 'DataDir' => \&fix_cluster_dir },
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Rules to run for each ndbd in the config
|
|
|
|
# - will be run in order listed here
|
|
|
|
#
|
|
|
|
my @ndbd_rules=
|
|
|
|
(
|
|
|
|
{ 'HostName' => \&fix_host },
|
|
|
|
{ 'DataDir' => \&fix_cluster_dir },
|
|
|
|
{ 'BackupDataDir' => \&fix_cluster_backup_dir },
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Rules to run for each cluster_config section
|
|
|
|
# - will be run in order listed here
|
|
|
|
#
|
|
|
|
my @cluster_config_rules=
|
|
|
|
(
|
|
|
|
{ 'ndb_mgmd' => \&fix_host },
|
|
|
|
{ 'ndbd' => \&fix_host },
|
|
|
|
{ 'mysqld' => \&fix_host },
|
|
|
|
{ 'ndbapi' => \&fix_host },
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Rules to run for [client] section
|
|
|
|
# - will be run in order listed here
|
|
|
|
#
|
|
|
|
my @client_rules=
|
|
|
|
(
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Rules to run for [mysqltest] section
|
|
|
|
# - will be run in order listed here
|
|
|
|
#
|
|
|
|
my @mysqltest_rules=
|
|
|
|
(
|
2007-12-13 15:02:50 +01:00
|
|
|
{ 'ssl-ca' => \&fix_ssl_ca },
|
|
|
|
{ 'ssl-cert' => \&fix_ssl_client_cert },
|
|
|
|
{ 'ssl-key' => \&fix_ssl_client_key },
|
2009-01-27 14:21:18 +01:00
|
|
|
{ 'skip-ssl' => \&fix_skip_ssl },
|
2007-12-12 18:19:24 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Rules to run for [mysqlbinlog] section
|
|
|
|
# - will be run in order listed here
|
|
|
|
#
|
|
|
|
my @mysqlbinlog_rules=
|
|
|
|
(
|
|
|
|
{ 'character-sets-dir' => \&fix_charset_dir },
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2008-06-19 10:07:55 +02:00
|
|
|
#
|
|
|
|
# Rules to run for [mysql_upgrade] section
|
|
|
|
# - will be run in order listed here
|
|
|
|
#
|
|
|
|
my @mysql_upgrade_rules=
|
|
|
|
(
|
|
|
|
{ 'tmpdir' => sub { return shift->{ARGS}->{tmpdir}; } },
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
#
|
2008-02-22 15:38:10 +01:00
|
|
|
# Generate a [client.<suffix>] group to be
|
2007-12-12 18:19:24 +01:00
|
|
|
# used for connecting to [mysqld.<suffix>]
|
|
|
|
#
|
|
|
|
sub post_check_client_group {
|
|
|
|
my ($self, $config, $client_group_name, $mysqld_group_name)= @_;
|
|
|
|
|
2009-11-20 16:41:07 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Settings needed for client, copied from its "mysqld"
|
|
|
|
my %client_needs=
|
|
|
|
(
|
|
|
|
port => 'port',
|
|
|
|
socket => 'socket',
|
|
|
|
host => '#host',
|
|
|
|
user => '#user',
|
|
|
|
password => '#password',
|
|
|
|
);
|
|
|
|
my $group_to_copy_from= $config->group($mysqld_group_name);
|
|
|
|
while (my ($name_to, $name_from)= each( %client_needs )) {
|
|
|
|
my $option= $group_to_copy_from->option($name_from);
|
|
|
|
|
|
|
|
if (! defined $option){
|
|
|
|
#print $config;
|
2011-02-23 02:00:30 +02:00
|
|
|
croak "Could not get value for '$name_from' for test $self->{testname}";
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
$config->insert($client_group_name, $name_to, $option->value())
|
|
|
|
}
|
2009-11-03 01:19:37 +01:00
|
|
|
|
|
|
|
if (IS_WINDOWS)
|
|
|
|
{
|
2009-11-25 16:12:23 +04:00
|
|
|
if (! $self->{ARGS}->{embedded})
|
2009-11-03 01:19:37 +01:00
|
|
|
{
|
2009-11-25 16:12:23 +04:00
|
|
|
# Shared memory base may or may not be defined (e.g not defined in embedded)
|
|
|
|
my $shm = $group_to_copy_from->option("shared-memory-base-name");
|
|
|
|
if (defined $shm)
|
|
|
|
{
|
|
|
|
$config->insert($client_group_name,"shared-memory-base-name", $shm->value());
|
|
|
|
}
|
2009-11-03 01:19:37 +01:00
|
|
|
}
|
|
|
|
}
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub post_check_client_groups {
|
|
|
|
my ($self, $config)= @_;
|
|
|
|
|
2009-03-18 16:46:32 +01:00
|
|
|
my $first_mysqld= $config->first_like('mysqld\.');
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
return unless $first_mysqld;
|
|
|
|
|
|
|
|
# Always generate [client] pointing to the first
|
|
|
|
# [mysqld.<suffix>]
|
|
|
|
$self->post_check_client_group($config,
|
|
|
|
'client',
|
|
|
|
$first_mysqld->name());
|
|
|
|
|
|
|
|
# Then generate [client.<suffix>] for each [mysqld.<suffix>]
|
|
|
|
foreach my $mysqld ( $config->like('mysqld.') ) {
|
|
|
|
$self->post_check_client_group($config,
|
|
|
|
'client'.$mysqld->after('mysqld'),
|
|
|
|
$mysqld->name())
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-22 15:38:10 +01:00
|
|
|
#
|
|
|
|
# Generate [embedded] by copying the values
|
2008-03-12 12:35:30 +01:00
|
|
|
# needed from the default [mysqld] section
|
|
|
|
# and from first [mysqld.<suffix>]
|
2008-02-22 15:38:10 +01:00
|
|
|
#
|
|
|
|
sub post_check_embedded_group {
|
2008-02-25 16:41:59 +01:00
|
|
|
my ($self, $config)= @_;
|
2008-02-22 15:38:10 +01:00
|
|
|
|
2008-02-25 16:41:59 +01:00
|
|
|
return unless $self->{ARGS}->{embedded};
|
2008-02-22 15:38:10 +01:00
|
|
|
|
2008-03-12 12:35:30 +01:00
|
|
|
my $mysqld= $config->group('mysqld') or
|
|
|
|
croak "Can't run with embedded, config has no default mysqld section";
|
|
|
|
|
2008-02-25 16:41:59 +01:00
|
|
|
my $first_mysqld= $config->first_like('mysqld.') or
|
|
|
|
croak "Can't run with embedded, config has no mysqld";
|
|
|
|
|
|
|
|
my @no_copy =
|
|
|
|
(
|
2009-03-02 13:48:35 +01:00
|
|
|
'#log-error', # Embedded server writes stderr to mysqltest's log file
|
2008-03-12 12:35:30 +01:00
|
|
|
'slave-net-timeout', # Embedded server are not build with replication
|
2009-11-03 01:19:37 +01:00
|
|
|
'shared-memory-base-name', # No shared memory for embedded
|
2008-02-25 16:41:59 +01:00
|
|
|
);
|
2008-02-22 15:38:10 +01:00
|
|
|
|
2008-03-12 12:35:30 +01:00
|
|
|
foreach my $option ( $mysqld->options(), $first_mysqld->options() ) {
|
2008-02-25 16:41:59 +01:00
|
|
|
# Don't copy options whose name is in "no_copy" list
|
|
|
|
next if grep ( $option->name() eq $_, @no_copy);
|
|
|
|
|
2008-02-22 15:38:10 +01:00
|
|
|
$config->insert('embedded', $option->name(), $option->value())
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub resolve_at_variable {
|
|
|
|
my ($self, $config, $group, $option)= @_;
|
2010-08-17 11:14:46 +04:00
|
|
|
local $_ = $option->value();
|
|
|
|
my ($res, $after);
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2010-08-17 11:14:46 +04:00
|
|
|
while (m/(.*?)\@((?:\w+\.)+)(#?[-\w]+)/g) {
|
|
|
|
my ($before, $group_name, $option_name)= ($1, $2, $3);
|
|
|
|
$after = $';
|
|
|
|
chop($group_name);
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
my $from_group= $config->group($group_name)
|
|
|
|
or croak "There is no group named '$group_name' that ",
|
2011-02-23 02:00:30 +02:00
|
|
|
"can be used to resolve '$option_name' for test '$self->{testname}'";
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2010-08-17 11:14:46 +04:00
|
|
|
my $value= $from_group->value($option_name);
|
|
|
|
$res .= $before.$value;
|
|
|
|
}
|
|
|
|
$res .= $after;
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2010-08-17 11:14:46 +04:00
|
|
|
$config->insert($group->name(), $option->name(), $res)
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub post_fix_resolve_at_variables {
|
|
|
|
my ($self, $config)= @_;
|
|
|
|
|
|
|
|
foreach my $group ( $config->groups() ) {
|
|
|
|
foreach my $option ( $group->options()) {
|
|
|
|
next unless defined $option->value();
|
|
|
|
|
|
|
|
$self->resolve_at_variable($config, $group, $option)
|
2010-08-17 11:14:46 +04:00
|
|
|
if ($option->value() =~ /\@/);
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub post_fix_mysql_cluster_section {
|
|
|
|
my ($self, $config)= @_;
|
|
|
|
|
|
|
|
# Add a [mysl_cluster.<suffix>] section for each
|
|
|
|
# defined [cluster_config.<suffix>] section
|
2008-04-25 16:09:25 +02:00
|
|
|
foreach my $group ( $config->like('cluster_config\.\w*$') )
|
2007-12-12 18:19:24 +01:00
|
|
|
{
|
|
|
|
my @urls;
|
|
|
|
# Generate ndb_connectstring for this cluster
|
|
|
|
foreach my $ndb_mgmd ( $config->like('cluster_config.ndb_mgmd.')) {
|
|
|
|
if ($ndb_mgmd->suffix() eq $group->suffix()) {
|
|
|
|
my $host= $ndb_mgmd->value('HostName');
|
|
|
|
my $port= $ndb_mgmd->value('PortNumber');
|
|
|
|
push(@urls, "$host:$port");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
croak "Could not generate valid ndb_connectstring for '$group'"
|
|
|
|
unless @urls > 0;
|
|
|
|
my $ndb_connectstring= join(";", @urls);
|
|
|
|
|
|
|
|
# Add ndb_connectstring to [mysql_cluster.<suffix>]
|
|
|
|
$config->insert('mysql_cluster'.$group->suffix(),
|
|
|
|
'ndb_connectstring', $ndb_connectstring);
|
|
|
|
|
|
|
|
# Add ndb_connectstring to each mysqld connected to this
|
|
|
|
# cluster
|
|
|
|
foreach my $mysqld ( $config->like('cluster_config.mysqld.')) {
|
|
|
|
if ($mysqld->suffix() eq $group->suffix()) {
|
|
|
|
my $after= $mysqld->after('cluster_config.mysqld');
|
|
|
|
$config->insert("mysqld$after",
|
|
|
|
'ndb_connectstring', $ndb_connectstring);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Rules to run last of all
|
|
|
|
#
|
|
|
|
my @post_rules=
|
|
|
|
(
|
|
|
|
\&post_check_client_groups,
|
|
|
|
\&post_fix_mysql_cluster_section,
|
|
|
|
\&post_fix_resolve_at_variables,
|
2008-02-22 15:38:10 +01:00
|
|
|
\&post_check_embedded_group,
|
2007-12-12 18:19:24 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
sub run_rules_for_group {
|
|
|
|
my ($self, $config, $group, @rules)= @_;
|
|
|
|
foreach my $hash ( @rules ) {
|
|
|
|
while (my ($option, $rule)= each( %{$hash} )) {
|
|
|
|
# Only run this rule if the value is not already defined
|
|
|
|
if (!$config->exists($group->name(), $option)) {
|
|
|
|
my $value;
|
|
|
|
if (ref $rule eq "CODE") {
|
|
|
|
# Call the rule function
|
|
|
|
$value= &$rule($self, $config, $group->name(),
|
|
|
|
$config->group($group->name()));
|
|
|
|
} else {
|
|
|
|
$value= $rule;
|
|
|
|
}
|
|
|
|
if (defined $value) {
|
|
|
|
$config->insert($group->name(), $option, $value, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub run_section_rules {
|
|
|
|
my ($self, $config, $name, @rules)= @_;
|
|
|
|
|
|
|
|
foreach my $group ( $config->like($name) ) {
|
|
|
|
$self->run_rules_for_group($config, $group, @rules);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub run_generate_sections_from_cluster_config {
|
|
|
|
my ($self, $config)= @_;
|
|
|
|
|
|
|
|
my @options= ('ndb_mgmd', 'ndbd',
|
|
|
|
'mysqld', 'ndbapi');
|
|
|
|
|
2008-04-25 16:09:25 +02:00
|
|
|
foreach my $group ( $config->like('cluster_config\.\w*$') ) {
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
# Keep track of current index per process type
|
|
|
|
my %idxes;
|
|
|
|
map { $idxes{$_}= 1; } @options;
|
|
|
|
|
|
|
|
foreach my $option_name ( @options ) {
|
|
|
|
my $value= $group->value($option_name);
|
|
|
|
my @hosts= split(/,/, $value, -1); # -1 => return also empty strings
|
|
|
|
|
|
|
|
# Add at least one host
|
|
|
|
push(@hosts, undef) unless scalar(@hosts);
|
|
|
|
|
|
|
|
# Assign hosts unless already fixed
|
|
|
|
@hosts= map { $self->fix_host() unless $_; } @hosts;
|
|
|
|
|
|
|
|
# Write the hosts value back
|
|
|
|
$group->insert($option_name, join(",", @hosts));
|
|
|
|
|
|
|
|
# Generate sections for each host
|
|
|
|
foreach my $host ( @hosts ){
|
|
|
|
my $idx= $idxes{$option_name}++;
|
|
|
|
|
|
|
|
my $suffix= $group->suffix();
|
|
|
|
# Generate a section for ndb_mgmd to read
|
|
|
|
$config->insert("cluster_config.$option_name.$idx$suffix",
|
|
|
|
"HostName", $host);
|
|
|
|
|
|
|
|
if ($option_name eq 'mysqld'){
|
|
|
|
my $datadir=
|
|
|
|
$self->fix_cluster_dir($config,
|
|
|
|
"cluster_config.mysqld.$idx$suffix",
|
|
|
|
$group);
|
|
|
|
$config->insert("mysqld.$idx$suffix",
|
|
|
|
'datadir', "$datadir/data");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub new_config {
|
|
|
|
my ($class, $args)= @_;
|
|
|
|
|
|
|
|
my @required_args= ('basedir', 'baseport', 'vardir', 'template_path');
|
|
|
|
|
|
|
|
foreach my $required ( @required_args ) {
|
|
|
|
croak "you must pass '$required'" unless defined $args->{$required};
|
|
|
|
}
|
|
|
|
|
|
|
|
# Open the config template
|
|
|
|
my $config= My::Config->new($args->{'template_path'});
|
|
|
|
my $self= bless {
|
|
|
|
CONFIG => $config,
|
|
|
|
ARGS => $args,
|
2010-08-17 11:14:46 +04:00
|
|
|
PORT => $args->{baseport},
|
2007-12-12 18:19:24 +01:00
|
|
|
SERVER_ID => 1,
|
2011-02-23 02:00:30 +02:00
|
|
|
testname => $args->{testname},
|
2007-12-12 18:19:24 +01:00
|
|
|
}, $class;
|
|
|
|
|
2010-08-17 11:14:46 +04:00
|
|
|
# add auto-options
|
|
|
|
$config->insert('OPT', 'port' => sub { fix_port($self, $config) });
|
2010-08-29 19:02:26 +02:00
|
|
|
$config->insert('OPT', 'vardir' => sub { $self->{ARGS}->{vardir} });
|
2011-07-02 22:12:12 +02:00
|
|
|
$config->insert('OPT', 'plugindir' => sub { $::plugindir });
|
2007-12-12 18:19:24 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
# Run pre rules
|
|
|
|
foreach my $rule ( @pre_rules ) {
|
|
|
|
&$rule($self, $config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$self->run_section_rules($config,
|
2008-04-25 16:09:25 +02:00
|
|
|
'cluster_config\.\w*$',
|
2007-12-12 18:19:24 +01:00
|
|
|
@cluster_config_rules);
|
|
|
|
$self->run_generate_sections_from_cluster_config($config);
|
|
|
|
|
|
|
|
$self->run_section_rules($config,
|
|
|
|
'cluster_config.ndb_mgmd.',
|
|
|
|
@ndb_mgmd_rules);
|
|
|
|
$self->run_section_rules($config,
|
|
|
|
'cluster_config.ndbd',
|
|
|
|
@ndbd_rules);
|
|
|
|
|
|
|
|
$self->run_section_rules($config,
|
|
|
|
'mysqld.',
|
|
|
|
@mysqld_rules);
|
|
|
|
|
|
|
|
# [mysqlbinlog] need additional settings
|
|
|
|
$self->run_rules_for_group($config,
|
|
|
|
$config->insert('mysqlbinlog'),
|
|
|
|
@mysqlbinlog_rules);
|
|
|
|
|
2008-06-19 10:07:55 +02:00
|
|
|
# [mysql_upgrade] need additional settings
|
|
|
|
$self->run_rules_for_group($config,
|
|
|
|
$config->insert('mysql_upgrade'),
|
|
|
|
@mysql_upgrade_rules);
|
|
|
|
|
2008-02-22 15:38:10 +01:00
|
|
|
# Additional rules required for [client]
|
2007-12-12 18:19:24 +01:00
|
|
|
$self->run_rules_for_group($config,
|
|
|
|
$config->insert('client'),
|
|
|
|
@client_rules);
|
|
|
|
|
|
|
|
|
2008-02-22 15:38:10 +01:00
|
|
|
# Additional rules required for [mysqltest]
|
2007-12-12 18:19:24 +01:00
|
|
|
$self->run_rules_for_group($config,
|
|
|
|
$config->insert('mysqltest'),
|
|
|
|
@mysqltest_rules);
|
|
|
|
|
|
|
|
{
|
|
|
|
# Run post rules
|
|
|
|
foreach my $rule ( @post_rules ) {
|
|
|
|
&$rule($self, $config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $config;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
1;
|
|
|
|
|