Merging with 5.1-bugteam.

This commit is contained in:
Mats Kindahl 2009-02-09 23:51:59 +01:00
commit 8a98664d3b
1446 changed files with 30517 additions and 16406 deletions

View File

@ -1289,6 +1289,7 @@ mysql-test/funcs_1.log
mysql-test/funcs_1.tar mysql-test/funcs_1.tar
mysql-test/gmon.out mysql-test/gmon.out
mysql-test/install_test_db mysql-test/install_test_db
mysql-test/lib/My/SafeProcess/my_safe_process
mysql-test/lib/init_db.sql mysql-test/lib/init_db.sql
mysql-test/linux_sys_vars.inc mysql-test/linux_sys_vars.inc
mysql-test/load_sysvars.inc mysql-test/load_sysvars.inc
@ -2097,10 +2098,13 @@ sql/.libs/udf_example.lai
sql/.libs/udf_example.so.0 sql/.libs/udf_example.so.0
sql/.libs/udf_example.so.0.0.0 sql/.libs/udf_example.so.0.0.0
sql/client.c sql/client.c
sql/Doxyfile
sql/f.c sql/f.c
sql/gen_lex_hash sql/gen_lex_hash
sql/gmon.out sql/gmon.out
sql/handlerton.cc sql/handlerton.cc
sql/html
sql/latex
sql/lex_hash.h sql/lex_hash.h
sql/link_sources sql/link_sources
sql/max/* sql/max/*

View File

@ -259,3 +259,4 @@ IF(WITH_EMBEDDED_SERVER)
ADD_SUBDIRECTORY(libmysqld) ADD_SUBDIRECTORY(libmysqld)
ADD_SUBDIRECTORY(libmysqld/examples) ADD_SUBDIRECTORY(libmysqld/examples)
ENDIF(WITH_EMBEDDED_SERVER) ENDIF(WITH_EMBEDDED_SERVER)
ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)

View File

@ -121,6 +121,10 @@ test-reprepare:
test: test-unit test-ns test-pr test: test-unit test-ns test-pr
smoke:
cd mysql-test ; \
@PERL@ ./mysql-test-run.pl --do-test=s
test-full: test test-nr test-ps test-full: test test-nr test-ps
test-force: test-force:

View File

@ -32,8 +32,8 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c) ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c)
TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32) TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32)
ADD_EXECUTABLE(mysqltest mysqltest.c) ADD_EXECUTABLE(mysqltest mysqltest.cc)
SET_SOURCE_FILES_PROPERTIES(mysqltest.c PROPERTIES COMPILE_FLAGS "-DTHREADS") SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys regex wsock32 dbug) TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys regex wsock32 dbug)
ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) ADD_EXECUTABLE(mysqlcheck mysqlcheck.c)

View File

@ -86,9 +86,9 @@ mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
$(LIBMYSQLCLIENT_LA) \ $(LIBMYSQLCLIENT_LA) \
$(top_builddir)/mysys/libmysys.a $(top_builddir)/mysys/libmysys.a
mysqltest_SOURCES= mysqltest.c mysqltest_SOURCES= mysqltest.cc
mysqltest_CFLAGS= -DTHREAD -UUNDEF_THREADS_HACK mysqltest_CXXFLAGS= -DTHREAD -UUNDEF_THREADS_HACK
mysqltest_LDADD = $(CXXLDFLAGS) \ mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
@CLIENT_EXTRA_LDFLAGS@ \ @CLIENT_EXTRA_LDFLAGS@ \
$(LIBMYSQLCLIENT_LA) \ $(LIBMYSQLCLIENT_LA) \
$(top_builddir)/mysys/libmysys.a \ $(top_builddir)/mysys/libmysys.a \

View File

@ -2044,7 +2044,8 @@ static bool add_line(String &buffer,char *line,char *in_string,
} }
#endif #endif
if (!*ml_comment && inchar == '\\' && if (!*ml_comment && inchar == '\\' &&
!(mysql.server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)) !(*in_string &&
(mysql.server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)))
{ {
// Found possbile one character command like \c // Found possbile one character command like \c

View File

@ -23,10 +23,6 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <mysql.h> #include <mysql.h>
#ifdef LATER_HAVE_NDBCLUSTER_DB
#include "../ndb/src/mgmclient/ndb_mgmclient.h"
#endif
#define ADMIN_VERSION "8.42" #define ADMIN_VERSION "8.42"
#define MAX_MYSQL_VAR 256 #define MAX_MYSQL_VAR 256
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */ #define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */
@ -46,10 +42,6 @@ static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations;
static uint opt_count_iterations= 0, my_end_arg; static uint opt_count_iterations= 0, my_end_arg;
static ulong opt_connect_timeout, opt_shutdown_timeout; static ulong opt_connect_timeout, opt_shutdown_timeout;
static char * unix_port=0; static char * unix_port=0;
#ifdef LATER_HAVE_NDBCLUSTER_DB
static my_bool opt_ndbcluster=0;
static char *opt_ndb_connectstring=0;
#endif
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
static char *shared_memory_base_name=0; static char *shared_memory_base_name=0;
@ -105,9 +97,6 @@ enum commands {
ADMIN_PING, ADMIN_EXTENDED_STATUS, ADMIN_FLUSH_STATUS, ADMIN_PING, ADMIN_EXTENDED_STATUS, ADMIN_FLUSH_STATUS,
ADMIN_FLUSH_PRIVILEGES, ADMIN_START_SLAVE, ADMIN_STOP_SLAVE, ADMIN_FLUSH_PRIVILEGES, ADMIN_START_SLAVE, ADMIN_STOP_SLAVE,
ADMIN_FLUSH_THREADS, ADMIN_OLD_PASSWORD ADMIN_FLUSH_THREADS, ADMIN_OLD_PASSWORD
#ifdef LATER_HAVE_NDBCLUSTER_DB
,ADMIN_NDB_MGM
#endif
}; };
static const char *command_names[]= { static const char *command_names[]= {
"create", "drop", "shutdown", "create", "drop", "shutdown",
@ -118,9 +107,6 @@ static const char *command_names[]= {
"ping", "extended-status", "flush-status", "ping", "extended-status", "flush-status",
"flush-privileges", "start-slave", "stop-slave", "flush-privileges", "start-slave", "stop-slave",
"flush-threads","old-password", "flush-threads","old-password",
#ifdef LATER_HAVE_NDBCLUSTER_DB
"ndb-mgm",
#endif
NullS NullS
}; };
@ -224,14 +210,6 @@ static struct my_option my_long_options[] =
{"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", (uchar**) &opt_shutdown_timeout, {"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", (uchar**) &opt_shutdown_timeout,
(uchar**) &opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG, (uchar**) &opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG,
SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0}, SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0},
#ifdef LATER_HAVE_NDBCLUSTER_DB
{"ndbcluster", OPT_NDBCLUSTER, ""
"", (uchar**) &opt_ndbcluster,
(uchar**) &opt_ndbcluster, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"ndb-connectstring", OPT_NDB_CONNECTSTRING, ""
"", (uchar**) &opt_ndb_connectstring,
(uchar**) &opt_ndb_connectstring, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
@ -984,24 +962,6 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
} }
mysql->reconnect=1; /* Automatic reconnect is default */ mysql->reconnect=1; /* Automatic reconnect is default */
break; break;
#ifdef LATER_HAVE_NDBCLUSTER_DB
case ADMIN_NDB_MGM:
{
if (argc < 2)
{
my_printf_error(0, "Too few arguments to ndb-mgm", error_flags);
return 1;
}
{
Ndb_mgmclient_handle cmd=
ndb_mgmclient_handle_create(opt_ndb_connectstring);
ndb_mgmclient_execute(cmd, --argc, ++argv);
ndb_mgmclient_handle_destroy(cmd);
}
argc= 0;
}
break;
#endif
default: default:
my_printf_error(0, "Unknown command: '%-.60s'", error_flags, argv[0]); my_printf_error(0, "Unknown command: '%-.60s'", error_flags, argv[0]);
return 1; return 1;

File diff suppressed because it is too large Load Diff

View File

@ -2048,7 +2048,7 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \ mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \
pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \ pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \ pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \
pthread_key_delete pthread_rwlock_rdlock pthread_setprio pthread_setschedprio \ pthread_key_delete pthread_rwlock_rdlock pthread_setprio \
pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \ pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \
realpath rename rint rwlock_init setupterm \ realpath rename rint rwlock_init setupterm \
shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \ shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
@ -2071,6 +2071,15 @@ case "$target" in
;; ;;
esac esac
case "$mysql_cv_sys_os" in
OS400) # i5/OS (OS/400) emits a SIGILL (Function not implemented) when
# unsupported priority values are passed to pthread_setschedprio.
# Since the only supported value is 1, treat it as inexistent.
;;
*) AC_CHECK_FUNCS(pthread_setschedprio)
;;
esac
# Check that isinf() is available in math.h and can be used in both C and C++ # Check that isinf() is available in math.h and can be used in both C and C++
# code # code
AC_MSG_CHECKING(for isinf in <math.h>) AC_MSG_CHECKING(for isinf in <math.h>)
@ -2798,8 +2807,8 @@ AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl
server-tools/Makefile server-tools/instance-manager/Makefile dnl server-tools/Makefile server-tools/instance-manager/Makefile dnl
cmd-line-utils/Makefile cmd-line-utils/libedit/Makefile dnl cmd-line-utils/Makefile cmd-line-utils/libedit/Makefile dnl
libmysqld/Makefile libmysqld/examples/Makefile dnl libmysqld/Makefile libmysqld/examples/Makefile dnl
mysql-test/Makefile dnl mysql-test/Makefile mysql-test/lib/My/SafeProcess/Makefile dnl
mysql-test/ndb/Makefile netware/Makefile sql-bench/Makefile dnl netware/Makefile sql-bench/Makefile dnl
include/mysql_version.h plugin/Makefile win/Makefile) include/mysql_version.h plugin/Makefile win/Makefile)
AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h) AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h)

View File

@ -724,7 +724,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define UNSINT32 /* unsigned int32 */ #define UNSINT32 /* unsigned int32 */
/* General constants */ /* General constants */
#define SC_MAXWIDTH 256 /* Max width of screen (for error messages) */
#define FN_LEN 256 /* Max file name len */ #define FN_LEN 256 /* Max file name len */
#define FN_HEADLEN 253 /* Max length of filepart of file name */ #define FN_HEADLEN 253 /* Max length of filepart of file name */
#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */ #define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */
@ -1133,6 +1132,9 @@ typedef char bool; /* Ordinary boolean values 0 1 */
#define dbug_volatile #define dbug_volatile
#endif #endif
/* Some helper macros */
#define YESNO(X) ((X) ? "yes" : "no")
/* Defines for time function */ /* Defines for time function */
#define SCALE_SEC 100 #define SCALE_SEC 100
#define SCALE_USEC 10000 #define SCALE_USEC 10000

View File

@ -39,8 +39,6 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;} #define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
#define MY_INIT(name); { my_progname= name; my_init(); } #define MY_INIT(name); { my_progname= name; my_init(); }
#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */
#define NRERRBUFFS (2) /* Buffers for parameters */
#define MY_FILE_ERROR ((size_t) -1) #define MY_FILE_ERROR ((size_t) -1)
/* General bitmaps for my_func's */ /* General bitmaps for my_func's */
@ -208,7 +206,6 @@ extern void my_large_free(uchar * ptr, myf my_flags);
extern int errno; /* declare errno */ extern int errno; /* declare errno */
#endif #endif
#endif /* #ifndef errno */ #endif /* #ifndef errno */
extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
extern char *home_dir; /* Home directory for user */ extern char *home_dir; /* Home directory for user */
extern const char *my_progname; /* program-name (printed in errors) */ extern const char *my_progname; /* program-name (printed in errors) */
extern char NEAR curr_dir[]; /* Current directory for user */ extern char NEAR curr_dir[]; /* Current directory for user */

View File

@ -185,7 +185,7 @@ typedef struct st_mi_keydef /* Key definition with open & info */
uint16 maxlength; /* max length of (packed) key (auto) */ uint16 maxlength; /* max length of (packed) key (auto) */
uint16 block_size_index; /* block_size (auto) */ uint16 block_size_index; /* block_size (auto) */
uint32 version; /* For concurrent read/write */ uint32 version; /* For concurrent read/write */
uint32 ftparser_nr; /* distinct ftparser number */ uint32 ftkey_nr; /* full-text index number */
HA_KEYSEG *seg,*end; HA_KEYSEG *seg,*end;
struct st_mysql_ftparser *parser; /* Fulltext [pre]parser */ struct st_mysql_ftparser *parser; /* Fulltext [pre]parser */

View File

@ -159,7 +159,8 @@ void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock); void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock);
my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread); my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
void thr_print_locks(void); /* For debugging */ void thr_print_locks(void); /* For debugging */
my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data); my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data,
enum thr_lock_type new_lock_type);
void thr_downgrade_write_lock(THR_LOCK_DATA *data, void thr_downgrade_write_lock(THR_LOCK_DATA *data,
enum thr_lock_type new_lock_type); enum thr_lock_type new_lock_type);
my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data); my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data);

View File

@ -32,7 +32,7 @@ ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc
TARGET_LINK_LIBRARIES(mysql_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32) TARGET_LINK_LIBRARIES(mysql_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
ADD_DEPENDENCIES(mysql_embedded libmysqld) ADD_DEPENDENCIES(mysql_embedded libmysqld)
ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.c) ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc)
TARGET_LINK_LIBRARIES(mysqltest_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32) TARGET_LINK_LIBRARIES(mysqltest_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
ADD_DEPENDENCIES(mysqltest_embedded libmysqld) ADD_DEPENDENCIES(mysqltest_embedded libmysqld)

View File

@ -41,7 +41,7 @@ LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @LIBDL@ $(CXXLDFLAGS) \
@NDB_SCI_LIBS@ @NDB_SCI_LIBS@
mysqltest_embedded_LINK = $(CXXLINK) mysqltest_embedded_LINK = $(CXXLINK)
nodist_mysqltest_embedded_SOURCES = mysqltest.c nodist_mysqltest_embedded_SOURCES = mysqltest.cc
mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a
nodist_mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \ nodist_mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \

View File

@ -17,132 +17,111 @@
## Process this file with automake to create Makefile.in ## Process this file with automake to create Makefile.in
SUBDIRS = ndb testdir = $(prefix)/mysql-test
benchdir_root= $(prefix) test_SCRIPTS = mtr \
testdir = $(benchdir_root)/mysql-test mysql-test-run \
EXTRA_SCRIPTS = mysql-test-run-shell.sh install_test_db.sh \ mysql-test-run.pl \
valgrind.supp $(PRESCRIPTS) mysql-stress-test.pl
EXTRA_DIST = $(EXTRA_SCRIPTS) suite
GENSCRIPTS = mysql-test-run-shell install_test_db mtr mysql-test-run
PRESCRIPTS = mysql-test-run.pl mysql-stress-test.pl
test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS)
CLEANFILES = $(GENSCRIPTS)
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I.. nobase_test_DATA = \
lib/v1/mysql-test-run.pl \
lib/v1/mtr_cases.pl \
lib/v1/mtr_io.pl \
lib/v1/mtr_report.pl \
lib/v1/My/Config.pm \
lib/v1/mtr_gcov.pl \
lib/v1/mtr_match.pl \
lib/v1/mtr_stress.pl \
lib/v1/ndb_config_1_node.ini \
lib/v1/ndb_config_2_node.ini \
lib/v1/mtr_gprof.pl \
lib/v1/mtr_misc.pl \
lib/v1/mtr_timer.pl \
lib/v1/mtr_im.pl \
lib/v1/mtr_process.pl \
lib/v1/mtr_unique.pl \
\
lib/mtr_cases.pm \
lib/mtr_gcov.pl \
lib/mtr_gprof.pl \
lib/mtr_io.pl \
lib/mtr_match.pm \
lib/mtr_misc.pl \
lib/mtr_process.pl \
lib/mtr_report.pm \
lib/mtr_stress.pl \
lib/mtr_unique.pm \
lib/My/ConfigFactory.pm \
lib/My/Config.pm \
lib/My/Find.pm \
lib/My/Handles.pm \
lib/My/Options.pm \
lib/My/Test.pm \
lib/My/Platform.pm \
lib/My/SafeProcess.pm \
lib/My/File/Path.pm \
lib/My/SysInfo.pm \
lib/My/CoreDump.pm \
lib/My/SafeProcess/Base.pm \
lib/My/SafeProcess/safe_process.pl
SUBDIRS = lib/My/SafeProcess
EXTRA_DIST = README \
valgrind.supp \
$(test_SCRIPTS) \
$(nobase_test_DATA)
# List of directories containing test + result files and the
# related test data files that should be copied
TEST_DIRS = t r include std_data std_data/parts \
std_data/ndb_backup50 std_data/ndb_backup51 \
std_data/ndb_backup51_data_be std_data/ndb_backup51_data_le \
std_data/funcs_1 \
extra/binlog_tests/ extra/rpl_tests \
suite/binlog suite/binlog/t suite/binlog/r suite/binlog/std_data \
suite/bugs/data suite/bugs/t suite/bugs/r \
suite/federated \
suite/funcs_1 suite/funcs_1/bitdata \
suite/funcs_1/include suite/funcs_1/lib suite/funcs_1/r \
suite/funcs_1/t suite/funcs_1/views suite/funcs_1/cursors \
suite/funcs_1/datadict suite/funcs_1/storedproc suite/funcs_1/triggers \
suite/funcs_2 suite/funcs_2/charset suite/funcs_2/data \
suite/funcs_2/include suite/funcs_2/lib suite/funcs_2/r \
suite/funcs_2/t \
suite/jp suite/jp/t suite/jp/r suite/jp/std_data \
suite/manual/t suite/manual/r \
suite/ndb_team suite/ndb_team/t suite/ndb_team/r \
suite/rpl suite/rpl/data suite/rpl/include suite/rpl/r \
suite/rpl/t \
suite/stress/include suite/stress/t suite/stress/r \
suite/ndb suite/ndb/t suite/ndb/r \
suite/rpl_ndb suite/rpl_ndb/t suite/rpl_ndb/r \
suite/parts suite/parts/t suite/parts/r suite/parts/inc
# Used by dist-hook and install-data-local to copy all
# test files into either dist or install directory
install_test_files:
@if test -z "$(INSTALL_TO_DIR)"; then \
echo "Set INSTALL_TO_DIR!" && exit 1; \
fi
@for dir in $(TEST_DIRS); do \
from_dir="$(srcdir)/$$dir"; \
to_dir="$(INSTALL_TO_DIR)/$$dir"; \
$(mkinstalldirs) "$$to_dir"; \
for f in `(cd $$from_dir && ls)`; do \
if test -f "$$from_dir/$$f"; then \
$(INSTALL_DATA) "$$from_dir/$$f" "$$to_dir/$$f" ; \
fi; \
done \
done
dist-hook: dist-hook:
mkdir -p \ $(MAKE) INSTALL_TO_DIR="$(distdir)" install_test_files
$(distdir)/t \
$(distdir)/extra/binlog_tests \
$(distdir)/extra/rpl_tests \
$(distdir)/r \
$(distdir)/include \
$(distdir)/std_data \
$(distdir)/std_data/ndb_backup50 \
$(distdir)/std_data/ndb_backup51 \
$(distdir)/std_data/ndb_backup51_data_be \
$(distdir)/std_data/ndb_backup51_data_le \
$(distdir)/std_data/parts \
$(distdir)/lib \
$(distdir)/std_data/funcs_1 \
$(distdir)/lib/My
-$(INSTALL_DATA) $(srcdir)/t/*.def $(distdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.test $(distdir)/t
-$(INSTALL_DATA) $(srcdir)/t/*.imtest $(distdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.sql $(distdir)/t
-$(INSTALL_DATA) $(srcdir)/t/*.disabled $(distdir)/t
-$(INSTALL_DATA) $(srcdir)/t/*.opt $(srcdir)/t/*.slave-mi $(distdir)/t
-$(INSTALL_SCRIPT) $(srcdir)/t/*.sh $(distdir)/t
$(INSTALL_DATA) $(srcdir)/extra/binlog_tests/*.test $(distdir)/extra/binlog_tests
$(INSTALL_DATA) $(srcdir)/extra/rpl_tests/*.test $(distdir)/extra/rpl_tests
-$(INSTALL_DATA) $(srcdir)/extra/binlog_tests/*.opt $(distdir)/extra/binlog_tests
-$(INSTALL_DATA) $(srcdir)/extra/rpl_tests/*.opt $(distdir)/extra/rpl_tests
$(INSTALL_DATA) $(srcdir)/include/*.inc $(distdir)/include
$(INSTALL_DATA) $(srcdir)/include/*.sql $(distdir)/include
$(INSTALL_DATA) $(srcdir)/include/*.test $(distdir)/include
$(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.require $(distdir)/r
$(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/Index.xml $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.dat $(srcdir)/std_data/*.000001 $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.pem $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.frm $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.txt $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup50/BACKUP* $(distdir)/std_data/ndb_backup50
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51/BACKUP* $(distdir)/std_data/ndb_backup51
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_be/BACKUP* $(distdir)/std_data/ndb_backup51_data_be
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_le/BACKUP* $(distdir)/std_data/ndb_backup51_data_le
$(INSTALL_DATA) $(srcdir)/std_data/parts/part_* $(distdir)/std_data/parts
$(INSTALL_DATA) $(srcdir)/std_data/parts/*.MY* $(distdir)/std_data/parts
$(INSTALL_DATA) $(srcdir)/std_data/funcs_1/* $(distdir)/std_data/funcs_1
$(INSTALL_DATA) $(srcdir)/lib/*.pl $(distdir)/lib
$(INSTALL_DATA) $(srcdir)/lib/My/*.pm $(distdir)/lib/My
-rm -rf `find $(distdir)/suite -type d -name SCCS` $(distdir)/suite/row_lock
install-data-local: install-data-local:
$(mkinstalldirs) \ $(MAKE) INSTALL_TO_DIR="$(DESTDIR)$(testdir)" install_test_files
$(DESTDIR)$(testdir)/t \
$(DESTDIR)$(testdir)/extra/binlog_tests \
$(DESTDIR)$(testdir)/extra/rpl_tests \
$(DESTDIR)$(testdir)/r \
$(DESTDIR)$(testdir)/include \
$(DESTDIR)$(testdir)/std_data \
$(DESTDIR)$(testdir)/std_data/ndb_backup50 \
$(DESTDIR)$(testdir)/std_data/ndb_backup51 \
$(DESTDIR)$(testdir)/std_data/ndb_backup51_data_be \
$(DESTDIR)$(testdir)/std_data/ndb_backup51_data_le \
$(DESTDIR)$(testdir)/std_data/parts \
$(DESTDIR)$(testdir)/lib \
$(DESTDIR)$(testdir)/std_data/funcs_1 \
$(DESTDIR)$(testdir)/lib/My
$(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(testdir)
-$(INSTALL_DATA) $(srcdir)/t/*.def $(DESTDIR)$(testdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.test $(DESTDIR)$(testdir)/t
-$(INSTALL_DATA) $(srcdir)/t/*.imtest $(DESTDIR)$(testdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.sql $(DESTDIR)$(testdir)/t
-$(INSTALL_DATA) $(srcdir)/t/*.disabled $(DESTDIR)$(testdir)/t
-$(INSTALL_DATA) $(srcdir)/t/*.opt $(DESTDIR)$(testdir)/t
-$(INSTALL_SCRIPT) $(srcdir)/t/*.sh $(DESTDIR)$(testdir)/t
-$(INSTALL_DATA) $(srcdir)/t/*.slave-mi $(DESTDIR)$(testdir)/t
$(INSTALL_DATA) $(srcdir)/r/*.result $(DESTDIR)$(testdir)/r
$(INSTALL_DATA) $(srcdir)/r/*.require $(DESTDIR)$(testdir)/r
$(INSTALL_DATA) $(srcdir)/extra/binlog_tests/*.test $(DESTDIR)$(testdir)/extra/binlog_tests
$(INSTALL_DATA) $(srcdir)/extra/rpl_tests/*.test $(DESTDIR)$(testdir)/extra/rpl_tests
-$(INSTALL_DATA) $(srcdir)/extra/binlog_tests/*.opt $(DESTDIR)$(testdir)/extra/binlog_tests
-$(INSTALL_DATA) $(srcdir)/extra/rpl_tests/*.opt $(DESTDIR)$(testdir)/extra/rpl_tests
$(INSTALL_DATA) $(srcdir)/include/*.inc $(DESTDIR)$(testdir)/include
$(INSTALL_DATA) $(srcdir)/include/*.sql $(DESTDIR)$(testdir)/include
$(INSTALL_DATA) $(srcdir)/include/*.test $(DESTDIR)$(testdir)/include
$(INSTALL_DATA) $(srcdir)/std_data/*.dat $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.*001 $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/Index.xml $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.pem $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.frm $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.txt $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup50/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup50
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_be/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51_data_be
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_le/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51_data_le
$(INSTALL_DATA) $(srcdir)/std_data/parts/part_* $(DESTDIR)$(testdir)/std_data/parts
$(INSTALL_DATA) $(srcdir)/std_data/parts/*.MY* $(DESTDIR)$(testdir)/std_data/parts
$(INSTALL_DATA) $(srcdir)/std_data/funcs_1/* $(DESTDIR)$(testdir)/std_data/funcs_1
$(INSTALL_DATA) $(srcdir)/lib/*.pl $(DESTDIR)$(testdir)/lib
$(INSTALL_DATA) $(srcdir)/lib/My/*.pm $(DESTDIR)$(testdir)/lib/My
for f in `(cd $(srcdir); find suite -type f | egrep -v 'SCCS|row_lock')`; \
do \
d=$(DESTDIR)$(testdir)/`dirname $$f`; \
mkdir -p $$d ; \
$(INSTALL_DATA) $(srcdir)/$$f $$d ; \
done
uninstall-local: uninstall-local:
@RM@ -f -r $(DESTDIR)$(testdir) @RM@ -f -r $(DESTDIR)$(testdir)
@ -157,31 +136,5 @@ mysql-test-run:
$(RM) -f mysql-test-run $(RM) -f mysql-test-run
$(LN_S) mysql-test-run.pl mysql-test-run $(LN_S) mysql-test-run.pl mysql-test-run
SUFFIXES = .sh
.sh:
@RM@ -f $@ $@-t
@SED@ \
-e 's!@''testdir''@!$(testdir)!g' \
-e 's!@''bindir''@!$(bindir)!g' \
-e 's!@''scriptdir''@!$(bindir)!g' \
-e 's!@''prefix''@!$(prefix)!g' \
-e 's!@''datadir''@!$(datadir)!g' \
-e 's!@''localstatedir''@!$(localstatedir)!g' \
-e 's!@''libexecdir''@!$(libexecdir)!g' \
-e 's!@''PERL''@!@PERL@!' \
-e 's!@''VERSION''@!@VERSION@!' \
-e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \
-e 's!@''MYSQL_TCP_PORT_DEFAULT''@!@MYSQL_TCP_PORT_DEFAULT@!' \
-e 's!@''MYSQL_BASE_VERSION''@!@MYSQL_BASE_VERSION@!' \
-e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \
-e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \
-e 's!@''MYSQL_NO_DASH_VERSION''@!@MYSQL_NO_DASH_VERSION@!' \
-e 's!@''MYSQL_SERVER_SUFFIX''@!@MYSQL_SERVER_SUFFIX@!' \
-e 's!@''USE_NDBCLUSTER''@!@TEST_NDBCLUSTER@!g' \
$< > $@-t
@CHMOD@ +x $@-t
@MV@ $@-t $@
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%

View File

@ -1,65 +0,0 @@
#! /bin/sh
# This script is a hack for lazy developers who want to get a quick
# start on the result file. The code here is rather dirty, but it works
# If you have a spare moment feel free to improve it - the right way is
# to start mysqld yourself and run mysqltest -r
RESULT_DIR=r
if [ -z "$EDITOR" ] ; then
EDITOR=vi
fi
function die()
{
echo $1
exit 1
}
function usage()
{
echo "Usage: $0 test_name"
exit 1
}
test_name=$1
[ -z "$test_name" ] && usage
result_file=$RESULT_DIR/$test_name.result
reject_file=$RESULT_DIR/$test_name.reject
[ -f $result_file ] && die "result file $result_file has already been created"
touch $result_file
echo "Running the test case against empty file, will fail, but don't worry"
./mysql-test-run --local $test_name
if [ -f $reject_file ] ; then
echo "Below are the contents of the reject file:"
echo "-----start---------------------"
cat $reject_file
echo "-----end-----------------------"
echo "Is this the output you expected from your test case?(y/n)[n]"
read yes_no
if [ x$yes_no = xy ] ; then
echo "Press any key to edit it in $EDITOR, or Ctrl-C to abort"
read junk
$EDITOR $reject_file
edited="edited"
fi
echo "Save $edited file as master result? (y/n)[y]"
read yes_no
if [ x$yes_no != xn ]; then
mv $reject_file $result_file
fi
else
echo "Your test failed so bad, it did not even produce a reject file"
echo "You need to fix your bugs in the test case, the code, or both"
exit 1
fi

View File

@ -7,7 +7,7 @@
-- source include/have_log_bin.inc -- source include/have_log_bin.inc
# The server need to be started in $MYSQLTEST_VARDIR since it # The server need to be started in $MYSQLTEST_VARDIR since it
# uses ../std_data_ln/ # uses ../../std_data/
-- source include/uses_vardir.inc -- source include/uses_vardir.inc
--disable_warnings --disable_warnings
@ -114,7 +114,7 @@ insert into t1 values(1);
insert ignore into t1 values(1); insert ignore into t1 values(1);
replace into t1 values(100); replace into t1 values(100);
create table t2 (a varchar(200)) engine=blackhole; create table t2 (a varchar(200)) engine=blackhole;
eval load data infile '../std_data_ln/words.dat' into table t2; eval load data infile '../../std_data/words.dat' into table t2;
alter table t1 add b int; alter table t1 add b int;
alter table t1 drop b; alter table t1 drop b;
create table t3 like t1; create table t3 like t1;

View File

@ -16,7 +16,8 @@ source include/show_binlog_events.inc;
# escaped). # escaped).
flush logs; flush logs;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000001
drop table t2; drop table t2;
# End of 4.1 tests # End of 4.1 tests

View File

@ -317,17 +317,18 @@ connection con4;
select get_lock("a",10); # wait for rollback to finish select get_lock("a",10); # wait for rollback to finish
flush logs; flush logs;
let $MYSQLD_DATADIR= `select @@datadir`;
# we check that the error code of the "ROLLBACK" event is 0 and not # we check that the error code of the "ROLLBACK" event is 0 and not
# ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction # ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction
# and does not make slave to stop) # and does not make slave to stop)
if (`select @@binlog_format = 'ROW'`) if (`select @@binlog_format = 'ROW'`)
{ {
--exec $MYSQL_BINLOG --start-position=524 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output --exec $MYSQL_BINLOG --start-position=524 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
} }
if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`) if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
{ {
--exec $MYSQL_BINLOG --start-position=555 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output --exec $MYSQL_BINLOG --start-position=555 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
} }
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
@ -618,7 +619,7 @@ CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
# execute # execute
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
load data infile '../std_data_ln/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2); load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
# check # check
select * from t4; select * from t4;
select count(*) from t1 /* must be 2 */; select count(*) from t1 /* must be 2 */;

View File

@ -278,7 +278,7 @@ CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
# execute # execute
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
load data infile '../std_data_ln/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2); load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
# check # check
select * from t4; select * from t4;
select count(*) from t1 /* must be 2 */; select count(*) from t1 /* must be 2 */;

View File

@ -20,7 +20,8 @@
eval create table t1 (a int) engine=$engine_type; eval create table t1 (a int) engine=$engine_type;
flush tables; flush tables;
remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYI ; let $MYSQLD_DATADIR= `select @@datadir`;
remove_file $MYSQLD_DATADIR/test/t1.MYI ;
drop table if exists t1; drop table if exists t1;
save_master_pos; save_master_pos;
connection slave; connection slave;

View File

@ -0,0 +1,168 @@
# ==== Purpose ====
#
# Test that slave behaves well in some conflict situations. The
# following are tested:
#
# - The slave SQL thread sees an 'INSERT' of a row with a key that
# already exists in the table;
#
# - The slave SQL thread sees a 'DELETE' of a row that does not
# exist in the table.
#
# In statement-logging mode, the first conflict type causes the slave
# to stop with an error and the second conflict is ignored.
#
# In row-logging mode, the slave behavior depends the value of
# @@slave_exec_mode on the slave: if @@slave_exec_mode is IDEMPOTENT,
# the slave should ignore the conflicting statement and continue
# normally. If @@slave_exec_mode is STRICT, the slave should stop
# with an error.
#
# This test was previously named rpl_stm_mystery22/rpl_row_mystery22.
#
#
# ==== Method ====
#
# Create a table on master and slave, insert a row on slave, and
# insert the same row on master.
#
# Create a table on master and slave, insert a row on master with
# binlogging turned off, and remove the row on master with binlogging
# turned on.
#
#
# ==== Related bugs ====
#
# BUG#31552: Replication breaks when deleting rows from out-of-sync table without PK
# BUG#31609: Not all RBR slave errors reported as errors
#
# Bug in this test case:
# BUG#37718: rpl.rpl_stm_mystery22 fails sporadically on pushbuild
#
#
# ==== Usage ====
#
# This file assumes the following:
#
# - The test language variable $slave_is_idempotent is set to 1 if the
# slave is expected to stop on duplicate key errors (i.e., if the
# binlog is in statement mode or
# @@global.slave_exec_mode=STRICT). It is set to 0 otherwise.
#
# - Replication has been initialized by include/master-slave.inc
#
# - The test adds a suppression for the following warning:
# Slave: Can't find record in 't1' Error_code: 1032
--echo ==== Initialize ====
--echo [on master]
connection master;
CREATE TABLE t1(a INT PRIMARY KEY);
--echo [on slave]
sync_slave_with_master;
--echo ==== Test: SQL thread sees 'INSERT' of existing key ====
--echo ---- Prepare slave so that it will get duplicate key error ----
# This row will be in the way of the row inserted by master.
INSERT INTO t1 VALUES (1);
--echo ---- Insert rows on master ----
--echo [on master]
connection master;
# Insert the same row on master
INSERT INTO t1 VALUES (1);
save_master_pos;
SELECT * FROM t1;
--echo [on slave]
connection slave;
# If we are statement-logging or if slave_exec_mode=STRICT, we now
# expect to see an error on the slave. Otherwise (i.e., we are
# row-logging and slave_exec_mode=IDEMPOTENT), we expect that the
# duplicate row is ignored by the slave and replication continues.
if (`SELECT @@global.binlog_format != 'ROW' OR @@global.slave_exec_mode = 'STRICT'`) {
--echo ---- Wait until slave stops with an error ----
# Wait until the slave tries to run the query, fails with duplicate
# key error, and stops the SQL thread.
let $slave_sql_errno= 1062; # ER_DUP_ENTRY
source include/wait_for_slave_sql_error.inc;
let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
--echo Last_SQL_Error = $err (expected "duplicate key" error)
SELECT * FROM t1;
--echo ---- Resolve the conflict on the slave and restart SQL thread ----
DELETE FROM t1 WHERE a = 1;
START SLAVE SQL_THREAD;
source include/wait_for_slave_sql_to_start.inc;
}
--echo ---- Sync slave and verify that there is no error ----
sync_with_master;
let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
--echo Last_SQL_Error = '$err' (expected no error)
SELECT * FROM t1;
--echo ==== Test: SQL thread sees 'DELETE' of non-existing row ====
--echo ---- On master, insert two rows, the second with binlogging off ----
--echo [on master]
connection master;
DELETE FROM t1;
INSERT INTO t1 VALUES (1);
--echo [on slave]
sync_slave_with_master;
DELETE FROM t1 WHERE a = 1;
--echo ---- On master, remove the row that does not exist on slave ----
--echo [on master]
connection master;
DELETE FROM t1 WHERE a = 1;
SELECT * FROM t1;
save_master_pos;
--echo [on slave]
connection slave;
# If we are row-logging and slave_exec_mode is STRICT, we now expect
# an error since the row to delete does not exist on slave. Otherwise
# (i.e., either we are statement-logging or slave_exec_mode is
# IDEMPOTENT), the absence of the row to delete is ignored and
# replication continues.
if (`SELECT @@global.binlog_format = 'ROW' AND @@global.slave_exec_mode = 'STRICT'`) {
--echo ---- Wait until slave stops with an error ----
let $slave_sql_errno= 1032; # ER_KEY_NOT_FOUND
source include/wait_for_slave_sql_error.inc;
let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
--echo Last_SQL_Error = $err (expected "can't find record" error)
SELECT * FROM t1;
--echo ---- Resolve the conflict on the slave and restart SQL thread ----
INSERT INTO t1 VALUES (1);
START SLAVE SQL_THREAD;
source include/wait_for_slave_sql_to_start.inc;
}
--echo ---- Sync slave and verify that there is no error ----
# The slave should sync ok, and SHOW SLAVE STATUS should give no
# error.
sync_with_master;
let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
--echo Last_SQL_Error = $err (expected no error)
SELECT * FROM t1;
--echo ==== Clean up ====
--echo [on master]
connection master;
DROP TABLE t1;
--echo [on slave]
sync_slave_with_master;

View File

@ -419,7 +419,7 @@ connection master;
update t31 set f5=555555555555555 where f3=6; update t31 set f5=555555555555555 where f3=6;
update t31 set f2=2 where f3=2; update t31 set f2=2 where f3=2;
update t31 set f1=NULL where f3=1; update t31 set f1=NULL where f3=1;
update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3; update t31 set f3=NULL, f27=NULL, f35='f35 new value' where f3=3;
--echo --echo
--echo ** Delete from Master ** --echo ** Delete from Master **
@ -497,7 +497,7 @@ INSERT INTO t10 () VALUES(1,@b1,DEFAULT,'Kyle',DEFAULT),
--echo ******************************************** --echo ********************************************
--echo --echo
connection slave; connection slave;
wait_for_slave_to_stop; source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 # --replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
@ -554,7 +554,7 @@ INSERT INTO t11 () VALUES(1,@b1,'Testing is fun','Kyle',DEFAULT),
--echo ******************************************** --echo ********************************************
--echo --echo
connection slave; connection slave;
wait_for_slave_to_stop; source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 # --replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
@ -697,7 +697,7 @@ SELECT c1,c3,hex(c4),c5,c6 FROM t14 ORDER BY c1;
# Remove below once fixed # Remove below once fixed
#*************************** #***************************
connection slave; connection slave;
wait_for_slave_to_stop; source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 # --replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
@ -763,7 +763,7 @@ SELECT c1,hex(c4),c5,c6,c7,c2 FROM t15 ORDER BY c1;
--echo ******************************************** --echo ********************************************
--echo --echo
connection slave; connection slave;
wait_for_slave_to_stop; source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 # --replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
@ -840,7 +840,7 @@ SELECT c1,hex(c4),c5,c6,c7 FROM t16 ORDER BY c1;
--echo ***************** --echo *****************
--echo --echo
connection slave; connection slave;
wait_for_slave_to_stop; source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 # --replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS

View File

@ -94,7 +94,7 @@ SELECT * FROM t2 ORDER BY a;
--echo *** Start Slave *** --echo *** Start Slave ***
connection slave; connection slave;
START SLAVE; START SLAVE;
wait_for_slave_to_stop; source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 # --replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
@ -429,6 +429,7 @@ set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1); set @b1 = concat(@b1,@b1);
INSERT INTO t9 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA'); INSERT INTO t9 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
connection slave;
--source include/wait_for_slave_sql_to_stop.inc --source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 # --replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #

View File

@ -4,8 +4,7 @@
# Test of FLUSH NO_WRITE_TO_BINLOG by the way. # Test of FLUSH NO_WRITE_TO_BINLOG by the way.
# #
source include/master-slave.inc;
-- source include/master-slave.inc
let $SERVER_VERSION=`select version()`; let $SERVER_VERSION=`select version()`;
@ -34,26 +33,32 @@ flush tables;
--replace_column 2 # 5 # --replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/ --replace_regex /table_id: [0-9]+/table_id: #/
eval SHOW BINLOG EVENTS FROM $rename_event_pos ; eval SHOW BINLOG EVENTS FROM $rename_event_pos ;
save_master_pos;
connection slave; sync_slave_with_master;
sync_with_master;
# Check that the slave is not confused. # Check that the slave is not confused.
select * from t3; select * from t3;
# Note that all this confusion may cause warnings 'table xx is open on rename' # Note that all this confusion may cause warnings 'table xx is open on rename'
# in the .err files; these are not fatal and are not reported by mysql-test-run. # in the .err files; these are not fatal and are not reported by mysql-test-run.
stop slave; stop slave;
source include/wait_for_slave_to_stop.inc;
connection master; connection master;
drop table t1; drop table t1;
connection slave; connection slave;
flush tables with read lock; flush tables with read lock;
start slave; start slave;
sleep 1; source include/wait_for_slave_to_start.inc;
--error 1192 --error 1192
stop slave; stop slave;
# Cleanup
unlock tables;
connection master; connection master;
drop table t3, t4, t5; drop table t3, t4, t5;
sync_slave_with_master;
# End of 4.1 tests # End of 4.1 tests

View File

@ -23,12 +23,12 @@ connection master;
select last_insert_id(); select last_insert_id();
create table t1(a int not null auto_increment, b int, primary key(a) ); create table t1(a int not null auto_increment, b int, primary key(a) );
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; load data infile '../../std_data/rpl_loaddata.dat' into table t1;
# verify that LAST_INSERT_ID() is set by LOAD DATA INFILE # verify that LAST_INSERT_ID() is set by LOAD DATA INFILE
select last_insert_id(); select last_insert_id();
create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60)); create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60));
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines;
create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60)); create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60));
insert into t3 select * from t2; insert into t3 select * from t2;
@ -56,7 +56,7 @@ sync_with_master;
insert into t1 values(1,10); insert into t1 values(1,10);
connection master; connection master;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; load data infile '../../std_data/rpl_loaddata.dat' into table t1;
save_master_pos; save_master_pos;
connection slave; connection slave;
@ -80,7 +80,7 @@ connection master;
set sql_log_bin=0; set sql_log_bin=0;
delete from t1; delete from t1;
set sql_log_bin=1; set sql_log_bin=1;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; load data infile '../../std_data/rpl_loaddata.dat' into table t1;
save_master_pos; save_master_pos;
connection slave; connection slave;
# The SQL slave thread should be stopped now. # The SQL slave thread should be stopped now.
@ -105,7 +105,7 @@ connection master;
set sql_log_bin=0; set sql_log_bin=0;
delete from t1; delete from t1;
set sql_log_bin=1; set sql_log_bin=1;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; load data infile '../../std_data/rpl_loaddata.dat' into table t1;
save_master_pos; save_master_pos;
connection slave; connection slave;
# The SQL slave thread should be stopped now. # The SQL slave thread should be stopped now.
@ -125,7 +125,7 @@ reset master;
eval create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60), eval create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
unique(day)) engine=$engine_type; # no transactions unique(day)) engine=$engine_type; # no transactions
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
'\n##\n' starting by '>' ignore 1 lines; '\n##\n' starting by '>' ignore 1 lines;
select * from t2; select * from t2;
@ -141,24 +141,21 @@ alter table t2 drop key day;
connection master; connection master;
delete from t2; delete from t2;
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
'\n##\n' starting by '>' ignore 1 lines; '\n##\n' starting by '>' ignore 1 lines;
connection slave; connection slave;
--source include/wait_for_slave_sql_to_stop.inc --source include/wait_for_slave_sql_to_stop.inc
drop table t2; drop table t1, t2;
connection master; connection master;
drop table t2; drop table t1, t2;
drop table t1;
# BUG#17233 LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed # BUG#17233 LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB;
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1; LOAD DATA INFILE "../../std_data/words.dat" INTO TABLE t1;
--disable_warnings
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
--enable_warnings
# End of 4.1 tests # End of 4.1 tests

View File

@ -9,10 +9,8 @@
# test the slave immediately writes DROP TEMPORARY TABLE this_old_table). # test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
# We wait for the slave to have written all he wants to the binlog # We wait for the slave to have written all he wants to the binlog
# (otherwise RESET MASTER may come too early). # (otherwise RESET MASTER may come too early).
save_master_pos; sync_slave_with_master;
connection slave; source include/stop_slave.inc;
sync_with_master;
stop slave;
--source include/wait_for_slave_to_stop.inc --source include/wait_for_slave_to_stop.inc
reset master; reset master;
reset slave; reset slave;
@ -25,8 +23,13 @@ connection master;
eval create table t1(n int not null auto_increment primary key)ENGINE=$engine_type; eval create table t1(n int not null auto_increment primary key)ENGINE=$engine_type;
insert into t1 values (NULL); insert into t1 values (NULL);
drop table t1; drop table t1;
let $LOAD_FILE= ../../std_data/words.dat;
if (!`SELECT length(load_file('$LOAD_FILE'))`){
let $LOAD_FILE= ../$LOAD_FILE;
}
eval create table t1 (word char(20) not null)ENGINE=$engine_type; eval create table t1 (word char(20) not null)ENGINE=$engine_type;
load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines; --replace_result $LOAD_FILE LOAD_FILE
eval load data infile '$LOAD_FILE' into table t1 ignore 1 lines;
select count(*) from t1; select count(*) from t1;
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 # --replace_column 2 # 5 #
@ -67,19 +70,13 @@ eval create table t3 (a int)ENGINE=$engine_type;
connection master; connection master;
select * from t1 order by 1 asc; select * from t1 order by 1 asc;
save_master_pos; sync_slave_with_master;
connection slave;
# Note that the above 'slave start' will cause a 3rd rotate event (a fake one)
# to go into the relay log (the master always sends a fake one when replication
# starts).
let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%';
--source include/wait_slave_status.inc
sync_with_master;
#check t1 on slave to ensure whether it's identical with on master #check t1 on slave to ensure whether it's identical with on master
select * from t1 order by 1 asc; select * from t1 order by 1 asc;
flush logs; flush logs;
stop slave; source include/stop_slave.inc;
--source include/wait_for_slave_to_stop.inc source include/start_slave.inc;
connection master; connection master;
# Create some entries for second log # Create some entries for second log
@ -92,12 +89,11 @@ source include/show_binlog_events.inc;
--replace_column 2 # 5 # --replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
show binlog events in 'master-bin.000002'; show binlog events in 'master-bin.000002';
--replace_column 2 #
show binary logs; show binary logs;
save_master_pos; sync_slave_with_master;
connection slave;
start slave;
--source include/wait_for_slave_to_start.inc --source include/wait_for_slave_to_start.inc
sync_with_master; --replace_column 2 #
show binary logs; show binary logs;
--replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION --replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION
--replace_column 2 # 5 # --replace_column 2 # 5 #
@ -133,9 +129,13 @@ DROP TABLE t3;
# Bug #6880: LAST_INSERT_ID() within a statement # Bug #6880: LAST_INSERT_ID() within a statement
# #
# Reset binlog so that show binlog events will not show the tests
# above.
source include/master-slave-reset.inc;
connection master;
create table t1(a int auto_increment primary key, b int); create table t1(a int auto_increment primary key, b int);
insert into t1 values (NULL, 1); insert into t1 values (NULL, 1);
reset master;
set insert_id=5; set insert_id=5;
insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id()); insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
source include/show_binlog_events.inc; source include/show_binlog_events.inc;
@ -145,4 +145,3 @@ drop table t1;
# End of 4.1 tests # End of 4.1 tests
sync_slave_with_master; sync_slave_with_master;

View File

@ -1,7 +1,9 @@
let $LOAD_FILE= $MYSQLTEST_VARDIR/std_data/words.dat;
CREATE TABLE t1 (word CHAR(20) NOT NULL); CREATE TABLE t1 (word CHAR(20) NOT NULL);
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1; --replace_result $LOAD_FILE LOAD_FILE
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR eval LOAD DATA INFILE '$LOAD_FILE' INTO TABLE t1;
eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/std_data/words.dat' INTO TABLE t1; --replace_result $LOAD_FILE LOAD_FILE
eval LOAD DATA INFILE '$LOAD_FILE' INTO TABLE t1;
SELECT * FROM t1 ORDER BY word LIMIT 10; SELECT * FROM t1 ORDER BY word LIMIT 10;
# #

View File

@ -206,7 +206,7 @@ START TRANSACTION;
-- disable_query_log -- disable_query_log
-- disable_result_log -- disable_result_log
let $n=50; let $n=50;
while ($n>3) while ($n)
{ {
eval call test.p3($n); eval call test.p3($n);
dec $n; dec $n;

View File

@ -122,7 +122,7 @@ INSERT INTO t1_nodef VALUES (1,2);
connection slave; connection slave;
--source include/wait_for_slave_sql_to_stop.inc --source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error> --replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE; START SLAVE;
@ -142,7 +142,7 @@ sync_slave_with_master;
--echo **** On Slave **** --echo **** On Slave ****
SELECT * FROM t2; SELECT * FROM t2;
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error> --replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
connection master; connection master;
@ -154,7 +154,7 @@ INSERT INTO t4 VALUES (4);
connection slave; connection slave;
--source include/wait_for_slave_sql_to_stop.inc --source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error> --replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE; START SLAVE;
@ -168,7 +168,7 @@ INSERT INTO t5 VALUES (5,10,25);
connection slave; connection slave;
--source include/wait_for_slave_sql_to_stop.inc --source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error> --replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE; START SLAVE;
@ -182,7 +182,7 @@ INSERT INTO t6 VALUES (6,12,36);
connection slave; connection slave;
--source include/wait_for_slave_sql_to_stop.inc --source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error> --replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE; START SLAVE;
@ -191,7 +191,7 @@ connection master;
INSERT INTO t9 VALUES (6); INSERT INTO t9 VALUES (6);
sync_slave_with_master; sync_slave_with_master;
--replace_result $SLAVE_MYPORT SLAVE_PORT --replace_result $SLAVE_MYPORT SLAVE_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error> --replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS --query_vertical SHOW SLAVE STATUS
# Testing some tables extra field that can be null and cannot be null # Testing some tables extra field that can be null and cannot be null

View File

@ -2,7 +2,7 @@
-- source include/master-slave.inc -- source include/master-slave.inc
create table t1 (word char(20) not null); create table t1 (word char(20) not null);
load data infile '../std_data_ln/words.dat' into table t1; load data infile '../../std_data/words.dat' into table t1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1; eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1;
select * from t1 limit 10; select * from t1 limit 10;

View File

@ -18,13 +18,18 @@ eval create table t1 (a int, unique(a)) engine=$engine_type;
set sql_log_bin=0; set sql_log_bin=0;
insert into t1 values(2); insert into t1 values(2);
set sql_log_bin=1; set sql_log_bin=1;
save_master_pos;
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
insert into t1 values(1),(2); insert into t1 values(1),(2);
drop table t1; drop table t1;
save_master_pos;
connection slave; connection slave;
--source include/wait_for_slave_sql_to_stop.inc --source include/wait_for_slave_sql_to_stop.inc
let $error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
let $errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
--echo Error: "$error" (expected different error codes on master and slave)
--echo Errno: "$errno" (expected 0)
drop table t1;
# End of 4.1 tests # End of 4.1 tests

View File

@ -1,22 +0,0 @@
#! /bin/sh
# Sasha's hack to fix results generated with mysql-test-run --record
# to be version and test port independent. In some cases, further minor
# manual edititing may be required, but most of the time it should not
# happen
#It is assumed we are running the script in mysql-test directory
VERSION=4.0.1-alpha-debug-log
TEST_CASE=$1
if [ -z "$TEST_CASE" ] ;
then
echo "usage: $0 test_case_name"
exit 1
fi
../extra/replace $VERSION '$VERSION' 9306 '$MASTER_MYPORT' 9307 \
'$SLAVE_MYPORT' \\ \\\\ -- r/$TEST_CASE.result

View File

@ -0,0 +1,6 @@
SHOW PROCESSLIST;
let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1);
eval SHOW BINLOG EVENTS IN '$binlog_name';
exit;

View File

@ -0,0 +1,3 @@
SHOW PROCESSLIST;
exit;

View File

@ -1,15 +0,0 @@
# Connect to both master and slave
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
vertical_results;
echo == MASTER ===========================================================;
connection master;
show master status;
show slave status;
echo == SLAVE ===========================================================;
connection slave;
show master status;
show slave status;

View File

@ -1,51 +1,15 @@
# #
# This test is executed twice for each test case if mysql-test-run is passed # This test is executed twice for each test case if mysql-test-run is passed
# the flag --check-testcase. # the flag --check-testcase. Before every testcase it is run with mysqltest
# Before every testcase it's run with mysqltest in record mode and will # in record mode and will thus produce an output file that can be compared
# thus produce an output file # to output from after the tescase.
# that can be compared to output from after the tescase. # In that way its possible to check that a testcase does not have
# In that way it's possible to check that a testcase does not have
# any unwanted side affects. # any unwanted side affects.
# #
--disable_query_log
# call mtr.check_testcase();
# Dump all global variables --enable_query_log
#
SHOW GLOBAL VARIABLES WHERE variable_name != 'timestamp';
#
# Dump all databases
#
SHOW DATABASES;
#
# Dump the "test" database, all it's tables and their data
#
--exec $MYSQL_DUMP --skip-comments --skip-lock-tables test
#
# Dump the "mysql" database and it's tables
# Select data separately to add "order by"
#
--exec $MYSQL_DUMP --skip-comments --skip-lock-tables --no-data mysql
use mysql;
SELECT * FROM columns_priv;
SELECT * FROM db ORDER BY host, db, user;
SELECT * FROM func;
SELECT * FROM help_category;
SELECT * FROM help_keyword;
SELECT * FROM help_relation;
SELECT * FROM help_relation;
SELECT * FROM host;
SELECT * FROM proc;
SELECT * FROM procs_priv;
SELECT * FROM tables_priv;
SELECT * FROM time_zone;
SELECT * FROM time_zone_leap_second;
SELECT * FROM time_zone_name;
SELECT * FROM time_zone_transition;
SELECT * FROM time_zone_transition_type;
SELECT * FROM user;

View File

@ -0,0 +1,61 @@
#
# This test is executed once after each test to check the servers
# for unexpected warnings found in the servers error log
#
# NOTE! mysql-test-run.pl has already done a rough filtering
# of the file and written any suspicious lines
# to $error_log.warnings file
#
--disable_query_log
# Don't write these queries to binlog
set SQL_LOG_BIN=0;
# Turn off any debug crashes, allow the variable to be
# non existent in release builds
--error 0,1193
set debug="";
use mtr;
create temporary table error_log (
row int auto_increment primary key,
suspicious int default 1,
file_name varchar(255),
line varchar(1024) default null
) engine=myisam;
# Get the name of servers error log
let $log_error= query_get_value(show variables like 'log_error', Value, 1);
let $log_warning= $log_error.warnings;
# Try tload the warnings into a temporary table,
# it might fail with error saying "The MySQL server is
# running with the --secure-file-priv" in which case
# an attempt to load the file using LOAD DATA LOCAL is made
--error 0,1290
eval load data infile '$log_warning' into table error_log
fields terminated by 'xykls37' escaped by ''
ignore 1 lines
(line)
set file_name='$log_error';
if ($mysql_errno)
{
# Try LOAD DATA LOCAL
eval load data local infile '$log_warning' into table error_log
fields terminated by 'xykls37' escaped by ''
ignore 1 lines
(line)
set file_name='$log_error';
}
# Call check_warnings to filter out any warning in
# the error_log table
call mtr.check_warnings(@result);
if (`select @result = 0`){
skip OK;
}
--enable_query_log
echo ^ Found warnings!!;
exit;

View File

@ -0,0 +1,130 @@
#############################################################
#
# Author: Serge Kozlov <skozlov@mysql.com>
# Date: 03/11/2008
# Purpose: Set up circular replication based on schema
# A->B->C->D->A
#
# Notes:
# 1. --slave-num=3 must be added to *-master.opt file
# 2. Even the test uses new names for servers but file names
# of log files are still old:
# master_a -> master.[log|err]
# master_b -> slave.[log|err]
# master_c -> slave1.[log|err]
# master_d -> slave2.[log|err]
#
#############################################################
--source include/master-slave.inc
#
# Set up circular ring by schema A->B->C->D->A
#
--connection slave
STOP SLAVE;
RESET SLAVE;
# master a
--connection master
--disconnect master
connect (master_a,127.0.0.1,root,,test,$MASTER_MYPORT,);
RESET MASTER;
--disable_warnings
STOP SLAVE;
--enable_warnings
RESET SLAVE;
SET auto_increment_increment = 4;
SET auto_increment_offset = 1;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
# master b
--connection slave
--disconnect slave
connect (master_b,127.0.0.1,root,,test,$SLAVE_MYPORT,);
RESET MASTER;
RESET SLAVE;
--replace_result $MASTER_MYPORT MASTER_A_PORT $_binlog_file MASTER_A_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$MASTER_MYPORT,master_user='root',MASTER_LOG_FILE='$_binlog_file'
SET auto_increment_increment = 4;
SET auto_increment_offset = 2;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
# master c
--connection slave1
--disconnect slave1
connect (master_c,127.0.0.1,root,,test,$SLAVE_MYPORT1,);
RESET MASTER;
--disable_warnings
STOP SLAVE;
--enable_warnings
RESET SLAVE;
--replace_result $SLAVE_MYPORT MASTER_B_PORT $_binlog_file MASTER_B_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT,master_user='root',MASTER_LOG_FILE='$_binlog_file'
SET auto_increment_increment = 4;
SET auto_increment_offset = 3;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
# master d
connect (master_d,127.0.0.1,root,,test,$SLAVE_MYPORT2,);
RESET MASTER;
--disable_warnings
STOP SLAVE;
--enable_warnings
RESET SLAVE;
--replace_result $SLAVE_MYPORT1 MASTER_C_PORT $_binlog_file MASTER_C_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT1,master_user='root',MASTER_LOG_FILE='$_binlog_file'
SET auto_increment_increment = 4;
SET auto_increment_offset = 4;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
# master a
--connection master_a
--replace_result $SLAVE_MYPORT2 MASTER_D_PORT $_binlog_file MASTER_D_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT2,master_user='root',MASTER_LOG_FILE='$_binlog_file'
# Check server_ids: they should be different
--connection master_a
let $_id_a= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_b
let $_id_b= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_c
let $_id_c= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_d
let $_id_d= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_a
let $_compared_ids= (($_id_a <> $_id_b) AND ($_id_a <> $_id_c) AND ($_id_a <> $_id_d) AND ($_id_b <> $_id_c) AND ($_id_b <> $_id_d) AND ($_id_c <> $_id_d)) AS a;
let $_compared_ids_result= query_get_value(SELECT $_compared_ids, a, 1);
--echo $_compared_ids_result
# Start ring
--connection master_a
connect(slave,127.0.0.1,root,,test,$MASTER_MYPORT);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave
--connection master_b
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT1);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave
--connection master_c
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave
--connection master_d
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT2);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave

View File

@ -0,0 +1,23 @@
#############################################################
#
# Author: Serge Kozlov <skozlov@mysql.com>
# Date: 03/11/2008
# Purpose: Sync all hosts for circular replication based on
# schema A->B->C->D->A
#
# Notes: see include/circular_rpl_for_4_hosts_init.inc
#
#############################################################
# Make the full loop of sync
--connection master_a
--disable_query_log
--sync_slave_with_master master_b
--sync_slave_with_master master_c
--sync_slave_with_master master_d
--sync_slave_with_master master_a
--sync_slave_with_master master_b
--sync_slave_with_master master_c
--save_master_pos
--connection master_a
--enable_query_log

View File

@ -267,7 +267,7 @@ select * from t2;
insert into t2 (a) values (1026); insert into t2 (a) values (1026);
--replace_result $MYSQLTEST_VARDIR .. --replace_result $MYSQLTEST_VARDIR ..
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
eval load data infile "../std_data_ln/words.dat" into table t1 (a) set a:=f2(26); eval load data infile "../../std_data/words.dat" into table t1 (a) set a:=f2(26);
select * from t2; select * from t2;
rollback; rollback;

View File

@ -637,7 +637,7 @@ drop table t1;
--echo ** connection default --echo ** connection default
connection default; connection default;
drop table t1; drop table t1;
drop user mysqltest@localhost;
disconnect thread1; disconnect thread1;
disconnect thread2; disconnect thread2;

View File

@ -0,0 +1,21 @@
# include/count_sessions.inc
#
# SUMMARY
#
# Stores the number of current sessions in $count_sessions.
#
#
# USAGE
#
# Please look into include/wait_until_count_sessions.inc
# for examples of typical usage.
#
#
# EXAMPLE
# backup.test, grant3.test
#
#
# Created: 2009-01-14 mleich
#
let $count_sessions= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1);

View File

@ -0,0 +1,25 @@
# Use default setting for mysqld processes
!include default_mysqld.cnf
[mysqld.1]
# Run the master.sh script before starting this process
#!run-master-sh
log-bin= master-bin
[mysqlbinlog]
disable-force-if-open
# mysql_fix_privilege_tables.sh does not read from [client] so it
# need its own section
[mysql_fix_privilege_tables]
socket= @client.socket
port= @client.port
user= @client.user
password= @client.password
[ENV]
MASTER_MYPORT= @mysqld.1.port
MASTER_MYSOCK= @mysqld.1.socket

View File

@ -0,0 +1,21 @@
# Default values that applies to all MySQL Servers
[mysqld]
open-files-limit= 1024
local-infile
default-character-set= latin1
# Increase default connect_timeout to avoid intermittent
# disconnects when test servers are put under load see BUG#28359
connect-timeout= 60
log-bin-trust-function-creators=1
key_buffer_size= 1M
sort_buffer= 256K
max_heap_table_size= 1M
loose-innodb_data_file_path= ibdata1:10M:autoextend
slave-net-timeout=120
log-bin=mysqld-bin

View File

@ -0,0 +1,27 @@
[cluster_config]
MaxNoOfSavedMessages= 1000
MaxNoOfConcurrentTransactions= 128
MaxNoOfConcurrentOperations= 10000
DataMemory= 20M
IndexMemory= 1M
Diskless= 0
TimeBetweenWatchDogCheck= 30000
MaxNoOfOrderedIndexes= 32
MaxNoOfAttributes= 2048
TimeBetweenGlobalCheckpoints= 500
NoOfFragmentLogFiles= 4
FragmentLogFileSize= 12M
DiskPageBufferMemory= 4M
# O_DIRECT has issues on 2.4 whach have not been handled, Bug #29612
#ODirect= 1
# the following parametes just function as a small regression
# test that the parameter exists
InitialNoOfOpenFiles= 27
# Increase timeouts for slow test-machines
HeartbeatIntervalDbDb= 30000
HeartbeatIntervalDbApi= 30000
#TransactionDeadlockDetectionTimeout= 7500

View File

@ -1,28 +0,0 @@
--source include/have_log_bin.inc
--source include/not_embedded.inc
--source ./include/have_federated_db.inc
source ./include/master-slave.inc;
# remote table creation
# We have to sync with master, to ensure slave had time to start properly
# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
connection master;
sync_slave_with_master;
connection slave;
#--replicate-ignore-db=federated
stop slave;
--disable_warnings
# at this point, we are connected to master
DROP DATABASE IF EXISTS federated;
--enable_warnings
CREATE DATABASE federated;
connection master;
--disable_warnings
DROP DATABASE IF EXISTS federated;
--enable_warnings
CREATE DATABASE federated;

View File

@ -1,4 +1,5 @@
disable_query_log; if (!`SELECT count(*) FROM information_schema.engines WHERE
--require r/true.require (support = 'YES' OR support = 'DEFAULT') AND
select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'blackhole'; engine = 'blackhole'`){
enable_query_log; skip Need blackhole engine;
}

View File

@ -1,7 +0,0 @@
#
# Check if the variable MYSQL_BUG25714 is set
#
--require r/have_bug25714.require
disable_query_log;
eval select LENGTH('$MYSQL_BUG25714') > 0 as 'have_bug25714_exe';
enable_query_log;

View File

@ -1,4 +0,0 @@
disable_query_log;
--require r/true.require
select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'federated';
enable_query_log;

View File

@ -1,3 +1,11 @@
# ==== Purpose ====
#
# Ensure that the server is running with binlogging on
#
# ==== Usage ====
#
# source include/have_log_bin.inc;
-- require r/have_log_bin.require -- require r/have_log_bin.require
disable_query_log; disable_query_log;
show variables like 'log_bin'; show variables like 'log_bin';

View File

@ -1,4 +1,4 @@
--require r/have_ndbapi_examples.require --require r/have_ndbapi_examples.require
disable_query_log; disable_query_log;
eval select LENGTH('$MY_NDB_EXAMPLES_BINARY') > 0 as 'have_ndb_example'; eval select LENGTH('$NDB_EXAMPLES_BINARY') > 0 as 'have_ndb_example';
enable_query_log; enable_query_log;

View File

@ -7,16 +7,20 @@ eval SET SESSION STORAGE_ENGINE = $engine_type;
drop table if exists t1; drop table if exists t1;
--enable_warnings --enable_warnings
let $load_file= $MYSQLTEST_VARDIR/std_data/loaddata2.dat;
# NDB does not support the create option 'Binlog of table with BLOB attribute and no PK' # NDB does not support the create option 'Binlog of table with BLOB attribute and no PK'
# So use a dummy PK here. # So use a dummy PK here.
create table t1 (id int unsigned not null auto_increment primary key, a text, b text); create table t1 (id int unsigned not null auto_increment primary key, a text, b text);
start transaction; start transaction;
load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''' (a, b); --replace_result $load_file LOAD_FILE
eval load data infile '$load_file' into table t1 fields terminated by ',' enclosed by '''' (a, b);
commit; commit;
select count(*) from t1; select count(*) from t1;
truncate table t1; truncate table t1;
start transaction; start transaction;
load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''' (a, b); --replace_result $load_file LOAD_FILE
eval load data infile '$load_file' into table t1 fields terminated by ',' enclosed by '''' (a, b);
rollback; rollback;
select count(*) from t1; select count(*) from t1;

View File

@ -1,6 +1,13 @@
# Reset the master and the slave to start fresh.
#
# It is necessary to execute RESET MASTER and RESET SLAVE on both
# master and slave since the replication setup might be circular.
#
# Since we expect STOP SLAVE to produce a warning as the slave is
# stopped (the server was started with skip-slave-start), we disable
# warnings when doing STOP SLAVE.
connection slave; connection slave;
#we expect STOP SLAVE to produce a warning as the slave is stopped
#(the server was started with skip-slave-start)
--disable_warnings --disable_warnings
stop slave; stop slave;
source include/wait_for_slave_to_stop.inc; source include/wait_for_slave_to_stop.inc;
@ -13,11 +20,17 @@ use test;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings --enable_warnings
reset master; reset master;
--disable_query_log
reset slave;
--enable_query_log
connection slave; connection slave;
reset slave; reset slave;
# Clean up old test tables # Clean up old test tables
--disable_warnings --disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings --enable_warnings
--disable_query_log
reset master;
--enable_query_log
start slave; start slave;
source include/wait_for_slave_to_start.inc; source include/wait_for_slave_to_start.inc;

View File

@ -623,7 +623,8 @@ DROP TABLE t1,t2,t3;
# #
create table t1 (a int) engine=innodb; create table t1 (a int) engine=innodb;
copy_file $MYSQLTEST_VARDIR/master-data/test/t1.frm $MYSQLTEST_VARDIR/master-data/test/bug29807.frm; let $MYSQLD_DATADIR= `select @@datadir`;
copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/bug29807.frm;
--error 1146 --error 1146
select * from bug29807; select * from bug29807;
drop table t1; drop table t1;

View File

@ -0,0 +1,59 @@
delimiter ||;
use mtr||
--
-- Procedure used to check if server has been properly
-- restored after testcase has been run
--
CREATE DEFINER=root@localhost PROCEDURE check_testcase()
BEGIN
-- Dump all global variables except those
-- that are supposed to change
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME;
-- Dump all databases, there should be none
-- except those that was created during bootstrap
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA;
-- The test database should not contain any tables
SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema='test';
-- Show "mysql" database, tables and columns
SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema='mysql' AND table_name != 'ndb_apply_status'
ORDER BY tables_in_mysql;
SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql,
column_name, ordinal_position, column_default, is_nullable,
data_type, character_maximum_length, character_octet_length,
numeric_precision, numeric_scale, character_set_name,
collation_name, column_type, column_key, extra, column_comment
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_schema='mysql' AND table_name != 'ndb_apply_status'
ORDER BY columns_in_mysql;
-- Checksum system tables to make sure they have been properly
-- restored after test
checksum table
mysql.columns_priv,
mysql.db,
mysql.func,
mysql.help_category,
mysql.help_keyword,
mysql.help_relation,
mysql.host,
mysql.proc,
mysql.procs_priv,
mysql.tables_priv,
mysql.time_zone,
mysql.time_zone_leap_second,
mysql.time_zone_name,
mysql.time_zone_transition,
mysql.time_zone_transition_type,
mysql.user;
END||

View File

@ -0,0 +1,238 @@
delimiter ||;
use mtr||
--
-- Create table where testcases can insert patterns to
-- be suppressed
--
CREATE TABLE test_suppressions (
pattern VARCHAR(255)
) ENGINE=MyISAM||
--
-- Declare a trigger that makes sure
-- no invalid patterns can be inserted
-- into test_suppressions
--
/*!50002
CREATE DEFINER=root@localhost TRIGGER ts_insert
BEFORE INSERT ON test_suppressions
FOR EACH ROW BEGIN
DECLARE dummy INT;
SELECT "" REGEXP NEW.pattern INTO dummy;
END
*/||
--
-- Load table with patterns that will be suppressed globally(always)
--
CREATE TABLE global_suppressions (
pattern VARCHAR(255)
) ENGINE=MyISAM||
-- Declare a trigger that makes sure
-- no invalid patterns can be inserted
-- into global_suppressions
--
/*!50002
CREATE DEFINER=root@localhost TRIGGER gs_insert
BEFORE INSERT ON global_suppressions
FOR EACH ROW BEGIN
DECLARE dummy INT;
SELECT "" REGEXP NEW.pattern INTO dummy;
END
*/||
--
-- Insert patterns that should always be suppressed
--
INSERT INTO global_suppressions VALUES
("'SELECT UNIX_TIMESTAMP\\(\\)' failed on master"),
("Aborted connection"),
("Client requested master to start replication from impossible position"),
("Could not find first log file name in binary log"),
("Enabling keys got errno"),
("Error reading master configuration"),
("Error reading packet"),
("Event Scheduler"),
("Failed to open log"),
("Failed to open the existing master info file"),
("Forcing shutdown of [0-9]* plugins"),
("Forcing close of thread"),
/*
Due to timing issues, it might be that this warning
is printed when the server shuts down and the
computer is loaded.
*/
("Got error [0-9]* when reading table"),
("Incorrect definition of table"),
("Incorrect information in file"),
("InnoDB: Warning: we did not need to do crash recovery"),
("Invalid \\(old\\?\\) table or database name"),
("Lock wait timeout exceeded"),
("Log entry on master is longer than max_allowed_packet"),
("unknown option '--loose-"),
("unknown variable 'loose-"),
("You have forced lower_case_table_names to 0 through a command-line option"),
("Setting lower_case_table_names=2"),
("NDB Binlog:"),
("NDB: failed to setup table"),
("NDB: only row based binary logging"),
("Neither --relay-log nor --relay-log-index were used"),
("Query partially completed"),
("Slave I.O thread aborted while waiting for relay log"),
("Slave SQL thread is stopped because UNTIL condition"),
("Slave SQL thread retried transaction"),
("Slave \\(additional info\\)"),
("Slave: .*Duplicate column name"),
("Slave: .*master may suffer from"),
("Slave: According to the master's version"),
("Slave: Column [0-9]* type mismatch"),
("Slave: Error .* doesn't exist"),
("Slave: Error .*Unknown table"),
("Slave: Error in Write_rows event: "),
("Slave: Field .* of table .* has no default value"),
("Slave: Field .* doesn't have a default value"),
("Slave: Query caused different errors on master and slave"),
("Slave: Table .* doesn't exist"),
("Slave: Table width mismatch"),
("Slave: The incident LOST_EVENTS occured on the master"),
("Slave: Unknown error.* 1105"),
("Slave: Can't drop database.* database doesn't exist"),
("Slave SQL:.*(Error_code: \[\[:digit:\]\]+|Query:.*)"),
("Sort aborted"),
("Time-out in NDB"),
("Warning:\s+One can only use the --user.*root"),
("Warning:\s+Setting lower_case_table_names=2"),
("Warning:\s+Table:.* on (delete|rename)"),
("You have an error in your SQL syntax"),
("deprecated"),
("description of time zone"),
("equal MySQL server ids"),
("error .*connecting to master"),
("error reading log entry"),
("lower_case_table_names is set"),
("skip-name-resolve mode"),
("slave SQL thread aborted"),
("Slave: .*Duplicate entry"),
/*
Special case, made as specific as possible, for:
Bug #28436: Incorrect position in SHOW BINLOG EVENTS causes
server coredump
*/
("Error in Log_event::read_log_event\\\(\\\): 'Sanity check failed', data_len: 258, event_type: 49"),
("Statement is not safe to log in statement format"),
/* test case for Bug#bug29807 copies a stray frm into database */
("InnoDB: Error: table `test`.`bug29807` does not exist in the InnoDB internal"),
("Cannot find or open table test\/bug29807 from"),
/* innodb foreign key tests that fail in ALTER or RENAME produce this */
("InnoDB: Error: in ALTER TABLE `test`.`t[12]`"),
("InnoDB: Error: in RENAME TABLE table `test`.`t1`"),
("InnoDB: Error: table `test`.`t[12]` does not exist in the InnoDB internal"),
/* Test case for Bug#14233 produces the following warnings: */
("Stored routine 'test'.'bug14233_1': invalid value in column mysql.proc"),
("Stored routine 'test'.'bug14233_2': invalid value in column mysql.proc"),
("Stored routine 'test'.'bug14233_3': invalid value in column mysql.proc"),
/*
BUG#32080 - Excessive warnings on Solaris: setrlimit could not
change the size of core files
*/
("setrlimit could not change the size of core files to 'infinity'"),
/*
rpl_extrColmaster_*.test, the slave thread produces warnings
when it get updates to a table that has more columns on the
master
*/
("Slave: Unknown column 'c7' in 't15' Error_code: 1054"),
("Slave: Can't DROP 'c7'.* 1091"),
("Slave: Key column 'c6'.* 1072"),
/* Test case for Bug#31590 in order_by.test produces the following error */
("Out of sort memory; increase server sort buffer size"),
/* Special case for Bug #26402 in show_check.test
- Question marks are not valid file name parts on Windows. Ignore
this error message.
*/
("Can't find file: '.\\\\test\\\\\\?{8}.frm'"),
("THE_LAST_SUPPRESSION")||
--
-- Procedure that uses the above created tables to check
-- the servers error log for warnings
--
CREATE DEFINER=root@localhost PROCEDURE check_warnings(OUT result INT)
BEGIN
DECLARE `pos` bigint unsigned;
-- Don't write these queries to binlog
SET SQL_LOG_BIN=0;
--
-- Remove mark from lines that are suppressed by global suppressions
--
UPDATE error_log el, global_suppressions gs
SET suspicious=0
WHERE el.suspicious=1 AND el.line REGEXP gs.pattern;
--
-- Remove mark from lines that are suppressed by test specific suppressions
--
UPDATE error_log el, test_suppressions ts
SET suspicious=0
WHERE el.suspicious=1 AND el.line REGEXP ts.pattern;
--
-- Get the number of marked lines and return result
--
SELECT COUNT(*) INTO @num_warnings FROM error_log
WHERE suspicious=1;
IF @num_warnings > 0 THEN
SELECT file_name, line
FROM error_log WHERE suspicious=1;
--SELECT * FROM test_suppressions;
-- Return 2 -> check failed
SELECT 2 INTO result;
ELSE
-- Return 0 -> OK
SELECT 0 INTO RESULT;
END IF;
-- Cleanup for next test
TRUNCATE test_suppressions;
DROP TABLE error_log;
END||
--
-- Declare a procedure testcases can use to insert test
-- specific suppressions
--
/*!50001
CREATE DEFINER=root@localhost
PROCEDURE add_suppression(pattern VARCHAR(255))
BEGIN
INSERT INTO test_suppressions (pattern) VALUES (pattern);
END
*/||

View File

@ -1651,7 +1651,7 @@ FLUSH LOGS;
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/ --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/
--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLTEST_VARDIR/log/master-bin.000001 --exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
--echo # --echo #
--echo # Cleanup. --echo # Cleanup.
@ -1731,7 +1731,7 @@ FLUSH LOGS;
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/ --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/
--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLTEST_VARDIR/log/master-bin.000001 --exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
--echo # --echo #
--echo # Cleanup. --echo # Cleanup.
@ -1854,7 +1854,7 @@ FLUSH LOGS;
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/ --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/
--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLTEST_VARDIR/log/master-bin.000001 --exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
--echo # --echo #
--echo # Cleanup. --echo # Cleanup.
@ -1887,7 +1887,7 @@ eval CREATE TABLE t1 (
--echo # --echo #
--echo # Load data. --echo # Load data.
--echo # --echo #
LOAD DATA INFILE '../std_data_ln/loaddata5.dat' LOAD DATA INFILE '../../std_data/loaddata5.dat'
INTO TABLE t1 FIELDS TERMINATED BY '' ENCLOSED BY '' (c1,c2) INTO TABLE t1 FIELDS TERMINATED BY '' ENCLOSED BY '' (c1,c2)
SET c3 = 'Wow'; SET c3 = 'Wow';
@ -1912,7 +1912,7 @@ FLUSH LOGS;
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/ --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/
--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLTEST_VARDIR/log/master-bin.000001 --exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
--echo # --echo #
--echo # Cleanup. --echo # Cleanup.

View File

@ -1,2 +1,3 @@
echo Output from mysqltest-x.inc; echo Output from mysqltest-x.inc;
exit;

View File

@ -2,23 +2,21 @@
# By JBM 2006-02-16 So that the code is not repeated # # By JBM 2006-02-16 So that the code is not repeated #
# in test cases and can be reused. # # in test cases and can be reused. #
###################################################### ######################################################
--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "start backup" >> $NDB_TOOLS_OUTPUT --exec $NDB_MGM --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -e "start backup" >> $NDB_TOOLS_OUTPUT
# there is no neat way to find the backupid, this is a hack to find it... # there is no neat way to find the backupid, this is a hack to find it...
let $dump_file= $MYSQLTEST_VARDIR/tmp/tmp.dat;
--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="$NDB_CONNECTSTRING" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $dump_file
--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $MYSQLTEST_VARDIR/tmp.dat CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; --replace_result $dump_file DUMP_FILE
eval LOAD DATA INFILE '$dump_file' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DELETE FROM test.backup_info;
LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
--replace_column 1 <the_backup_id>
SELECT @the_backup_id:=backup_id FROM test.backup_info;
let the_backup_id=`select @the_backup_id`;
# Load backup id into environment variable
let the_backup_id=`SELECT backup_id from test.backup_info`;
DROP TABLE test.backup_info; DROP TABLE test.backup_info;
remove_file $dump_file;

View File

@ -0,0 +1,136 @@
#############################################################
# Author: Serge Kozlov <skozlov@mysql.com>
# Date: 03/17/2008
# Purpose: Set up circular cluster replication where each
# cluster has two mysqlds and replication directions are
# following:
# master ---> slave
# / \
# cluster A cluster B
# \ /
# master1 <--- slave1
#############################################################
--source include/have_log_bin.inc
# Make connections to mysqlds
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT1,);
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT1,);
# Check that all mysqld compiled with ndb support
--connection master
--disable_query_log
--require r/true.require
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
--source include/ndb_not_readonly.inc
--enable_query_log
--connection master1
--disable_query_log
--require r/true.require
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
--source include/ndb_not_readonly.inc
--enable_query_log
--connection slave
--disable_query_log
--require r/true.require
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
--source include/ndb_not_readonly.inc
--enable_query_log
--connection slave1
--disable_query_log
--require r/true.require
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
--source include/ndb_not_readonly.inc
--enable_query_log
# Stop slaves
--connection master
--disable_warnings
STOP SLAVE;
--wait_for_slave_to_stop
--enable_warnings
--connection master1
--disable_warnings
STOP SLAVE;
--wait_for_slave_to_stop
--enable_warnings
--connection slave
--disable_warnings
STOP SLAVE;
--wait_for_slave_to_stop
--enable_warnings
--connection slave1
--disable_warnings
STOP SLAVE;
--wait_for_slave_to_stop
--enable_warnings
# Reset masters
--connection master
--disable_warnings
--disable_query_log
USE test;
--enable_query_log
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
RESET MASTER;
--connection master1
--disable_warnings
--disable_query_log
USE test;
--enable_query_log
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
RESET MASTER;
--connection slave
--disable_warnings
--disable_query_log
USE test;
--enable_query_log
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
RESET MASTER;
--connection slave1
--disable_warnings
--disable_query_log
USE test;
--enable_query_log
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
RESET MASTER;
# Start slaves
--connection slave
RESET SLAVE;
--replace_result $MASTER_MYPORT MASTER_MYPORT
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$MASTER_MYPORT,master_user='root'
START SLAVE;
--source include/wait_for_slave_to_start.inc
--connection master1
RESET SLAVE;
--replace_result $SLAVE_MYPORT1 SLAVE_MYPORT1
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT1,master_user='root'
START SLAVE;
--source include/wait_for_slave_to_start.inc
# Set the default connection to 'master' (cluster A)
connection master;

View File

@ -17,7 +17,7 @@ while ($mysql_errno)
{ {
if (!$counter) if (!$counter)
{ {
die("Failed while waiting for mysqld to come out of readonly mode"); die Failed while waiting for mysqld to come out of readonly mode;
} }
dec $counter; dec $counter;
--sleep 0.1 --sleep 0.1

View File

@ -3,6 +3,6 @@
# in test cases and can be reused. # # in test cases and can be reused. #
###################################################### ######################################################
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -p 8 -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT --exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -p 8 -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -p 8 -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT --exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -p 8 -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT

View File

@ -3,9 +3,9 @@
# in test cases and can be reused. # # in test cases and can be reused. #
###################################################### ######################################################
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -p 8 -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT --exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING_SLAVE" -p 8 -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -p 8 -b $the_backup_id -n 2 -r -e --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT --exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING_SLAVE" -p 8 -b $the_backup_id -n 2 -r -e --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT

View File

@ -1,4 +1,3 @@
-- require r/not_as_root.require if ($MYSQL_TEST_ROOT){
disable_query_log; skip Not as root;
eval select "$MYSQL_TEST_ROOT" as running_as_root; }
enable_query_log;

View File

@ -108,7 +108,6 @@ execute stmt1 using @arg00, @arg01;
select a,b from t1 where a=@arg00; select a,b from t1 where a=@arg00;
set @arg00=NULL; set @arg00=NULL;
set @arg01=2; set @arg01=2;
--error 1048
execute stmt1 using @arg00, @arg01; execute stmt1 using @arg00, @arg01;
select a,b from t1 order by a; select a,b from t1 order by a;
set @arg00=0; set @arg00=0;

View File

@ -176,6 +176,7 @@ show status like "Qcache_queries_in_cache";
show status like "Qcache_hits"; show status like "Qcache_hits";
# Final cleanup # Final cleanup
eval set GLOBAL query_cache_size=$save_query_cache_size;
connection default; connection default;
drop table t2; drop table t2;
disconnect connection1; disconnect connection1;

View File

@ -9,3 +9,4 @@ show engines;
show variables; show variables;
--echo ===== STOP ===== --echo ===== STOP =====
--enable_query_log --enable_query_log
exit;

View File

@ -1,10 +1,8 @@
--echo **** Resetting master and slave **** --echo **** Resetting master and slave ****
connection slave; connection slave;
STOP SLAVE; source include/stop_slave.inc;
source include/wait_for_slave_to_stop.inc;
RESET SLAVE; RESET SLAVE;
connection master; connection master;
RESET MASTER; RESET MASTER;
connection slave; connection slave;
START SLAVE; source include/start_slave.inc;
source include/wait_for_slave_to_start.inc;

View File

@ -0,0 +1,25 @@
# Write file to make mysql-test-run.pl expect the "crash", but don't start
# it until it's told to
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
wait
EOF
# Send shutdown to the connected server and give
# it 10 seconds to die before zapping it
shutdown_server 10;
# Write file to make mysql-test-run.pl start up the server again
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF
# Turn on reconnect
--enable_reconnect
# Call script that will poll the server waiting for it to be back online again
--source include/wait_until_connected_again.inc
# Turn off reconnect again
--disable_reconnect

View File

@ -62,7 +62,9 @@ SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name
DROP EVENT IF EXISTS test.slave_once; DROP EVENT IF EXISTS test.slave_once;
--enable_warnings --enable_warnings
CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO # Create an event on slave and check its state. An event shouldn't be executed
# so set start time in 1 hour.
CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once'); INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once');
--echo "Checking event status on the slave for originator value = slave's server_id" --echo "Checking event status on the slave for originator value = slave's server_id"
@ -81,8 +83,11 @@ connection master;
DROP EVENT IF EXISTS test.justonce; DROP EVENT IF EXISTS test.justonce;
--enable_warnings --enable_warnings
# Create an event on master and check its state on slave. An event shouldn't be executed
# so set start time in 1 hour. Check that changes of event statement replicated to slave
--echo "Creating event test.er on the master" --echo "Creating event test.er on the master"
CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er'); INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er');
--echo "Checking event status on the master" --echo "Checking event status on the master"
@ -95,7 +100,7 @@ SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND
connection master; connection master;
--echo "Altering event test.er on the master" --echo "Altering event test.er on the master"
ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er'); INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er');
--echo "Checking event status on the master" --echo "Checking event status on the master"
@ -123,8 +128,11 @@ SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';
# test the DISABLE ON SLAVE for setting event SLAVESIDE_DISABLED as status # test the DISABLE ON SLAVE for setting event SLAVESIDE_DISABLED as status
# on CREATE EVENT # on CREATE EVENT
# Create an event on slave and check its status. An event shouldn't be executed
# so set start time in 1 hour.
--echo "Creating event test.slave_terminate on the slave" --echo "Creating event test.slave_terminate on the slave"
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate'); INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate');
--echo "Checking event status on the slave" --echo "Checking event status on the slave"

View File

@ -9,7 +9,7 @@ select id,hex(b1),vc,bc,d,f,total,y,t from t1 order by id;
sync_slave_with_master; sync_slave_with_master;
select id,hex(b1),vc,bc,d,f,total,y,t from t1 order by id; select id,hex(b1),vc,bc,d,f,total,y,t from t1 order by id;
connection master; connection master;
DELETE FROM mysqltest1.t1 WHERE id = 42; DELETE FROM t1 WHERE id = 42;
select id,hex(b1),vc,bc,d,f,total,y,t from t1 order by id; select id,hex(b1),vc,bc,d,f,total,y,t from t1 order by id;
sync_slave_with_master; sync_slave_with_master;
select id,hex(b1),vc,bc,d,f,total,y,t from t1 order by id; select id,hex(b1),vc,bc,d,f,total,y,t from t1 order by id;

View File

@ -68,9 +68,8 @@ let $_fake_relay_log_purge= `SELECT @@global.relay_log_purge`;
# Create relay log file. # Create relay log file.
copy_file $fake_relay_log $_fake_relay_log; copy_file $fake_relay_log $_fake_relay_log;
# Create relay log index. # Create relay log index.
eval SELECT '$_fake_relay_log' INTO OUTFILE '$_fake_relay_index'; --exec echo $_fake_relay_log > $_fake_relay_index
# Setup replication from existing relay log. # Setup replication from existing relay log.
eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_relay_log', RELAY_LOG_POS=4; eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_relay_log', RELAY_LOG_POS=4;

View File

@ -0,0 +1,87 @@
# ==== Purpose ====
#
# Print status information for replication, typically used to debug
# test failures.
#
# First, the following is printed on slave:
#
# SHOW SLAVE STATUS
# SHOW PROCESSLIST
# SHOW BINLOG EVENTS IN <binlog_name>
#
# Where <binlog_name> is the currently active binlog.
#
# Then, the following is printed on master:
#
# SHOW MASTER STATUS
# SHOW PROCESSLIST
# SHOW BINLOG EVENTS IN <sql_binlog_name>
# SHOW BINLOG EVENTS IN <io_binlog_name>
#
# Where <sql_binlog_name> is the binlog name that the slave sql thread
# is currently reading from and <io_binlog_name> is the binlog that
# the slave IO thread is currently reading from.
#
# ==== Usage ====
#
# [let $master_connection= <connection>;]
# source include/show_rpl_debug_info.inc;
#
# If $master_connection is set, debug info will be retrieved from the
# connection named $master_connection. Otherwise, it will be
# retrieved from the 'master' connection if the current connection is
# 'slave'.
let $_con= $CURRENT_CONNECTION;
--echo
--echo [on $_con]
--echo
--echo **** SHOW SLAVE STATUS on $_con ****
query_vertical SHOW SLAVE STATUS;
--echo
--echo **** SHOW PROCESSLIST on $_con ****
SHOW PROCESSLIST;
--echo
--echo **** SHOW BINLOG EVENTS on $_con ****
let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1);
eval SHOW BINLOG EVENTS IN '$binlog_name';
let $_master_con= $master_connection;
if (`SELECT '$_master_con' = ''`)
{
if (`SELECT '$_con' = 'slave'`)
{
let $_master_con= master;
}
if (`SELECT '$_master_con' = ''`)
{
--echo Unable to determine master connection. No debug info printed for master.
--echo Please fix the test case by setting $master_connection before sourcing
--echo show_rpl_debug_info.inc.
}
}
if (`SELECT '$_master_con' != ''`)
{
let $master_binlog_name_io= query_get_value("SHOW SLAVE STATUS", Master_Log_File, 1);
let $master_binlog_name_sql= query_get_value("SHOW SLAVE STATUS", Relay_Master_Log_File, 1);
--echo
--echo [on $_master_con]
connection $_master_con;
--echo
--echo **** SHOW MASTER STATUS on $_master_con ****
query_vertical SHOW MASTER STATUS;
--echo
--echo **** SHOW PROCESSLIST on $_master_con ****
SHOW PROCESSLIST;
--echo
--echo **** SHOW BINLOG EVENTS on $_master_con ****
eval SHOW BINLOG EVENTS IN '$master_binlog_name_sql';
if (`SELECT '$master_binlog_name_io' != '$master_binlog_name_sql'`)
{
eval SHOW BINLOG EVENTS IN '$master_binlog_name_io';
}
connection $_con;
}

View File

@ -0,0 +1,21 @@
# ==== Purpose ====
#
# Issues START SLAVE on the current connection. Then waits until both
# the IO and SQL threads have started, or until a timeout is reached.
#
# Please use this instead of 'START SLAVE', to reduce the risk of test
# case bugs.
#
# ==== Usage ====
#
# source include/wait_for_slave_to_start.inc;
#
# Parameters to this macro are $slave_timeout and
# $master_connection. See wait_for_slave_param.inc for
# descriptions.
--disable_query_log
START SLAVE;
--enable_query_log
--echo include/start_slave.inc
source include/wait_for_slave_to_start.inc;

View File

@ -0,0 +1,21 @@
# ==== Purpose ====
#
# Issues STOP SLAVE on the current connection. Then waits until both
# the IO and SQL threads have stopped, or until a timeout is reached.
#
# Please use this instead of 'STOP SLAVE', to reduce the risk of test
# case bugs.
#
# ==== Usage ====
#
# source include/wait_for_slave_to_start.inc;
#
# Parameters to this macro are $slave_timeout and
# $master_connection. See wait_for_slave_param.inc for
# descriptions.
--disable_query_log
STOP SLAVE;
--enable_query_log
--echo include/stop_slave.inc
source include/wait_for_slave_to_stop.inc;

View File

@ -0,0 +1,36 @@
# ==== Purpose ====
#
# Waits until the slave IO thread has been synced, i.e., all events
# have been copied over to slave. Does not care if the SQL thread is
# in sync.
#
#
# ==== Usage ====
#
# source include/sync_slave_io_with_master.inc;
#
# Syncs to the current position on master, as found by SHOW MASTER
# STATUS.
#
# Must be called on the master. Will change connection to the slave.
#
# Parameters to this macro are $slave_timeout and
# $master_connection. See wait_for_slave_param.inc for
# descriptions.
let $_master_file= query_get_value("SHOW MASTER STATUS", File, 1);
let $_master_pos= query_get_value("SHOW MASTER STATUS", Position, 1);
connection slave;
let $slave_error_message= Failed while waiting for slave IO thread to sync;
let $slave_param= Master_Log_File;
let $slave_param_value= $_master_file;
source include/wait_for_slave_param.inc;
let $slave_param= Read_Master_Log_Pos;
let $slave_param_value= $_master_pos;
source include/wait_for_slave_param.inc;
let $slave_error_message= ;

View File

@ -19,12 +19,6 @@
# # # #
################################################################### ###################################################################
--disable_query_log if ($USE_RUNNING_SERVER){
eval set @USE_RUNNING_SERVER= '$USE_RUNNING_SERVER'; skip Not with extern server;
--require r/testdb_only.require }
SELECT 'use extern server'
AS "Variable_name ",
IF(@USE_RUNNING_SERVER= '1','YES',
IF(@USE_RUNNING_SERVER= '0','NO','UNEXPECTED'))
AS "Value" ;
--enable_query_log

View File

@ -0,0 +1,19 @@
# ==== Purpose ====
#
# Waits until the IO thread of the current connection has started and
# connected to the master (i.e., until SHOW SLAVE STATUS returns Yes
# in the Slave_IO_Running field), or until a timeout is reached.
#
# ==== Usage ====
#
# source include/wait_for_slave_io_to_start.inc;
#
# Parameters to this macro are $slave_timeout and
# $master_connection. See wait_for_slave_param.inc for
# descriptions.
let $slave_param= Slave_IO_Running;
let $slave_param_value= Yes;
let $slave_error_message= Failed while waiting for slave IO thread to start;
source include/wait_for_slave_param.inc;
let $slave_error_message= ;

View File

@ -1,33 +1,24 @@
################################################### # ==== Purpose ====
#Author: Jeb #
#Date: 2007-06-11 # Waits until the IO thread of the current connection has stopped, or
#Purpose: used for io errors on the slave. If Slave gets an io # until a timeout is reached.
# error, the io trhead should stop #
#Details: # ==== Usage ====
# 1) Fill in and setup variables #
# 2) loop through looking for # source include/wait_for_slave_io_to_stop.inc;
# sql threads to stop #
# 3) If loops too long die. # Parameters to this macro are $slave_timeout and
#################################################### # $master_connection. See wait_for_slave_param.inc for
connection slave; # descriptions.
let $my_show= SHOW SLAVE STATUS;
let $sql_running= Slave_IO_Running;
let $row_number= 1;
let $run= 1;
let $counter= 300;
while ($run) # if server has not used CHANGE MASTER to initiate slave, SHOW SLAVE
# STATUS will return an empty set.
let $_slave_io_running= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1);
if (`SELECT '$_slave_io_running' != 'No such row'`)
{ {
let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number); let $slave_param= Slave_IO_Running;
if (`SELECT '$io_result' = 'No'`){ let $slave_param_value= No;
let $run= 0; let $slave_error_message= Failed while waiting for slave IO thread to stop;
} source include/wait_for_slave_param.inc;
sleep 0.1; let $slave_error_message= ;
if (!$counter){
--echo "Failed while waiting for slave IO thread to stop"
query_vertical SHOW SLAVE STATUS;
exit;
}
dec $counter;
} }

View File

@ -1,26 +1,82 @@
# include/wait_for_slave_param.inc # ==== Purpose ====
# #
# SUMMARY # Waits until SHOW SLAVE STATUS has returned a specified value, or
# until a timeout is reached.
# #
# Waits until SHOW SLAVE STATUS has returned a spicified value. # ==== Usage ====
# #
# USAGE # let $slave_param= Slave_SQL_Running;
# let $slave_param_value= No;
# source include/slave_wait_param.inc;
# #
# let $slave_param= Slave_SQL_Running; # Parameters:
# let $slave_param_value= No; #
# --source include/slave_wait_param.inc # $slave_param, $slave_param_value
# This macro will wait until the column of the output of SHOW SLAVE
# STATUS named $slave_param gets the value $slave_param_value. See
# the example above.
#
# $slave_param_comparison
# By default, this file waits until $slave_param becomes equal to
# $slave_param_value. If you want to wait until $slave_param
# becomes *unequal* to $slave_param_value, set this parameter to the
# string '!=', like this:
# let $slave_param_comparison= !=;
#
# $slave_timeout
# The default timeout is 5 minutes. You can change the timeout by
# setting $slave_timeout. The unit is tenths of seconds.
#
# $master_connection
# If the timeout is reached, debug info is given by calling SHOW
# SLAVE STATUS, SHOW PROCESSLIST, and SHOW BINLOG EVENTS. Then, a
# 'connection master' is then issued, and more debug info is given
# by calling SHOW MASTER STATUS, SHOW PROCESSLIST, and SHOW BINLOG
# EVENTS. If $master_connection is set, the latter three commands
# will be issued on $master_connection instead of on the host named
# 'master'. See also show_rpl_debug_info.inc
#
# $slave_error_message
# If set, this is printed when a timeout occurs. This is primarily
# intended to be used by other wait_for_slave_* macros, to indicate
# what the purpose of the wait was. (A very similar error message is
# given by default, but the wait_for_slave_* macros use this to give
# an error message identical to that in previous versions, so that
# errors are easier searchable in the pushbuild history.)
let $slave_wait_param_counter= 300; let $_slave_timeout_counter= $slave_timeout;
let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1); if (!$_slave_timeout_counter)
while (`select "$slave_value" != "$slave_param_value"`)
{ {
dec $slave_wait_param_counter; let $_slave_timeout_counter= 3000;
if (!$slave_wait_param_counter) }
{
--echo ERROR: failed while waiting for slave parameter $slave_param: $slave_param_value let $_slave_param_comparison= $slave_param_comparison;
query_vertical show slave status; if (`SELECT '$_slave_param_comparison' = ''`)
exit; {
} let $_slave_param_comparison= =;
sleep 0.1; }
let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
while (`SELECT NOT('$_show_slave_status_value' $_slave_param_comparison '$slave_param_value') AND $_slave_timeout_counter > 0`)
{
dec $_slave_timeout_counter;
if ($_slave_timeout_counter)
{
sleep 0.1;
let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
}
}
# This has to be outside the loop until BUG#41913 has been fixed
if (!$_slave_timeout_counter)
{
--echo **** ERROR: timeout after $slave_timeout seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
if (`SELECT '$slave_error_message' != ''`)
{
--echo Message: $slave_error_message
}
--echo Current connection is '$CURRENT_CONNECTION'
echo Note: the following output may have changed since the failure was detected;
source include/show_rpl_debug_info.inc;
exit;
} }

View File

@ -1,33 +1,39 @@
################################################### # ==== Purpose ====
#Author: Sven #
#Date: 2007-10-09 # Waits until the SQL thread of the current connection has got an
#Purpose: Wait until the slave has an error in the # error, or until a timeout is reached. Also waits until the SQL
# sql thread, as indicated by # thread has completely stopped.
# "SHOW SLAVE STATUS", or at most 30 #
# seconds. # ==== Usage ====
#Details: #
# 1) Fill in and setup variables # source include/wait_for_slave_sql_error.inc;
# 2) loop, looking for sql error on slave #
# 3) If it loops too long, die. # Parameters:
#################################################### #
connection slave; # $slave_sql_errno
let $row_number= 1; # The expected SQL error number. This is required.
let $run= 1; # (After BUG#41956 has been fixed, this will be required to be a
let $counter= 300; # symbolic name instead of a number.)
#
# $slave_timeout
# See wait_for_slave_param.inc for description.
#
# $master_connection
# See wait_for_slave_param.inc for description.
while ($run) if (`SELECT '$slave_sql_errno' = ''`) {
{ --echo !!!ERROR IN TEST: you must set \$slave_sql_errno before sourcing wait_fro_slave_sql_error.inc
let $sql_result= query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, $row_number); exit;
let $run= `SELECT '$sql_result' = '0'`; }
if ($run) {
real_sleep 0.1; let $slave_param= Slave_SQL_Running;
if (!$counter){ let $slave_param_value= No;
--echo "Failed while waiting for slave to produce an error in its sql thread" let $slave_error_message= Failed while waiting for slave to stop the SQL thread (expecting error in the SQL thread);
--replace_result $MASTER_MYPORT MASTER_PORT source include/wait_for_slave_param.inc;
--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
query_vertical SHOW SLAVE STATUS; let $_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
exit; if (`SELECT '$_error' != '$slave_sql_errno'`) {
} --echo Slave stopped with wrong error code: $_error (expected $slave_sql_errno)
dec $counter; source include/show_rpl_debug_info.inc;
} exit;
} }

View File

@ -5,8 +5,23 @@
# #
# ==== Usage ==== # ==== Usage ====
# #
# let show_sql_error=0|1; # let $slave_sql_error= <ERRNO>;
# source include/wait_for_slave_sql_error_and_skip.inc; # source include/wait_for_slave_sql_error_and_skip.inc;
#
# Parameters:
#
# $slave_sql_errno
# The error number to wait for. This is required. (See
# wait_for_slave_sql_error.inc)
#
# $show_sql_error
# If set, will print the error to the query log.
#
# $slave_timeout
# See wait_for_slave_param.inc for description.
#
# $master_connection
# See wait_for_slave_param.inc for description.
echo --source include/wait_for_slave_sql_error_and_skip.inc; echo --source include/wait_for_slave_sql_error_and_skip.inc;
connection slave; connection slave;
@ -17,11 +32,7 @@ if ($show_sql_error)
echo Last_SQL_Error = $error; echo Last_SQL_Error = $error;
} }
# wait for SQL thread to stop after the error
source include/wait_for_slave_sql_to_stop.inc;
# skip the erroneous statement # skip the erroneous statement
set global sql_slave_skip_counter=1; set global sql_slave_skip_counter=1;
start slave; source include/start_slave.inc;
source include/wait_for_slave_to_start.inc;
connection master; connection master;

View File

@ -1,31 +1,17 @@
################################################### # ==== Purpose ====
#Author: Mats (based on file written by Jeb) #
#Date: 2008-05-06 # Waits the SQL thread of the current connection has started, or until
#Purpose: To wait for slave SQL thread to start # a timeout is reached.
#Details: #
# 1) Fill in and setup variables # ==== Usage ====
# 2) loop through looking for both #
# io and sql threads to start # source include/wait_for_slave_sql_to_start.inc;
# 3) If loops too long die. #
#################################################### # Parameters to this macro are $slave_timeout and
connection slave; # $master_connection. See wait_for_slave_param.inc for
let $row_number= 1; # descriptions.
let $run= 1;
let $counter= 300;
while ($run)
{
let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number);
if (`SELECT '$sql_result' = 'Yes'`){
let $run= 0;
}
sleep 0.1;
if (!$counter){
--echo "Failed while waiting for slave SQL to start"
query_vertical SHOW SLAVE STATUS;
exit;
}
dec $counter;
}
let $slave_param= Slave_SQL_Running;
let $slave_param_value= Yes;
let $slave_error_message= Failed while waiting for slave SQL to start;
source include/wait_for_slave_param.inc;

View File

@ -1,33 +1,24 @@
################################################### # ==== Purpose ====
#Author: Jeb #
#Date: 2007-06-11 # Waits the SQL thread of the current connection has stopped, or until
#Purpose: used for SQL errors on the slave. If Slave gets a sql # a timeout is reached.
# error, the SQL trhead should stop #
#Details: # ==== Usage ====
# 1) Fill in and setup variables #
# 2) loop through looking for # source include/wait_for_slave_sql_to_stop.inc;
# sql threads to stop #
# 3) If loops too long die. # Parameters to this macro are $slave_timeout and
#################################################### # $master_connection. See wait_for_slave_param.inc for
if (!$keep_connection) # descriptions.
{
connection slave;
}
let $row_number= 1;
let $run= 1;
let $counter= 300;
while ($run) # if server has not used CHANGE MASTER to initiate slave, SHOW SLAVE
# STATUS will return an empty set.
let $_slave_io_running= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1);
if (`SELECT '$_slave_io_running' != 'No such row'`)
{ {
let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number); let $slave_param= Slave_SQL_Running;
if (`SELECT '$sql_result' = 'No'`){ let $slave_param_value= No;
let $run= 0; let $slave_error_message= Failed while waiting for slave SQL thread to stop;
} source include/wait_for_slave_param.inc;
sleep 0.1; let $slave_error_message= ;
if (!$counter){
--echo "Failed while waiting for slave SQL thread to stop"
query_vertical SHOW SLAVE STATUS;
exit;
}
dec $counter;
} }

View File

@ -1,35 +1,24 @@
################################################### # ==== Purpose ====
#Author: Jeb #
#Date: 2007-06-11 # Waits until both the IO and SQL threads of the current connection
#Purpose: To wait a brief time for slave to start # have started, or until a timeout is reached.
#Details: #
# 1) Fill in and setup variables # ==== Usage ====
# 2) loop through looking for both #
# io and sql threads to start # source include/wait_for_slave_to_start.inc;
# 3) If loops too long die. #
#################################################### # Parameters to this macro are $slave_timeout and
connection slave; # $master_connection. See wait_for_slave_param.inc for
let $row_number= 1; # descriptions.
let $run= 1;
let $counter= 300;
while ($run) let $slave_error_message= Failed while waiting for slave to start;
{
let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number);
if (`SELECT '$io_result' = 'Yes'`){
let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number); let $slave_param= Slave_IO_Running;
if (`SELECT '$sql_result' = 'Yes'`){ let $slave_param_value= Yes;
let $run= 0; source include/wait_for_slave_param.inc;
}
}
sleep 0.1;
if (!$counter){
--echo "Failed while waiting for slave to start"
query_vertical SHOW SLAVE STATUS;
exit;
}
dec $counter;
}
let $slave_param= Slave_SQL_Running;
let $slave_param_value= Yes;
source include/wait_for_slave_param.inc;
let $slave_error_message= ;

View File

@ -1,39 +1,30 @@
################################################### # ==== Purpose ====
#Author: Jeb #
#Date: 2007-06-11 # Waits until both the IO and SQL threads of the current connection
#Purpose: To replace the mysqltest.c executable # have stopped, or until a timeout is reached.
# wait_for_slave_to_stop function and #
# return this to the test language. # ==== Usage ====
#Details: #
# 1) Fill in and setup variables # source include/wait_for_slave_to_stop.inc;
# 2) loop through looking for both #
# io and sql threads to stop # Parameters to this macro are $slave_timeout and
# 3) If loops too long die. # $master_connection. See wait_for_slave_param.inc for
#################################################### # descriptions.
connection slave;
let $row_number= 1;
let $run= 1;
let $counter= 300;
while ($run) # if server has not used CHANGE MASTER to initiate slave, SHOW SLAVE
# STATUS will return an empty set.
let $_slave_io_running= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1);
if (`SELECT '$_slave_io_running' != 'No such row'`)
{ {
let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number); let $slave_error_message= Failed while waiting for slave to stop;
if (`SELECT '$io_result' = 'No'`){
let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number); let $slave_param= Slave_IO_Running;
if (`SELECT '$sql_result' = 'No'`){ let $slave_param_value= No;
let $run= 0; source include/wait_for_slave_param.inc;
}
} let $slave_param= Slave_SQL_Running;
sleep 0.1; let $slave_param_value= No;
if (!$counter){ source include/wait_for_slave_param.inc;
--echo "Failed while waiting for slave to stop"
--replace_result $MASTER_MYPORT MASTER_PORT let $slave_error_message= ;
--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
query_vertical SHOW SLAVE STATUS;
exit;
}
dec $counter;
} }

View File

@ -1,51 +0,0 @@
# include/wait_show_pattern.inc
#
# SUMMARY
#
# Waits until output produced by SHOW statement which particular type is
# specified as parameter matches certain pattern or maximum time reached.
#
# NOTES
#
# Only the first row produced by the parameter statement is checked.
#
# USAGE
#
# let $show_type= <Tail of SHOW statement>;
# let $show_pattern= 'Pattern to be used for LIKE matching';
# --source wait_show_pattern.inc
#
# EXAMPLES
#
# alter_table-big.test, wait_slave_status.inc
#
# SEE ALSO
#
# wait_slave_status.inc, wait_condition.inc (>=5.1)
#
###############################################################################
--disable_query_log
# We accept to wait maximum 30 seconds (0.2 sec/loop).
let $wait_counter= 150;
while ($wait_counter)
{
let $result= `SHOW $show_type`;
let $success= `SELECT '$result' LIKE $show_pattern`;
if ($success)
{
let $wait_counter= 0;
}
if (!$success)
{
real_sleep 0.2;
dec $wait_counter;
}
}
if (!$success)
{
echo Timeout in wait_show_pattern.inc \$show_type= $show_type \$show_pattern= $show_pattern (\$result= '$result');
}
--enable_query_log

View File

@ -1,129 +0,0 @@
# include/wait_slave_status.inc
#
# Created by Matthias Leich
#
# SUMMARY
#
# Waits until slave has reached certain state or maximum time reached.
#
# (This script will not work, when the SHOW command delivers more than one
# result record, because only the first record will be caught.)
#
# USAGE
#
# Set $result_pattern in test file and source this file:
#
# let $result_pattern= <pattern used for LIKE on the result of
# SHOW STATUS SLAVE>
# --include wait_slave_status.inc
#
# EXAMPLE
#
# The script rpl_until.test:
# ...
# --replace_result $MASTER_MYPORT MASTER_MYPORT
# --replace_column 1 # 9 # 23 # 33 #
# --vertical_results show slave status;
#
# outputs
# show slave status;
# Slave_IO_State #
# Master_Host 127.0.0.1
# Master_User root
# Master_Port MASTER_MYPORT
# Connect_Retry 1
# Master_Log_File master-bin.000001
# Read_Master_Log_Pos 776
# Relay_Log_File slave-relay-bin.000004
# Relay_Log_Pos #
# Relay_Master_Log_File master-bin.000001
# Slave_IO_Running Yes
# Slave_SQL_Running No
# Replicate_Do_DB
# Replicate_Ignore_DB
# Replicate_Do_Table
# Replicate_Ignore_Table
# Replicate_Wild_Do_Table
# Replicate_Wild_Ignore_Table
# Last_Errno 0
# Last_Error
# Skip_Counter 0
# Exec_Master_Log_Pos 319
# Relay_Log_Space #
# Until_Condition Master
# Until_Log_File master-bin.000001
# Until_Log_Pos 319
# Master_SSL_Allowed No
# Master_SSL_CA_File
# Master_SSL_CA_Path
# Master_SSL_Cert
# Master_SSL_Cipher
# Master_SSL_Key
# Seconds_Behind_Master #
#
# The main problem with the "show slave status;" in rpl_until is, that
# depending on the total test engine power and the current load caused by
# other processes, the expected slave status might be not reached though
# it will happen in maybe some seconds.
#
# The typical problem with rpl_until is that Slave_IO_Running is "No"
# instead of "Yes".
#
# The expected result follows the LIKE pattern:
#
# let $result_pattern= '%127.0.0.1%root%1%master-bin.000001%776%slave-relay-bin.000004%master-bin.000001%Yes%No%0%0%319%Master%master-bin.000001%319%No%';
#
# The Slave_IO_Running value is the "Yes" just after the "master-bin.000001".
#
# How to get this pattern ?
#
# Any lines "--replace_result ..." and "--replace_colum ..." just before
# the SHOW TABLE STATUS and of course the expected result itself
# show us columns where the content must be unified, because it is non
# deterministic or it depends on the current test environment.
#
# Unfortunately "--replace_result ..." and "--replace_colum ..." do not
# affect the result of our assignment let $my_val= `SHOW SLAVE STATUS`;
# Therefore such content must be covered by '%'.
#
# Please be careful. A more simple pattern might be dangerous, because we
# might get "wrong" matches. Example: There might be several "Yes" and "No"
# within one result row.
#
###############################################################################
# We do not want to print the auxiliary commands, because they are not of
# interest and their amount will vary depending how fast we get the
# desired state.
--disable_query_log
# The protocol should show
# - the setting of $result_pattern and
# - that this file is sourced ,
# because this increases the chance to use the protocol as replay script.
eval SELECT "let \$result_pattern= $result_pattern ;" AS "";
SELECT '--source include/wait_slave_status.inc' AS "";
let $show_type= SLAVE STATUS;
let $show_pattern= $result_pattern;
--enable_query_log
--source include/wait_show_pattern.inc
if (!$success)
{
let $message= ! Attention: Timeout in wait_slave_status.inc.
| Possible reasons with decreasing probability:
| - The LIKE pattern is wrong, because the
| testcase was altered or the layout of the
| SHOW SLAVE STATUS result set changed.
| - There is a new bug within the replication.
| - We met an extreme testing environment and timeout is
| too small.;
--source include/show_msg80.inc
--echo DEBUG INFO START (wait_slave_status.inc):
--echo $result_pattern
--vertical_results
show slave status;
--echo DEBUG INFO END
}

View File

@ -4,9 +4,13 @@
--disable_result_log --disable_result_log
--disable_query_log --disable_query_log
let $counter= 500; let $counter= 500;
let $mysql_errno= 9999;
while ($mysql_errno) while ($mysql_errno)
{ {
--error 0,2002,2003,2006,2013 # Strangely enough, the server might return "Too many connections"
# while being shutdown, thus 1040 is an "allowed" error
# See BUG#36228
--error 0,1040,1053,2002,2003,2006,2013
show status; show status;
dec $counter; dec $counter;

View File

@ -0,0 +1,112 @@
# include/wait_until_count_sessions.inc
#
# SUMMARY
#
# Waits until the passed number ($count_sessions) of concurrent sessions was
# observed via
# SHOW STATUS LIKE 'Threads_connected'
# or the operation times out.
# Note: Starting with 5.1 we could also use
# SELECT COUNT(*) FROM information_schema.processlist
# I stay with "SHOW STATUS LIKE 'Threads_connected'" because this
# runs in all versions 5.0+
#
#
# USAGE
#
# let $count_sessions= 3;
# --source include/wait_until_count_sessions.inc
#
# OR typical example of a test which uses more than one session
# Such a test could harm successing tests if there is no server shutdown
# and start between.cw
#
# If the testing box is slow than the disconnect of sessions belonging to
# the current test might happen when the successing test gets executed.
# This means the successing test might see activities like unexpected
# rows within the general log or the PROCESSLIST.
# Example from bug http://bugs.mysql.com/bug.php?id=40377
# --- bzr_mysql-6.0-rpl/.../r/log_state.result
# +++ bzr_mysql-6.0-rpl/.../r/log_state.reject
# @@ -25,6 +25,7 @@
# event_time user_host ... command_type argument
# TIMESTAMP USER_HOST ... Query create table t1(f1 int)
# TIMESTAMP USER_HOST ... Query select * from mysql.general_log
# +TIMESTAMP USER_HOST ... Quit
# ....
#
# What to do?
# -----------
# <start of test>
# # Determine initial number of connections (set $count_sessions)
# --source include/count_sessions.inc
# ...
# connect (con1,.....)
# ...
# connection default;
# ...
# disconnect con1;
# ...
# # Wait until we have reached the initial number of connections
# # or more than the sleep time above (10 seconds) has passed.
# # $count_sessions
# --source include/wait_until_count_sessions.inc
# <end of test>
#
# Important note about tests with unfortunate (= not cooperative
# to successing tests) architecture:
# connection con1;
# send SELECT ..., sleep(10)
# connection default;
# ...
# disconnect con1;
# <end of test>
# should be fixed by
# connection con1;
# send SELECT ..., sleep(10)
# connection default;
# ...
# connect con1;
# reap;
# connection default;
# disconnect con1;
# <end of test>
# and not only by appending include/wait_until_count_sessions.inc etc.
#
#
# EXAMPLE
#
# backup.test, grant3.test
#
#
# Created: 2009-01-14 mleich
#
let $wait_counter= 50;
if ($wait_timeout)
{
let $wait_counter= `SELECT $wait_timeout * 10`;
}
# Reset $wait_timeout so that its value won't be used on subsequent
# calls, and default will be used instead.
let $wait_timeout= 0;
while ($wait_counter)
{
let $current_sessions= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1);
let $success= `SELECT $current_sessions = $count_sessions`;
if ($success)
{
let $wait_counter= 0;
}
if (!$success)
{
real_sleep 0.1;
dec $wait_counter;
}
}
if (!$success)
{
--echo # Timeout in wait_until_count_sessions.inc
--echo # Number of sessions expected: $count_sessions found: $current_sessions
}

View File

@ -0,0 +1,21 @@
#
# Include this script to wait until the connection to the
# server has been dropped
--disable_result_log
--disable_query_log
let $counter= 500;
let $mysql_errno= 0;
while (!$mysql_errno)
{
--error 0,1053,2002,2006,2013
show status;
dec $counter;
if (!$counter)
{
--die Server failed to dissapear
}
--sleep 0.1
}
--enable_query_log
--enable_result_log

View File

@ -1,115 +0,0 @@
#!/bin/sh
# Copyright (C) 1997-2006 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU 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 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
# This scripts creates the privilege tables db, host, user, tables_priv,
# columns_priv in the mysql database, as well as the func table.
if [ x$1 = x"--bin" ]; then
shift 1
BINARY_DIST=1
bindir=../bin
scriptdir=bin
libexecdir=../libexec
# Check if it's a binary distribution or a 'make install'
if test -x ../libexec/mysqld
then
execdir=../libexec
elif test -x ../../sbin/mysqld # RPM installation
then
execdir=../../sbin
bindir=../../bin
scriptdir=../bin
libexecdir=../../libexec
else
execdir=../bin
fi
fix_bin=mysql-test
else
execdir=../sql
bindir=../client
fix_bin=.
scriptdir=scripts
libexecdir=../libexec
fi
vardir=var
logdir=$vardir/log
if [ x$1 = x"-slave" ]
then
shift 1
data=var/slave-data
else
if [ x$1 = x"-1" ]
then
data=var/master-data1
else
data=var/master-data
fi
fi
ldata=$fix_bin/$data
mdata=$data/mysql
EXTRA_ARG=""
mysqld=
if test -x $execdir/mysqld
then
mysqld=$execdir/mysqld
else
if test ! -x $libexecdir/mysqld
then
echo "mysqld is missing - looked in $execdir and in $libexecdir"
exit 1
else
mysqld=$libexecdir/mysqld
fi
fi
# On IRIX hostname is in /usr/bsd so add this to the path
PATH=$PATH:/usr/bsd
hostname=`hostname` # Install this too in the user table
hostname="$hostname%" # Fix if not fully qualified hostname
#create the directories
[ -d $vardir ] || mkdir $vardir
[ -d $logdir ] || mkdir $logdir
# Create database directories mysql & test
if [ -d $data ] ; then rm -rf $data ; fi
mkdir $data $data/mysql $data/test
#for error messages
if [ x$BINARY_DIST = x1 ] ; then
basedir=..
else
basedir=.
EXTRA_ARG="--windows"
fi
INSTALL_CMD="$scriptdir/mysql_install_db --no-defaults $EXTRA_ARG --basedir=$basedir --datadir=mysql-test/$ldata --srcdir=."
echo "running $INSTALL_CMD"
cd ..
if $INSTALL_CMD
then
exit 0
else
echo "Error executing mysqld --bootstrap"
exit 1
fi

View File

@ -4,6 +4,7 @@ package My::Config::Option;
use strict; use strict;
use warnings; use warnings;
use Carp;
sub new { sub new {
@ -26,12 +27,22 @@ sub value {
return $self->{value}; return $self->{value};
} }
sub option {
my ($self)= @_;
my $name= $self->{name};
my $value= $self->{value};
my $opt= $name;
$opt= "$name=$value" if ($value);
$opt= "--$opt" unless ($opt =~ /^--/);
return $opt;
}
package My::Config::Group; package My::Config::Group;
use strict; use strict;
use warnings; use warnings;
use Carp;
sub new { sub new {
my ($class, $group_name)= @_; my ($class, $group_name)= @_;
@ -68,7 +79,7 @@ sub remove {
return undef unless defined $option; return undef unless defined $option;
# Remove from the hash # Remove from the hash
delete($self->{options_by_name}->{$option_name}) or die; delete($self->{options_by_name}->{$option_name}) or croak;
# Remove from the array # Remove from the array
@{$self->{options}}= grep { $_->name ne $option_name } @{$self->{options}}; @{$self->{options}}= grep { $_->name ne $option_name } @{$self->{options}};
@ -88,6 +99,33 @@ sub name {
return $self->{name}; return $self->{name};
} }
sub suffix {
my ($self)= @_;
# Everything in name from the last .
my @parts= split(/\./, $self->{name});
my $suffix= pop(@parts);
return ".$suffix";
}
sub after {
my ($self, $prefix)= @_;
die unless defined $prefix;
# everything after $prefix
my $name= $self->{name};
if ($name =~ /^\Q$prefix\E(.*)$/)
{
return $1;
}
die "Failed to extract the value after '$prefix' in $name";
}
sub split {
my ($self)= @_;
# Return an array with name parts
return split(/\./, $self->{name});
}
# #
# Return a specific option in the group # Return a specific option in the group
@ -100,23 +138,37 @@ sub option {
# #
# Return a specific value for an option in the group # Return value for an option in the group, fail if it does not exist
# #
sub value { sub value {
my ($self, $option_name)= @_; my ($self, $option_name)= @_;
my $option= $self->option($option_name); my $option= $self->option($option_name);
die "No option named '$option_name' in this group" croak "No option named '$option_name' in group '$self->{name}'"
if ! defined($option); if ! defined($option);
return $option->value(); return $option->value();
} }
#
# Return value for an option if it exist
#
sub if_exist {
my ($self, $option_name)= @_;
my $option= $self->option($option_name);
return undef if ! defined($option);
return $option->value();
}
package My::Config; package My::Config;
use strict; use strict;
use warnings; use warnings;
use Carp;
use IO::File; use IO::File;
use File::Basename; use File::Basename;
@ -132,13 +184,13 @@ sub new {
my $self= bless { groups => [] }, $class; my $self= bless { groups => [] }, $class;
my $F= IO::File->new($path, "<") my $F= IO::File->new($path, "<")
or die "Could not open '$path': $!"; or croak "Could not open '$path': $!";
while ( my $line= <$F> ) { while ( my $line= <$F> ) {
chomp($line); chomp($line);
# [group] # [group]
if ( $line =~ /\[(.*)\]/ ) { if ( $line =~ /^\[(.*)\]/ ) {
# New group found # New group found
$group_name= $1; $group_name= $1;
#print "group: $group_name\n"; #print "group: $group_name\n";
@ -149,7 +201,7 @@ sub new {
# Magic #! comments # Magic #! comments
elsif ( $line =~ /^#\!/) { elsif ( $line =~ /^#\!/) {
my $magic= $line; my $magic= $line;
die "Found magic comment '$magic' outside of group" croak "Found magic comment '$magic' outside of group"
unless $group_name; unless $group_name;
#print "$magic\n"; #print "$magic\n";
@ -171,8 +223,13 @@ sub new {
# !include <filename> # !include <filename>
elsif ( $line =~ /^\!include\s*(.*?)\s*$/ ) { elsif ( $line =~ /^\!include\s*(.*?)\s*$/ ) {
my $include_file_name= dirname($path)."/".$1; my $include_file_name= dirname($path)."/".$1;
# Check that the file exists
die "The include file '$include_file_name' does not exist" # Check that the file exists relative to path of first config file
if (! -f $include_file_name){
# Try to include file relativ to current dir
$include_file_name= $1;
}
croak "The include file '$include_file_name' does not exist"
unless -f $include_file_name; unless -f $include_file_name;
$self->append(My::Config->new($include_file_name)); $self->append(My::Config->new($include_file_name));
@ -182,7 +239,7 @@ sub new {
elsif ( $line =~ /^([\@\w-]+)\s*$/ ) { elsif ( $line =~ /^([\@\w-]+)\s*$/ ) {
my $option= $1; my $option= $1;
die "Found option '$option' outside of group" croak "Found option '$option' outside of group"
unless $group_name; unless $group_name;
#print "$option\n"; #print "$option\n";
@ -194,13 +251,13 @@ sub new {
my $option= $1; my $option= $1;
my $value= $2; my $value= $2;
die "Found option '$option=$value' outside of group" croak "Found option '$option=$value' outside of group"
unless $group_name; unless $group_name;
#print "$option=$value\n"; #print "$option=$value\n";
$self->insert($group_name, $option, $value); $self->insert($group_name, $option, $value);
} else { } else {
die "Unexpected line '$line' found in '$path'"; croak "Unexpected line '$line' found in '$path'";
} }
} }
@ -231,6 +288,7 @@ sub insert {
# Add the option to the group # Add the option to the group
$group->insert($option, $value, $if_not_exist); $group->insert($option, $value, $if_not_exist);
} }
return $group;
} }
# #
@ -240,11 +298,11 @@ sub remove {
my ($self, $group_name, $option_name)= @_; my ($self, $group_name, $option_name)= @_;
my $group= $self->group($group_name); my $group= $self->group($group_name);
die "group '$group_name' does not exist" croak "group '$group_name' does not exist"
unless defined($group); unless defined($group);
$group->remove($option_name) or $group->remove($option_name) or
die "option '$option_name' does not exist"; croak "option '$option_name' does not exist";
} }
@ -267,10 +325,10 @@ sub group_exists {
# #
sub _group_insert { sub _group_insert {
my ($self, $group_name)= @_; my ($self, $group_name)= @_;
caller eq __PACKAGE__ or die; caller eq __PACKAGE__ or croak;
# Check that group does not already exist # Check that group does not already exist
die "Group already exists" if $self->group_exists($group_name); croak "Group already exists" if $self->group_exists($group_name);
my $group= My::Config::Group->new($group_name); my $group= My::Config::Group->new($group_name);
push(@{$self->{groups}}, $group); push(@{$self->{groups}}, $group);
@ -354,11 +412,11 @@ sub value {
my ($self, $group_name, $option_name)= @_; my ($self, $group_name, $option_name)= @_;
my $group= $self->group($group_name); my $group= $self->group($group_name);
die "group '$group_name' does not exist" croak "group '$group_name' does not exist"
unless defined($group); unless defined($group);
my $option= $group->option($option_name); my $option= $group->option($option_name);
die "option '$option_name' does not exist" croak "option '$option_name' does not exist"
unless defined($option); unless defined($option);
return $option->value(); return $option->value();
@ -372,7 +430,7 @@ sub exists {
my ($self, $group_name, $option_name)= @_; my ($self, $group_name, $option_name)= @_;
my $group= $self->group($group_name); my $group= $self->group($group_name);
die "group '$group_name' does not exist" croak "group '$group_name' does not exist"
unless defined($group); unless defined($group);
my $option= $group->option($option_name); my $option= $group->option($option_name);
@ -412,11 +470,11 @@ sub stringify {
# Save the config to named file # Save the config to named file
# #
sub save { sub save {
my ($self, $path)= @_; my ($self, $path)= @_;
my $F= IO::File->new($path, ">") my $F= IO::File->new($path, ">")
or die "Could not open '$path': $!"; or croak "Could not open '$path': $!";
print $F $self; print $F $self;
undef $F; # Close the file undef $F; # Close the file
} }
1; 1;

View File

@ -0,0 +1,655 @@
# -*- cperl -*-
package My::ConfigFactory;
use strict;
use warnings;
use Carp;
use My::Config;
use My::Find;
use File::Basename;
#
# Rules to run first of all
#
my @pre_rules=
(
);
my @share_locations= ("share/mysql", "sql/share", "share");
sub get_basedir {
my ($self, $group)= @_;
my $basedir= $group->if_exist('basedir') ||
$self->{ARGS}->{basedir};
return $basedir;
}
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)= @_;
return my_find_dir($self->get_basedir($group),
\@share_locations, "english");
}
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)= @_;
my $hostname= $group->value('#host');
return $self->{HOSTS}->{$hostname}++;
}
sub fix_host {
my ($self)= @_;
# Get next host from HOSTS array
my @hosts= keys(%{$self->{HOSTS}});;
my $host_no= $self->{NEXT_HOST}++ % @hosts;
return $hosts[$host_no];
}
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
my $dir= $self->{ARGS}->{tmpdir};
return "$dir/$group_name.sock";
}
sub fix_tmpdir {
my ($self, $config, $group_name, $group)= @_;
my $dir= $self->{ARGS}->{tmpdir};
return "$dir/$group_name";
}
sub fix_log_error {
my ($self, $config, $group_name, $group)= @_;
my $dir= dirname($group->value('datadir'));
return "$dir/mysqld.err";
}
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_secure_file_priv {
my ($self)= @_;
my $vardir= $self->{ARGS}->{vardir};
# By default, prevent the started mysqld to access files outside of vardir
return $vardir;
}
sub fix_std_data {
my ($self, $config, $group_name, $group)= @_;
my $basedir= $self->get_basedir($group);
return "$basedir/mysql-test/std_data";
}
sub ssl_supported {
my ($self)= @_;
return $self->{ARGS}->{ssl};
}
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;
}
sub fix_ssl_ca {
return if !ssl_supported(@_);
my $std_data= fix_std_data(@_);
return "$std_data/cacert.pem"
}
sub fix_ssl_server_cert {
return if !ssl_supported(@_);
my $std_data= fix_std_data(@_);
return "$std_data/server-cert.pem"
}
sub fix_ssl_client_cert {
return if !ssl_supported(@_);
my $std_data= fix_std_data(@_);
return "$std_data/client-cert.pem"
}
sub fix_ssl_server_key {
return if !ssl_supported(@_);
my $std_data= fix_std_data(@_);
return "$std_data/server-key.pem"
}
sub fix_ssl_client_key {
return if !ssl_supported(@_);
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}; } },
{ 'tmpdir' => \&fix_tmpdir },
{ 'character-sets-dir' => \&fix_charset_dir },
{ 'language' => \&fix_language },
{ 'datadir' => \&fix_datadir },
{ 'pid-file' => \&fix_pidfile },
{ '#host' => \&fix_host },
{ 'port' => \&fix_port },
{ 'socket' => \&fix_socket },
{ 'log-error' => \&fix_log_error },
{ 'log' => \&fix_log },
{ 'log-slow-queries' => \&fix_log_slow_queries },
{ '#user' => sub { return shift->{ARGS}->{user} || ""; } },
{ '#password' => sub { return shift->{ARGS}->{password} || ""; } },
{ 'server-id' => \&fix_server_id, },
# By default, prevent the started mysqld to access files outside of vardir
{ 'secure-file-priv' => sub { return shift->{ARGS}->{vardir}; } },
{ 'ssl-ca' => \&fix_ssl_ca },
{ 'ssl-cert' => \&fix_ssl_server_cert },
{ 'ssl-key' => \&fix_ssl_server_key },
);
sub fix_ndb_mgmd_port {
my ($self, $config, $group_name, $group)= @_;
my $hostname= $group->value('HostName');
return $self->{HOSTS}->{$hostname}++;
}
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=
(
{ 'ssl-ca' => \&fix_ssl_ca },
{ 'ssl-cert' => \&fix_ssl_client_cert },
{ 'ssl-key' => \&fix_ssl_client_key },
{ 'skip-ssl' => \&fix_skip_ssl },
);
#
# Rules to run for [mysqlbinlog] section
# - will be run in order listed here
#
my @mysqlbinlog_rules=
(
{ 'character-sets-dir' => \&fix_charset_dir },
);
#
# Rules to run for [mysql_upgrade] section
# - will be run in order listed here
#
my @mysql_upgrade_rules=
(
{ 'tmpdir' => sub { return shift->{ARGS}->{tmpdir}; } },
);
#
# Generate a [client.<suffix>] group to be
# used for connecting to [mysqld.<suffix>]
#
sub post_check_client_group {
my ($self, $config, $client_group_name, $mysqld_group_name)= @_;
# 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;
croak "Could not get value for '$name_from'";
}
$config->insert($client_group_name, $name_to, $option->value())
}
}
sub post_check_client_groups {
my ($self, $config)= @_;
my $first_mysqld= $config->first_like('mysqld.');
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())
}
}
#
# Generate [embedded] by copying the values
# needed from the default [mysqld] section
# and from first [mysqld.<suffix>]
#
sub post_check_embedded_group {
my ($self, $config)= @_;
return unless $self->{ARGS}->{embedded};
my $mysqld= $config->group('mysqld') or
croak "Can't run with embedded, config has no default mysqld section";
my $first_mysqld= $config->first_like('mysqld.') or
croak "Can't run with embedded, config has no mysqld";
my @no_copy =
(
'log-error', # Embedded server writes stderr to mysqltest's log file
'slave-net-timeout', # Embedded server are not build with replication
);
foreach my $option ( $mysqld->options(), $first_mysqld->options() ) {
# Don't copy options whose name is in "no_copy" list
next if grep ( $option->name() eq $_, @no_copy);
$config->insert('embedded', $option->name(), $option->value())
}
}
sub resolve_at_variable {
my ($self, $config, $group, $option)= @_;
# Split the options value on last .
my @parts= split(/\./, $option->value());
my $option_name= pop(@parts);
my $group_name= join('.', @parts);
$group_name =~ s/^\@//; # Remove at
my $from_group= $config->group($group_name)
or croak "There is no group named '$group_name' that ",
"can be used to resolve '$option_name'";
my $from= $from_group->value($option_name);
$config->insert($group->name(), $option->name(), $from)
}
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)
if ($option->value() =~ /^\@/);
}
}
}
sub post_fix_mysql_cluster_section {
my ($self, $config)= @_;
# Add a [mysl_cluster.<suffix>] section for each
# defined [cluster_config.<suffix>] section
foreach my $group ( $config->like('cluster_config\.\w*$') )
{
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,
\&post_check_embedded_group,
);
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');
foreach my $group ( $config->like('cluster_config\.\w*$') ) {
# 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};
}
# Fill in hosts/port hash
my $hosts= {};
my $baseport= $args->{baseport};
$args->{hosts}= [ 'localhost' ] unless exists($args->{hosts});
foreach my $host ( @{$args->{hosts}} ) {
$hosts->{$host}= $baseport;
}
# Open the config template
my $config= My::Config->new($args->{'template_path'});
my $extra_template_path= $args->{'extra_template_path'};
if ($extra_template_path){
$config->append(My::Config->new($extra_template_path));
}
my $self= bless {
CONFIG => $config,
ARGS => $args,
HOSTS => $hosts,
NEXT_HOST => 0,
SERVER_ID => 1,
}, $class;
{
# Run pre rules
foreach my $rule ( @pre_rules ) {
&$rule($self, $config);
}
}
$self->run_section_rules($config,
'cluster_config\.\w*$',
@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);
# [mysql_upgrade] need additional settings
$self->run_rules_for_group($config,
$config->insert('mysql_upgrade'),
@mysql_upgrade_rules);
# Additional rules required for [client]
$self->run_rules_for_group($config,
$config->insert('client'),
@client_rules);
# Additional rules required for [mysqltest]
$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;

View File

@ -0,0 +1,131 @@
# -*- cperl -*-
# Copyright (C) 2004-2006 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU 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 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
package My::CoreDump;
use strict;
use Carp;
use My::Platform;
use File::Temp qw/ tempfile tempdir /;
sub _gdb {
my ($core_name)= @_;
print "\nTrying 'gdb' to get a backtrace\n";
return unless -f $core_name;
# Find out name of binary that generated core
`gdb -c '$core_name' --batch 2>&1` =~
/Core was generated by `([^\s\'\`]+)/;
my $binary= $1 or return;
print "Core generated by '$binary'\n";
# Create tempfile containing gdb commands
my ($tmp, $tmp_name) = tempfile();
print $tmp
"bt\n",
"thread apply all bt\n",
"quit\n";
close $tmp or die "Error closing $tmp_name: $!";
# Run gdb
my $gdb_output=
`gdb '$binary' -c '$core_name' -x '$tmp_name' --batch 2>&1`;
unlink $tmp_name or die "Error removing $tmp_name: $!";
return if $? >> 8;
return unless $gdb_output;
print <<EOF, $gdb_output, "\n";
Output from gdb follows. The first stack trace is from the failing thread.
The following stack traces are from all threads (so the failing one is
duplicated).
--------------------------
EOF
return 1;
}
sub _dbx {
my ($core_name)= @_;
print "\nTrying 'dbx' to get a backtrace\n";
return unless -f $core_name;
# Find out name of binary that generated core
`echo | dbx - '$core_name' 2>&1` =~
/Corefile specified executable: "([^"]+)"/;
my $binary= $1 or return;
print "Core generated by '$binary'\n";
# Find all threads
my @thr_ids = `echo threads | dbx '$binary' '$core_name' 2>&1` =~ /t@\d+/g;
# Create tempfile containing dbx commands
my ($tmp, $tmp_name) = tempfile();
foreach my $thread (@thr_ids) {
print $tmp "where $thread\n";
}
print $tmp "exit\n";
close $tmp or die "Error closing $tmp_name: $!";
# Run dbx
my $dbx_output=
`cat '$tmp_name' | dbx '$binary' '$core_name' 2>&1`;
unlink $tmp_name or die "Error removing $tmp_name: $!";
return if $? >> 8;
return unless $dbx_output;
print <<EOF, $dbx_output, "\n";
Output from dbx follows. Stack trace is printed for all threads in order,
above this you should see info about which thread was the failing one.
----------------------------
EOF
return 1;
}
sub show {
my ($class, $core_name)= @_;
# We try dbx first; gdb itself may coredump if run on a Sun Studio
# compiled binary on Solaris.
my @debuggers =
(
\&_dbx,
\&_gdb,
# TODO...
);
# Try debuggers until one succeeds
foreach my $debugger (@debuggers){
if ($debugger->($core_name)){
return;
}
}
return;
}
1;

View File

@ -0,0 +1,177 @@
# -*- cperl -*-
package My::File::Path;
use strict;
#
# File::Path::rmtree has a problem with deleting files
# and directories where it hasn't got read permission
#
# Patch this by installing a 'rmtree' function in local
# scope that first chmod all files to 0777 before calling
# the original rmtree function.
#
# This is almost gone in version 1.08 of File::Path -
# but unfortunately some hosts still suffers
# from this also in 1.08
#
use Exporter;
use base "Exporter";
our @EXPORT= qw / rmtree mkpath copytree /;
use File::Find;
use File::Copy;
use File::Spec;
use Carp;
use My::Handles;
use My::Platform;
sub rmtree {
my ($dir)= @_;
find( {
bydepth => 1,
no_chdir => 1,
wanted => sub {
my $name= $_;
if (!-l $name && -d _){
return if (rmdir($name) == 1);
chmod(0777, $name) or carp("couldn't chmod(0777, $name): $!");
return if (rmdir($name) == 1);
# Failed to remove the directory, analyze
carp("Couldn't remove directory '$name': $!");
My::Handles::show_handles($name);
} else {
return if (unlink($name) == 1);
chmod(0777, $name) or carp("couldn't chmod(0777, $name): $!");
return if (unlink($name) == 1);
carp("Couldn't delete file '$name': $!");
My::Handles::show_handles($name);
}
}
}, $dir );
};
use File::Basename;
sub _mkpath_debug {
my ($message, $path, $dir, $err)= @_;
print "=" x 40, "\n";
print $message, "\n";
print "err: '$err'\n";
print "path: '$path'\n";
print "dir: '$dir'\n";
print "-" x 40, "\n";
my $dirname= dirname($path);
print "ls -l $dirname\n";
print `ls -l $dirname`, "\n";
print "-" x 40, "\n";
print "dir $dirname\n";
print `dir $dirname`, "\n";
print "-" x 40, "\n";
my $dirname2= dirname($dirname);
print "ls -l $dirname2\n";
print `ls -l $dirname2`, "\n";
print "-" x 40, "\n";
print "dir $dirname2\n";
print `dir $dirname2`, "\n";
print "-" x 40, "\n";
print "file exists\n" if (-e $path);
print "file is a plain file\n" if (-f $path);
print "file is a directory\n" if (-d $path);
print "-" x 40, "\n";
print "showing handles for $path\n";
My::Handles::show_handles($path);
print "=" x 40, "\n";
}
sub mkpath {
my $path;
die "Usage: mkpath(<path>)" unless @_ == 1;
foreach my $dir ( File::Spec->splitdir( @_ ) ) {
#print "dir: $dir\n";
if ($dir =~ /^[a-z]:/i){
# Found volume ie. C:
$path= $dir;
next;
}
$path= File::Spec->catdir($path, $dir);
#print "path: $path\n";
next if -d $path; # Path already exists and is a directory
croak("File already exists but is not a directory: '$path'") if -e $path;
next if mkdir($path);
_mkpath_debug("mkdir failed", $path, $dir, $!);
# mkdir failed, try one more time
next if mkdir($path);
_mkpath_debug("mkdir failed, second time", $path, $dir, $!);
# mkdir failed again, try two more time after sleep(s)
sleep(1);
next if mkdir($path);
_mkpath_debug("mkdir failed, third time", $path, $dir, $!);
sleep(1);
next if mkdir($path);
_mkpath_debug("mkdir failed, fourth time", $path, $dir, $!);
# Report failure and die
croak("Couldn't create directory '$path' ",
" after 4 attempts and 2 sleep(1): $!");
}
};
sub copytree {
my ($from_dir, $to_dir, $use_umask) = @_;
die "Usage: copytree(<fromdir>, <todir>, [<umask>])"
unless @_ == 2 or @_ == 3;
my $orig_umask;
if ($use_umask){
# Set new umask and remember the original
$orig_umask= umask(oct($use_umask));
}
mkpath("$to_dir");
opendir(DIR, "$from_dir")
or croak("Can't find $from_dir$!");
for(readdir(DIR)) {
next if "$_" eq "." or "$_" eq "..";
# Skip SCCS/ directories
next if "$_" eq "SCCS";
if ( -d "$from_dir/$_" )
{
copytree("$from_dir/$_", "$to_dir/$_");
next;
}
copy("$from_dir/$_", "$to_dir/$_");
}
closedir(DIR);
if ($orig_umask){
# Set the original umask
umask($orig_umask);
}
}
1;

245
mysql-test/lib/My/Find.pm Normal file
View File

@ -0,0 +1,245 @@
# -*- cperl -*-
# Copyright (C) 2004-2006 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU 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 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
package My::Find;
#
# Utility functions to find files in a MySQL source or bindist
#
use strict;
use Carp;
use My::Platform;
use base qw(Exporter);
our @EXPORT= qw(my_find_bin my_find_dir my_find_file NOT_REQUIRED);
our $vs_config_dir;
my $bin_extension= ".exe" if IS_WINDOWS;
# Helper function to be used for fourth parameter to find functions
sub NOT_REQUIRED { return 0; }
#
# my_find_bin - find an executable with "name_1...name_n" in
# paths "path_1...path_n" and return the full path
#
# Example:
# my $mysqld_exe= my_find_bin($basedir.
# ["sql", "bin"],
# ["mysqld", "mysqld-debug"]);
# my $mysql_exe= my_find_bin($basedir,
# ["client", "bin"],
# "mysql");
#
#
# To check if something exists, use the required parameter
# set to 0, the function will return an empty string if the
# binary is not found
# my $mysql_exe= my_find_bin($basedir,
# ["client", "bin"],
# "mysql", NOT_REQUIRED);
#
# NOTE: The function honours MTR_VS_CONFIG environment variable
#
#
sub my_find_bin {
my ($base, $paths, $names, $required)= @_;
croak "usage: my_find_bin(<base>, <paths>, <names>, [<required>])"
unless @_ == 4 or @_ == 3;
# -------------------------------------------------------
# Find and return the first executable
# -------------------------------------------------------
foreach my $path (my_find_paths($base, $paths, $names, $bin_extension)) {
return $path if ( -x $path or (IS_WINDOWS and -f $path) );
}
if (defined $required and $required == NOT_REQUIRED){
# Return empty string to indicate not found
return "";
}
find_error($base, $paths, $names);
}
#
# my_find_file - find a file with "name_1...name_n" in
# paths "path_1...path_n" and return the full path
#
# Example:
# my $mysqld_exe= my_find_file($basedir.
# ["sql", "bin"],
# "filename");
#
#
# Also supports NOT_REQUIRED flag
#
# NOTE: The function honours MTR_VS_CONFIG environment variable
#
#
sub my_find_file {
my ($base, $paths, $names, $required)= @_;
croak "usage: my_find_file(<base>, <paths>, <names>, [<required>])"
unless @_ == 4 or @_ == 3;
# -------------------------------------------------------
# Find and return the first executable
# -------------------------------------------------------
foreach my $path (my_find_paths($base, $paths, $names, $bin_extension)) {
return $path if ( -f $path );
}
if (defined $required and $required == NOT_REQUIRED){
# Return empty string to indicate not found
return "";
}
find_error($base, $paths, $names);
}
#
# my_find_dir - find the first existing directory in one of
# the given paths
#
# Example:
# my $charset_set= my_find_dir($basedir,
# ["mysql/share","sql/share", "share"],
# ["charset"]);
# or
# my $charset_set= my_find_dir($basedir,
# ['client_release', 'client_debug',
# 'client', 'bin']);
#
# NOTE: The function honours MTR_VS_CONFIG environment variable
#
#
sub my_find_dir {
my ($base, $paths, $dirs, $required)= @_;
croak "usage: my_find_dir(<base>, <paths>[, <dirs>])"
unless (@_ == 3 or @_ == 2);
# -------------------------------------------------------
# Find and return the first directory
# -------------------------------------------------------
foreach my $path (my_find_paths($base, $paths, $dirs)) {
return $path if ( -d $path );
}
find_error($base, $paths, $dirs);
}
sub my_find_paths {
my ($base, $paths, $names, $extension)= @_;
# Convert the arguments into two normal arrays to ease
# further mappings
my (@names, @paths);
push(@names, ref $names eq "ARRAY" ? @$names : $names);
push(@paths, ref $paths eq "ARRAY" ? @$paths : $paths);
#print "base: $base\n";
#print "names: @names\n";
#print "paths: @paths\n";
# User can select to look in a special build dir
# which is a subdirectory of any of the paths
my @extra_dirs;
my $build_dir= $vs_config_dir || $ENV{MTR_VS_CONFIG} || $ENV{MTR_BUILD_DIR};
push(@extra_dirs, $build_dir) if defined $build_dir;
if (defined $extension){
# Append extension to names, if name does not already have extension
map { $_.=$extension unless /\.(.*)+$/ } @names;
}
# -------------------------------------------------------
# Windows specific
# -------------------------------------------------------
if (IS_WINDOWS) {
# Add the default extra build dirs unless a specific one has
# already been selected
push(@extra_dirs,
("release",
"relwithdebinfo",
"debug")) if @extra_dirs == 0;
}
#print "extra_build_dir: @extra_dirs\n";
# -------------------------------------------------------
# Build cross product of "paths * extra_build_dirs"
# -------------------------------------------------------
push(@paths, map { my $path= $_;
map { "$path/$_" } @extra_dirs
} @paths);
#print "paths: @paths\n";
# -------------------------------------------------------
# Build cross product of "paths * names"
# -------------------------------------------------------
@paths= map { my $path= $_;
map { "$path/$_" } @names
} @paths;
#print "paths: @paths\n";
# -------------------------------------------------------
# Prepend base to all paths
# -------------------------------------------------------
@paths= map { "$base/$_" } @paths;
#print "paths: @paths\n";
# -------------------------------------------------------
# Glob all paths to expand wildcards
# -------------------------------------------------------
@paths= map { glob("$_") } @paths;
#print "paths: @paths\n";
# -------------------------------------------------------
# Return the list of paths
# -------------------------------------------------------
return @paths;
}
sub commify {
return
(@_ == 0) ? '' :
(@_ == 1) ? $_[0] :
(@_ == 2) ? join(" or ", @_) :
join(", ", @_[0..($#_-1)], "or $_[-1]");
}
sub fnuttify {
return map('\''.$_.'\'', @_);
}
sub find_error {
my ($base, $paths, $names)= @_;
my (@names, @paths);
push(@names, ref $names eq "ARRAY" ? @$names : $names);
push(@paths, ref $paths eq "ARRAY" ? @$paths : $paths);
croak "** ERROR: Could not find ",
commify(fnuttify(@names)), " in ",
commify(fnuttify(my_find_paths($base, $paths, $names))), "\n";
}
1;

69
mysql-test/lib/My/Handles.pm Executable file
View File

@ -0,0 +1,69 @@
# -*- cperl -*-
# Copyright (C) 2008 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU 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 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
package My::Handles;
use strict;
use Carp;
use My::Platform;
my $handle_exe;
if (IS_WINDOWS){
# Check if handle.exe is available
# Pass switch to accept the EULA to avoid hanging
# if the program hasn't been run before.
my $list= `handle.exe -? -accepteula 2>&1`;
foreach my $line (split('\n', $list))
{
$handle_exe= "$1.$2"
if ($line =~ /Handle v([0-9]*)\.([0-9]*)/);
}
if ($handle_exe){
print "Found handle.exe version $handle_exe\n";
}
}
sub show_handles
{
my ($dir)= @_;
return unless $handle_exe;
return unless $dir;
$dir= native_path($dir);
# Get a list of open handles in a particular directory
my $list= `handle.exe "$dir" 2>&1` or return;
foreach my $line (split('\n', $list))
{
return if ($line =~ /No matching handles found/);
}
print "\n";
print "=" x 50, "\n";
print "Open handles in '$dir':\n";
print "$list\n";
print "=" x 50, "\n\n";
return;
}
1;

Some files were not shown because too many files have changed in this diff Show More