summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysqlimport.c45
-rw-r--r--client/mysqlslap.c8
-rw-r--r--client/mysqltest.c86
-rw-r--r--include/my_base.h1
-rw-r--r--mysql-test/extra/rpl_tests/rpl_insert_id_pk.test3
-rw-r--r--mysql-test/extra/rpl_tests/rpl_loaddata.test2
-rw-r--r--mysql-test/extra/rpl_tests/rpl_multi_update3.test2
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_sp006.test1
-rw-r--r--mysql-test/include/check-testcase.test4
-rw-r--r--mysql-test/lib/mtr_cases.pl133
-rw-r--r--mysql-test/lib/mtr_process.pl487
-rw-r--r--mysql-test/lib/mtr_report.pl26
-rw-r--r--mysql-test/lib/mtr_stress.pl5
-rwxr-xr-xmysql-test/mysql-test-run.pl1704
-rw-r--r--mysql-test/r/func_group.result9
-rw-r--r--mysql-test/r/func_group_innodb.result147
-rw-r--r--mysql-test/r/group_min_max_innodb.result72
-rw-r--r--mysql-test/r/innodb_mysql.result6
-rw-r--r--mysql-test/r/join_outer.result19
-rw-r--r--mysql-test/r/join_outer_innodb.result19
-rw-r--r--mysql-test/r/mysqltest.result8
-rw-r--r--mysql-test/r/ndb_binlog_discover.result1
-rw-r--r--mysql-test/r/ndb_cache_multi.result2
-rw-r--r--mysql-test/r/partition.result6
-rw-r--r--mysql-test/r/partition_innodb.result123
-rw-r--r--mysql-test/r/rpl_drop_db.result2
-rw-r--r--mysql-test/r/rpl_insert_id_pk.result1
-rw-r--r--mysql-test/r/rpl_loaddata.result1
-rw-r--r--mysql-test/r/rpl_multi_update3.result1
-rw-r--r--mysql-test/r/rpl_ndb_multi_update3.result1
-rw-r--r--mysql-test/r/rpl_ndb_sp006.result1
-rw-r--r--mysql-test/r/rpl_row_sp006_InnoDB.result1
-rw-r--r--mysql-test/r/rpl_stm_no_op.result2
-rw-r--r--mysql-test/r/rpl_variables.result1
-rw-r--r--mysql-test/r/sp-error.result2
-rw-r--r--mysql-test/r/sp-security.result10
-rw-r--r--mysql-test/r/sp.result16
-rw-r--r--mysql-test/r/sp_notembedded.result11
-rw-r--r--mysql-test/r/sp_trans.result26
-rw-r--r--mysql-test/r/type_newdecimal.result10
-rw-r--r--mysql-test/t/create.test1
-rw-r--r--mysql-test/t/disabled.def1
-rw-r--r--mysql-test/t/func_group.test21
-rw-r--r--mysql-test/t/func_group_innodb.test85
-rw-r--r--mysql-test/t/group_min_max.test25
-rw-r--r--mysql-test/t/group_min_max_innodb.test95
-rw-r--r--mysql-test/t/innodb_mysql.test8
-rw-r--r--mysql-test/t/join_outer.test18
-rw-r--r--mysql-test/t/join_outer_innodb.test26
-rw-r--r--mysql-test/t/mysqltest.test8
-rw-r--r--mysql-test/t/ndb_autodiscover3.test6
-rw-r--r--mysql-test/t/ndb_binlog_discover.test16
-rw-r--r--mysql-test/t/ndb_cache_multi.test7
-rw-r--r--mysql-test/t/partition.test8
-rw-r--r--mysql-test/t/partition_innodb.test93
-rw-r--r--mysql-test/t/ps_1general.test4
-rw-r--r--mysql-test/t/rpl_drop_db.test4
-rw-r--r--mysql-test/t/rpl_insert.test14
-rw-r--r--mysql-test/t/rpl_stm_no_op.test2
-rw-r--r--mysql-test/t/rpl_variables.test3
-rw-r--r--mysql-test/t/sp-error.test4
-rw-r--r--mysql-test/t/sp-security.test23
-rw-r--r--mysql-test/t/sp.test17
-rw-r--r--mysql-test/t/sp_notembedded.test4
-rw-r--r--mysql-test/t/sp_trans.test39
-rw-r--r--mysql-test/t/type_newdecimal.test11
-rw-r--r--mysql-test/t/wait_timeout.test6
-rw-r--r--mysys/my_append.c1
-rw-r--r--mysys/my_clock.c1
-rw-r--r--mysys/my_copy.c1
-rw-r--r--mysys/my_create.c1
-rw-r--r--mysys/my_dup.c1
-rw-r--r--mysys/my_lib.c1
-rw-r--r--mysys/my_open.c1
-rw-r--r--mysys/my_redel.c1
-rw-r--r--mysys/my_rename.c1
-rw-r--r--mysys/test_dir.c1
-rw-r--r--sql/field.cc12
-rw-r--r--sql/field.h1
-rw-r--r--sql/sp.cc27
-rw-r--r--sql/sp.h3
-rw-r--r--sql/sql_base.cc20
-rw-r--r--sql/unireg.cc1
-rw-r--r--storage/ndb/tools/waiter.cpp4
84 files changed, 2248 insertions, 1384 deletions
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index ccd6932e25b..18a31117c08 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -35,9 +35,10 @@
/* Global Thread counter */
-int counter= 0;
+int counter;
#ifdef HAVE_LIBPTHREAD
pthread_mutex_t counter_mutex;
+pthread_cond_t count_threshhold;
#endif
static void db_error_with_table(MYSQL *mysql, char *table);
@@ -556,6 +557,7 @@ error:
pthread_mutex_lock(&counter_mutex);
counter--;
+ pthread_cond_signal(&count_threshhold);
pthread_mutex_unlock(&counter_mutex);
my_thread_end();
@@ -584,28 +586,26 @@ int main(int argc, char **argv)
{
pthread_t mainthread; /* Thread descriptor */
pthread_attr_t attr; /* Thread attributes */
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr,
+ PTHREAD_CREATE_DETACHED);
+
VOID(pthread_mutex_init(&counter_mutex, NULL));
+ VOID(pthread_cond_init(&count_threshhold, NULL));
- for (; *argv != NULL; argv++) /* Loop through tables */
+ for (counter= 0; *argv != NULL; argv++) /* Loop through tables */
{
- /*
- If we hit thread count limit we loop until some threads exit.
- We sleep for a second, so that we don't chew up a lot of
- CPU in the loop.
- */
-sanity_label:
- if (counter == opt_use_threads)
+ pthread_mutex_lock(&counter_mutex);
+ while (counter == opt_use_threads)
{
- sleep(1);
- goto sanity_label;
+ struct timespec abstime;
+
+ set_timespec(abstime, 3);
+ pthread_cond_timedwait(&count_threshhold, &counter_mutex, &abstime);
}
- pthread_mutex_lock(&counter_mutex);
+ /* Before exiting the lock we set ourselves up for the next thread */
counter++;
pthread_mutex_unlock(&counter_mutex);
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr,
- PTHREAD_CREATE_DETACHED);
-
/* now create the thread */
if (pthread_create(&mainthread, &attr, worker_thread,
(void *)*argv) != 0)
@@ -621,13 +621,18 @@ sanity_label:
/*
We loop until we know that all children have cleaned up.
*/
-loop_label:
- if (counter)
+ pthread_mutex_lock(&counter_mutex);
+ while (counter)
{
- sleep(1);
- goto loop_label;
+ struct timespec abstime;
+
+ set_timespec(abstime, 3);
+ pthread_cond_timedwait(&count_threshhold, &counter_mutex, &abstime);
}
+ pthread_mutex_unlock(&counter_mutex);
VOID(pthread_mutex_destroy(&counter_mutex));
+ VOID(pthread_cond_destroy(&count_threshhold));
+ pthread_attr_destroy(&attr);
}
else
#endif
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index 11d3ae5a2df..c061433178b 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -130,6 +130,8 @@ static my_bool opt_compress= FALSE, tty_password= FALSE,
opt_silent= FALSE,
auto_generate_sql= FALSE;
+static unsigned long connect_flags= CLIENT_MULTI_RESULTS;
+
static int verbose, num_int_cols, num_char_cols, delimiter_length;
static int iterations;
static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
@@ -243,7 +245,6 @@ static int gettimeofday(struct timeval *tp, void *tzp)
int main(int argc, char **argv)
{
MYSQL mysql;
- int client_flag= 0;
int x;
unsigned long long client_limit;
statement *eptr;
@@ -293,12 +294,11 @@ int main(int argc, char **argv)
#endif
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
- client_flag|= CLIENT_MULTI_RESULTS;
if (!opt_only_print)
{
if (!(mysql_real_connect(&mysql, host, user, opt_password,
NULL, opt_mysql_port,
- opt_mysql_unix_port, client_flag)))
+ opt_mysql_unix_port, connect_flags)))
{
fprintf(stderr,"%s: Error when connecting to server: %s\n",
my_progname,mysql_error(&mysql));
@@ -1141,7 +1141,7 @@ run_task(thread_context *con)
create_schema_string,
opt_mysql_port,
opt_mysql_unix_port,
- 0)))
+ connect_flags)))
{
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(mysql));
goto end;
diff --git a/client/mysqltest.c b/client/mysqltest.c
index b21e3883631..3b55ebb2f8b 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -100,7 +100,8 @@ enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT, OPT_SKIP_SAFEMALLOC,
OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH,
OPT_SSL_CIPHER,OPT_PS_PROTOCOL,OPT_SP_PROTOCOL,OPT_CURSOR_PROTOCOL,
- OPT_VIEW_PROTOCOL, OPT_SSL_VERIFY_SERVER_CERT, OPT_MAX_CONNECT_RETRIES};
+ OPT_VIEW_PROTOCOL, OPT_SSL_VERIFY_SERVER_CERT, OPT_MAX_CONNECT_RETRIES,
+ OPT_MARK_PROGRESS};
/* ************************************************************************ */
/*
@@ -153,6 +154,7 @@ static int port = 0;
static int opt_max_connect_retries;
static my_bool opt_big_test= 0, opt_compress= 0, silent= 0, verbose = 0;
static my_bool tty_password= 0;
+static my_bool opt_mark_progress= 0;
static my_bool ps_protocol= 0, ps_protocol_enabled= 0;
static my_bool sp_protocol= 0, sp_protocol_enabled= 0;
static my_bool view_protocol= 0, view_protocol_enabled= 0;
@@ -234,7 +236,7 @@ static my_bool display_result_vertically= FALSE, display_metadata= FALSE;
/* See the timer_output() definition for details */
static char *timer_file = NULL;
-static ulonglong timer_start;
+static ulonglong timer_start, progress_start= 0;
static int got_end_timer= FALSE;
static void timer_output(void);
static ulonglong timer_now(void);
@@ -445,7 +447,7 @@ const char *command_names[]=
TYPELIB command_typelib= {array_elements(command_names),"",
command_names, 0};
-DYNAMIC_STRING ds_res;
+DYNAMIC_STRING ds_res, ds_progress;
static void die(const char *fmt, ...);
static void init_var_hash();
static VAR* var_from_env(const char *, const char *);
@@ -631,6 +633,7 @@ static void free_used_memory()
my_free(embedded_server_args[--embedded_server_arg_count],MYF(0));
delete_dynamic(&q_lines);
dynstr_free(&ds_res);
+ dynstr_free(&ds_progress);
free_replace();
free_replace_column();
my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
@@ -1204,7 +1207,7 @@ static void do_exec(struct st_query *query)
}
}
error= pclose(res_file);
- if (error != 0)
+ if (error > 0)
{
uint status= WEXITSTATUS(error), i;
my_bool ok= 0;
@@ -2518,7 +2521,7 @@ int safe_connect(MYSQL* mysql, const char *host, const char *user,
{
int con_error= 1;
my_bool reconnect= 1;
- static int connection_retry_sleep= 2; /* Seconds */
+ static ulong connection_retry_sleep= 100000; /* Microseconds */
int i;
for (i= 0; i < opt_max_connect_retries; i++)
{
@@ -2528,7 +2531,7 @@ int safe_connect(MYSQL* mysql, const char *host, const char *user,
con_error= 0;
break;
}
- sleep(connection_retry_sleep);
+ my_sleep(connection_retry_sleep);
}
/*
TODO: change this to 0 in future versions, but the 'kill' test relies on
@@ -3298,10 +3301,14 @@ static struct my_option my_long_options[] =
{"manager-wait-timeout", OPT_MANAGER_WAIT_TIMEOUT,
"Undocumented: Used for debugging.", (gptr*) &manager_wait_timeout,
(gptr*) &manager_wait_timeout, 0, GET_INT, REQUIRED_ARG, 3, 0, 0, 0, 0, 0},
+ {"mark-progress", OPT_MARK_PROGRESS,
+ "Write linenumber and elapsed time to <testname>.progress ",
+ (gptr*) &opt_mark_progress, (gptr*) &opt_mark_progress, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"max-connect-retries", OPT_MAX_CONNECT_RETRIES,
"Max number of connection attempts when connecting to server",
(gptr*) &opt_max_connect_retries, (gptr*) &opt_max_connect_retries, 0,
- GET_INT, REQUIRED_ARG, 5, 1, 10, 0, 0, 0},
+ GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0},
{"password", 'p', "Password to use when connecting to server.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &port,
@@ -3537,6 +3544,13 @@ void dump_result_to_log_file(const char *record_file, char *buf, int size)
str_to_file(fn_format(log_file, record_file,"",".log",2), buf, size);
}
+void dump_progress(const char *record_file)
+{
+ char log_file[FN_REFLEN];
+ str_to_file(fn_format(log_file, record_file,"",".progress",2),
+ ds_progress.str, ds_progress.length);
+}
+
static void check_regerr(my_regex_t* r, int err)
{
char err_buf[1024];
@@ -5116,36 +5130,47 @@ static void init_var_hash(MYSQL *mysql)
DBUG_VOID_RETURN;
}
-static void mark_progress(int line __attribute__((unused)))
+
+/*
+ Record how many milliseconds it took to execute the test file
+ up until the current line and save it in the dynamic string ds_progress.
+
+ The ds_progress will be dumped to <test_name>.progress when
+ test run completes
+
+*/
+static void mark_progress(struct st_query* q, int line)
{
-#ifdef NOT_YET
- static FILE* fp = NULL;
- static double first;
+ char buf[32], *end;
+ ulonglong timer= timer_now();
+ if (!progress_start)
+ progress_start= timer;
+ timer-= progress_start;
- struct timeval tv;
- double now;
+ /* Milliseconds since start */
+ end= longlong2str(timer, buf, 10);
+ dynstr_append_mem(&ds_progress, buf, (int)(end-buf));
+ dynstr_append_mem(&ds_progress, "\t", 1);
- if (!fp)
- {
+ /* Parser line number */
+ end= int10_to_str(line, buf, 10);
+ dynstr_append_mem(&ds_progress, buf, (int)(end-buf));
+ dynstr_append_mem(&ds_progress, "\t", 1);
- fp = fopen("/tmp/mysqltest_progress.log", "wt");
+ /* Filename */
+ dynstr_append(&ds_progress, cur_file->file_name);
+ dynstr_append_mem(&ds_progress, ":", 1);
- if (!fp)
- {
- abort();
- }
+ /* Line in file */
+ end= int10_to_str(cur_file->lineno, buf, 10);
+ dynstr_append_mem(&ds_progress, buf, (int)(end-buf));
- gettimeofday(&tv, NULL);
- first = tv.tv_sec * 1e6 + tv.tv_usec;
- }
- gettimeofday(&tv, NULL);
- now = tv.tv_sec * 1e6 + tv.tv_usec;
+ dynstr_append_mem(&ds_progress, "\n", 1);
- fprintf(fp, "%d %f\n", parser.current_line, (now - first) / 1e6);
-#endif
}
+
int main(int argc, char **argv)
{
struct st_query *q;
@@ -5185,6 +5210,7 @@ int main(int argc, char **argv)
memset(&master_pos, 0, sizeof(master_pos));
init_dynamic_string(&ds_res, "", 0, 65536);
+ init_dynamic_string(&ds_progress, "", 0, 2048);
parse_args(argc, argv);
DBUG_PRINT("info",("result_file: '%s'", result_file ? result_file : ""));
@@ -5509,7 +5535,8 @@ int main(int argc, char **argv)
}
parser.current_line += current_line_inc;
- mark_progress(parser.current_line);
+ if ( opt_mark_progress )
+ mark_progress(q, parser.current_line);
}
start_lineno= 0;
@@ -5560,6 +5587,9 @@ int main(int argc, char **argv)
die("No queries executed but result file found!");
}
+ if ( opt_mark_progress )
+ dump_progress(result_file);
+ dynstr_free(&ds_progress);
dynstr_free(&ds_res);
diff --git a/include/my_base.h b/include/my_base.h
index 1f77e315222..d75df093a11 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -21,7 +21,6 @@
#define _my_base_h
#ifndef stdin /* Included first in handler */
-#define USES_TYPES /* my_dir with sys/types is included */
#define CHSIZE_USED
#include <my_global.h>
#include <my_dir.h> /* This includes types */
diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test
index a36c402b630..6feafc5a9a7 100644
--- a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test
+++ b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test
@@ -83,5 +83,6 @@ SET FOREIGN_KEY_CHECKS=0;
--error 1022, 1062
INSERT INTO t1 VALUES (1),(1);
sync_slave_with_master;
-
+connection master;
+drop table t1;
# End of 4.1 tests
diff --git a/mysql-test/extra/rpl_tests/rpl_loaddata.test b/mysql-test/extra/rpl_tests/rpl_loaddata.test
index 61f58ff5279..08e89c20973 100644
--- a/mysql-test/extra/rpl_tests/rpl_loaddata.test
+++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test
@@ -155,5 +155,5 @@ wait_for_slave_to_stop;
drop table t2;
connection master;
drop table t2;
-
+drop table t1;
# End of 4.1 tests
diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update3.test b/mysql-test/extra/rpl_tests/rpl_multi_update3.test
index 90cc81cfd58..98fb085f0a8 100644
--- a/mysql-test/extra/rpl_tests/rpl_multi_update3.test
+++ b/mysql-test/extra/rpl_tests/rpl_multi_update3.test
@@ -217,4 +217,6 @@ select "-- SLAVE AFTER JOIN --" as "";
select * from t1;
select * from t2;
+connection master;
+DROP TABLE t1, t2;
# End of 4.1 tests
diff --git a/mysql-test/extra/rpl_tests/rpl_row_sp006.test b/mysql-test/extra/rpl_tests/rpl_row_sp006.test
index f40b3cbb078..25073e54991 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_sp006.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_sp006.test
@@ -76,6 +76,7 @@ DROP PROCEDURE IF EXISTS mysqltest1.p1;
DROP PROCEDURE IF EXISTS mysqltest1.p2;
DROP TABLE IF EXISTS mysqltest1.t1;
DROP TABLE IF EXISTS mysqltest1.t2;
+DROP DATABASE mysqltest1;
# Lets compare. Note: If they match test will pass, if they do not match
# the test will show that the diff statement failed and not reject file
diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test
index 30cb7391f30..5bdbf6cd072 100644
--- a/mysql-test/include/check-testcase.test
+++ b/mysql-test/include/check-testcase.test
@@ -21,13 +21,13 @@ show databases;
#
# Dump the "test" database, all it's tables and their data
#
---exec $MYSQL_DUMP --skip-comments test
+--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 --no-data mysql
+--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;
diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl
index 6f326562649..b0ba27e6736 100644
--- a/mysql-test/lib/mtr_cases.pl
+++ b/mysql-test/lib/mtr_cases.pl
@@ -5,11 +5,14 @@
# same name.
use File::Basename;
+use IO::File();
use strict;
sub collect_test_cases ($);
sub collect_one_test_case ($$$$$$$);
+sub mtr_options_from_test_file($$);
+
##############################################################################
#
# Collect information about test cases we are to run
@@ -243,29 +246,25 @@ sub collect_one_test_case($$$$$$$) {
if ( $::opt_skip_rpl )
{
$tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "No replication tests(--skip-rpl)";
return;
}
$tinfo->{'slave_num'}= 1; # Default, use one slave
- # FIXME currently we always restart slaves
- $tinfo->{'slave_restart'}= 1;
-
if ( $tname eq 'rpl_failsafe' or $tname eq 'rpl_chain_temp_table' )
{
-# $tinfo->{'slave_num'}= 3; # Not 3 ? Check old code, strange
+ # $tinfo->{'slave_num'}= 3; # Not 3 ? Check old code, strange
}
}
if ( defined mtr_match_prefix($tname,"federated") )
{
- $tinfo->{'slave_num'}= 1; # Default, use one slave
-
- # FIXME currently we always restart slaves
- $tinfo->{'slave_restart'}= 1;
+ # Default, federated uses the first slave as it's federated database
+ $tinfo->{'slave_num'}= 1;
}
- if ( $::opt_with_ndbcluster_all or defined mtr_match_substring($tname,"ndb") )
+ if ( $::opt_with_ndbcluster or defined mtr_match_substring($tname,"ndb") )
{
# This is an ndb test or all tests should be run with ndb cluster started
$tinfo->{'ndb_test'}= 1;
@@ -273,12 +272,14 @@ sub collect_one_test_case($$$$$$$) {
{
# All ndb test's should be skipped
$tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "No ndbcluster test(--skip-ndbcluster)";
return;
}
- if ( ! $::opt_with_ndbcluster )
+ if ( ! $::opt_ndbcluster_supported )
{
# Ndb is not supported, skip them
$tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "No ndbcluster support";
return;
}
}
@@ -287,9 +288,10 @@ sub collect_one_test_case($$$$$$$) {
# This is not a ndb test
$tinfo->{'ndb_test'}= 0;
if ( $::opt_with_ndbcluster_only )
- {
+ {
# Only the ndb test should be run, all other should be skipped
$tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "Only ndbcluster tests(--with-ndbcluster-only)";
return;
}
}
@@ -383,6 +385,7 @@ sub collect_one_test_case($$$$$$$) {
if ( $::glob_win32_perl )
{
$tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "No tests with sh scripts on Windows";
}
else
{
@@ -396,6 +399,7 @@ sub collect_one_test_case($$$$$$$) {
if ( $::glob_win32_perl )
{
$tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "No tests with sh scripts on Windows";
}
else
{
@@ -448,26 +452,60 @@ sub collect_one_test_case($$$$$$$) {
if ( $::glob_use_embedded_server )
{
$tinfo->{'skip'}= 1;
-
- mtr_report(
- "Instance Manager tests are not available in embedded mode. " .
- "Test case '$tname' is skipped.");
+ $tinfo->{'comment'}= "No IM with embedded server";
}
elsif ( $::opt_ps_protocol )
{
$tinfo->{'skip'}= 1;
-
- mtr_report(
- "Instance Manager tests are not run with --ps-protocol. " .
- "Test case '$tname' is skipped.");
+ $tinfo->{'comment'}= "No IM with --ps-protocol";
}
elsif ( $::opt_skip_im )
{
$tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "No IM tests(--skip-im)";
+ }
+ }
+ else
+ {
+ mtr_options_from_test_file($tinfo,"$testdir/${tname}.test");
+
+ if ( ! $tinfo->{'innodb_test'} )
+ {
+ # mtr_verbose("Adding '--skip-innodb' to $tinfo->{'name'}");
+ # FIXME activate the --skip-innodb only when running with
+ # selected test cases
+ # push(@{$tinfo->{'master_opt'}}, "--skip-innodb");
+ }
+
+ if ( $tinfo->{'big_test'} and ! $::opt_big_test )
+ {
+ $tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "Test need 'big-test' option";
+ }
+
+ if ( $tinfo->{'ndb_extra'} and ! $::opt_ndb_extra_test )
+ {
+ $tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "Test need 'ndb_extra' option";
+ }
+
+ if ( $tinfo->{'require_manager'} )
+ {
+ $tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "Test need the _old_ manager(to be removed)";
+ }
- mtr_report(
- "Instance Manager executable is unavailable." .
- "Test case '$tname' is skipped.");
+ if ( defined $tinfo->{'binlog_format'} and
+ ! ( $tinfo->{'binlog_format'} eq $::used_binlog_format ) )
+ {
+ $tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "Not running with binlog format '$tinfo->{'binlog_format'}'";
+ }
+
+ if ( $tinfo->{'need_debug'} && ! $::debug_compiled_binaries )
+ {
+ $tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "Test need debug binaries";
}
}
@@ -477,8 +515,59 @@ sub collect_one_test_case($$$$$$$) {
( $tinfo->{'master_restart'} or $tinfo->{'slave_restart'} ) )
{
$tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= "Can't restart a running server";
}
+
}
+# List of tags in the .test files that if found should set
+# the specified value in "tinfo"
+our @tags=
+(
+ ["include/have_innodb.inc", "innodb_test", 1],
+ ["include/have_binlog_format_row.inc", "binlog_format", "row"],
+ ["include/have_binlog_format_statement.inc", "binlog_format", "stmt"],
+ ["include/big_test.inc", "big_test", 1],
+ ["include/have_debug.inc", "need_debug", 1],
+ ["include/have_ndb_extra.inc", "ndb_extra", 1],
+ ["require_manager", "require_manager", 1],
+);
+
+sub mtr_options_from_test_file($$) {
+ my $tinfo= shift;
+ my $file= shift;
+ #mtr_verbose("$file");
+ my $F= IO::File->new($file) or mtr_error("can't open file \"$file\": $!");
+
+ while ( my $line= <$F> )
+ {
+ chomp;
+
+ next if ( $line !~ /^--/ );
+
+ # Match this line against tag in "tags" array
+ foreach my $tag (@tags)
+ {
+ if ( index($line, $tag->[0]) >= 0 )
+ {
+ # Tag matched, assign value to "tinfo"
+ $tinfo->{"$tag->[1]"}= $tag->[2];
+ }
+ }
+
+ # If test sources another file, open it as well
+ if ( $line =~ /^\-\-([[:space:]]*)source(.*)$/ )
+ {
+ my $value= $2;
+ $value =~ s/^\s+//; # Remove leading space
+ $value =~ s/[[:space:]]+$//; # Remove ending space
+
+ my $sourced_file= "$::glob_mysql_test_dir/$value";
+ mtr_options_from_test_file($tinfo, $sourced_file);
+ }
+
+ }
+}
+
1;
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl
index 1b2ce17a689..ca1ae13978d 100644
--- a/mysql-test/lib/mtr_process.pl
+++ b/mysql-test/lib/mtr_process.pl
@@ -14,13 +14,18 @@ use POSIX 'WNOHANG';
sub mtr_run ($$$$$$;$);
sub mtr_spawn ($$$$$$;$);
-sub mtr_stop_mysqld_servers ($);
+sub mtr_check_stop_servers ($);
sub mtr_kill_leftovers ();
+sub mtr_wait_blocking ($);
sub mtr_record_dead_children ();
+sub mtr_ndbmgm_start($$);
+sub mtr_mysqladmin_start($$$);
sub mtr_exit ($);
sub sleep_until_file_created ($$$);
sub mtr_kill_processes ($);
-sub mtr_kill_process ($$$$);
+sub mtr_ping_with_timeout($);
+sub mtr_ping_port ($);
+sub mtr_kill_process ($$$);
# static in C
sub spawn_impl ($$$$$$$$);
@@ -32,7 +37,6 @@ sub spawn_impl ($$$$$$$$);
##############################################################################
# This function try to mimic the C version used in "netware/mysql_test_run.c"
-# FIXME learn it to handle append mode as well, a "new" flag or a "append"
sub mtr_run ($$$$$$;$) {
my $path= shift;
@@ -268,40 +272,17 @@ sub spawn_parent_impl {
last;
}
- # If one of the mysqld processes died, we want to
+ # If one of the processes died, we want to
# mark this, and kill the mysqltest process.
- foreach my $idx (0..1)
- {
- if ( $::master->[$idx]->{'pid'} eq $ret_pid )
- {
- mtr_debug("child $ret_pid was master[$idx], " .
- "exit during mysqltest run");
- $::master->[$idx]->{'pid'}= 0;
- last;
- }
- }
-
- foreach my $idx (0..2)
- {
- if ( $::slave->[$idx]->{'pid'} eq $ret_pid )
- {
- mtr_debug("child $ret_pid was slave[$idx], " .
- "exit during mysqltest run");
- $::slave->[$idx]->{'pid'}= 0;
- last;
- }
- }
-
- mtr_debug("waitpid() catched exit of unknown child $ret_pid, " .
- "exit during mysqltest run");
+ mark_process_dead($ret_pid);
}
if ( $ret_pid != $pid )
{
# We terminated the waiting because a "mysqld" process died.
# Kill the mysqltest process.
-
+ mtr_verbose("Kill mysqltest because another process died");
kill(9,$pid);
$ret_pid= waitpid($pid,0);
@@ -347,49 +328,72 @@ sub mtr_process_exit_status {
#
##############################################################################
-# We just "ping" on the ports, and if we can't do a socket connect
-# we assume the server is dead. So we don't *really* know a server
-# is dead, we just hope that it after letting the listen port go,
-# it is dead enough for us to start a new server.
+# Kill all processes(mysqld, ndbd, ndb_mgmd and im) that would conflict with
+# this run
+# Make sure to remove the PID file, if any.
+# kill IM manager first, else it will restart the servers
sub mtr_kill_leftovers () {
- # First, kill all masters and slaves that would conflict with
- # this run. Make sure to remove the PID file, if any.
- # FIXME kill IM manager first, else it will restart the servers, how?!
- my @args;
+ my @kill_pids;
+ my %admin_pids;
+ my $pid;
- for ( my $idx; $idx < 2; $idx++ )
+ #Start shutdown of instance_managers, masters and slaves
+ foreach my $srv ($::instance_manager,
+ @{$::instance_manager->{'instances'}},
+ @{$::master},@{$::slave})
{
- push(@args,{
- pid => 0, # We don't know the PID
- pidfile => $::instance_manager->{'instances'}->[$idx]->{'path_pid'},
- sockfile => $::instance_manager->{'instances'}->[$idx]->{'path_sock'},
- port => $::instance_manager->{'instances'}->[$idx]->{'port'},
- });
- }
+ $pid= mtr_mysqladmin_start($srv, "shutdown", 70);
- for ( my $idx; $idx < 2; $idx++ )
- {
- push(@args,{
- pid => 0, # We don't know the PID
- pidfile => $::master->[$idx]->{'path_mypid'},
- sockfile => $::master->[$idx]->{'path_mysock'},
- port => $::master->[$idx]->{'path_myport'},
- });
+ # Save the pid of the mysqladmin process
+ $admin_pids{$pid}= 1;
+
+ push(@kill_pids,{
+ pid => $srv->{'pid'},
+ pidfile => $srv->{'path_pid'},
+ sockfile => $srv->{'path_sock'},
+ port => $srv->{'port'},
+ });
+ $srv->{'pid'}= 0; # Assume we are done with it
}
- for ( my $idx; $idx < 3; $idx++ )
+ # Start shutdown of clusters
+ foreach my $cluster (@{$::clusters})
{
- push(@args,{
- pid => 0, # We don't know the PID
- pidfile => $::slave->[$idx]->{'path_mypid'},
- sockfile => $::slave->[$idx]->{'path_mysock'},
- port => $::slave->[$idx]->{'path_myport'},
- });
+ $pid= mtr_ndbmgm_start($cluster, "shutdown");
+
+ # Save the pid of the ndb_mgm process
+ $admin_pids{$pid}= 1;
+
+ push(@kill_pids,{
+ pid => $cluster->{'pid'},
+ pidfile => $cluster->{'path_pid'}
+ });
+
+ $cluster->{'pid'}= 0; # Assume we are done with it
+
+
+ foreach my $ndbd (@{$cluster->{'ndbds'}})
+ {
+ push(@kill_pids,{
+ pid => $ndbd->{'pid'},
+ pidfile => $ndbd->{'path_pid'},
+ });
+ $ndbd->{'pid'}= 0; # Assume we are done with it
+ }
+
}
- mtr_mysqladmin_shutdown(\@args, 20);
+ # Wait for all the admin processes to complete
+ mtr_wait_blocking(\%admin_pids);
+
+ # If we trusted "mysqladmin --shutdown_timeout= ..." we could just
+ # terminate now, but we don't (FIXME should be debugged).
+ # So we try again to ping and at least wait the same amount of time
+ # mysqladmin would for all to die.
+
+ mtr_ping_with_timeout(\@kill_pids);
# We now have tried to terminate nice. We have waited for the listen
# port to be free, but can't really tell if the mysqld process died
@@ -454,7 +458,7 @@ sub mtr_kill_leftovers () {
do
{
kill(9, @pids);
- mtr_debug("Sleep 1 second waiting for processes to die");
+ mtr_report("Sleep 1 second waiting for processes to die");
sleep(1) # Wait one second
} while ( $retries-- and kill(0, @pids) );
@@ -466,53 +470,61 @@ sub mtr_kill_leftovers () {
}
}
- # We may have failed everything, bug we now check again if we have
+ # We may have failed everything, but we now check again if we have
# the listen ports free to use, and if they are free, just go for it.
- foreach my $srv ( @args )
+ foreach my $srv ( @kill_pids )
{
- if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
+ if ( defined $srv->{'port'} and mtr_ping_port($srv->{'port'}) )
{
- mtr_warning("can't kill old mysqld holding port $srv->{'port'}");
+ mtr_warning("can't kill old process holding port $srv->{'port'}");
}
}
}
-##############################################################################
-#
-# Shut down mysqld servers we have started from this run of this script
-#
-##############################################################################
-
-# To speed things we kill servers in parallel. The argument is a list
-# of 'ports', 'pids', 'pidfiles' and 'socketfiles'.
+# Check that all processes in list are killed
+# The argument is a list of 'ports', 'pids', 'pidfiles' and 'socketfiles'
+# for which shutdown has been started. Make sure they all get killed
+# in one way or the other.
+#
# FIXME On Cygwin, and maybe some other platforms, $srv->{'pid'} and
-# $srv->{'pidfile'} will not be the same PID. We need to try to kill
+# the pid in $srv->{'pidfile'} will not be the same PID. We need to try to kill
# both I think.
-sub mtr_stop_mysqld_servers ($) {
+sub mtr_check_stop_servers ($) {
my $spec= shift;
- # ----------------------------------------------------------------------
- # First try nice normal shutdown using 'mysqladmin'
- # ----------------------------------------------------------------------
+ # Return if no processes are defined
+ return if ! @$spec;
- # Shutdown time must be high as slave may be in reconnect
- mtr_mysqladmin_shutdown($spec, 70);
+ #mtr_report("mtr_check_stop_servers");
+
+ mtr_ping_with_timeout(\@$spec);
# ----------------------------------------------------------------------
# We loop with waitpid() nonblocking to see how many of the ones we
- # are to kill, actually got killed by mtr_mysqladmin_shutdown().
- # Note that we don't rely on this, the mysqld server might have stop
+ # are to kill, actually got killed by mysqladmin or ndb_mgm
+ #
+ # Note that we don't rely on this, the mysqld server might have stopped
# listening to the port, but still be alive. But it is a start.
# ----------------------------------------------------------------------
foreach my $srv ( @$spec )
{
- if ( $srv->{'pid'} and (waitpid($srv->{'pid'},&WNOHANG) == $srv->{'pid'}) )
+ my $ret_pid;
+ if ( $srv->{'pid'} )
{
- $srv->{'pid'}= 0;
+ $ret_pid= waitpid($srv->{'pid'},&WNOHANG);
+ if ($ret_pid == $srv->{'pid'})
+ {
+ mtr_verbose("Caught exit of process $ret_pid");
+ $srv->{'pid'}= 0;
+ }
+ else
+ {
+ # mtr_warning("caught exit of unknown child $ret_pid");
+ }
}
}
@@ -546,13 +558,12 @@ sub mtr_stop_mysqld_servers ($) {
}
# ----------------------------------------------------------------------
- # If the processes where started from this script, and we had no PIDS
+ # If all the processes in list already have been killed,
# then we don't have to do anything.
# ----------------------------------------------------------------------
if ( ! keys %mysqld_pids )
{
- # cluck "This is how we got here!";
return;
}
@@ -601,107 +612,127 @@ sub mtr_stop_mysqld_servers ($) {
foreach my $file ($srv->{'pidfile'}, $srv->{'sockfile'})
{
# Know it is dead so should be no race, careful anyway
- if ( -f $file and ! unlink($file) and -f $file )
+ if ( defined $file and -f $file and ! unlink($file) and -f $file )
{
$errors++;
mtr_warning("couldn't delete $file");
}
}
+ $srv->{'pid'}= 0;
}
}
}
if ( $errors )
{
- # We are in trouble, just die....
- mtr_error("we could not kill or clean up all processes");
+ # There where errors killing processes
+ # do one last attempt to ping the servers
+ # and if they can't be pinged, assume they are dead
+ if ( ! mtr_ping_with_timeout( \@$spec ) )
+ {
+ mtr_error("we could not kill or clean up all processes");
+ }
+ else
+ {
+ mtr_verbose("All ports where free, continuing");
+ }
}
}
# FIXME We just assume they are all dead, for Cygwin we are not
# really sure
-
+
}
+# Wait for all the process in the list to terminate
+sub mtr_wait_blocking($) {
+ my $admin_pids= shift;
-##############################################################################
-#
-# Shut down mysqld servers using "mysqladmin ... shutdown".
-# To speed this up, we start them in parallel and use waitpid() to
-# catch their termination. Note that this doesn't say the servers
-# are terminated, just that 'mysqladmin' is terminated.
-#
-# Note that mysqladmin will ask the server about what PID file it uses,
-# and mysqladmin will wait for it to be removed before it terminates
-# (unless passes timeout).
-#
-# This function will take at most about 20 seconds, and we still are not
-# sure we killed them all. If none is responding to ping, we return 1,
-# else we return 0.
-#
-##############################################################################
-sub mtr_mysqladmin_shutdown {
- my $spec= shift;
- my $adm_shutdown_tmo= shift;
+ # Return if no processes defined
+ return if ! %$admin_pids;
- my %mysql_admin_pids;
+ mtr_verbose("mtr_wait_blocking");
- # Start one "mysqladmin shutdown" for each server
- foreach my $srv ( @$spec )
+ # Wait for all the started processes to exit
+ # As mysqladmin is such a simple program, we trust it to terminate itself.
+ # I.e. we wait blocking, and wait for them all before we go on.
+ foreach my $pid (keys %{$admin_pids})
{
- my $args;
+ my $ret_pid= waitpid($pid,0);
- mtr_init_args(\$args);
+ }
+}
- mtr_add_arg($args, "--no-defaults");
- mtr_add_arg($args, "--user=%s", $::opt_user);
- mtr_add_arg($args, "--password=");
- mtr_add_arg($args, "--silent");
- if ( -e $srv->{'sockfile'} )
- {
- mtr_add_arg($args, "--socket=%s", $srv->{'sockfile'});
- }
- if ( $srv->{'port'} )
- {
- mtr_add_arg($args, "--port=%s", $srv->{'port'});
- }
- if ( $srv->{'port'} and ! -e $srv->{'sockfile'} )
- {
- mtr_add_arg($args, "--protocol=tcp"); # Needed if no --socket
- }
- mtr_add_arg($args, "--connect_timeout=5");
- # Shutdown time must be high as slave may be in reconnect
- mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo");
- mtr_add_arg($args, "shutdown");
- my $path_mysqladmin_log= "$::opt_vardir/log/mysqladmin.log";
- # Start mysqladmin in paralell and wait for termination later
- my $pid= mtr_spawn($::exe_mysqladmin, $args,
- "", $path_mysqladmin_log, $path_mysqladmin_log, "",
- { append_log_file => 1 });
- # Save the pid of the mysqladmin process
- $mysql_admin_pids{$pid}= 1;
+# Start "mysqladmin shutdown" for a specific mysqld
+sub mtr_mysqladmin_start($$$) {
+ my $srv= shift;
+ my $command= shift;
+ my $adm_shutdown_tmo= shift;
- # We don't wait for termination of mysqladmin
- }
+ my $args;
+ mtr_init_args(\$args);
- # Wait for all the started mysqladmin to exit
- # As mysqladmin is such a simple program, we trust it to terminate.
- # I.e. we wait blocking, and wait wait for them all before we go on.
- foreach my $pid (keys %mysql_admin_pids)
+ mtr_add_arg($args, "--no-defaults");
+ mtr_add_arg($args, "--user=%s", $::opt_user);
+ mtr_add_arg($args, "--password=");
+ mtr_add_arg($args, "--silent");
+ if ( -e $srv->{'path_sock'} )
{
- my $ret_pid= waitpid($pid,0);
-
- # If this was any of the mysqladmin's we waited for, delete its
- # pid from list
- delete $mysql_admin_pids{$ret_pid} if exists $mysql_admin_pids{$ret_pid};
+ mtr_add_arg($args, "--socket=%s", $srv->{'path_sock'});
+ }
+ if ( $srv->{'port'} )
+ {
+ mtr_add_arg($args, "--port=%s", $srv->{'port'});
+ }
+ if ( $srv->{'port'} and ! -e $srv->{'path_sock'} )
+ {
+ mtr_add_arg($args, "--protocol=tcp"); # Needed if no --socket
}
+ mtr_add_arg($args, "--connect_timeout=5");
- # If we trusted "mysqladmin --shutdown_timeout= ..." we could just
- # terminate now, but we don't (FIXME should be debugged).
- # So we try again to ping and at least wait the same amount of time
- # mysqladmin would for all to die.
+ # Shutdown time must be high as slave may be in reconnect
+ mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo");
+ mtr_add_arg($args, "$command");
+ my $path_mysqladmin_log= "$::opt_vardir/log/mysqladmin.log";
+ my $pid= mtr_spawn($::exe_mysqladmin, $args,
+ "", $path_mysqladmin_log, $path_mysqladmin_log, "",
+ { append_log_file => 1 });
+ mtr_verbose("mtr_mysqladmin_start, pid: $pid");
+ return $pid;
+
+}
+
+# Start "ndb_mgm shutdown" for a specific cluster, it will
+# shutdown all data nodes and leave the ndb_mgmd running
+sub mtr_ndbmgm_start($$) {
+ my $cluster= shift;
+ my $command= shift;
+
+ my $args;
- my $timeout= 20; # 20 seconds max
+ mtr_init_args(\$args);
+
+ mtr_add_arg($args, "--no-defaults");
+ mtr_add_arg($args, "--core");
+ mtr_add_arg($args, "--try-reconnect=1");
+ mtr_add_arg($args, "--ndb_connectstring=%s", $cluster->{'connect_string'});
+ mtr_add_arg($args, "-e");
+ mtr_add_arg($args, "$command");
+
+ my $pid= mtr_spawn($::exe_ndb_mgm, $args,
+ "", "/dev/null", "/dev/null", "",
+ {});
+ mtr_verbose("mtr_ndbmgm_start, pid: $pid");
+ return $pid;
+
+}
+
+
+# Ping all servers in list, exit when none of them answers
+# or when timeout has passed
+sub mtr_ping_with_timeout($) {
+ my $spec= shift;
+ my $timeout= 200; # 20 seconds max
my $res= 1; # If we just fall through, we are done
# in the sense that the servers don't
# listen to their ports any longer
@@ -711,22 +742,75 @@ sub mtr_mysqladmin_shutdown {
foreach my $srv ( @$spec )
{
$res= 1; # We are optimistic
- if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
+ if ( $srv->{'pid'} and defined $srv->{'port'} )
{
- mtr_debug("Sleep 1 second waiting for processes to stop using port");
- sleep(1); # One second
- $res= 0;
- next TIME;
+ if ( mtr_ping_port($srv->{'port'}) )
+ {
+ mtr_verbose("waiting for process $srv->{'pid'} to stop ".
+ "using port $srv->{'port'}");
+
+ # Millisceond sleep emulated with select
+ select(undef, undef, undef, (0.1));
+ $res= 0;
+ next TIME;
+ }
+ else
+ {
+ # Process was not using port
+ }
}
}
last; # If we got here, we are done
}
- $timeout or mtr_debug("At least one server is still listening to its port");
+ $timeout or mtr_report("At least one server is still listening to its port");
return $res;
}
+
+#
+# Loop through our list of processes and look for and entry
+# with the provided pid
+# Set the pid of that process to 0 if found
+#
+sub mark_process_dead($)
+{
+ my $ret_pid= shift;
+
+ foreach my $mysqld (@{$::master}, @{$::slave})
+ {
+ if ( $mysqld->{'pid'} eq $ret_pid )
+ {
+ mtr_verbose("$mysqld->{'type'} $mysqld->{'idx'} exited, pid: $ret_pid");
+ $mysqld->{'pid'}= 0;
+ return;
+ }
+ }
+
+ foreach my $cluster (@{$::clusters})
+ {
+ if ( $cluster->{'pid'} eq $ret_pid )
+ {
+ mtr_verbose("$cluster->{'name'} cluster ndb_mgmd exited, pid: $ret_pid");
+ $cluster->{'pid'}= 0;
+ return;
+ }
+
+ foreach my $ndbd (@{$cluster->{'ndbds'}})
+ {
+ if ( $ndbd->{'pid'} eq $ret_pid )
+ {
+ mtr_verbose("$cluster->{'name'} cluster ndbd exited, pid: $ret_pid");
+ $ndbd->{'pid'}= 0;
+ return;
+ }
+ }
+ }
+ mtr_warning("mark_process_dead couldn't find an entry for pid: $ret_pid");
+
+}
+
##############################################################################
#
# The operating system will keep information about dead children,
@@ -743,25 +827,8 @@ sub mtr_record_dead_children () {
# -1 or 0 means there are no more procesess to wait for
while ( ($ret_pid= waitpid(-1,&WNOHANG)) != 0 and $ret_pid != -1)
{
- mtr_debug("waitpid() catched exit of child $ret_pid");
- foreach my $idx (0..1)
- {
- if ( $::master->[$idx]->{'pid'} eq $ret_pid )
- {
- mtr_debug("child $ret_pid was master[$idx]");
- $::master->[$idx]->{'pid'}= 0;
- }
- }
-
- foreach my $idx (0..2)
- {
- if ( $::slave->[$idx]->{'pid'} eq $ret_pid )
- {
- mtr_debug("child $ret_pid was slave[$idx]");
- $::slave->[$idx]->{'pid'}= 0;
- last;
- }
- }
+ mtr_warning("mtr_record_dead_children: $ret_pid");
+ mark_process_dead($ret_pid);
}
}
@@ -777,7 +844,8 @@ sub start_reap_all {
my $pid;
while(($pid= waitpid(-1, &WNOHANG)) != 0 and $pid != -1)
{
- print "start_reap_all: pid: $pid.\n";
+ mtr_warning("start_reap_all pid: $pid");
+ mark_process_dead($pid);
};
}
@@ -785,9 +853,12 @@ sub stop_reap_all {
$SIG{CHLD}= 'DEFAULT';
}
-sub mtr_ping_mysqld_server () {
+
+sub mtr_ping_port ($) {
my $port= shift;
+ mtr_verbose("mtr_ping_port: $port");
+
my $remote= "localhost";
my $iaddr= inet_aton($remote);
if ( ! $iaddr )
@@ -803,10 +874,12 @@ sub mtr_ping_mysqld_server () {
if ( connect(SOCK, $paddr) )
{
close(SOCK); # FIXME check error?
+ mtr_verbose("USED");
return 1;
}
else
{
+ mtr_verbose("FREE");
return 0;
}
}
@@ -833,18 +906,18 @@ sub sleep_until_file_created ($$$) {
return $pid;
}
- # Check if it died after the fork() was successful
+ # Check if it died after the fork() was successful
if ( $pid != 0 && waitpid($pid,&WNOHANG) == $pid )
{
+ mtr_warning("Process $pid died");
return 0;
}
- mtr_debug("Sleep $sleeptime milliseconds waiting for ".
- "creation of $pidfile");
+ mtr_debug("Sleep $sleeptime milliseconds waiting for $pidfile");
# Print extra message every 60 seconds
my $seconds= ($loop * $sleeptime) / 1000;
- if ( $seconds > 1 and $seconds % 60 == 0 )
+ if ( $seconds > 1 and int($seconds) % 60 == 0 )
{
my $left= $timeout - $seconds;
mtr_warning("Waited $seconds seconds for $pidfile to be created, " .
@@ -862,46 +935,38 @@ sub sleep_until_file_created ($$$) {
sub mtr_kill_processes ($) {
my $pids = shift;
- foreach my $sig (15, 9)
+ mtr_verbose("mtr_kill_processes " . join(" ", @$pids));
+
+ foreach my $pid (@$pids)
{
- my $retries= 10;
- while (1)
+ foreach my $sig (15, 9)
{
- kill($sig, @{$pids});
- last unless kill (0, @{$pids}) and $retries--;
-
- mtr_debug("Sleep 2 second waiting for processes to die");
- sleep(2);
+ last if mtr_kill_process($pid, $sig, 10);
}
}
}
-sub mtr_kill_process ($$$$) {
+sub mtr_kill_process ($$$) {
my $pid= shift;
my $signal= shift;
- my $total_retries= shift;
- my $timeout= shift;
+ my $timeout= shift; # Seconds to wait for process
+ my $max_loop= $timeout*10; # Sleeping 0.1 between each kill attempt
- for (my $cur_attempt= 1; $cur_attempt <= $total_retries; ++$cur_attempt)
+ for (my $cur_attempt= 1; $cur_attempt <= $max_loop; ++$cur_attempt)
{
mtr_debug("Sending $signal to $pid...");
kill($signal, $pid);
- unless (kill (0, $pid))
- {
- mtr_debug("Process $pid died.");
- return;
- }
+ last unless kill (0, $pid) and $max_loop--;
- mtr_debug("Sleeping $timeout second(s) waiting for processes to die...");
+ mtr_verbose("Sleep 0.1 second waiting for processes $pid to die");
- sleep($timeout);
+ select(undef, undef, undef, 0.1);
}
- mtr_debug("Process $pid is still alive after $total_retries " .
- "of sending signal $signal.");
+ return $max_loop;
}
##############################################################################
@@ -913,7 +978,7 @@ sub mtr_kill_process ($$$$) {
# FIXME something is wrong, we sometimes terminate with "Hangup" written
# to tty, and no STDERR output telling us why.
-# FIXME for some readon, setting HUP to 'IGNORE' will cause exit() to
+# FIXME for some reason, setting HUP to 'IGNORE' will cause exit() to
# write out "Hangup", and maybe loose some output. We insert a sleep...
sub mtr_exit ($) {
diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl
index 6a68e3a68d0..6e3796133f2 100644
--- a/mysql-test/lib/mtr_report.pl
+++ b/mysql-test/lib/mtr_report.pl
@@ -22,6 +22,7 @@ sub mtr_warning (@);
sub mtr_error (@);
sub mtr_child_error (@);
sub mtr_debug (@);
+sub mtr_verbose (@);
##############################################################################
@@ -97,7 +98,7 @@ sub mtr_report_test_skipped ($) {
}
else
{
- print "[ skipped ]\n";
+ print "[ skipped ] $tinfo->{'comment'}\n";
}
}
@@ -125,7 +126,7 @@ sub mtr_report_test_passed ($) {
if ( $::opt_timer and -f "$::opt_vardir/log/timer" )
{
$timer= mtr_fromfile("$::opt_vardir/log/timer");
- $::glob_tot_real_time += $timer;
+ $::glob_tot_real_time += ($timer/1000);
$timer= sprintf "%12s", $timer;
}
$tinfo->{'result'}= 'MTR_RES_PASSED';
@@ -140,7 +141,7 @@ sub mtr_report_test_failed ($) {
{
print "[ fail ] timeout\n";
}
- elsif ( $tinfo->{'ndb_test'} and !$::flag_ndb_status_ok)
+ elsif ( $tinfo->{'ndb_test'} and $::cluster->[0]->{'installed_ok'} eq "NO")
{
print "[ fail ] ndbcluster start failure\n";
return;
@@ -175,6 +176,7 @@ sub mtr_report_stats ($) {
my $tot_passed= 0;
my $tot_failed= 0;
my $tot_tests= 0;
+ my $tot_restarts= 0;
my $found_problems= 0; # Some warnings are errors...
foreach my $tinfo (@$tests)
@@ -193,6 +195,10 @@ sub mtr_report_stats ($) {
$tot_tests++;
$tot_failed++;
}
+ if ( $tinfo->{'restarted'} )
+ {
+ $tot_restarts++;
+ }
}
# ----------------------------------------------------------------------
@@ -215,6 +221,14 @@ sub mtr_report_stats ($) {
"the documentation at\n",
"http://www.mysql.com/doc/en/MySQL_test_suite.html\n";
}
+ print
+ "The servers were restarted $tot_restarts times\n";
+
+ if ( $::opt_timer )
+ {
+ print
+ "Spent $::glob_tot_real_time seconds actually executing testcases\n"
+ }
# ----------------------------------------------------------------------
# If a debug run, there might be interesting information inside
@@ -353,5 +367,11 @@ sub mtr_debug (@) {
print STDERR "####: ",join(" ", @_),"\n";
}
}
+sub mtr_verbose (@) {
+ if ( $::opt_verbose )
+ {
+ print STDERR "> ",join(" ", @_),"\n";
+ }
+}
1;
diff --git a/mysql-test/lib/mtr_stress.pl b/mysql-test/lib/mtr_stress.pl
index 92bb220461b..a7d4b68b69d 100644
--- a/mysql-test/lib/mtr_stress.pl
+++ b/mysql-test/lib/mtr_stress.pl
@@ -25,10 +25,9 @@ sub run_stress_test ()
mtr_report("Starting stress testing\n");
- if ( ! $::glob_use_embedded_server and ! $::opt_local_master )
+ if ( ! $::glob_use_embedded_server )
{
- $::master->[0]->{'pid'}= mysqld_start('master',0,[],[],0);
- if ( ! $::master->[0]->{'pid'} )
+ if ( ! mysqld_start($::master->[0],[],[]) )
{
mtr_error("Can't start the mysqld server");
}
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index fb6a534f107..1055380d0e5 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -145,9 +145,6 @@ our $glob_use_running_ndbcluster_slave= 0;
our $glob_use_embedded_server= 0;
our @glob_test_mode;
-our $using_ndbcluster_master= 0;
-our $using_ndbcluster_slave= 0;
-
our $glob_basedir;
# The total result
@@ -171,6 +168,7 @@ our $opt_suite;
our $opt_netware;
our $opt_script_debug= 0; # Script debugging, enable with --script-debug
+our $opt_verbose= 0; # Verbose output, enable with --verbose
# Options FIXME not all....
@@ -187,6 +185,8 @@ our $exe_mysqlimport; # Called from test case
our $exe_mysqlshow; # Called from test case
our $exe_mysql_fix_system_tables;
our $exe_mysqltest;
+our $exe_ndbd;
+our $exe_ndb_mgmd;
our $exe_slave_mysqld;
our $exe_im;
our $exe_my_print_defaults;
@@ -238,11 +238,9 @@ our $opt_gprof_dir;
our $opt_gprof_master;
our $opt_gprof_slave;
-our $opt_local;
-our $opt_local_master;
-
our $master; # Will be struct in C
our $slave;
+our $clusters;
our $instance_manager;
@@ -251,8 +249,6 @@ our $opt_ndbconnectstring;
our $opt_ndbcluster_port_slave;
our $opt_ndbconnectstring_slave;
-our $opt_old_master;
-
our $opt_record;
our $opt_check_testcases;
@@ -294,6 +290,7 @@ our $opt_valgrind_mysqltest= 0;
our $default_valgrind_options= "--show-reachable=yes";
our $opt_valgrind_options;
our $opt_valgrind_path;
+our $opt_callgrind;
our $opt_stress= "";
our $opt_stress_suite= "main";
@@ -314,25 +311,25 @@ our $opt_warnings;
our $opt_udiff;
our $opt_skip_ndbcluster= 0;
-our $opt_with_ndbcluster;
our $opt_skip_ndbcluster_slave= 0;
-our $opt_with_ndbcluster_slave;
-our $opt_with_ndbcluster_all= 0;
+our $opt_with_ndbcluster= 0;
our $opt_with_ndbcluster_only= 0;
+our $opt_ndbcluster_supported= 0;
our $opt_ndb_extra_test= 0;
our $opt_skip_master_binlog= 0;
our $opt_skip_slave_binlog= 0;
our $exe_ndb_mgm;
+our $exe_ndb_waiter;
our $path_ndb_tools_dir;
-our $path_ndb_data_dir;
-our $path_ndb_slave_data_dir;
our $file_ndb_testrun_log;
-our $flag_ndb_status_ok= 1;
-our $flag_ndb_slave_status_ok= 1;
our @data_dir_lst;
+our $used_binlog_format;
+our $debug_compiled_binaries;
+our $glob_tot_real_time= 0;
+
######################################################################
#
# Function declarations
@@ -351,27 +348,27 @@ sub check_ssl_support ();
sub check_running_as_root();
sub check_ndbcluster_support ();
sub rm_ndbcluster_tables ($);
-sub ndbcluster_install ();
-sub ndbcluster_start ($);
-sub ndbcluster_stop ();
-sub ndbcluster_install_slave ();
-sub ndbcluster_start_slave ($);
-sub ndbcluster_stop_slave ();
+sub ndbcluster_start_install ($);
+sub ndbcluster_start ($$);
+sub ndbcluster_wait_started ($$);
+sub mysqld_wait_started($);
sub run_benchmarks ($);
sub initialize_servers ();
sub mysql_install_db ();
sub install_db ($$);
sub run_testcase ($);
+sub run_testcase_stop_servers ($);
+sub run_testcase_start_servers ($);
sub report_failure_and_restart ($);
sub do_before_start_master ($$);
sub do_before_start_slave ($$);
-sub mysqld_start ($$$$$);
-sub mysqld_arguments ($$$$$$);
-sub stop_masters_slaves ();
-sub stop_masters ();
-sub stop_slaves ();
+sub ndbd_start ($$$);
+sub ndb_mgmd_start ($);
+sub mysqld_start ($$$);
+sub mysqld_arguments ($$$$$);
+sub stop_all_servers ();
sub im_start ($$);
-sub im_stop ($);
+sub im_stop ($$);
sub run_mysqltest ($);
sub usage ($);
@@ -389,8 +386,9 @@ sub main () {
command_line_setup();
executable_setup();
- check_ndbcluster_support(); # We check whether to actually use it later
+ check_ndbcluster_support();
check_ssl_support();
+ check_debug_support();
environment_setup();
signal_setup();
@@ -428,7 +426,7 @@ sub main () {
$need_im||= $test->{component_id} eq 'im';
$use_slaves||= $test->{slave_num};
}
- $opt_with_ndbcluster= $opt_with_ndbcluster_slave= 0
+ $opt_skip_ndbcluster= $opt_skip_ndbcluster_slave= 1
unless $need_ndbcluster;
$opt_skip_im= 1 unless $need_im;
@@ -581,12 +579,10 @@ sub command_line_setup () {
# Control what test suites or cases to run
'force' => \$opt_force,
'with-ndbcluster' => \$opt_with_ndbcluster,
+ 'with-ndbcluster-only' => \$opt_with_ndbcluster_only,
'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster,
- 'with-ndbcluster-slave' => \$opt_with_ndbcluster_slave,
'skip-ndbcluster-slave|skip-ndb-slave'
=> \$opt_skip_ndbcluster_slave,
- 'with-ndbcluster-all' => \$opt_with_ndbcluster_all,
- 'with-ndbcluster-only' => \$opt_with_ndbcluster_only,
'ndb-extra-test' => \$opt_ndb_extra_test,
'skip-master-binlog' => \$opt_skip_master_binlog,
'skip-slave-binlog' => \$opt_skip_slave_binlog,
@@ -640,6 +636,7 @@ sub command_line_setup () {
'valgrind-mysqld' => \$opt_valgrind_mysqld,
'valgrind-options=s' => \$opt_valgrind_options,
'valgrind-path=s' => \$opt_valgrind_path,
+ 'callgrind' => \$opt_callgrind,
# Stress testing
'stress' => \$opt_stress,
@@ -661,13 +658,11 @@ sub command_line_setup () {
'comment=s' => \$opt_comment,
'debug' => \$opt_debug,
'fast' => \$opt_fast,
- 'local' => \$opt_local,
- 'local-master' => \$opt_local_master,
'netware' => \$opt_netware,
- 'old-master' => \$opt_old_master,
'reorder' => \$opt_reorder,
'enable-disabled' => \$opt_enable_disabled,
'script-debug' => \$opt_script_debug,
+ 'verbose' => \$opt_verbose,
'sleep=i' => \$opt_sleep,
'socket=s' => \$opt_socket,
'start-dirty' => \$opt_start_dirty,
@@ -717,6 +712,21 @@ sub command_line_setup () {
}
# --------------------------------------------------------------------------
+ # Find out type of logging that are being used
+ # --------------------------------------------------------------------------
+
+ # NOTE if the default binlog format is changed, this has to be changed
+ $used_binlog_format= "stmt";
+ foreach my $arg ( @opt_extra_mysqld_opt )
+ {
+ if ( defined mtr_match_substring($arg,"binlog-format=row"))
+ {
+ $used_binlog_format= "row";
+ }
+ }
+ mtr_report("Using binlog format '$used_binlog_format'");
+
+ # --------------------------------------------------------------------------
# Set the "var/" directory, as it is the base for everything else
# --------------------------------------------------------------------------
@@ -747,11 +757,6 @@ sub command_line_setup () {
# Do sanity checks of command line arguments
# --------------------------------------------------------------------------
- if ( $opt_extern and $opt_local )
- {
- mtr_error("Can't use --extern and --local at the same time");
- }
-
if ( ! $opt_socket )
{ # FIXME set default before reading options?
# $opt_socket= '@MYSQL_UNIX_ADDR@';
@@ -772,8 +777,8 @@ sub command_line_setup () {
$glob_use_embedded_server= 1;
push(@glob_test_mode, "embedded");
$opt_skip_rpl= 1; # We never run replication with embedded
- $opt_skip_ndbcluster= 1; # Avoid auto detection
- $opt_skip_ssl= 1;
+ $opt_skip_ndbcluster= 1; # Turn off use of NDB cluster
+ $opt_skip_ssl= 1; # Turn off use of SSL
if ( $opt_extern )
{
@@ -786,11 +791,40 @@ sub command_line_setup () {
push(@glob_test_mode, "ps-protocol");
}
- # FIXME don't understand what this is
-# if ( $opt_local_master )
-# {
-# $opt_master_myport= 3306;
-# }
+ if ( $opt_with_ndbcluster and $opt_skip_ndbcluster)
+ {
+ mtr_error("Can't specify both --with-ndbcluster and --skip-ndbcluster");
+ }
+
+ if ( $opt_ndbconnectstring )
+ {
+ $glob_use_running_ndbcluster= 1;
+ mtr_error("Can't specify --ndb-connectstring and --skip-ndbcluster")
+ if $opt_skip_ndbcluster;
+ mtr_error("Can't specify --ndb-connectstring and --ndbcluster-port")
+ if $opt_ndbcluster_port;
+ }
+ else
+ {
+ # Set default connect string
+ $opt_ndbconnectstring= "host=localhost:$opt_ndbcluster_port";
+ }
+
+ if ( $opt_ndbconnectstring_slave )
+ {
+ $glob_use_running_ndbcluster_slave= 1;
+ mtr_error("Can't specify ndb-connectstring_slave and " .
+ "--skip-ndbcluster-slave")
+ if $opt_skip_ndbcluster;
+ mtr_error("Can't specify --ndb-connectstring-slave and " .
+ "--ndbcluster-port-slave")
+ if $opt_ndbcluster_port_slave;
+ }
+ else
+ {
+ # Set default connect string
+ $opt_ndbconnectstring_slave= "host=localhost:$opt_ndbcluster_port_slave";
+ }
if ( $opt_small_bench )
{
@@ -841,6 +875,17 @@ sub command_line_setup () {
$opt_valgrind= 1;
}
+ if ( $opt_callgrind )
+ {
+ mtr_report("Turning on valgrind with callgrind for mysqld(s)");
+ $opt_valgrind= 1;
+ $opt_valgrind_mysqld= 1;
+
+ # Set special valgrind options unless options passed on command line
+ $opt_valgrind_options="--trace-children=yes"
+ unless defined $opt_valgrind_options;
+ }
+
if ( $opt_valgrind )
{
# Set valgrind_options to default unless already defined
@@ -891,61 +936,78 @@ sub command_line_setup () {
$master->[0]=
{
+ type => "master",
+ idx => 0,
path_myddir => "$opt_vardir/master-data",
path_myerr => "$opt_vardir/log/master.err",
path_mylog => "$opt_vardir/log/master.log",
- path_mypid => "$opt_vardir/run/master.pid",
- path_mysock => "$sockdir/master.sock",
- path_myport => $opt_master_myport,
+ path_pid => "$opt_vardir/run/master.pid",
+ path_sock => "$sockdir/master.sock",
+ port => $opt_master_myport,
start_timeout => 400, # enough time create innodb tables
-
- ndbcluster => 1, # ndbcluster not started
+ cluster => 0, # index in clusters list
+ start_opts => [],
};
$master->[1]=
{
+ type => "master",
+ idx => 1,
path_myddir => "$opt_vardir/master1-data",
path_myerr => "$opt_vardir/log/master1.err",
path_mylog => "$opt_vardir/log/master1.log",
- path_mypid => "$opt_vardir/run/master1.pid",
- path_mysock => "$sockdir/master1.sock",
- path_myport => $opt_master_myport + 1,
+ path_pid => "$opt_vardir/run/master1.pid",
+ path_sock => "$sockdir/master1.sock",
+ port => $opt_master_myport + 1,
start_timeout => 400, # enough time create innodb tables
+ cluster => 0, # index in clusters list
+ start_opts => [],
};
$slave->[0]=
{
+ type => "slave",
+ idx => 0,
path_myddir => "$opt_vardir/slave-data",
path_myerr => "$opt_vardir/log/slave.err",
path_mylog => "$opt_vardir/log/slave.log",
- path_mypid => "$opt_vardir/run/slave.pid",
- path_mysock => "$sockdir/slave.sock",
- path_myport => $opt_slave_myport,
+ path_pid => "$opt_vardir/run/slave.pid",
+ path_sock => "$sockdir/slave.sock",
+ port => $opt_slave_myport,
start_timeout => 400,
- ndbcluster => 1, # ndbcluster not started
+ cluster => 1, # index in clusters list
+ start_opts => [],
};
$slave->[1]=
{
+ type => "slave",
+ idx => 1,
path_myddir => "$opt_vardir/slave1-data",
path_myerr => "$opt_vardir/log/slave1.err",
path_mylog => "$opt_vardir/log/slave1.log",
- path_mypid => "$opt_vardir/run/slave1.pid",
- path_mysock => "$sockdir/slave1.sock",
- path_myport => $opt_slave_myport + 1,
+ path_pid => "$opt_vardir/run/slave1.pid",
+ path_sock => "$sockdir/slave1.sock",
+ port => $opt_slave_myport + 1,
start_timeout => 300,
+ cluster => -1, # index in clusters list
+ start_opts => [],
};
$slave->[2]=
{
+ type => "slave",
+ idx => 2,
path_myddir => "$opt_vardir/slave2-data",
path_myerr => "$opt_vardir/log/slave2.err",
path_mylog => "$opt_vardir/log/slave2.log",
- path_mypid => "$opt_vardir/run/slave2.pid",
- path_mysock => "$sockdir/slave2.sock",
- path_myport => $opt_slave_myport + 2,
+ path_pid => "$opt_vardir/run/slave2.pid",
+ path_sock => "$sockdir/slave2.sock",
+ port => $opt_slave_myport + 2,
start_timeout => 300,
+ cluster => -1, # index in clusters list
+ start_opts => [],
};
$instance_manager=
@@ -985,11 +1047,53 @@ sub command_line_setup () {
old_log_format => 1
};
+ my $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port";
+ $clusters->[0]=
+ {
+ name => "Master",
+ nodes => 2,
+ port => "$opt_ndbcluster_port",
+ data_dir => "$data_dir",
+ connect_string => "$opt_ndbconnectstring",
+ path_pid => "$data_dir/ndb_3.pid", # Nodes + 1
+ pid => 0, # pid of ndb_mgmd
+ installed_ok => 'NO',
+ };
+
+ $data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port_slave";
+ $clusters->[1]=
+ {
+ name => "Slave",
+ nodes => 1,
+ port => "$opt_ndbcluster_port_slave",
+ data_dir => "$data_dir",
+ connect_string => "$opt_ndbconnectstring_slave",
+ path_pid => "$data_dir/ndb_2.pid", # Nodes + 1
+ pid => 0, # pid of ndb_mgmd
+ installed_ok => 'NO',
+ };
+
+ # Init pids of ndbd's
+ foreach my $cluster ( @{$clusters} )
+ {
+ for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ )
+ {
+ my $nodeid= $idx+1;
+ $cluster->{'ndbds'}->[$idx]=
+ {
+ pid => 0,
+ nodeid => $nodeid,
+ path_pid => "$cluster->{'data_dir'}/ndb_${nodeid}.pid",
+ path_fs => "$cluster->{'data_dir'}/ndb_${nodeid}_fs",
+ };
+ }
+ }
+
if ( $opt_extern )
{
$glob_use_running_server= 1;
$opt_skip_rpl= 1; # We don't run rpl test cases
- $master->[0]->{'path_mysock'}= $opt_socket;
+ $master->[0]->{'path_sock'}= $opt_socket;
}
$path_timefile= "$opt_vardir/log/mysqltest-time";
@@ -1118,6 +1222,9 @@ sub executable_setup () {
"/usr/bin/false");
$path_ndb_tools_dir= mtr_path_exists("$glob_basedir/storage/ndb/tools");
$exe_ndb_mgm= "$glob_basedir/storage/ndb/src/mgmclient/ndb_mgm";
+ $exe_ndb_waiter= "$glob_basedir/storage/ndb/tools/ndb_waiter";
+ $exe_ndbd= "$glob_basedir/storage/ndb/src/kernel/ndbd";
+ $exe_ndb_mgmd= "$glob_basedir/storage/ndb/src/mgmsrv/ndb_mgmd";
$lib_udf_example=
mtr_file_exists("$glob_basedir/sql/.libs/udf_example.so");
}
@@ -1177,13 +1284,14 @@ sub executable_setup () {
$path_ndb_tools_dir= "$glob_basedir/bin";
$exe_ndb_mgm= "$glob_basedir/bin/ndb_mgm";
+ $exe_ndb_waiter= "$glob_basedir/bin/ndb_waiter";
+ $exe_ndbd= "$glob_basedir/libexec/ndbd";
+ $exe_ndb_mgmd= "$glob_basedir/libexec/ndb_mgmd";
}
$exe_master_mysqld= $exe_master_mysqld || $exe_mysqld;
$exe_slave_mysqld= $exe_slave_mysqld || $exe_mysqld;
- $path_ndb_data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port";
- $path_ndb_slave_data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port_slave";
$file_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
}
@@ -1234,13 +1342,13 @@ sub environment_setup () {
$ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir;
$ENV{'MYSQLTEST_VARDIR'}= $opt_vardir;
$ENV{'MYSQL_TMP_DIR'}= $opt_tmpdir;
- $ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_mysock'};
- $ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_mysock'};
- $ENV{'MASTER_MYPORT'}= $master->[0]->{'path_myport'};
- $ENV{'MASTER_MYPORT1'}= $master->[1]->{'path_myport'};
- $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'path_myport'};
- $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'path_myport'};
- $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'path_myport'};
+ $ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_sock'};
+ $ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_sock'};
+ $ENV{'MASTER_MYPORT'}= $master->[0]->{'port'};
+ $ENV{'MASTER_MYPORT1'}= $master->[1]->{'port'};
+ $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
+ $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
+ $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
# $ENV{'MYSQL_TCP_PORT'}= '@MYSQL_TCP_PORT@'; # FIXME
$ENV{'MYSQL_TCP_PORT'}= 3306;
@@ -1297,7 +1405,7 @@ sub signal_setup () {
sub handle_int_signal () {
$SIG{INT}= 'DEFAULT'; # If we get a ^C again, we die...
mtr_warning("got INT signal, cleaning up.....");
- stop_masters_slaves();
+ stop_all_servers();
mtr_error("We die from ^C signal from user");
}
@@ -1313,11 +1421,11 @@ sub kill_running_server () {
if ( $opt_fast or $glob_use_embedded_server )
{
# FIXME is embedded server really using PID files?!
- unlink($master->[0]->{'path_mypid'});
- unlink($master->[1]->{'path_mypid'});
- unlink($slave->[0]->{'path_mypid'});
- unlink($slave->[1]->{'path_mypid'});
- unlink($slave->[2]->{'path_mypid'});
+ unlink($master->[0]->{'path_pid'});
+ unlink($master->[1]->{'path_pid'});
+ unlink($slave->[0]->{'path_pid'});
+ unlink($slave->[1]->{'path_pid'});
+ unlink($slave->[2]->{'path_pid'});
}
else
{
@@ -1330,13 +1438,7 @@ sub kill_running_server () {
mkpath("$opt_vardir/log"); # Needed for mysqladmin log
mtr_kill_leftovers();
- $using_ndbcluster_master= $opt_with_ndbcluster;
- ndbcluster_stop();
- $master->[0]->{'ndbcluster'}= 1;
- $using_ndbcluster_slave= $opt_with_ndbcluster;
- ndbcluster_stop_slave();
- $slave->[0]->{'ndbcluster'}= 1;
- }
+ }
}
sub kill_and_cleanup () {
@@ -1474,6 +1576,29 @@ sub check_ssl_support () {
}
+sub check_debug_support () {
+
+ # check debug support by testing using a switch
+ # that is only available in that case
+ if ( mtr_run($exe_mysqld,
+ ["--no-defaults",
+ "--debug",
+ "--help"],
+ "", "/dev/null", "/dev/null", "") != 0 )
+ {
+ # mtr_report("Binaries are not debug compiled");
+ $debug_compiled_binaries= 0;
+
+ if ( $opt_debug )
+ {
+ mtr_error("Can't use --debug, binaries does not support it");
+ }
+ return;
+ }
+ mtr_report("Binaries are debug compiled");
+ $debug_compiled_binaries= 1;
+}
+
##############################################################################
#
# Start the ndb cluster
@@ -1486,12 +1611,10 @@ sub check_ndbcluster_support () {
{
mtr_report("Skipping ndbcluster");
$opt_skip_ndbcluster_slave= 1;
- $opt_with_ndbcluster= 0;
- $opt_with_ndbcluster_slave= 0;
return;
}
- # check ndbcluster support by testing using a switch
+ # check ndbcluster support by runnning mysqld using a switch
# that is only available in that case
if ( mtr_run($exe_mysqld,
["--no-defaults",
@@ -1502,221 +1625,227 @@ sub check_ndbcluster_support () {
mtr_report("Skipping ndbcluster, mysqld not compiled with ndbcluster");
$opt_skip_ndbcluster= 1;
$opt_skip_ndbcluster_slave= 1;
- $opt_with_ndbcluster= 0;
- $opt_with_ndbcluster_slave= 0;
return;
}
+ $opt_ndbcluster_supported= 1;
+ mtr_report("Using ndbcluster when necessary, mysqld supports it");
+ return;
+}
- mtr_report("Using ndbcluster if necessary, mysqld supports it");
- $opt_with_ndbcluster= 1;
- if ( $opt_ndbconnectstring )
- {
- $glob_use_running_ndbcluster= 1;
- }
- else
- {
- $opt_ndbconnectstring= "host=localhost:$opt_ndbcluster_port";
- }
- if ( $opt_skip_ndbcluster_slave )
- {
- $opt_with_ndbcluster_slave= 0;
- }
- else
+sub ndbcluster_start_install ($) {
+ my $cluster= shift;
+
+ if ( $opt_skip_ndbcluster or $glob_use_running_ndbcluster )
{
- $opt_with_ndbcluster_slave= 1;
- if ( $opt_ndbconnectstring_slave )
- {
- $glob_use_running_ndbcluster_slave= 1;
- }
- else
- {
- $opt_ndbconnectstring_slave= "host=localhost:$opt_ndbcluster_port_slave";
- }
+ return 0;
}
- return;
-}
+ mtr_report("Installing $cluster->{'name'} Cluster");
+ mkdir($cluster->{'data_dir'});
-sub ndbcluster_install () {
+ # Create a config file from template
+ my $ndb_no_ord=512;
+ my $ndb_no_attr=2048;
+ my $ndb_con_op=105000;
+ my $ndb_dmem="80M";
+ my $ndb_imem="24M";
+ my $ndb_pbmem="32M";
+ my $nodes= $cluster->{'nodes'};
+ my $ndb_host= "localhost";
+ my $ndb_diskless= 0;
- if ( ! $opt_with_ndbcluster or $glob_use_running_ndbcluster )
+ if (!$opt_bench)
{
- return 0;
+ # Use a smaller configuration
+ $ndb_no_ord=32;
+ $ndb_con_op=5000;
+ $ndb_dmem="20M";
+ $ndb_imem="1M";
+ $ndb_pbmem="4M";
}
- mtr_report("Installing ndbcluster master");
- my $ndbcluster_opts= $opt_bench ? "" : "--small";
- if ( mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
- ["--port=$opt_ndbcluster_port",
- "--data-dir=$opt_vardir",
- "--verbose=2",
- $ndbcluster_opts,
- "--initial",
- "--relative-config-data-dir",
- "--core"],
- "", "", "", "") )
+
+ my $config_file_template= "ndb/ndb_config_${nodes}_node.ini";
+ my $config_file= "$cluster->{'data_dir'}/config.ini";
+
+ open(IN, $config_file_template)
+ or mtr_error("Can't open $config_file_template: $!");
+ open(OUT, ">", $config_file)
+ or mtr_error("Can't write to $config_file: $!");
+ while (<IN>)
{
- return 1;
+ chomp;
+
+ s/CHOOSE_MaxNoOfAttributes/$ndb_no_attr/;
+ s/CHOOSE_MaxNoOfOrderedIndexes/$ndb_no_ord/;
+ s/CHOOSE_MaxNoOfConcurrentOperations/$ndb_con_op/;
+ s/CHOOSE_DataMemory/$ndb_dmem/;
+ s/CHOOSE_IndexMemory/$ndb_imem/;
+ s/CHOOSE_Diskless/$ndb_diskless/;
+ s/CHOOSE_HOSTNAME_.*/$ndb_host/;
+ s/CHOOSE_FILESYSTEM/$cluster->{'data_dir'}/;
+ s/CHOOSE_PORT_MGM/$cluster->{'port'}/;
+ s/CHOOSE_DiskPageBufferMemory/$ndb_pbmem/;
+
+ print OUT "$_ \n";
}
+ close OUT;
+ close IN;
- $using_ndbcluster_master= 1;
- ndbcluster_stop();
- $master->[0]->{'ndbcluster'}= 1;
+
+ # Start cluster with "--initial"
+
+ ndbcluster_start($cluster, "--initial");
return 0;
}
-sub ndbcluster_start ($) {
- my $use_ndbcluster= shift;
+sub ndbcluster_wait_started($$){
+ my $cluster= shift;
+ my $ndb_waiter_extra_opt= shift;
+ my $path_waiter_log= "$cluster->{'data_dir'}/ndb_waiter.log";
+ my $args;
- if ( ! $use_ndbcluster )
- {
- $using_ndbcluster_master= 0;
- return 0;
- }
- if ( $glob_use_running_ndbcluster )
- {
- $using_ndbcluster_master= 1;
- return 0;
- }
- if ( $using_ndbcluster_master )
- {
- # Master already started
- return 0;
- }
- # FIXME, we want to _append_ output to file $file_ndb_testrun_log instead of /dev/null
- #mtr_report("Starting ndbcluster master");
- if ( mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
- ["--port=$opt_ndbcluster_port",
- "--data-dir=$opt_vardir",
- "--character-sets-dir=$path_charsetsdir",
- "--verbose=2",
- "--core"],
- "", "/dev/null", "", "") )
+ mtr_init_args(\$args);
+
+ mtr_add_arg($args, "--no-defaults");
+ mtr_add_arg($args, "--core");
+ mtr_add_arg($args, "--ndb-connectstring=%s", $cluster->{'connect_string'});
+ mtr_add_arg($args, "--timeout=60");
+
+ if ($ndb_waiter_extra_opt)
{
- mtr_error("Error ndbcluster_start");
- $using_ndbcluster_master= 0;
- return 1;
+ mtr_add_arg($args, "$ndb_waiter_extra_opt");
}
- $using_ndbcluster_master= 1;
- return 0;
+ # Start the ndb_waiter which will connect to the ndb_mgmd
+ # and poll it for state of the ndbd's, will return when
+ # all nodes in the cluster is started
+ my $res= mtr_run($exe_ndb_waiter, $args,
+ "", $path_waiter_log, $path_waiter_log, "");
+ mtr_verbose("ndbcluster_wait_started, returns: $res") if $res;
+ return $res;
}
-sub rm_ndbcluster_tables ($) {
- my $dir= shift;
- foreach my $bin ( glob("$dir/cluster/apply_status*"),
- glob("$dir/cluster/schema*") )
- {
- unlink($bin);
- }
+
+
+sub mysqld_wait_started($){
+ my $mysqld= shift;
+
+ my $res= sleep_until_file_created($mysqld->{'path_pid'},
+ $mysqld->{'start_timeout'},
+ $mysqld->{'pid'});
+ return $res == 0;
}
-sub ndbcluster_stop () {
- if ( ! $using_ndbcluster_master or $glob_use_running_ndbcluster )
+sub ndb_mgmd_start ($) {
+ my $cluster= shift;
+
+ my $args; # Arg vector
+ my $pid= -1;
+
+ mtr_init_args(\$args);
+ mtr_add_arg($args, "--no-defaults");
+ mtr_add_arg($args, "--core");
+ mtr_add_arg($args, "--nodaemon");
+ mtr_add_arg($args, "--config-file=%s", "$cluster->{'data_dir'}/config.ini");
+
+
+ my $path_ndb_mgmd_log= "$cluster->{'data_dir'}/\l$cluster->{'name'}_ndb_mgmd.log";
+ $pid= mtr_spawn($exe_ndb_mgmd, $args, "",
+ $path_ndb_mgmd_log,
+ $path_ndb_mgmd_log,
+ "",
+ { append_log_file => 1 });
+
+
+ # FIXME Should not be needed
+ # Unfortunately the cluster nodes will fail to start
+ # if ndb_mgmd has not started properly
+ while (ndbcluster_wait_started($cluster, "--no-contact"))
{
- $using_ndbcluster_master= 0;
- return;
+ select(undef, undef, undef, 0.1);
}
- # FIXME, we want to _append_ output to file $file_ndb_testrun_log instead of /dev/null
- #mtr_report("Stopping ndbcluster master");
- mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
- ["--port=$opt_ndbcluster_port",
- "--data-dir=$opt_vardir",
- "--verbose=2",
- "--stop"],
- "", "/dev/null", "", "");
-
- rm_ndbcluster_tables ($master->[0]->{'path_myddir'});
- rm_ndbcluster_tables ($master->[1]->{'path_myddir'});
- $using_ndbcluster_master= 0;
- return;
+
+ # Remember pid of ndb_mgmd
+ $cluster->{'pid'}= $pid;
+
+ mtr_verbose("ndb_mgmd_start, pid: $pid");
+
+ return $pid;
}
-sub ndbcluster_install_slave () {
- if ( ! $opt_with_ndbcluster_slave or $glob_use_running_ndbcluster_slave )
- {
- return 0;
- }
- mtr_report("Installing ndbcluster slave");
- if ( mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
- ["--port=$opt_ndbcluster_port_slave",
- "--data-dir=$opt_vardir",
- "--verbose=2",
- "--small",
- "--ndbd-nodes=1",
- "--initial",
- "--relative-config-data-dir",
- "--core"],
- "", "", "", "") )
- {
- return 1;
- }
+sub ndbd_start ($$$) {
+ my $cluster= shift;
+ my $idx= shift;
+ my $extra_args= shift;
- $using_ndbcluster_slave= 1;
- ndbcluster_stop_slave();
- $slave->[0]->{'ndbcluster'}= 1;
+ my $args; # Arg vector
+ my $pid= -1;
- return 0;
+ mtr_init_args(\$args);
+ mtr_add_arg($args, "--no-defaults");
+ mtr_add_arg($args, "--core");
+ mtr_add_arg($args, "--ndb-connectstring=%s", "$cluster->{'connect_string'}");
+ mtr_add_arg($args, "--character-sets-dir=%s", "$path_charsetsdir");
+ mtr_add_arg($args, "--nodaemon");
+ mtr_add_arg($args, "$extra_args");
+
+ my $nodeid= $cluster->{'ndbds'}->[$idx]->{'nodeid'};
+ my $path_ndbd_log= "$cluster->{'data_dir'}/ndb_${nodeid}.log";
+ $pid= mtr_spawn($exe_ndbd, $args, "",
+ $path_ndbd_log,
+ $path_ndbd_log,
+ "",
+ { append_log_file => 1 });
+
+ # Add pid to list of pids for this cluster
+ $cluster->{'ndbds'}->[$idx]->{'pid'}= $pid;
+
+ mtr_verbose("ndbd_start, pid: $pid");
+
+ return $pid;
}
-sub ndbcluster_start_slave ($) {
- my $use_ndbcluster= shift;
- if ( ! $use_ndbcluster )
+sub ndbcluster_start ($$) {
+ my $cluster= shift;
+ my $extra_args= shift;
+
+ mtr_verbose("ndbcluster_start '$cluster->{'name'}'");
+
+ if ( $glob_use_running_ndbcluster )
{
- $using_ndbcluster_slave= 0;
return 0;
}
- if ( $glob_use_running_ndbcluster_slave )
+
+ if ( $cluster->{'pid'} )
{
- $using_ndbcluster_slave= 1;
- return 0;
+ mtr_error("Cluster '$cluster->{'name'}' already started");
}
- # FIXME, we want to _append_ output to file $file_ndb_testrun_log instead of /dev/null
- #mtr_report("Starting ndbcluster slave");
- if ( mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
- ["--port=$opt_ndbcluster_port_slave",
- "--data-dir=$opt_vardir",
- "--verbose=2",
- "--ndbd-nodes=1",
- "--core"],
- "", "/dev/null", "", "") )
+ my $pid= ndb_mgmd_start($cluster);
+
+ for ( my $idx= 0; $idx < $cluster->{'nodes'}; $idx++ )
{
- mtr_error("Error ndbcluster_start_slave");
- $using_ndbcluster_slave= 0;
- return 1;
+ ndbd_start($cluster, $idx, $extra_args);
}
- $using_ndbcluster_slave= 1;
return 0;
}
-sub ndbcluster_stop_slave () {
- if ( ! $using_ndbcluster_slave or $glob_use_running_ndbcluster_slave )
+sub rm_ndbcluster_tables ($) {
+ my $dir= shift;
+ foreach my $bin ( glob("$dir/cluster/apply_status*"),
+ glob("$dir/cluster/schema*") )
{
- $using_ndbcluster_slave= 0;
- return;
+ unlink($bin);
}
- # FIXME, we want to _append_ output to file $file_ndb_testrun_log instead of /dev/null
- #mtr_report("Stopping ndbcluster slave");
- mtr_run("$glob_mysql_test_dir/ndb/ndbcluster",
- ["--port=$opt_ndbcluster_port_slave",
- "--data-dir=$opt_vardir",
- "--verbose=2",
- "--stop"],
- "", "/dev/null", "", "");
-
- rm_ndbcluster_tables ($slave->[0]->{'path_myddir'});
-
- $using_ndbcluster_slave= 0;
- return;
}
@@ -1731,10 +1860,9 @@ sub run_benchmarks ($) {
my $args;
- if ( ! $glob_use_embedded_server and ! $opt_local_master )
+ if ( ! $glob_use_embedded_server )
{
- $master->[0]->{'pid'}= mysqld_start('master',0,[],[],
- $using_ndbcluster_master);
+ mysqld_start($master->[0],[],[]);
if ( ! $master->[0]->{'pid'} )
{
mtr_error("Can't start the mysqld server");
@@ -1743,7 +1871,7 @@ sub run_benchmarks ($) {
mtr_init_args(\$args);
- mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_mysock'});
+ mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_sock'});
mtr_add_arg($args, "--user=%s", $opt_user);
if ( $opt_small_bench )
@@ -1822,7 +1950,7 @@ sub run_suite () {
! $glob_use_running_server and
! $glob_use_embedded_server )
{
- stop_masters_slaves();
+ stop_all_servers();
}
if ( $opt_gcov )
@@ -1884,42 +2012,50 @@ sub mysql_install_db () {
im_prepare_env($instance_manager);
}
- if ( ndbcluster_install() )
+
+ my $cluster_started_ok= 1; # Assume it can be started
+
+
+ if (ndbcluster_start_install($clusters->[0]) ||
+ $use_slaves && ndbcluster_start_install($clusters->[1]))
{
- if ( $opt_force)
+ mtr_warning("Failed to start install of cluster");
+ $cluster_started_ok= 0;
+ }
+
+
+ foreach my $cluster (@{$clusters})
+ {
+
+ next if !$cluster->{'pid'};
+
+ $cluster->{'installed_ok'}= "YES"; # Assume install suceeds
+
+ if (ndbcluster_wait_started($cluster, ""))
{
# failed to install, disable usage and flag that its no ok
- mtr_report("ndbcluster_install failed, continuing without cluster");
- $opt_with_ndbcluster= 0;
- $flag_ndb_status_ok= 0;
- $ENV{'NDB_STATUS_OK'}= "NO";
- }
- else
- {
- print "Aborting: Failed to install ndb cluster\n";
- print "To continue, re-run with '--force'.\n";
- mtr_exit(1);
+ mtr_report("ndbcluster_install of $cluster->{'name'} failed");
+ $cluster->{"installed_ok"}= "NO";
+
+ $cluster_started_ok= 0;
}
}
- if ( $use_slaves and ndbcluster_install_slave() )
+ if ( ! $cluster_started_ok )
{
if ( $opt_force)
{
- # failed to install, disable usage and flag that its no ok
- mtr_report("ndbcluster_install_slave failed, " .
- "continuing without slave cluster");
- $opt_with_ndbcluster_slave= 0;
- $flag_ndb_slave_status_ok= 0;
+ # Continue without cluster
}
else
{
- print "Aborting: Failed to install ndb cluster\n";
- print "To continue, re-run with '--force'.\n";
- mtr_exit(1);
+ mtr_error("To continue, re-run with '--force'.");
}
}
+ # Stop clusters...
+ stop_all_servers();
+
return 0;
}
@@ -2108,8 +2244,6 @@ sub run_testcase ($) {
my $tname= $tinfo->{'name'};
- my $ndbcluster_opt;
-
mtr_tonewfile($path_current_test_log,"$tname\n"); # Always tell where we are
# output current test to ndbcluster log file to enable diagnostics
@@ -2129,68 +2263,25 @@ sub run_testcase ($) {
return;
}
- if ( $tinfo->{'ndb_test'} and ! $flag_ndb_status_ok )
+ # If test needs cluster, check that master installed ok
+ if ( $tinfo->{'ndb_test'} and $clusters->[0]->{'installed_ok'} eq "NO" )
{
mtr_report_test_name($tinfo);
mtr_report_test_failed($tinfo);
return;
}
- # ----------------------------------------------------------------------
- # If not using a running servers we may need to stop and restart.
- # We restart in the case we have initiation scripts, server options
- # etc to run. But we also restart again after the test first restart
- # and test is run, to get back to normal server settings.
- #
- # To make the code a bit more clean, we actually only stop servers
- # here, and mark this to be done. Then a generic "start" part will
- # start up the needed servers again.
- # ----------------------------------------------------------------------
-
- if ( ! $glob_use_running_server and ! $glob_use_embedded_server )
+ # If test needs slave cluster, check that it installed ok
+ if ( $tinfo->{'ndb_test'} and $tinfo->{'slave_num'} and
+ $clusters->[1]->{'installed_ok'} eq "NO" )
{
- # We try to find out if we are to restart the server
- my $do_restart= 0; # Assumes we don't have to
-
- if ( $tinfo->{'master_sh'} )
- {
- $do_restart= 1; # Always restart if script to run
- }
- elsif ( $opt_with_ndbcluster and $tinfo->{'ndb_test'} != $using_ndbcluster_master )
- {
- $do_restart= 1; # Restart without cluster
- }
- elsif ( $master->[0]->{'running_master_is_special'} and
- $master->[0]->{'running_master_is_special'}->{'timezone'} eq
- $tinfo->{'timezone'} and
- mtr_same_opts($master->[0]->{'running_master_is_special'}->{'master_opt'},
- $tinfo->{'master_opt'}) )
- {
- # If running master was started with special settings, but
- # the current test requuires the same ones, we *don't* restart.
- $do_restart= 0;
- }
- elsif ( $tinfo->{'master_restart'} or
- $master->[0]->{'running_master_is_special'} )
- {
- $do_restart= 1;
- }
-
- if ( $do_restart )
- {
- stop_masters();
- delete $master->[0]->{'running_master_is_special'}; # Forget history
- }
-
- # ----------------------------------------------------------------------
- # Always terminate all slaves, if any. Else we may have useless
- # reconnection attempts and error messages in case the slave and
- # master servers restart.
- # ----------------------------------------------------------------------
-
- stop_slaves();
+ mtr_report_test_name($tinfo);
+ mtr_report_test_failed($tinfo);
+ return;
}
+ run_testcase_stop_servers($tinfo);
+
# ----------------------------------------------------------------------
# Prepare to start masters. Even if we use embedded, we want to run
# the preparation.
@@ -2198,18 +2289,12 @@ sub run_testcase ($) {
$ENV{'TZ'}= $tinfo->{'timezone'};
- mtr_report_test_name($tinfo);
-
mtr_tofile($master->[0]->{'path_myerr'},"CURRENT_TEST: $tname\n");
if ( $master->[1]->{'pid'} )
{
mtr_tofile($master->[1]->{'path_myerr'},"CURRENT_TEST: $tname\n");
}
- # FIXME test cases that depend on each other, prevent this from
- # being at this location.
- # do_before_start_master($tname,$tinfo->{'master_sh'});
-
# ----------------------------------------------------------------------
# If any mysqld servers running died, we have to know
# ----------------------------------------------------------------------
@@ -2217,126 +2302,9 @@ sub run_testcase ($) {
mtr_record_dead_children();
# ----------------------------------------------------------------------
- # Start masters
+ # Start masters needed by the testcase
# ----------------------------------------------------------------------
-
- if ( ! $glob_use_running_server and ! $glob_use_embedded_server )
- {
- # FIXME give the args to the embedded server?!
- # FIXME what does $opt_local_master mean?!
- # FIXME split up start and check that started so that can do
- # starts in parallel, masters and slaves at the same time.
-
- if ( $tinfo->{'component_id'} eq 'mysqld' and ! $opt_local_master )
- {
- if ( $opt_with_ndbcluster and $master->[0]->{'ndbcluster'} )
- {
- # Cluster is not started
-
- # Call ndbcluster_start to check if test case needs cluster
- # Start it if not already started
- $master->[0]->{'ndbcluster'}= ndbcluster_start($tinfo->{'ndb_test'});
- if ( $master->[0]->{'ndbcluster'} )
- {
- report_failure_and_restart($tinfo);
- return;
- }
- }
- if ( ! $master->[0]->{'pid'} )
- {
- # FIXME not correct location for do_before_start_master()
- do_before_start_master($tname,$tinfo->{'master_sh'});
- $master->[0]->{'pid'}=
- mysqld_start('master',0,$tinfo->{'master_opt'},[],
- $using_ndbcluster_master);
- if ( ! $master->[0]->{'pid'} )
- {
- report_failure_and_restart($tinfo);
- return;
- }
- }
- if ( $using_ndbcluster_master and ! $master->[1]->{'pid'} )
- {
- # Test needs cluster, start an extra mysqld connected to cluster
- # First wait for first mysql server to have created ndb system tables ok
- if ( ! sleep_until_file_created("$master->[0]->{'path_myddir'}/cluster/apply_status.ndb",
- $master->[0]->{'start_timeout'},
- $master->[0]->{'pid'}))
- {
- report_failure_and_restart($tinfo);
- return;
- }
- mtr_tofile($master->[1]->{'path_myerr'},"CURRENT_TEST: $tname\n");
- $master->[1]->{'pid'}=
- mysqld_start('master',1,$tinfo->{'master_opt'},[],
- $using_ndbcluster_master);
- if ( ! $master->[1]->{'pid'} )
- {
- report_failure_and_restart($tinfo);
- return;
- }
- }
-
- if ( $tinfo->{'master_restart'} )
- {
- # Save this test case information, so next can examine it
- $master->[0]->{'running_master_is_special'}= $tinfo;
- }
- }
- elsif ( ! $opt_skip_im and $tinfo->{'component_id'} eq 'im' )
- {
- # We have to create defaults file every time, in order to ensure that it
- # will be the same for each test. The problem is that test can change the
- # file (by SET/UNSET commands), so w/o recreating the file, execution of
- # one test can affect the other.
-
- im_create_defaults_file($instance_manager);
-
- im_start($instance_manager, $tinfo->{im_opts});
- }
-
- # ----------------------------------------------------------------------
- # Start slaves - if needed
- # ----------------------------------------------------------------------
-
- if ( $tinfo->{'slave_num'} )
- {
- mtr_tofile($slave->[0]->{'path_myerr'},"CURRENT_TEST: $tname\n");
-
- do_before_start_slave($tname,$tinfo->{'slave_sh'});
-
- for ( my $idx= 0; $idx < $tinfo->{'slave_num'}; $idx++ )
- {
- if ( ! $slave->[$idx]->{'pid'} )
- {
- $ndbcluster_opt= 0;
- if ( $idx == 0)
- {
- if ( $slave->[0]->{'ndbcluster'} )
- {
- $slave->[0]->{'ndbcluster'}=
- ndbcluster_start_slave($tinfo->{'ndb_test'});
- if ( $slave->[0]->{'ndbcluster'} )
- {
- report_failure_and_restart($tinfo);
- return;
- }
- }
- $ndbcluster_opt= $using_ndbcluster_slave;
- }
- $slave->[$idx]->{'pid'}=
- mysqld_start('slave',$idx,
- $tinfo->{'slave_opt'}, $tinfo->{'slave_mi'},
- $ndbcluster_opt);
- if ( ! $slave->[$idx]->{'pid'} )
- {
- report_failure_and_restart($tinfo);
- return;
- }
- }
- }
- }
- }
+ run_testcase_start_servers($tinfo);
# ----------------------------------------------------------------------
# If --start-and-exit or --start-dirty given, stop here to let user manually
@@ -2353,6 +2321,8 @@ sub run_testcase ($) {
# Run the test case
# ----------------------------------------------------------------------
+ mtr_report_test_name($tinfo);
+
{
# remove the old reject file
if ( $opt_suite eq "main" )
@@ -2366,7 +2336,6 @@ sub run_testcase ($) {
unlink($path_timefile);
my $res= run_mysqltest($tinfo);
-
if ( $res == 0 )
{
mtr_report_test_passed($tinfo);
@@ -2374,6 +2343,8 @@ sub run_testcase ($) {
elsif ( $res == 62 )
{
# Testcase itself tell us to skip this one
+ # FIXME get reason to skip from mysqltest
+ $tinfo->{'comment'}= "Detected by testcase";
mtr_report_test_skipped($tinfo);
}
elsif ( $res == 63 )
@@ -2390,6 +2361,7 @@ sub run_testcase ($) {
"mysqltest returned unexpected code $res, " .
"it has probably crashed");
}
+
report_failure_and_restart($tinfo);
}
# Save info from this testcase run to mysqltest.log
@@ -2405,7 +2377,7 @@ sub run_testcase ($) {
if ( ! $glob_use_running_server and $tinfo->{'component_id'} eq 'im' and
$instance_manager->{'pid'} )
{
- im_stop($instance_manager);
+ im_stop($instance_manager, $tinfo->{'name'});
}
}
@@ -2456,8 +2428,6 @@ sub restore_installed_db ($) {
if ( -d $path_snapshot)
{
- kill_running_server ();
-
mtr_report("Restoring snapshot of databases");
foreach my $data_dir (@data_dir_lst)
@@ -2467,27 +2437,24 @@ sub restore_installed_db ($) {
rmtree("$data_dir");
mtr_copy_dir("$path_snapshot/$name", "$data_dir");
}
- if ($opt_with_ndbcluster)
- {
- # Remove the ndb_*_fs dirs, forcing a clean start of ndb
- rmtree("$path_ndb_data_dir/ndb_1_fs");
- rmtree("$path_ndb_data_dir/ndb_2_fs");
- if ( $opt_with_ndbcluster_slave )
+ # Remove the ndb_*_fs dirs for all ndbd nodes
+ # forcing a clean start of ndb
+ foreach my $cluster (@{$clusters})
+ {
+ foreach my $ndbd (@{$cluster->{'ndbds'}})
{
- # Remove also the ndb_*_fs dirs for slave cluster
- rmtree("$path_ndb_slave_data_dir/ndb_1_fs");
+ rmtree("$ndbd->{'path_fs'}" );
}
}
}
else
{
- # No snapshot existed, just stop all processes
- stop_masters_slaves();
+ # No snapshot existed
+ mtr_error("No snapshot existed");
}
}
-
sub report_failure_and_restart ($) {
my $tinfo= shift;
@@ -2496,6 +2463,9 @@ sub report_failure_and_restart ($) {
print "\n";
if ( $opt_force )
{
+ # Stop all servers that are known to be running
+ stop_all_servers();
+
# Restore the snapshot of the installed test db
restore_installed_db($tinfo->{'name'});
print "Resuming Tests\n\n";
@@ -2509,7 +2479,7 @@ sub report_failure_and_restart ($) {
! $glob_use_running_server and
! $glob_use_embedded_server )
{
- stop_masters_slaves();
+ stop_all_servers();
}
mtr_exit(1);
@@ -2603,18 +2573,17 @@ sub do_before_start_slave ($$) {
}
-sub mysqld_arguments ($$$$$$) {
+sub mysqld_arguments ($$$$$) {
my $args= shift;
- my $type= shift; # master/slave/bootstrap
+ my $type= shift;
my $idx= shift;
my $extra_opt= shift;
my $slave_master_info= shift;
- my $using_ndbcluster= shift;
my $sidx= ""; # Index as string, 0 is empty string
if ( $idx > 0 )
{
- $sidx= sprintf("%d", $idx); # sprintf not needed in Perl for this
+ $sidx= "$idx";
}
my $prefix= ""; # If mysqltest server arg
@@ -2654,12 +2623,12 @@ sub mysqld_arguments ($$$$$$) {
$opt_vardir, $sidx);
}
mtr_add_arg($args, "%s--pid-file=%s", $prefix,
- $master->[$idx]->{'path_mypid'});
+ $master->[$idx]->{'path_pid'});
mtr_add_arg($args, "%s--port=%d", $prefix,
- $master->[$idx]->{'path_myport'});
+ $master->[$idx]->{'port'});
mtr_add_arg($args, "%s--server-id=%d", $prefix, $id);
mtr_add_arg($args, "%s--socket=%s", $prefix,
- $master->[$idx]->{'path_mysock'});
+ $master->[$idx]->{'path_sock'});
mtr_add_arg($args, "%s--innodb_data_file_path=ibdata1:10M:autoextend", $prefix);
mtr_add_arg($args, "%s--local-infile", $prefix);
mtr_add_arg($args, "%s--datadir=%s", $prefix,
@@ -2670,7 +2639,9 @@ sub mysqld_arguments ($$$$$$) {
mtr_add_arg($args, "%s--skip-innodb", $prefix);
}
- if ( $opt_skip_ndbcluster || !$using_ndbcluster)
+ my $cluster= $clusters->[$master->[$idx]->{'cluster'}];
+ if ( $opt_skip_ndbcluster ||
+ !$cluster->{'pid'})
{
mtr_add_arg($args, "%s--skip-ndbcluster", $prefix);
}
@@ -2678,7 +2649,7 @@ sub mysqld_arguments ($$$$$$) {
{
mtr_add_arg($args, "%s--ndbcluster", $prefix);
mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
- $opt_ndbconnectstring);
+ $cluster->{'connect_string'});
mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
}
}
@@ -2704,14 +2675,14 @@ sub mysqld_arguments ($$$$$$) {
$slave->[$idx]->{'path_mylog'});
mtr_add_arg($args, "%s--master-retry-count=10", $prefix);
mtr_add_arg($args, "%s--pid-file=%s", $prefix,
- $slave->[$idx]->{'path_mypid'});
+ $slave->[$idx]->{'path_pid'});
mtr_add_arg($args, "%s--port=%d", $prefix,
- $slave->[$idx]->{'path_myport'});
+ $slave->[$idx]->{'port'});
mtr_add_arg($args, "%s--relay-log=%s/log/slave%s-relay-bin", $prefix,
$opt_vardir, $sidx);
mtr_add_arg($args, "%s--report-host=127.0.0.1", $prefix);
mtr_add_arg($args, "%s--report-port=%d", $prefix,
- $slave->[$idx]->{'path_myport'});
+ $slave->[$idx]->{'port'});
mtr_add_arg($args, "%s--report-user=root", $prefix);
mtr_add_arg($args, "%s--skip-innodb", $prefix);
mtr_add_arg($args, "%s--skip-ndbcluster", $prefix);
@@ -2723,7 +2694,7 @@ sub mysqld_arguments ($$$$$$) {
mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix,
"../tmp");
mtr_add_arg($args, "%s--socket=%s", $prefix,
- $slave->[$idx]->{'path_mysock'});
+ $slave->[$idx]->{'path_sock'});
mtr_add_arg($args, "%s--set-variable=slave_net_timeout=10", $prefix);
if ( @$slave_master_info )
@@ -2740,20 +2711,22 @@ sub mysqld_arguments ($$$$$$) {
mtr_add_arg($args, "%s--master-host=127.0.0.1", $prefix);
mtr_add_arg($args, "%s--master-password=", $prefix);
mtr_add_arg($args, "%s--master-port=%d", $prefix,
- $master->[0]->{'path_myport'}); # First master
+ $master->[0]->{'port'}); # First master
mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
mtr_add_arg($args, "%s--rpl-recovery-rank=%d", $prefix, $slave_rpl_rank);
}
-
- if ( $opt_skip_ndbcluster_slave )
+
+ if ( $opt_skip_ndbcluster_slave ||
+ $slave->[$idx]->{'cluster'} == -1 ||
+ !$clusters->[$slave->[$idx]->{'cluster'}]->{'pid'} )
{
mtr_add_arg($args, "%s--skip-ndbcluster", $prefix);
}
- if ( $idx == 0 and $using_ndbcluster_slave )
+ else
{
mtr_add_arg($args, "%s--ndbcluster", $prefix);
mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
- $opt_ndbconnectstring_slave);
+ $clusters->[$slave->[$idx]->{'cluster'}]->{'connect_string'});
mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
}
} # end slave
@@ -2807,24 +2780,6 @@ sub mysqld_arguments ($$$$$$) {
mtr_add_arg($args, "%s--user=root", $prefix);
}
- if ( $type eq 'master' )
- {
-
- if ( ! $opt_old_master )
- {
- mtr_add_arg($args, "%s--rpl-recovery-rank=1", $prefix);
- mtr_add_arg($args, "%s--init-rpl-role=master", $prefix);
- }
-
- # FIXME strange,.....
- # FIXME MYSQL_MYPORT is not set anythere?!
- if ( $opt_local_master )
- {
- mtr_add_arg($args, "%s--host=127.0.0.1", $prefix);
- mtr_add_arg($args, "%s--port=%s", $prefix, $ENV{'MYSQL_MYPORT'});
- }
- }
-
foreach my $arg ( @opt_extra_mysqld_opt, @$extra_opt )
{
mtr_add_arg($args, "%s%s", $prefix, $arg);
@@ -2852,23 +2807,24 @@ sub mysqld_arguments ($$$$$$) {
#
##############################################################################
-sub mysqld_start ($$$$$) {
- my $type= shift; # master/slave/bootstrap
- my $idx= shift;
+sub mysqld_start ($$$) {
+ my $mysqld= shift;
my $extra_opt= shift;
my $slave_master_info= shift;
- my $using_ndbcluster= shift;
-
my $args; # Arg vector
my $exe;
my $pid= -1;
+ my $wait_for_pid_file= 1;
+
+ my $type= $mysqld->{'type'};
+ my $idx= $mysqld->{'idx'};
if ( $type eq 'master' )
{
$exe= $exe_master_mysqld;
}
- elsif ( $type eq 'slave' )
+ if ( $type eq 'slave' )
{
$exe= $exe_slave_mysqld;
}
@@ -2884,8 +2840,7 @@ sub mysqld_start ($$$$$) {
valgrind_arguments($args, \$exe);
}
- mysqld_arguments($args,$type,$idx,$extra_opt,$slave_master_info,
- $using_ndbcluster);
+ mysqld_arguments($args,$type,$idx,$extra_opt,$slave_master_info);
if ( $opt_gdb || $opt_manual_gdb)
{
@@ -2910,6 +2865,11 @@ sub mysqld_start ($$$$$) {
# Indicate the exe should not be started
$exe= undef;
}
+ else
+ {
+ # Default to not wait until pid file has been created
+ $wait_for_pid_file= 0;
+ }
if ($exe_libtool and $opt_valgrind)
{
@@ -2920,116 +2880,500 @@ sub mysqld_start ($$$$$) {
}
- if ( $type eq 'master' )
+ if ( defined $exe )
{
- if ( ! defined $exe or
- $pid= mtr_spawn($exe, $args, "",
- $master->[$idx]->{'path_myerr'},
- $master->[$idx]->{'path_myerr'},
- "",
- { append_log_file => 1 }) )
+ $pid= mtr_spawn($exe, $args, "",
+ $mysqld->{'path_myerr'},
+ $mysqld->{'path_myerr'},
+ "",
+ { append_log_file => 1 });
+ }
+
+
+ if ( $wait_for_pid_file && !sleep_until_file_created($mysqld->{'path_pid'},
+ $mysqld->{'start_timeout'},
+ $pid))
+ {
+
+ mtr_error("Failed to start mysqld $mysqld->{'type'}");
+ }
+
+
+ # Remember pid of the started process
+ $mysqld->{'pid'}= $pid;
+
+ # Remember options used when starting
+ $mysqld->{'start_opts'}= $extra_opt;
+
+ mtr_verbose("mysqld pid: $pid");
+ return $pid;
+}
+
+
+sub stop_all_servers () {
+
+ print "Stopping All Servers\n";
+
+ if ( $instance_manager->{'pid'} )
+ {
+ print "Shutting-down Instance Manager\n";
+ im_stop($instance_manager, "stop_all_servers");
+ }
+
+ my %admin_pids; # hash of admin processes that requests shutdown
+ my @kill_pids; # list of processes to shutdown/kill
+ my $pid;
+
+ # Start shutdown of all started masters
+ foreach my $mysqld (@{$master}, @{$slave})
+ {
+ if ( $mysqld->{'pid'} )
{
- return sleep_until_file_created($master->[$idx]->{'path_mypid'},
- $master->[$idx]->{'start_timeout'},
- $pid);
+ $pid= mtr_mysqladmin_start($mysqld, "shutdown", 70);
+ $admin_pids{$pid}= 1;
+
+ push(@kill_pids,{
+ pid => $mysqld->{'pid'},
+ pidfile => $mysqld->{'path_pid'},
+ sockfile => $mysqld->{'path_sock'},
+ port => $mysqld->{'port'},
+ });
+
+ $mysqld->{'pid'}= 0; # Assume we are done with it
}
}
- if ( $type eq 'slave' )
+ # Start shutdown of clusters
+ foreach my $cluster (@{$clusters})
{
- if ( ! defined $exe or
- $pid= mtr_spawn($exe, $args, "",
- $slave->[$idx]->{'path_myerr'},
- $slave->[$idx]->{'path_myerr'},
- "",
- { append_log_file => 1 }) )
+ if ( $cluster->{'pid'} )
{
- return sleep_until_file_created($slave->[$idx]->{'path_mypid'},
- $master->[$idx]->{'start_timeout'},
- $pid);
+ $pid= mtr_ndbmgm_start($cluster, "shutdown");
+ $admin_pids{$pid}= 1;
+
+ push(@kill_pids,{
+ pid => $cluster->{'pid'},
+ pidfile => $cluster->{'path_pid'}
+ });
+
+ $cluster->{'pid'}= 0; # Assume we are done with it
+
+ foreach my $ndbd (@{$cluster->{'ndbds'}})
+ {
+ if ( $ndbd->{'pid'} )
+ {
+ push(@kill_pids,{
+ pid => $ndbd->{'pid'},
+ pidfile => $ndbd->{'path_pid'},
+ });
+ $ndbd->{'pid'}= 0;
+ }
+ }
}
}
- return 0;
+ # Wait blocking until all shutdown processes has completed
+ mtr_wait_blocking(\%admin_pids);
+
+ # Make sure that process has shutdown else try to kill them
+ mtr_check_stop_servers(\@kill_pids);
+
+ foreach my $mysqld (@{$master}, @{$slave})
+ {
+ rm_ndbcluster_tables($mysqld->{'path_myddir'});
+ }
}
-sub stop_masters_slaves () {
+# ----------------------------------------------------------------------
+# If not using a running servers we may need to stop and restart.
+# We restart in the case we have initiation scripts, server options
+# etc to run. But we also restart again after the test first restart
+# and test is run, to get back to normal server settings.
+#
+# To make the code a bit more clean, we actually only stop servers
+# here, and mark this to be done. Then a generic "start" part will
+# start up the needed servers again.
+# ----------------------------------------------------------------------
- print "Ending Tests\n";
+sub run_testcase_stop_servers($) {
+ my $tinfo= shift;
- if ( $instance_manager->{'pid'} )
+ if ( $glob_use_running_server || $glob_use_embedded_server )
{
- print "Shutting-down Instance Manager\n";
- im_stop($instance_manager);
+ return;
}
- print "Shutting-down MySQL daemon\n\n";
- stop_masters();
- print "Master(s) shutdown finished\n";
- stop_slaves();
- print "Slave(s) shutdown finished\n";
-}
+ # We try to find out if we are to restart the master(s)
+ my $do_restart= 0; # Assumes we don't have to
+
+ if ( $tinfo->{'master_sh'} )
+ {
+ $do_restart= 1; # Always restart if script to run
+ mtr_verbose("Restart because: Always restart if script to run");
+ }
+ elsif ( ! $opt_skip_ndbcluster and
+ $tinfo->{'ndb_test'} == 0 and
+ $clusters->[0]->{'pid'} != 0 )
+ {
+ $do_restart= 1; # Restart without cluster
+ mtr_verbose("Restart because: Test does not need cluster");
+ }
+ elsif ( ! $opt_skip_ndbcluster and
+ $tinfo->{'ndb_test'} == 1 and
+ $clusters->[0]->{'pid'} == 0 )
+ {
+ $do_restart= 1; # Restart with cluster
+ mtr_verbose("Restart because: Test need cluster");
+ }
+ elsif ( $master->[0]->{'running_master_is_special'} and
+ $master->[0]->{'running_master_is_special'}->{'timezone'} eq
+ $tinfo->{'timezone'} and
+ mtr_same_opts($master->[0]->{'running_master_is_special'}->{'master_opt'},
+ $tinfo->{'master_opt'}) )
+ {
+ # If running master was started with special settings, but
+ # the current test requires the same ones, we *don't* restart.
+ $do_restart= 0;
+ mtr_verbose("Skip restart: options are equal " .
+ join(" ", @{$tinfo->{'master_opt'}}));
+ }
+ elsif ( $tinfo->{'master_restart'} )
+ {
+ $do_restart= 1;
+ mtr_verbose("Restart because: master_restart");
+ }
+ elsif ( $master->[0]->{'running_master_is_special'} )
+ {
+ $do_restart= 1;
+ mtr_verbose("Restart because: running_master_is_special");
+ }
+ # Check that running master was started with same options
+ # as the current test requires
+ elsif (! mtr_same_opts($master->[0]->{'start_opts'},
+ $tinfo->{'master_opt'}) )
+ {
+ $do_restart= 1;
+ mtr_verbose("Restart because: running with different options '" .
+ join(" ", @{$tinfo->{'master_opt'}}) . "' != '" .
+ join(" ", @{$master->[0]->{'start_opts'}}) . "'" );
+ }
+
+ my $pid;
+ my %admin_pids; # hash of admin processes that requests shutdown
+ my @kill_pids; # list of processes to shutdown/kill
+
+
+ # Remember if we restarted for this test case
+ $tinfo->{'restarted'}= $do_restart;
+
+ if ( $do_restart )
+ {
+ delete $master->[0]->{'running_master_is_special'}; # Forget history
+
+ # Start shutdown of all started masters
+ foreach my $mysqld (@{$master})
+ {
+ if ( $mysqld->{'pid'} )
+ {
+ $pid= mtr_mysqladmin_start($mysqld, "shutdown", 70);
+
+ $admin_pids{$pid}= 1;
+
+ push(@kill_pids,{
+ pid => $mysqld->{'pid'},
+ pidfile => $mysqld->{'path_pid'},
+ sockfile => $mysqld->{'path_sock'},
+ port => $mysqld->{'port'},
+ });
+
+ $mysqld->{'pid'}= 0; # Assume we are done with it
+ }
+ }
+
+ # Start shutdown of master cluster
+ my $cluster= $clusters->[0];
+ if ( $cluster->{'pid'} )
+ {
+ $pid= mtr_ndbmgm_start($cluster, "shutdown");
+ $admin_pids{$pid}= 1;
+
+ push(@kill_pids,{
+ pid => $cluster->{'pid'},
+ pidfile => $cluster->{'path_pid'}
+ });
+
+ $cluster->{'pid'}= 0; # Assume we are done with it
+
+ foreach my $ndbd (@{$cluster->{'ndbds'}})
+ {
+ push(@kill_pids,{
+ pid => $ndbd->{'pid'},
+ pidfile => $ndbd->{'path_pid'},
+ });
+ $ndbd->{'pid'}= 0; # Assume we are done with it
+ }
+ }
+ }
+
+ # We try to find out if we are to restart the slaves
+ my $do_slave_restart= 0; # Assumes we don't have to
+
+ # FIXME only restaret when necessary
+ $do_slave_restart= 1;
+
+# if ( ! $slave->[0]->{'pid'} )
+# {
+# # mtr_verbose("Slave not started, no need to check slave restart");
+# }
+# elsif ( $do_restart )
+# {
+# $do_slave_restart= 1; # Always restart if master restart
+# mtr_verbose("Restart slave because: Master restart");
+# }
+# elsif ( $tinfo->{'slave_sh'} )
+# {
+# $do_slave_restart= 1; # Always restart if script to run
+# mtr_verbose("Restart slave because: Always restart if script to run");
+# }
+# elsif ( ! $opt_skip_ndbcluster_slave and
+# $tinfo->{'ndb_test'} == 0 and
+# $clusters->[1]->{'pid'} != 0 )
+# {
+# $do_slave_restart= 1; # Restart without slave cluster
+# mtr_verbose("Restart slave because: Test does not need slave cluster");
+# }
+# elsif ( ! $opt_with_ndbcluster_slave and
+# $tinfo->{'ndb_test'} == 1 and
+# $clusters->[1]->{'pid'} == 0 )
+# {
+# $do_slave_restart= 1; # Restart with slave cluster
+# mtr_verbose("Restart slave because: Test need slave cluster");
+# }
+# elsif ( $tinfo->{'slave_restart'} )
+# {
+# $do_slave_restart= 1;
+# mtr_verbose("Restart slave because: slave_restart");
+# }
+# elsif ( $slave->[0]->{'running_slave_is_special'} )
+# {
+# $do_slave_restart= 1;
+# mtr_verbose("Restart slave because: running_slave_is_special");
+# }
+# # Check that running slave was started with same options
+# # as the current test requires
+# elsif (! mtr_same_opts($slave->[0]->{'start_opts'},
+# $tinfo->{'slave_opt'}) )
+# {
+# $do_slave_restart= 1;
+# mtr_verbose("Restart slave because: running with different options '" .
+# join(" ", @{$tinfo->{'slave_opt'}}) . "' != '" .
+# join(" ", @{$slave->[0]->{'start_opts'}}) . "'" );
+# }
+
+ if ( $do_slave_restart )
+ {
+
+ delete $slave->[0]->{'running_slave_is_special'}; # Forget history
+
+ # Start shutdown of all started slaves
+ foreach my $mysqld (@{$slave})
+ {
+ if ( $mysqld->{'pid'} )
+ {
+ $pid= mtr_mysqladmin_start($mysqld, "shutdown", 70);
+
+ $admin_pids{$pid}= 1;
+
+ push(@kill_pids,{
+ pid => $mysqld->{'pid'},
+ pidfile => $mysqld->{'path_pid'},
+ sockfile => $mysqld->{'path_sock'},
+ port => $mysqld->{'port'},
+ });
+
+
+ $mysqld->{'pid'}= 0; # Assume we are done with it
+ }
+ }
+
+ # Start shutdown of slave cluster
+ my $cluster= $clusters->[1];
+ if ( $cluster->{'pid'} )
+ {
+ $pid= mtr_ndbmgm_start($cluster, "shutdown");
+
+ $admin_pids{$pid}= 1;
+
+ push(@kill_pids,{
+ pid => $cluster->{'pid'},
+ pidfile => $cluster->{'path_pid'}
+ });
+
+ $cluster->{'pid'}= 0; # Assume we are done with it
+
+ foreach my $ndbd (@{$cluster->{'ndbds'}} )
+ {
+ push(@kill_pids,{
+ pid => $ndbd->{'pid'},
+ pidfile => $ndbd->{'path_pid'},
+ });
+ $ndbd->{'pid'}= 0; # Assume we are done with it
+ }
+ }
+ }
+ # ----------------------------------------------------------------------
+ # Shutdown has now been started and lists for the shutdown processes
+ # and the processes to be killed has been created
+ # ----------------------------------------------------------------------
-sub stop_masters () {
+ # Wait blocking until all shutdown processes has completed
+ mtr_wait_blocking(\%admin_pids);
- my @args;
- for ( my $idx; $idx < 2; $idx++ )
+ # Make sure that process has shutdown else try to kill them
+ mtr_check_stop_servers(\@kill_pids);
+
+ foreach my $mysqld (@{$master}, @{$slave})
{
- # FIXME if we hit ^C before fully started, this test will prevent
- # the mysqld process from being killed
- if ( $master->[$idx]->{'pid'} )
+ if ( ! $mysqld->{'pid'} )
{
- push(@args,{
- pid => $master->[$idx]->{'pid'},
- pidfile => $master->[$idx]->{'path_mypid'},
- sockfile => $master->[$idx]->{'path_mysock'},
- port => $master->[$idx]->{'path_myport'},
- });
- $master->[$idx]->{'pid'}= 0; # Assume we are done with it
+ # Remove ndbcluster tables if server is stopped
+ rm_ndbcluster_tables($mysqld->{'path_myddir'});
}
}
+}
+
+sub run_testcase_start_servers($) {
+ my $tinfo= shift;
+
+ my $tname= $tinfo->{'name'};
- if ( ! $master->[0]->{'ndbcluster'} )
+ if ( $glob_use_running_server or $glob_use_embedded_server )
{
- ndbcluster_stop();
- $master->[0]->{'ndbcluster'}= 1;
+ return;
}
- mtr_stop_mysqld_servers(\@args);
-}
+ if ( $tinfo->{'component_id'} eq 'mysqld' )
+ {
+ if ( ! $opt_skip_ndbcluster and
+ !$clusters->[0]->{'pid'} and
+ $tinfo->{'ndb_test'} )
+ {
+ # Test need cluster, cluster is not started, start it
+ ndbcluster_start($clusters->[0], "");
+ }
+ if ( !$master->[0]->{'pid'} )
+ {
+ # Master mysqld is not started
+ do_before_start_master($tname,$tinfo->{'master_sh'});
-sub stop_slaves () {
- my $force= shift;
+ mysqld_start($master->[0],$tinfo->{'master_opt'},[]);
- my @args;
+ }
- for ( my $idx; $idx < 3; $idx++ )
+ if ( $clusters->[0]->{'pid'} and ! $master->[1]->{'pid'} )
+ {
+ # Test needs cluster, start an extra mysqld connected to cluster
+
+ # First wait for first mysql server to have created ndb system tables ok
+ # FIXME This is a workaround so that only one mysqld creates the tables
+ if ( ! sleep_until_file_created(
+ "$master->[0]->{'path_myddir'}/cluster/apply_status.ndb",
+ $master->[0]->{'start_timeout'},
+ $master->[0]->{'pid'}))
+ {
+ mtr_report("Failed to create 'cluster/apply_status' table");
+ report_failure_and_restart($tinfo);
+ return;
+ }
+ mtr_tofile($master->[1]->{'path_myerr'},"CURRENT_TEST: $tname\n");
+
+ mysqld_start($master->[1],$tinfo->{'master_opt'},[]);
+ }
+
+ if ( $tinfo->{'master_restart'} )
+ {
+ # Save this test case information, so next can examine it
+ $master->[0]->{'running_master_is_special'}= $tinfo;
+ }
+ }
+ elsif ( ! $opt_skip_im and $tinfo->{'component_id'} eq 'im' )
{
- if ( $slave->[$idx]->{'pid'} )
+ # We have to create defaults file every time, in order to ensure that it
+ # will be the same for each test. The problem is that test can change the
+ # file (by SET/UNSET commands), so w/o recreating the file, execution of
+ # one test can affect the other.
+
+ im_create_defaults_file($instance_manager);
+
+ im_start($instance_manager, $tinfo->{im_opts});
+ }
+
+ # ----------------------------------------------------------------------
+ # Start slaves - if needed
+ # ----------------------------------------------------------------------
+ if ( $tinfo->{'slave_num'} )
+ {
+ mtr_tofile($slave->[0]->{'path_myerr'},"CURRENT_TEST: $tname\n");
+
+ do_before_start_slave($tname,$tinfo->{'slave_sh'});
+
+ if ( ! $opt_skip_ndbcluster_slave and
+ !$clusters->[1]->{'pid'} and
+ $tinfo->{'ndb_test'} )
{
- push(@args,{
- pid => $slave->[$idx]->{'pid'},
- pidfile => $slave->[$idx]->{'path_mypid'},
- sockfile => $slave->[$idx]->{'path_mysock'},
- port => $slave->[$idx]->{'path_myport'},
- });
- $slave->[$idx]->{'pid'}= 0; # Assume we are done with it
+ # Test need slave cluster, cluster is not started, start it
+ ndbcluster_start($clusters->[1], "");
}
+
+ for ( my $idx= 0; $idx < $tinfo->{'slave_num'}; $idx++ )
+ {
+ if ( ! $slave->[$idx]->{'pid'} )
+ {
+ mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
+ $tinfo->{'slave_mi'});
+
+ }
+ }
+
+ if ( $tinfo->{'slave_restart'} )
+ {
+ # Save this test case information, so next can examine it
+ $slave->[0]->{'running_slave_is_special'}= $tinfo;
+ }
+
}
- if ( ! $slave->[0]->{'ndbcluster'} )
+ # Wait for clusters to start
+ foreach my $cluster (@{$clusters})
{
- ndbcluster_stop_slave();
- $slave->[0]->{'ndbcluster'}= 1;
+
+ next if !$cluster->{'pid'};
+
+ if (ndbcluster_wait_started($cluster, ""))
+ {
+ # failed to start
+ mtr_report("Start of $cluster->{'name'} cluster failed, ");
+ }
}
- mtr_stop_mysqld_servers(\@args);
+ # Wait for mysqld's to start
+ foreach my $mysqld (@{$master},@{$slave})
+ {
+
+ next if !$mysqld->{'pid'};
+
+ if (mysqld_wait_started($mysqld))
+ {
+ mtr_warning("Failed to start $mysqld->{'type'} mysqld $mysqld->{'idx'}");
+ }
+ }
}
+
##############################################################################
#
# Instance Manager management routines.
@@ -3086,13 +3430,15 @@ sub im_start($$) {
return;
}
- $instance_manager->{'pid'} =
- mtr_get_pid_from_file($instance_manager->{'path_pid'});
+ my $pid= mtr_get_pid_from_file($instance_manager->{'path_pid'});
+ $instance_manager->{'pid'} = $pid;
+ mtr_verbose("im_start: pid: $pid");
}
-sub im_stop($) {
+sub im_stop($$) {
my $instance_manager = shift;
+ my $where = shift;
# Obtain mysqld-process pids before we start stopping IM (it can delete pid
# files).
@@ -3129,25 +3475,23 @@ sub im_stop($) {
# Try graceful shutdown.
- mtr_debug("IM-main pid: $instance_manager->{'pid'}");
- mtr_debug("Stopping IM-main...");
-
- mtr_kill_process($instance_manager->{'pid'}, 'TERM', 10, 1);
+ mtr_verbose("Stopping IM-main, pid: $instance_manager->{'pid'}");
+ mtr_kill_process($instance_manager->{'pid'}, 'TERM', 10);
# If necessary, wait for angel process to die.
- if (defined $instance_manager->{'angel_pid'})
+ my $pid= $instance_manager->{'angel_pid'};
+ if (defined $pid)
{
- mtr_debug("IM-angel pid: $instance_manager->{'angel_pid'}");
- mtr_debug("Waiting for IM-angel to die...");
+ mtr_verbose("Waiting for IM-angel to die, pid: $pid");
my $total_attempts= 10;
for (my $cur_attempt=1; $cur_attempt <= $total_attempts; ++$cur_attempt)
{
- unless (kill (0, $instance_manager->{'angel_pid'}))
+ unless (kill (0, $pid))
{
- mtr_debug("IM-angel died.");
+ mtr_verbose("IM-angel died.");
last;
}
@@ -3155,57 +3499,49 @@ sub im_stop($) {
}
}
- # Check that all processes died.
-
- my $clean_shutdown= 0;
+ # Check if all processes shutdown cleanly
+ my $clean_shutdown= 1; # Assum they did
- while (1)
+ if (kill (0, $instance_manager->{'pid'}))
{
- if (kill (0, $instance_manager->{'pid'}))
- {
- mtr_debug("IM-main is still alive.");
- last;
- }
+ mtr_warning("IM-main is still alive.");
+ $clean_shutdown= 0;
+ }
- if (defined $instance_manager->{'angel_pid'} &&
- kill (0, $instance_manager->{'angel_pid'}))
- {
- mtr_debug("IM-angel is still alive.");
- last;
- }
+ if (defined $instance_manager->{'angel_pid'} &&
+ kill (0, $instance_manager->{'angel_pid'}))
+ {
+ mtr_warning("IM-angel is still alive.");
+ $clean_shutdown= 0;
+ }
- foreach my $pid (@mysqld_pids)
+ foreach my $pid (@mysqld_pids)
+ {
+ if (kill (0, $pid))
{
- if (kill (0, $pid))
- {
- mtr_debug("Guarded mysqld ($pid) is still alive.");
- last;
- }
+ mtr_warning("Guarded mysqld ($pid) is still alive.");
+ $clean_shutdown= 0;
}
-
- $clean_shutdown= 1;
- last;
}
# Kill leftovers (the order is important).
-
unless ($clean_shutdown)
{
if (defined $instance_manager->{'angel_pid'})
{
- mtr_debug("Killing IM-angel...");
- mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10, 1)
+ mtr_verbose("Killing IM-angel, pid: $instance_manager->{'angel_pid'}");
+ mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10)
}
-
- mtr_debug("Killing IM-main...");
- mtr_kill_process($instance_manager->{'pid'}, 'KILL', 10, 1);
+
+ mtr_verbose("Killing IM-main, pid: $instance_manager->{'pid'}");
+ mtr_kill_process($instance_manager->{'pid'}, 'KILL', 10);
# Shutdown managed mysqld-processes. Some of them may be nonguarded, so IM
# will not stop them on shutdown. So, we should firstly try to end them
# legally.
- mtr_debug("Killing guarded mysqld(s)...");
+ mtr_verbose("Killing guarded mysqld(s) " . join(" ", @mysqld_pids));
mtr_kill_processes(\@mysqld_pids);
# Complain in error log so that a warning will be shown.
@@ -3217,7 +3553,7 @@ sub im_stop($) {
my $ts= localtime();
print ERRLOG
- "Warning: [$ts] Instance Manager did not shutdown gracefully.\n";
+ "[$where] Warning: [$ts] Instance Manager did not shutdown gracefully.\n";
close ERRLOG;
}
@@ -3236,9 +3572,12 @@ sub im_stop($) {
# Before a testcase, run in record mode, save result file to var
# After testcase, run and compare with the recorded file, they should be equal!
#
-sub run_check_testcase ($) {
+sub run_check_testcase ($$) {
my $mode= shift;
+ my $mysqld= shift;
+
+ my $name= "check-" . $mysqld->{'type'} . $mysqld->{'idx'};
my $args;
mtr_init_args(\$args);
@@ -3249,14 +3588,14 @@ sub run_check_testcase ($) {
mtr_add_arg($args, "--skip-safemalloc");
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
- mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_mysock'});
- mtr_add_arg($args, "--port=%d", $master->[0]->{'path_myport'});
+ mtr_add_arg($args, "--socket=%s", $mysqld->{'path_sock'});
+ mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
mtr_add_arg($args, "--database=test");
mtr_add_arg($args, "--user=%s", $opt_user);
mtr_add_arg($args, "--password=");
mtr_add_arg($args, "-R");
- mtr_add_arg($args, "$opt_vardir/tmp/check-testcase.result");
+ mtr_add_arg($args, "$opt_vardir/tmp/$name.result");
if ( $mode eq "before" )
{
@@ -3269,8 +3608,8 @@ sub run_check_testcase ($) {
if ( $res == 1 and $mode = "after")
{
mtr_run("diff",["-u",
- "$opt_vardir/tmp/check-testcase.result",
- "$opt_vardir/tmp/check-testcase.reject"],
+ "$opt_vardir/tmp/$name.result",
+ "$opt_vardir/tmp/$name.reject"],
"", "", "", "");
}
elsif ( $res )
@@ -3284,15 +3623,15 @@ sub generate_cmdline_mysqldump ($) {
my($info) = @_;
return
"$exe_mysqldump --no-defaults -uroot " .
- "--port=$info->[0]->{'path_myport'} " .
- "--socket=$info->[0]->{'path_mysock'} --password=";
+ "--port=$info->[0]->{'port'} " .
+ "--socket=$info->[0]->{'path_sock'} --password=";
}
sub run_mysqltest ($) {
my $tinfo= shift;
my $cmdline_mysqlcheck= "$exe_mysqlcheck --no-defaults -uroot " .
- "--port=$master->[0]->{'path_myport'} " .
- "--socket=$master->[0]->{'path_mysock'} --password=";
+ "--port=$master->[0]->{'port'} " .
+ "--socket=$master->[0]->{'path_sock'} --password=";
if ( $opt_debug )
{
$cmdline_mysqlcheck .=
@@ -3315,8 +3654,8 @@ sub run_mysqltest ($) {
unless ( $glob_win32 )
{
$cmdline_mysqlslap= "$exe_mysqlslap -uroot " .
- "--port=$master->[0]->{'path_myport'} " .
- "--socket=$master->[0]->{'path_mysock'} --password= " .
+ "--port=$master->[0]->{'port'} " .
+ "--socket=$master->[0]->{'path_sock'} --password= " .
"--lock-directory=$opt_tmpdir";
if ( $opt_debug )
{
@@ -3326,8 +3665,8 @@ sub run_mysqltest ($) {
}
my $cmdline_mysqlimport= "$exe_mysqlimport -uroot " .
- "--port=$master->[0]->{'path_myport'} " .
- "--socket=$master->[0]->{'path_mysock'} --password=";
+ "--port=$master->[0]->{'port'} " .
+ "--socket=$master->[0]->{'path_sock'} --password=";
if ( $opt_debug )
{
$cmdline_mysqlimport .=
@@ -3335,8 +3674,8 @@ sub run_mysqltest ($) {
}
my $cmdline_mysqlshow= "$exe_mysqlshow -uroot " .
- "--port=$master->[0]->{'path_myport'} " .
- "--socket=$master->[0]->{'path_mysock'} --password=";
+ "--port=$master->[0]->{'port'} " .
+ "--socket=$master->[0]->{'path_sock'} --password=";
if ( $opt_debug )
{
$cmdline_mysqlshow .=
@@ -3356,13 +3695,13 @@ sub run_mysqltest ($) {
my $cmdline_mysql=
"$exe_mysql --no-defaults --host=localhost --user=root --password= " .
- "--port=$master->[0]->{'path_myport'} " .
- "--socket=$master->[0]->{'path_mysock'}";
+ "--port=$master->[0]->{'port'} " .
+ "--socket=$master->[0]->{'path_sock'}";
my $cmdline_mysql_client_test=
"$exe_mysql_client_test --no-defaults --testcase --user=root --silent " .
- "--port=$master->[0]->{'path_myport'} " .
- "--socket=$master->[0]->{'path_mysock'}";
+ "--port=$master->[0]->{'port'} " .
+ "--socket=$master->[0]->{'path_sock'}";
if ( $opt_debug )
{
@@ -3381,8 +3720,8 @@ sub run_mysqltest ($) {
my $cmdline_mysql_fix_system_tables=
"$exe_mysql_fix_system_tables --no-defaults --host=localhost --user=root --password= " .
"--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " .
- "--port=$master->[0]->{'path_myport'} " .
- "--socket=$master->[0]->{'path_mysock'}";
+ "--port=$master->[0]->{'port'} " .
+ "--socket=$master->[0]->{'path_sock'}";
$ENV{'MYSQL'}= $cmdline_mysql;
$ENV{'MYSQL_CHECK'}= $cmdline_mysqlcheck;
@@ -3399,12 +3738,12 @@ sub run_mysqltest ($) {
$ENV{'UDF_EXAMPLE_LIB'}=
($lib_udf_example ? basename($lib_udf_example) : "");
- $ENV{'NDB_STATUS_OK'}= $flag_ndb_status_ok ? "YES" : "NO";
- $ENV{'NDB_SLAVE_STATUS_OK'}= $flag_ndb_slave_status_ok ? "YES" : "NO";
+ $ENV{'NDB_STATUS_OK'}= $clusters->[0]->{'installed_ok'};
+ $ENV{'NDB_SLAVE_STATUS_OK'}= $clusters->[0]->{'installed_ok'};;
$ENV{'NDB_EXTRA_TEST'}= $opt_ndb_extra_test;
$ENV{'NDB_MGM'}= $exe_ndb_mgm;
- $ENV{'NDB_BACKUP_DIR'}= $path_ndb_data_dir;
- $ENV{'NDB_DATA_DIR'}= $path_ndb_data_dir;
+ $ENV{'NDB_BACKUP_DIR'}= $clusters->[0]->{'data_dir'};
+ $ENV{'NDB_DATA_DIR'}= $clusters->[0]->{'data_dir'};
$ENV{'NDB_TOOLS_DIR'}= $path_ndb_tools_dir;
$ENV{'NDB_TOOLS_OUTPUT'}= $file_ndb_testrun_log;
$ENV{'NDB_CONNECTSTRING'}= $opt_ndbconnectstring;
@@ -3429,8 +3768,8 @@ sub run_mysqltest ($) {
}
else # component_id == mysqld
{
- mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_mysock'});
- mtr_add_arg($args, "--port=%d", $master->[0]->{'path_myport'});
+ mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_sock'});
+ mtr_add_arg($args, "--port=%d", $master->[0]->{'port'});
mtr_add_arg($args, "--database=test");
mtr_add_arg($args, "--user=%s", $opt_user);
mtr_add_arg($args, "--password=");
@@ -3517,7 +3856,7 @@ sub run_mysqltest ($) {
if ( $glob_use_embedded_server )
{
- mysqld_arguments($args,'master',0,$tinfo->{'master_opt'},[],0);
+ mysqld_arguments($args,'master',0,$tinfo->{'master_opt'},[]);
}
# ----------------------------------------------------------------------
@@ -3574,14 +3913,26 @@ sub run_mysqltest ($) {
if ( $opt_check_testcases )
{
- run_check_testcase("before");
+ foreach my $mysqld (@{$master}, @{$slave})
+ {
+ if ($mysqld->{'pid'})
+ {
+ run_check_testcase("before", $mysqld);
+ }
+ }
}
my $res = mtr_run_test($exe,$args,"","",$path_timefile,"");
if ( $opt_check_testcases )
{
- run_check_testcase("after");
+ foreach my $mysqld (@{$master}, @{$slave})
+ {
+ if ($mysqld->{'pid'})
+ {
+ run_check_testcase("after", $mysqld);
+ }
+ }
}
return $res;
@@ -3760,12 +4111,20 @@ sub valgrind_arguments {
my $args= shift;
my $exe= shift;
- mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
- mtr_add_arg($args, "--alignment=8");
- mtr_add_arg($args, "--leak-check=yes");
- mtr_add_arg($args, "--num-callers=16");
- mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
- if -f "$glob_mysql_test_dir/valgrind.supp";
+ if ( $opt_callgrind)
+ {
+ mtr_add_arg($args, "--tool=callgrind");
+ mtr_add_arg($args, "--base=$opt_vardir/log");
+ }
+ else
+ {
+ mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
+ mtr_add_arg($args, "--alignment=8");
+ mtr_add_arg($args, "--leak-check=yes");
+ mtr_add_arg($args, "--num-callers=16");
+ mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
+ if -f "$glob_mysql_test_dir/valgrind.supp";
+ }
# Add valgrind options, can be overriden by user
mtr_add_arg($args, '%s', $_) for (split(' ', $opt_valgrind_options));
@@ -3822,10 +4181,11 @@ Options to control directories to use
Options to control what test suites or cases to run
force Continue to run the suite after failure
- with-ndbcluster Use cluster, and enable test cases that requires it
- with-ndbcluster-all Use cluster in all tests
+ with-ndbcluster Use cluster in all tests
with-ndbcluster-only Run only tests that include "ndb" in the filename
- skip-ndb[cluster] Skip the ndb test cases, don't start cluster
+ skip-ndb[cluster] Skip all tests that need cluster
+ skip-ndb[cluster]-slave Skip all tests that need a slave cluster
+ ndb-extra Run extra tests from ndb directory
do-test=PREFIX Run test cases which name are prefixed with PREFIX
start-from=PREFIX Run test cases starting from test prefixed with PREFIX
suite=NAME Run the test suite named NAME. The default is "main"
@@ -3855,7 +4215,8 @@ Options that pass on options
Options to run test on running server
extern Use running server for tests FIXME DANGEROUS
- ndbconnectstring=STR Use running cluster, and connect using STR
+ ndb-connectstring=STR Use running cluster, and connect using STR
+ ndb-connectstring-slave=STR Use running slave cluster, and connect using STR
user=USER User for connect to server
Options for debugging the product
@@ -3886,12 +4247,14 @@ Options for coverage, profiling etc
valgrind-mysqld Run the "mysqld" executable with valgrind
valgrind-options=ARGS Options to give valgrind, replaces default options
valgrind-path=[EXE] Path to the valgrind executable
+ callgrind Instruct valgrind to use callgrind
Misc options
comment=STR Write STR to the output
notimer Don't show test case execution time
script-debug Debug this script itself
+ verbose More verbose output
start-and-exit Only initialize and start the servers, using the
startup settings for the specified test case (if any)
start-dirty Only start the servers (without initialization) for
@@ -3904,15 +4267,14 @@ Misc options
testcase-timeout=MINUTES Max test case run time (default $default_testcase_timeout)
suite-timeout=MINUTES Max test suite run time (default $default_suite_timeout)
+
Deprecated options
with-openssl Deprecated option for ssl
Options not yet described, or that I want to look into more
local
- local-master
netware
- old-master
sleep=SECONDS
socket=PATH
user-test=s
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index d9695c5f3df..6ea28efd91c 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -653,15 +653,6 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range k2 k2 4 NULL 6 Using where; Using index
1 SIMPLE t1 index NULL PRIMARY 3 NULL 15 Using index
drop table t1, t2;
-create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB;
-insert into t1 values (1, 3);
-select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ;
-count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ
-1
-select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ;
-Case When Count(*) < MAX_REQ Then 1 Else 0 End
-1
-drop table t1;
create table t1 (a char(10));
insert into t1 values ('a'),('b'),('c');
select coercibility(max(a)) from t1;
diff --git a/mysql-test/r/func_group_innodb.result b/mysql-test/r/func_group_innodb.result
new file mode 100644
index 00000000000..5f12a437eed
--- /dev/null
+++ b/mysql-test/r/func_group_innodb.result
@@ -0,0 +1,147 @@
+create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB;
+insert into t1 values (1, 3);
+select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ;
+count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ
+1
+select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ;
+Case When Count(*) < MAX_REQ Then 1 Else 0 End
+1
+drop table t1;
+create table t1m (a int) engine=myisam;
+create table t1i (a int) engine=innodb;
+create table t2m (a int) engine=myisam;
+create table t2i (a int) engine=innodb;
+insert into t2m values (5);
+insert into t2i values (5);
+select min(a) from t1m;
+min(a)
+NULL
+select min(7) from t1m;
+min(7)
+NULL
+select min(7) from DUAL;
+min(7)
+NULL
+explain select min(7) from t2m join t1m;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(7) from t2m join t1m;
+min(7)
+NULL
+select max(a) from t1m;
+max(a)
+NULL
+select max(7) from t1m;
+max(7)
+NULL
+select max(7) from DUAL;
+max(7)
+NULL
+explain select max(7) from t2m join t1m;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select max(7) from t2m join t1m;
+max(7)
+NULL
+select 1, min(a) from t1m where a=99;
+1 min(a)
+1 NULL
+select 1, min(a) from t1m where 1=99;
+1 min(a)
+1 NULL
+select 1, min(1) from t1m where a=99;
+1 min(1)
+1 NULL
+select 1, min(1) from t1m where 1=99;
+1 min(1)
+1 NULL
+select 1, max(a) from t1m where a=99;
+1 max(a)
+1 NULL
+select 1, max(a) from t1m where 1=99;
+1 max(a)
+1 NULL
+select 1, max(1) from t1m where a=99;
+1 max(1)
+1 NULL
+select 1, max(1) from t1m where 1=99;
+1 max(1)
+1 NULL
+select min(a) from t1i;
+min(a)
+NULL
+select min(7) from t1i;
+min(7)
+NULL
+select min(7) from DUAL;
+min(7)
+NULL
+explain select min(7) from t2i join t1i;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2i ALL NULL NULL NULL NULL 1
+1 SIMPLE t1i ALL NULL NULL NULL NULL 1
+select min(7) from t2i join t1i;
+min(7)
+NULL
+select max(a) from t1i;
+max(a)
+NULL
+select max(7) from t1i;
+max(7)
+NULL
+select max(7) from DUAL;
+max(7)
+NULL
+explain select max(7) from t2i join t1i;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2i ALL NULL NULL NULL NULL 1
+1 SIMPLE t1i ALL NULL NULL NULL NULL 1
+select max(7) from t2i join t1i;
+max(7)
+NULL
+select 1, min(a) from t1i where a=99;
+1 min(a)
+1 NULL
+select 1, min(a) from t1i where 1=99;
+1 min(a)
+1 NULL
+select 1, min(1) from t1i where a=99;
+1 min(1)
+1 NULL
+select 1, min(1) from t1i where 1=99;
+1 min(1)
+1 NULL
+select 1, max(a) from t1i where a=99;
+1 max(a)
+1 NULL
+select 1, max(a) from t1i where 1=99;
+1 max(a)
+1 NULL
+select 1, max(1) from t1i where a=99;
+1 max(1)
+1 NULL
+select 1, max(1) from t1i where 1=99;
+1 max(1)
+1 NULL
+explain select count(*), min(7), max(7) from t1m, t1i;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
+1 SIMPLE t1i ALL NULL NULL NULL NULL 1
+select count(*), min(7), max(7) from t1m, t1i;
+count(*) min(7) max(7)
+0 NULL NULL
+explain select count(*), min(7), max(7) from t1m, t2i;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
+1 SIMPLE t2i ALL NULL NULL NULL NULL 1
+select count(*), min(7), max(7) from t1m, t2i;
+count(*) min(7) max(7)
+0 NULL NULL
+explain select count(*), min(7), max(7) from t2m, t1i;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2m system NULL NULL NULL NULL 1
+1 SIMPLE t1i ALL NULL NULL NULL NULL 1
+select count(*), min(7), max(7) from t2m, t1i;
+count(*) min(7) max(7)
+0 NULL NULL
+drop table t1m, t1i, t2m, t2i;
diff --git a/mysql-test/r/group_min_max_innodb.result b/mysql-test/r/group_min_max_innodb.result
new file mode 100644
index 00000000000..ae4b9d4d5dd
--- /dev/null
+++ b/mysql-test/r/group_min_max_innodb.result
@@ -0,0 +1,72 @@
+create table t4 (
+pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
+) engine=innodb;
+insert into t4 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
+('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
+('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
+('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
+('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'),
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
+('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
+('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
+('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
+('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');
+create index idx12672_0 on t4 (a1);
+create index idx12672_1 on t4 (a1,a2,b,c);
+create index idx12672_2 on t4 (a1,a2,b);
+analyze table t4;
+Table Op Msg_type Msg_text
+test.t4 analyze status OK
+select distinct a1 from t4 where pk_col not in (1,2,3,4);
+a1
+a
+b
+c
+d
+drop table t4;
+create table t1 (
+a varchar(30), b varchar(30), primary key(a), key(b)
+) engine=innodb;
+select distinct a from t1;
+a
+drop table t1;
+create table t1(a int, key(a)) engine=innodb;
+insert into t1 values(1);
+select a, count(a) from t1 group by a with rollup;
+a count(a)
+1 1
+NULL 1
+drop table t1;
+create table t1 (f1 int, f2 char(1), primary key(f1,f2)) engine=innodb;
+insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
+alter table t1 drop primary key, add primary key (f2, f1);
+explain select distinct f1 a, f1 b from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 5 NULL 4 Using index; Using temporary
+explain select distinct f1, f2 from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL PRIMARY 5 NULL 3 Using index for group-by; Using temporary
+drop table t1;
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
index 62e1c2f4019..d5b52feb06c 100644
--- a/mysql-test/r/innodb_mysql.result
+++ b/mysql-test/r/innodb_mysql.result
@@ -332,3 +332,9 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
SELECT * from t2;
a b
drop table t1,t2;
+create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb
+character set utf8 collate utf8_general_ci;
+Warnings:
+Warning 1071 Specified key was too long; max key length is 765 bytes
+insert into t1 values('aaa');
+drop table t1;
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index f4ec997e50c..b199ec5b2fb 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -1135,25 +1135,6 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 4 Using where
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1
DROP TABLE t1,t2;
-CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
-INDEX (name)) ENGINE=InnoDB;
-CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
-FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
-INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
-EXPLAIN
-SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
-WHERE t1.name LIKE 'A%';
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
-1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using where; Using index
-EXPLAIN
-SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
-WHERE t1.name LIKE 'A%' OR FALSE;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index
-1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where
-DROP TABLE t1,t2;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a int);
diff --git a/mysql-test/r/join_outer_innodb.result b/mysql-test/r/join_outer_innodb.result
new file mode 100644
index 00000000000..e8a2d6f668b
--- /dev/null
+++ b/mysql-test/r/join_outer_innodb.result
@@ -0,0 +1,19 @@
+CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
+INDEX (name)) ENGINE=InnoDB;
+CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
+FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
+INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+WHERE t1.name LIKE 'A%';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
+1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using where; Using index
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+WHERE t1.name LIKE 'A%' OR FALSE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index 1a18bf3f110..ef4dd83564b 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -168,8 +168,8 @@ source database
- most popular open
- source database
- MySQL: The world''s
--- most popular open
--- source database
+-- most popular
+-- open source database
# MySQL: The
--world''s
# most popular
@@ -195,8 +195,8 @@ source database
# source database
-- MySQL: The
-- world''s most
--- popular open
--- source database
+-- popular
+-- open source database
# MySQL: The
- world''s most
-- popular open
diff --git a/mysql-test/r/ndb_binlog_discover.result b/mysql-test/r/ndb_binlog_discover.result
index 2a1bf6efa84..01e15dc1c39 100644
--- a/mysql-test/r/ndb_binlog_discover.result
+++ b/mysql-test/r/ndb_binlog_discover.result
@@ -1,7 +1,6 @@
drop table if exists t1;
create table t1 (a int key) engine=ndb;
reset master;
-insert into t1 values(1);
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
diff --git a/mysql-test/r/ndb_cache_multi.result b/mysql-test/r/ndb_cache_multi.result
index c7135ed9e8a..388131ec30a 100644
--- a/mysql-test/r/ndb_cache_multi.result
+++ b/mysql-test/r/ndb_cache_multi.result
@@ -70,3 +70,5 @@ show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
drop table t1, t2;
+set GLOBAL query_cache_size=0;
+set GLOBAL query_cache_size=0;
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index 875358100b6..e95489864f7 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -708,11 +708,6 @@ partition by list (a)
alter table t1 rebuild partition;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
drop table t1;
-create table t1 (a int) engine=innodb partition by hash(a) ;
-show table status like 't1';
-Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t1 InnoDB 10 Compact 2 8192 16384 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned
-drop table t1;
create table t2 (s1 int not null auto_increment, primary key (s1)) partition by list (s1) (partition p1 values in (1),partition p2 values in (2),partition p3 values in (3),partition p4 values in (4));
insert into t2 values (null),(null),(null);
select * from t2;
@@ -787,6 +782,7 @@ CALL test.p1(13);
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
drop table t1;
+drop procedure test.p1;
CREATE TABLE t1 (a int not null)
partition by key(a)
(partition p0 COMMENT='first partition');
diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result
index 73745aad58b..f4e75ccdb05 100644
--- a/mysql-test/r/partition_innodb.result
+++ b/mysql-test/r/partition_innodb.result
@@ -1,120 +1,5 @@
-SET @max_row = 20;
-DROP TABLE IF EXISTS t0_template;
-CREATE TABLE t0_template (
-f_int1 INTEGER,
-f_int2 INTEGER,
-f_char1 CHAR(20),
-f_char2 CHAR(20),
-f_charbig VARCHAR(1000) ,
-PRIMARY KEY(f_int1))
-ENGINE = MEMORY;
-INSERT INTO t0_template
-SET f_int1 = 20, f_int2 = 20, f_char1 = '20', f_char2 = '20',
-f_charbig = '===20===';
-INSERT INTO t0_template
-SET f_int1 = 19, f_int2 = 19, f_char1 = '19', f_char2 = '19',
-f_charbig = '===19===';
-INSERT INTO t0_template
-SET f_int1 = 18, f_int2 = 18, f_char1 = '18', f_char2 = '18',
-f_charbig = '===18===';
-INSERT INTO t0_template
-SET f_int1 = 17, f_int2 = 17, f_char1 = '17', f_char2 = '17',
-f_charbig = '===17===';
-INSERT INTO t0_template
-SET f_int1 = 16, f_int2 = 16, f_char1 = '16', f_char2 = '16',
-f_charbig = '===16===';
-INSERT INTO t0_template
-SET f_int1 = 15, f_int2 = 15, f_char1 = '15', f_char2 = '15',
-f_charbig = '===15===';
-INSERT INTO t0_template
-SET f_int1 = 14, f_int2 = 14, f_char1 = '14', f_char2 = '14',
-f_charbig = '===14===';
-INSERT INTO t0_template
-SET f_int1 = 13, f_int2 = 13, f_char1 = '13', f_char2 = '13',
-f_charbig = '===13===';
-INSERT INTO t0_template
-SET f_int1 = 12, f_int2 = 12, f_char1 = '12', f_char2 = '12',
-f_charbig = '===12===';
-INSERT INTO t0_template
-SET f_int1 = 11, f_int2 = 11, f_char1 = '11', f_char2 = '11',
-f_charbig = '===11===';
-INSERT INTO t0_template
-SET f_int1 = 10, f_int2 = 10, f_char1 = '10', f_char2 = '10',
-f_charbig = '===10===';
-INSERT INTO t0_template
-SET f_int1 = 9, f_int2 = 9, f_char1 = '9', f_char2 = '9',
-f_charbig = '===9===';
-INSERT INTO t0_template
-SET f_int1 = 8, f_int2 = 8, f_char1 = '8', f_char2 = '8',
-f_charbig = '===8===';
-INSERT INTO t0_template
-SET f_int1 = 7, f_int2 = 7, f_char1 = '7', f_char2 = '7',
-f_charbig = '===7===';
-INSERT INTO t0_template
-SET f_int1 = 6, f_int2 = 6, f_char1 = '6', f_char2 = '6',
-f_charbig = '===6===';
-INSERT INTO t0_template
-SET f_int1 = 5, f_int2 = 5, f_char1 = '5', f_char2 = '5',
-f_charbig = '===5===';
-INSERT INTO t0_template
-SET f_int1 = 4, f_int2 = 4, f_char1 = '4', f_char2 = '4',
-f_charbig = '===4===';
-INSERT INTO t0_template
-SET f_int1 = 3, f_int2 = 3, f_char1 = '3', f_char2 = '3',
-f_charbig = '===3===';
-INSERT INTO t0_template
-SET f_int1 = 2, f_int2 = 2, f_char1 = '2', f_char2 = '2',
-f_charbig = '===2===';
-INSERT INTO t0_template
-SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1',
-f_charbig = '===1===';
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30)) engine='InnoDB';
-INSERT INTO t1 (f_date, f_varchar)
-SELECT CONCAT(CAST((f_int1 + 999) AS CHAR),'-02-10'), CAST(f_char1 AS CHAR)
-FROM t0_template
-WHERE f_int1 + 999 BETWEEN 1000 AND 9999;
-SELECT IF(9999 - 1000 + 1 > @max_row, @max_row , 9999 - 1000 + 1)
-INTO @exp_row_count;
-ALTER TABLE t1 PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER));
-# 1.1.5 Add two named partitions + test
-ALTER TABLE t1 ADD PARTITION (PARTITION part1, PARTITION part7);
-drop table t1;
-CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30))
-ENGINE=InnoDB
-PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER));
-# This statement crashes the server.
-# CREATE partitioned table with three partitions in one step
-# would be harmless.
-ALTER TABLE t1 ADD PARTITION PARTITIONS 1;
-DROP VIEW IF EXISTS v1;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t0_aux;
-DROP TABLE IF EXISTS t0_definition;
-DROP TABLE IF EXISTS t0_template;
-create table t1 (id varchar(64) primary key) engine=innodb
-partition by key(id) partitions 5;
-insert into t1 values ('a');
-insert into t1 values ('aa');
-insert into t1 values ('aaa');
-select * from t1 where id = 'a';
-id
-a
-select * from t1 where id = 'aa';
-id
-aa
-select * from t1 where id = 'aaa';
-id
-aaa
-drop table t1;
-create table t1 (a int, b int, primary key (b,a))
-engine = innodb
-partition by hash (a);
-insert into t1 values (0, 0);
-insert into t1 values (1, 0);
-update t1 set b = b + 1 where a = 1;
-select * from t1;
-a b
-0 0
-1 1
+create table t1 (a int) engine=innodb partition by hash(a) ;
+show table status like 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
+t1 InnoDB 10 Compact 2 8192 16384 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned
drop table t1;
diff --git a/mysql-test/r/rpl_drop_db.result b/mysql-test/r/rpl_drop_db.result
index 3a35dc266b6..51d6d71ca95 100644
--- a/mysql-test/r/rpl_drop_db.result
+++ b/mysql-test/r/rpl_drop_db.result
@@ -33,3 +33,5 @@ n
1234
DROP DATABASE mysqltest1;
stop slave;
+use test;
+drop table t1;
diff --git a/mysql-test/r/rpl_insert_id_pk.result b/mysql-test/r/rpl_insert_id_pk.result
index 0a452d2dd73..79815355332 100644
--- a/mysql-test/r/rpl_insert_id_pk.result
+++ b/mysql-test/r/rpl_insert_id_pk.result
@@ -73,3 +73,4 @@ CREATE TABLE t1 ( a INT UNIQUE );
SET FOREIGN_KEY_CHECKS=0;
INSERT INTO t1 VALUES (1),(1);
Got one of the listed errors
+drop table t1;
diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result
index 5f8da2ee384..c22815186d1 100644
--- a/mysql-test/r/rpl_loaddata.result
+++ b/mysql-test/r/rpl_loaddata.result
@@ -85,3 +85,4 @@ terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
ERROR 23000: Duplicate entry '2003-03-22' for key 'day'
drop table t2;
drop table t2;
+drop table t1;
diff --git a/mysql-test/r/rpl_multi_update3.result b/mysql-test/r/rpl_multi_update3.result
index b81af7c6e39..f20cecfb68f 100644
--- a/mysql-test/r/rpl_multi_update3.result
+++ b/mysql-test/r/rpl_multi_update3.result
@@ -194,3 +194,4 @@ idpro price nbprice
1 1.0000 3
2 1.0000 2
3 2.0000 1
+DROP TABLE t1, t2;
diff --git a/mysql-test/r/rpl_ndb_multi_update3.result b/mysql-test/r/rpl_ndb_multi_update3.result
index 63ec20d8fc8..2bbbe7785a9 100644
--- a/mysql-test/r/rpl_ndb_multi_update3.result
+++ b/mysql-test/r/rpl_ndb_multi_update3.result
@@ -194,3 +194,4 @@ idpro price nbprice
1 1.0000 3
2 1.0000 2
3 2.0000 1
+DROP TABLE t1, t2;
diff --git a/mysql-test/r/rpl_ndb_sp006.result b/mysql-test/r/rpl_ndb_sp006.result
index 6d32f26b280..482d43c8f10 100644
--- a/mysql-test/r/rpl_ndb_sp006.result
+++ b/mysql-test/r/rpl_ndb_sp006.result
@@ -43,3 +43,4 @@ DROP PROCEDURE IF EXISTS mysqltest1.p1;
DROP PROCEDURE IF EXISTS mysqltest1.p2;
DROP TABLE IF EXISTS mysqltest1.t1;
DROP TABLE IF EXISTS mysqltest1.t2;
+DROP DATABASE mysqltest1;
diff --git a/mysql-test/r/rpl_row_sp006_InnoDB.result b/mysql-test/r/rpl_row_sp006_InnoDB.result
index 9b9b04dbbee..8339e77d3a0 100644
--- a/mysql-test/r/rpl_row_sp006_InnoDB.result
+++ b/mysql-test/r/rpl_row_sp006_InnoDB.result
@@ -43,3 +43,4 @@ DROP PROCEDURE IF EXISTS mysqltest1.p1;
DROP PROCEDURE IF EXISTS mysqltest1.p2;
DROP TABLE IF EXISTS mysqltest1.t1;
DROP TABLE IF EXISTS mysqltest1.t2;
+DROP DATABASE mysqltest1;
diff --git a/mysql-test/r/rpl_stm_no_op.result b/mysql-test/r/rpl_stm_no_op.result
index eb445085a1d..5a253d61fcb 100644
--- a/mysql-test/r/rpl_stm_no_op.result
+++ b/mysql-test/r/rpl_stm_no_op.result
@@ -49,4 +49,4 @@ select * from t1;
a b
select * from t2;
a b
-drop table t1;
+drop table t1, t2;
diff --git a/mysql-test/r/rpl_variables.result b/mysql-test/r/rpl_variables.result
index 25b5ca13f77..bbfe8373a46 100644
--- a/mysql-test/r/rpl_variables.result
+++ b/mysql-test/r/rpl_variables.result
@@ -15,3 +15,4 @@ slave_load_tmpdir SLAVE_LOAD_TMPDIR
show variables like 'slave_skip_errors';
Variable_name Value
slave_skip_errors 3,100,137,643,1752
+set global slave_net_timeout=default;
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 29206393b04..bf36b4796b9 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -754,7 +754,7 @@ bug11834_2()
10
drop function bug11834_1;
execute stmt;
-ERROR 42000: FUNCTION test.bug11834_1 does not exist
+ERROR 42000: FUNCTION test.bug11834_2 does not exist
deallocate prepare stmt;
drop function bug11834_2;
DROP FUNCTION IF EXISTS bug12953|
diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result
index 05cde76f8dd..4860058a8a1 100644
--- a/mysql-test/r/sp-security.result
+++ b/mysql-test/r/sp-security.result
@@ -314,16 +314,6 @@ select * from db_bug14533.t1;
ERROR 42000: SELECT command denied to user 'user_bug14533'@'localhost' for table 't1'
drop user user_bug14533@localhost;
drop database db_bug14533;
-CREATE DATABASE db_bug7787;
-use db_bug7787;
-CREATE PROCEDURE p1()
-SHOW INNODB STATUS;
-Warnings:
-Warning 1541 The syntax 'SHOW INNODB STATUS' is deprecated and will be removed in MySQL 5.2. Please use 'SHOW ENGINE INNODB STATUS' instead.
-GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost;
-DROP DATABASE db_bug7787;
-drop user user_bug7787@localhost;
-use test;
---> connection: root
DROP DATABASE IF EXISTS mysqltest;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index c67250534ba..db72d190441 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -4796,22 +4796,6 @@ i
0
drop table t3|
drop procedure bug16887|
-create table t3 (f1 int, f2 varchar(3), primary key(f1)) engine=innodb|
-insert into t3 values (1,'aaa'),(2,'bbb'),(3,'ccc')|
-CREATE FUNCTION bug13575 ( p1 integer )
-returns varchar(3)
-BEGIN
-DECLARE v1 VARCHAR(10) DEFAULT null;
-SELECT f2 INTO v1 FROM t3 WHERE f1 = p1;
-RETURN v1;
-END|
-select distinct f1, bug13575(f1) from t3 order by f1|
-f1 bug13575(f1)
-1 aaa
-2 bbb
-3 ccc
-drop function bug13575;
-drop table t3|
drop procedure if exists bug16474_1|
drop procedure if exists bug16474_2|
delete from t1|
diff --git a/mysql-test/r/sp_notembedded.result b/mysql-test/r/sp_notembedded.result
index d2a958e8f0c..a15f5013ef6 100644
--- a/mysql-test/r/sp_notembedded.result
+++ b/mysql-test/r/sp_notembedded.result
@@ -25,17 +25,6 @@ Id User Host db Command Time State Info
# event_scheduler localhost NULL Connect # Suspended NULL
# root localhost test Query # NULL show processlist
drop procedure bug4902_2|
-drop function if exists bug5278|
-create function bug5278 () returns char
-begin
-SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');
-return 'okay';
-end|
-select bug5278()|
-ERROR 42000: Can't find any matching row in the user table
-select bug5278()|
-ERROR 42000: Can't find any matching row in the user table
-drop function bug5278|
drop table if exists t1|
create table t1 (
id char(16) not null default '',
diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result
index 4c17226a9b0..a5012673c12 100644
--- a/mysql-test/r/sp_trans.result
+++ b/mysql-test/r/sp_trans.result
@@ -530,3 +530,29 @@ count(*)
drop table t3, t4|
drop procedure bug14210|
set @@session.max_heap_table_size=default|
+CREATE DATABASE db_bug7787|
+use db_bug7787|
+CREATE PROCEDURE p1()
+SHOW INNODB STATUS; |
+Warnings:
+Warning 1541 The syntax 'SHOW INNODB STATUS' is deprecated and will be removed in MySQL 5.2. Please use 'SHOW ENGINE INNODB STATUS' instead.
+GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost|
+DROP DATABASE db_bug7787|
+drop user user_bug7787@localhost|
+use test|
+create table t3 (f1 int, f2 varchar(3), primary key(f1)) engine=innodb|
+insert into t3 values (1,'aaa'),(2,'bbb'),(3,'ccc')|
+CREATE FUNCTION bug13575 ( p1 integer )
+returns varchar(3)
+BEGIN
+DECLARE v1 VARCHAR(10) DEFAULT null;
+SELECT f2 INTO v1 FROM t3 WHERE f1 = p1;
+RETURN v1;
+END|
+select distinct f1, bug13575(f1) from t3 order by f1|
+f1 bug13575(f1)
+1 aaa
+2 bbb
+3 ccc
+drop function bug13575|
+drop table t3|
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index b15683a0882..9755083ab1c 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -1397,6 +1397,16 @@ c1
9999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999
drop table t1;
+create table t1(a decimal(7,2));
+insert into t1 values(123.12);
+select * from t1;
+a
+123.12
+alter table t1 modify a decimal(10,2);
+select * from t1;
+a
+123.12
+drop table t1;
create table t1 (i int, j int);
insert into t1 values (1,1), (1,2), (2,3), (2,4);
select i, count(distinct j) from t1 group by i;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 22847a318d7..140cdccc218 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -670,6 +670,7 @@ alter table t1 max_rows=100000000000;
show create table t1;
drop table t1;
+
# End of 5.0 tests
#
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 81e20585fa9..3dde06b5ae8 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -38,3 +38,4 @@ rpl_sp_effects : BUG#19862 2006-06-15 mkindahl
# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
#ndb_binlog_ddl_multi : BUG#18976 2006-04-10 kent CRBR: multiple binlog, second binlog may miss schema log events
+rpl_insert # BUG#21297 2006-07-26 msvensson
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index e8c5fa18a25..760745dc14e 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -378,13 +378,15 @@ explain
select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME';
drop table t1, t2;
---disable_warnings
-create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB;
---enable_warnings
-insert into t1 values (1, 3);
-select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ;
-select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ;
-drop table t1;
+# Moved to func_group_innodb
+#--disable_warnings
+#create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB;
+#--enable_warnings
+#insert into t1 values (1, 3);
+#select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ;
+#select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ;
+#drop table t1;
+
create table t1 (a char(10));
insert into t1 values ('a'),('b'),('c');
@@ -539,6 +541,11 @@ INSERT INTO t1 VALUES
SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6;
DROP TABLE t1;
+
+#
+# Bug #12882 min/max inconsistent on empty table
+#
+# Test case moved to func_group_innodb
#
# Bug #18206: min/max optimization cannot be applied to partial index
#
diff --git a/mysql-test/t/func_group_innodb.test b/mysql-test/t/func_group_innodb.test
new file mode 100644
index 00000000000..1bdfd8f54bb
--- /dev/null
+++ b/mysql-test/t/func_group_innodb.test
@@ -0,0 +1,85 @@
+#
+# Test of group functions that depend on innodb
+#
+
+--source include/have_innodb.inc
+
+--disable_warnings
+create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB;
+--enable_warnings
+insert into t1 values (1, 3);
+select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ;
+select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ;
+drop table t1;
+
+
+#
+# Bug #12882 min/max inconsistent on empty table
+#
+
+--disable_warnings
+create table t1m (a int) engine=myisam;
+create table t1i (a int) engine=innodb;
+create table t2m (a int) engine=myisam;
+create table t2i (a int) engine=innodb;
+--enable_warnings
+insert into t2m values (5);
+insert into t2i values (5);
+
+# test with MyISAM
+select min(a) from t1m;
+select min(7) from t1m;
+select min(7) from DUAL;
+explain select min(7) from t2m join t1m;
+select min(7) from t2m join t1m;
+
+select max(a) from t1m;
+select max(7) from t1m;
+select max(7) from DUAL;
+explain select max(7) from t2m join t1m;
+select max(7) from t2m join t1m;
+
+select 1, min(a) from t1m where a=99;
+select 1, min(a) from t1m where 1=99;
+select 1, min(1) from t1m where a=99;
+select 1, min(1) from t1m where 1=99;
+
+select 1, max(a) from t1m where a=99;
+select 1, max(a) from t1m where 1=99;
+select 1, max(1) from t1m where a=99;
+select 1, max(1) from t1m where 1=99;
+
+# test with InnoDB
+select min(a) from t1i;
+select min(7) from t1i;
+select min(7) from DUAL;
+explain select min(7) from t2i join t1i;
+select min(7) from t2i join t1i;
+
+select max(a) from t1i;
+select max(7) from t1i;
+select max(7) from DUAL;
+explain select max(7) from t2i join t1i;
+select max(7) from t2i join t1i;
+
+select 1, min(a) from t1i where a=99;
+select 1, min(a) from t1i where 1=99;
+select 1, min(1) from t1i where a=99;
+select 1, min(1) from t1i where 1=99;
+
+select 1, max(a) from t1i where a=99;
+select 1, max(a) from t1i where 1=99;
+select 1, max(1) from t1i where a=99;
+select 1, max(1) from t1i where 1=99;
+
+# mixed MyISAM/InnoDB test
+explain select count(*), min(7), max(7) from t1m, t1i;
+select count(*), min(7), max(7) from t1m, t1i;
+
+explain select count(*), min(7), max(7) from t1m, t2i;
+select count(*), min(7), max(7) from t1m, t2i;
+
+explain select count(*), min(7), max(7) from t2m, t1i;
+select count(*), min(7), max(7) from t2m, t1i;
+
+drop table t1m, t1i, t2m, t2i;
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index 874f3cd1a80..fec51a24920 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -659,7 +659,32 @@ select a1 from t1 where a2 = 'b' group by a1;
explain select distinct a1 from t1 where a2 = 'b';
select distinct a1 from t1 where a2 = 'b';
+#
+# Bug #12672: primary key implcitly included in every innodb index
+#
+# Test case moved to group_min_max_innodb
+
+
+#
+# Bug #6142: a problem with the empty innodb table
+#
+# Test case moved to group_min_max_innodb
+
+
+#
+# Bug #9798: group by with rollup
+#
+# Test case moved to group_min_max_innodb
+
+
+#
+# Bug #13293 Wrongly used index results in endless loop.
+#
+# Test case moved to group_min_max_innodb
+
+
drop table t1,t2,t3;
+
#
# Bug #14920 Ordering aggregated result sets with composite primary keys
# corrupts resultset
diff --git a/mysql-test/t/group_min_max_innodb.test b/mysql-test/t/group_min_max_innodb.test
new file mode 100644
index 00000000000..ea2a603a8a4
--- /dev/null
+++ b/mysql-test/t/group_min_max_innodb.test
@@ -0,0 +1,95 @@
+#
+# Test file for WL#1724 (Min/Max Optimization for Queries with Group By Clause).
+# The queries in this file test query execution via QUICK_GROUP_MIN_MAX_SELECT
+# that depends on InnoDB
+#
+
+--source include/have_innodb.inc
+
+#
+# Bug #12672: primary key implcitly included in every innodb index
+#
+
+--disable_warnings
+create table t4 (
+ pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
+) engine=innodb;
+--enable_warnings
+
+insert into t4 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
+('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
+('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
+('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
+('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'),
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
+('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
+('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
+('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
+('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');
+
+create index idx12672_0 on t4 (a1);
+create index idx12672_1 on t4 (a1,a2,b,c);
+create index idx12672_2 on t4 (a1,a2,b);
+analyze table t4;
+
+select distinct a1 from t4 where pk_col not in (1,2,3,4);
+
+drop table t4;
+
+
+#
+# Bug #6142: a problem with the empty innodb table
+#
+
+--disable_warnings
+create table t1 (
+ a varchar(30), b varchar(30), primary key(a), key(b)
+) engine=innodb;
+--enable_warnings
+select distinct a from t1;
+drop table t1;
+
+#
+# Bug #9798: group by with rollup
+#
+
+--disable_warnings
+create table t1(a int, key(a)) engine=innodb;
+--enable_warnings
+insert into t1 values(1);
+select a, count(a) from t1 group by a with rollup;
+drop table t1;
+
+
+#
+# Bug #13293 Wrongly used index results in endless loop.
+#
+create table t1 (f1 int, f2 char(1), primary key(f1,f2)) engine=innodb;
+insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
+alter table t1 drop primary key, add primary key (f2, f1);
+explain select distinct f1 a, f1 b from t1;
+explain select distinct f1, f2 from t1;
+drop table t1;
diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test
index 65e2cc658f5..6796840f2d2 100644
--- a/mysql-test/t/innodb_mysql.test
+++ b/mysql-test/t/innodb_mysql.test
@@ -280,3 +280,11 @@ TRUNCATE table t2;
INSERT INTO t2 select * from t1;
SELECT * from t2;
drop table t1,t2;
+
+#
+# Bug#17530: Incorrect key truncation on table creation caused server crash.
+#
+create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb
+ character set utf8 collate utf8_general_ci;
+insert into t1 values('aaa');
+drop table t1;
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index dc4e240750c..3f82219fadb 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -761,24 +761,10 @@ DROP TABLE t1,t2;
#
# Test for bug #17164: ORed FALSE blocked conversion of outer join into join
-#
-
-CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
- INDEX (name)) ENGINE=InnoDB;
-CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
- FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
-INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
-
-EXPLAIN
-SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
- WHERE t1.name LIKE 'A%';
+#
-EXPLAIN
-SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
- WHERE t1.name LIKE 'A%' OR FALSE;
+# Test case moved to join_outer_innodb
-DROP TABLE t1,t2;
#
# Bug 19396: LEFT OUTER JOIN over views in curly braces
diff --git a/mysql-test/t/join_outer_innodb.test b/mysql-test/t/join_outer_innodb.test
new file mode 100644
index 00000000000..40add7f488f
--- /dev/null
+++ b/mysql-test/t/join_outer_innodb.test
@@ -0,0 +1,26 @@
+#
+# test of left outer join for tests that depends on innodb
+#
+
+--source include/have_innodb.inc
+
+#
+# Test for bug #17164: ORed FALSE blocked conversion of outer join into join
+#
+
+CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
+ INDEX (name)) ENGINE=InnoDB;
+CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
+ FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
+INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
+
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+ WHERE t1.name LIKE 'A%';
+
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+ WHERE t1.name LIKE 'A%' OR FALSE;
+
+DROP TABLE t1,t2;
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index 42065cfae81..86cfd66ae2b 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -411,8 +411,8 @@ echo - MySQL: The world''s
- source database;
echo - MySQL: The world''s
--- most popular open
--- source database;
+-- most popular
+-- open source database;
echo # MySQL: The
--world''s
@@ -469,8 +469,8 @@ echo $message;
let $message= -- MySQL: The
-- world''s most
--- popular open
--- source database;
+-- popular
+-- open source database;
echo $message;
let $message= # MySQL: The
diff --git a/mysql-test/t/ndb_autodiscover3.test b/mysql-test/t/ndb_autodiscover3.test
index 5f6d457d140..4257fb686d7 100644
--- a/mysql-test/t/ndb_autodiscover3.test
+++ b/mysql-test/t/ndb_autodiscover3.test
@@ -17,7 +17,7 @@ insert into t1 values (1);
--exec $NDB_MGM --no-defaults -e "all restart" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT
-
+sleep 1;
--error 1297
insert into t1 values (2);
--error 1296
@@ -37,7 +37,7 @@ select * from t2 order by a limit 3;
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT
# to ensure mysqld has connected again, and recreated system tables
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -r 30 -d cluster apply_status >> $NDB_TOOLS_OUTPUT
-
+sleep 2;
--connection server2
--error ER_NO_SUCH_TABLE
select * from t2;
@@ -56,7 +56,7 @@ reset master;
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT
# to ensure mysqld has connected again, and recreated system tables
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -r 30 -d cluster apply_status >> $NDB_TOOLS_OUTPUT
-
+sleep 2;
--connection server1
--error ER_NO_SUCH_TABLE
select * from t2;
diff --git a/mysql-test/t/ndb_binlog_discover.test b/mysql-test/t/ndb_binlog_discover.test
index e74bd3380bd..9c86922b82f 100644
--- a/mysql-test/t/ndb_binlog_discover.test
+++ b/mysql-test/t/ndb_binlog_discover.test
@@ -14,6 +14,20 @@ reset master;
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --not-started > /dev/null
--exec $NDB_MGM --no-defaults -e "all start" > /dev/null
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults > /dev/null
-insert into t1 values(1);
+
+--disable_query_log
+let $mysql_errno= 1;
+while ($mysql_errno)
+{
+ # Table t1 is readonly until the mysqld has reconnected properly
+ --error 0,1036
+ insert into t1 values(1);
+ if ($mysql_errno)
+ {
+ --sleep 0.1
+ }
+}
+--enable_query_log
+
--source include/show_binlog_events.inc
drop table t1;
diff --git a/mysql-test/t/ndb_cache_multi.test b/mysql-test/t/ndb_cache_multi.test
index beb8e4bc2ac..404393c211e 100644
--- a/mysql-test/t/ndb_cache_multi.test
+++ b/mysql-test/t/ndb_cache_multi.test
@@ -63,3 +63,10 @@ show status like "Qcache_hits";
drop table t1, t2;
+# Turn off query cache on server1
+connection server1;
+set GLOBAL query_cache_size=0;
+
+# Turn off query cache on server2
+connection server2;
+set GLOBAL query_cache_size=0;
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index 6deb8f77a58..d4e930f91ec 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -835,13 +835,6 @@ alter table t1 rebuild partition;
drop table t1;
#
-# Bug #14673: Wrong InnoDB default row format
-#
-create table t1 (a int) engine=innodb partition by hash(a) ;
-show table status like 't1';
-drop table t1;
-
-#
# Bug #14526: Partitions: indexed searches fail
#
create table t2 (s1 int not null auto_increment, primary key (s1)) partition by list (s1) (partition p1 values in (1),partition p2 values in (2),partition p3 values in (3),partition p4 values in (4));
@@ -931,6 +924,7 @@ delimiter ;|
CALL test.p1(12);
CALL test.p1(13);
drop table t1;
+drop procedure test.p1;
#
# Bug 13520: Problem with delimiters in COMMENT DATA DIRECTORY ..
diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test
index e40d9fffbf8..a110fb30a3b 100644
--- a/mysql-test/t/partition_innodb.test
+++ b/mysql-test/t/partition_innodb.test
@@ -1,93 +1,10 @@
--- source include/have_innodb.inc
--- source include/have_partition.inc
-SET @max_row = 20;
-let $engine= 'InnoDB';
-let $MAX_VALUE= (2147483646);
-
-let $max_row= `SELECT @max_row`;
-
-# Column list with definition for all tables to be checked
-let $column_list= f_int1 INTEGER,
-f_int2 INTEGER,
-f_char1 CHAR(20),
-f_char2 CHAR(20),
-f_charbig VARCHAR(1000);
-
-let $sub_part_no= 3;
---disable_warnings
-DROP TABLE IF EXISTS t0_template;
---enable_warnings
-eval CREATE TABLE t0_template (
-$column_list ,
-PRIMARY KEY(f_int1))
-ENGINE = MEMORY;
-let $num= `SELECT @max_row`;
-while ($num)
-{
- eval INSERT INTO t0_template
-SET f_int1 = $num, f_int2 = $num, f_char1 = '$num', f_char2 = '$num',
-f_charbig = '===$num===';
- dec $num;
-}
-# 1. Create the table
---disable_warnings
-DROP TABLE IF EXISTS t1;
---enable_warnings
-eval CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30)) engine=$engine;
-# 2. Fill the table t1 with records
-INSERT INTO t1 (f_date, f_varchar)
-SELECT CONCAT(CAST((f_int1 + 999) AS CHAR),'-02-10'), CAST(f_char1 AS CHAR)
-FROM t0_template
-WHERE f_int1 + 999 BETWEEN 1000 AND 9999;
-# 3. Calculate the number of inserted records.
-SELECT IF(9999 - 1000 + 1 > @max_row, @max_row , 9999 - 1000 + 1)
- INTO @exp_row_count;
-# DEBUG SELECT @exp_row_count;
-# 4. Print the layout, check Readability
-ALTER TABLE t1 PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER));
---echo # 1.1.5 Add two named partitions + test
-ALTER TABLE t1 ADD PARTITION (PARTITION part1, PARTITION part7);
-drop table t1;
-
-CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30))
-ENGINE=InnoDB
-PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER));
-
---echo # This statement crashes the server.
---echo # CREATE partitioned table with three partitions in one step
---echo # would be harmless.
-ALTER TABLE t1 ADD PARTITION PARTITIONS 1;
-
---disable_warnings
-DROP VIEW IF EXISTS v1;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t0_aux;
-DROP TABLE IF EXISTS t0_definition;
-DROP TABLE IF EXISTS t0_template;
---enable_warnings
-
-#
-# Bug#20086: Can't get data from key partitioned tables with VARCHAR key
-#
-create table t1 (id varchar(64) primary key) engine=innodb
-partition by key(id) partitions 5;
-insert into t1 values ('a');
-insert into t1 values ('aa');
-insert into t1 values ('aaa');
-select * from t1 where id = 'a';
-select * from t1 where id = 'aa';
-select * from t1 where id = 'aaa';
-drop table t1;
+--source include/have_partition.inc
+--source include/have_innodb.inc
#
-# Bug #20852 Partitions: Crash if hash innodb, composite primary key
+# Bug #14673: Wrong InnoDB default row format
#
-create table t1 (a int, b int, primary key (b,a))
-engine = innodb
-partition by hash (a);
-insert into t1 values (0, 0);
-insert into t1 values (1, 0);
-update t1 set b = b + 1 where a = 1;
-select * from t1;
+create table t1 (a int) engine=innodb partition by hash(a) ;
+show table status like 't1';
drop table t1;
diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test
index 76da296c0b0..e9b8a1c95b1 100644
--- a/mysql-test/t/ps_1general.test
+++ b/mysql-test/t/ps_1general.test
@@ -324,10 +324,8 @@ execute stmt4;
# history (actions of the bdb engine).
# That is the reason why, we switch the output here off.
# (The real output will be tested in ps_6bdb.test)
---disable_warnings
-prepare stmt4 from ' show engine bdb logs ';
---enable_warnings
--disable_result_log
+prepare stmt4 from ' show engine bdb logs ';
execute stmt4;
--enable_result_log
prepare stmt4 from ' show grants for user ';
diff --git a/mysql-test/t/rpl_drop_db.test b/mysql-test/t/rpl_drop_db.test
index 38ad07f72f1..ffdc605b402 100644
--- a/mysql-test/t/rpl_drop_db.test
+++ b/mysql-test/t/rpl_drop_db.test
@@ -56,3 +56,7 @@ connection slave;
stop slave;
#system rm -rf $MYSQLTEST_VARDIR/master-data/mysqltest1;
+connection master;
+use test;
+drop table t1;
+
diff --git a/mysql-test/t/rpl_insert.test b/mysql-test/t/rpl_insert.test
index 9225606c94b..9beaff6bab6 100644
--- a/mysql-test/t/rpl_insert.test
+++ b/mysql-test/t/rpl_insert.test
@@ -17,7 +17,19 @@ CREATE TABLE t1 (id INT, name VARCHAR(64));
let $query = "INSERT DELAYED INTO t1 VALUES (1, 'Dr. No'), (2, 'From Russia With Love'), (3, 'Goldfinger'), (4, 'Thunderball'), (5, 'You Only Live Twice')";
--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=200 --query=$query --delimiter=";"
---sleep 10
+# Wait until all the 5000 inserts has been inserted into the table
+--disable_query_log
+let $counter= 300; # Max 30 seconds wait
+while (`select count(*)!=5000 from mysqlslap.t1`)
+{
+ sleep 0.1;
+ dec $counter;
+ if (!$counter)
+ {
+ Number of records in t1 didnt reach 5000;
+ }
+}
+--enable_query_log
SELECT COUNT(*) FROM mysqlslap.t1;
sync_slave_with_master;
diff --git a/mysql-test/t/rpl_stm_no_op.test b/mysql-test/t/rpl_stm_no_op.test
index d1e0b49abe9..f82bbd8cd55 100644
--- a/mysql-test/t/rpl_stm_no_op.test
+++ b/mysql-test/t/rpl_stm_no_op.test
@@ -89,5 +89,5 @@ select * from t2;
# cleanup
connection master;
-drop table t1;
+drop table t1, t2;
sync_slave_with_master;
diff --git a/mysql-test/t/rpl_variables.test b/mysql-test/t/rpl_variables.test
index 57ae2b9c3c4..b1744c57c9b 100644
--- a/mysql-test/t/rpl_variables.test
+++ b/mysql-test/t/rpl_variables.test
@@ -12,3 +12,6 @@ show variables like 'slave_load_tmpdir';
# We just set some arbitrary values in variables-master.opt so we can test
# that a list of values works correctly
show variables like 'slave_skip_errors';
+
+# Cleanup
+set global slave_net_timeout=default;
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index 24b0d4674c5..d370cb3037c 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -1075,6 +1075,10 @@ execute stmt;
drop function bug11834_1;
# Attempt to execute statement should return proper error and
# should not crash server.
+
+# NOTE! The error we get from the below query indicates that the sp bug11834_2
+# does not exist(this is wrong but can be accepted)
+# This behaviour has been reported as bug#21294
--error ER_SP_DOES_NOT_EXIST
execute stmt;
deallocate prepare stmt;
diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test
index d323b180216..591e9a3ed70 100644
--- a/mysql-test/t/sp-security.test
+++ b/mysql-test/t/sp-security.test
@@ -527,29 +527,6 @@ drop database db_bug14533;
#
-# BUG#7787: Stored procedures: improper warning for "grant execute" statement
-#
-
-# Prepare.
-
-CREATE DATABASE db_bug7787;
-use db_bug7787;
-
-# Test.
-
-CREATE PROCEDURE p1()
- SHOW INNODB STATUS;
-
-GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost;
-
-# Cleanup.
-
-DROP DATABASE db_bug7787;
-drop user user_bug7787@localhost;
-use test;
-
-
-#
# WL#2897: Complete definer support in the stored routines.
#
# The following cases are tested:
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 33259b999fc..99f3bbbbd14 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -5636,23 +5636,6 @@ drop table t3|
drop procedure bug16887|
#
-# Bug#13575 SP funcs in select with distinct/group and order by can
-# produce bad data
-#
-create table t3 (f1 int, f2 varchar(3), primary key(f1)) engine=innodb|
-insert into t3 values (1,'aaa'),(2,'bbb'),(3,'ccc')|
-CREATE FUNCTION bug13575 ( p1 integer )
-returns varchar(3)
-BEGIN
-DECLARE v1 VARCHAR(10) DEFAULT null;
-SELECT f2 INTO v1 FROM t3 WHERE f1 = p1;
-RETURN v1;
-END|
-select distinct f1, bug13575(f1) from t3 order by f1|
-drop function bug13575;
-drop table t3|
-
-#
# BUG#16474: SP crashed MySQL
# (when using "order by localvar", where 'localvar' is just that.
#
diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test
index b087f699f86..28abf448089 100644
--- a/mysql-test/t/sp_notembedded.test
+++ b/mysql-test/t/sp_notembedded.test
@@ -46,6 +46,8 @@ call bug4902_2()|
drop procedure bug4902_2|
+# Disable until bug#17244 is fixed
+--disable_parsing
#
# BUG#5278: Stored procedure packets out of order if SET PASSWORD.
#
@@ -63,7 +65,7 @@ select bug5278()|
--error 1133
select bug5278()|
drop function bug5278|
-
+--enable_parsing
--disable_warnings
drop table if exists t1|
diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test
index 1ea32316f1e..325e11b1ec9 100644
--- a/mysql-test/t/sp_trans.test
+++ b/mysql-test/t/sp_trans.test
@@ -552,6 +552,45 @@ drop table t3, t4|
drop procedure bug14210|
set @@session.max_heap_table_size=default|
+#
+# BUG#7787: Stored procedures: improper warning for "grant execute" statement
+#
+
+# Prepare.
+
+CREATE DATABASE db_bug7787|
+use db_bug7787|
+
+# Test.
+
+CREATE PROCEDURE p1()
+ SHOW INNODB STATUS; |
+
+GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost|
+
+# Cleanup.
+
+DROP DATABASE db_bug7787|
+drop user user_bug7787@localhost|
+use test|
+
+#
+# Bug#13575 SP funcs in select with distinct/group and order by can
+# produce bad data
+#
+create table t3 (f1 int, f2 varchar(3), primary key(f1)) engine=innodb|
+insert into t3 values (1,'aaa'),(2,'bbb'),(3,'ccc')|
+CREATE FUNCTION bug13575 ( p1 integer )
+returns varchar(3)
+BEGIN
+DECLARE v1 VARCHAR(10) DEFAULT null;
+SELECT f2 INTO v1 FROM t3 WHERE f1 = p1;
+RETURN v1;
+END|
+select distinct f1, bug13575(f1) from t3 order by f1|
+drop function bug13575|
+drop table t3|
+
#
# BUG#NNNN: New bug synopsis
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 35aff8b3c5a..7afdb857ca2 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1097,6 +1097,17 @@ select * from t1;
drop table t1;
#
+# Bug #18014: problem with 'alter table'
+#
+
+create table t1(a decimal(7,2));
+insert into t1 values(123.12);
+select * from t1;
+alter table t1 modify a decimal(10,2);
+select * from t1;
+drop table t1;
+
+#
# Bug#19667 group by a decimal expression yields wrong result
#
create table t1 (i int, j int);
diff --git a/mysql-test/t/wait_timeout.test b/mysql-test/t/wait_timeout.test
index 195d1a5d3f2..dbd792e48d8 100644
--- a/mysql-test/t/wait_timeout.test
+++ b/mysql-test/t/wait_timeout.test
@@ -42,6 +42,9 @@ while (!`select @aborted_clients`)
}
}
--enable_query_log
+# The server has disconnected, add small sleep to make sure
+# the disconnect has reached client
+sleep 1;
connection default;
# When the connection is closed in this way, the error code should
@@ -86,6 +89,9 @@ while (!`select @aborted_clients`)
}
}
--enable_query_log
+# The server has disconnected, add small sleep to make sure
+# the disconnect has reached client
+sleep 1;
connection con1;
# When the connection is closed in this way, the error code should
diff --git a/mysys/my_append.c b/mysys/my_append.c
index c3549c670c3..6d52c03c6cc 100644
--- a/mysys/my_append.c
+++ b/mysys/my_append.c
@@ -14,7 +14,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define USES_TYPES /* sys/types is included */
#include "mysys_priv.h"
#include <sys/stat.h>
#include <m_string.h>
diff --git a/mysys/my_clock.c b/mysys/my_clock.c
index 41d659c0ffe..70bb374a749 100644
--- a/mysys/my_clock.c
+++ b/mysys/my_clock.c
@@ -14,7 +14,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define USES_TYPES
#include "my_global.h"
#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__NETWARE__)
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index a8a3a775040..2233c791153 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -14,7 +14,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define USES_TYPES /* sys/types is included */
#include "mysys_priv.h"
#include <my_dir.h> /* for stat */
#include <m_string.h>
diff --git a/mysys/my_create.c b/mysys/my_create.c
index d27edb31d32..e1e32b50842 100644
--- a/mysys/my_create.c
+++ b/mysys/my_create.c
@@ -14,7 +14,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define USES_TYPES
#include "mysys_priv.h"
#include <my_dir.h>
#include "mysys_err.h"
diff --git a/mysys/my_dup.c b/mysys/my_dup.c
index 9666f5b1858..1fdb4db7276 100644
--- a/mysys/my_dup.c
+++ b/mysys/my_dup.c
@@ -14,7 +14,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define USES_TYPES
#include "mysys_priv.h"
#include "mysys_err.h"
#include <my_dir.h>
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 586bce0449c..76c31a8fbae 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -17,7 +17,6 @@
/* TODO: check for overun of memory for names. */
/* Convert MSDOS-TIME to standar time_t (still needed?) */
-#define USES_TYPES /* sys/types is included */
#include "mysys_priv.h"
#include <m_string.h>
#include <my_dir.h> /* Structs used by my_dir,includes sys/types */
diff --git a/mysys/my_open.c b/mysys/my_open.c
index 6041ddde9fc..6e57132ae23 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -14,7 +14,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define USES_TYPES
#include "mysys_priv.h"
#include "mysys_err.h"
#include <my_dir.h>
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index abfe84102ef..7782190ae11 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -14,7 +14,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define USES_TYPES /* sys/types is included */
#include "mysys_priv.h"
#include <my_dir.h>
#include <m_string.h>
diff --git a/mysys/my_rename.c b/mysys/my_rename.c
index b5d813ad787..9c27238cc72 100644
--- a/mysys/my_rename.c
+++ b/mysys/my_rename.c
@@ -14,7 +14,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define USES_TYPES
#include "mysys_priv.h"
#include <my_dir.h>
#include "mysys_err.h"
diff --git a/mysys/test_dir.c b/mysys/test_dir.c
index f3d220e942f..c9693ab3c68 100644
--- a/mysys/test_dir.c
+++ b/mysys/test_dir.c
@@ -16,7 +16,6 @@
/* TODO: Test all functions */
-#define USES_TYPES
#include "mysys_priv.h"
#include "my_dir.h"
diff --git a/sql/field.cc b/sql/field.cc
index 0377d0a62da..d4bd38724ae 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2620,6 +2620,18 @@ void Field_new_decimal::sql_type(String &str) const
}
+uint Field_new_decimal::is_equal(create_field *new_field)
+{
+ return ((new_field->sql_type == real_type()) &&
+ ((new_field->flags & UNSIGNED_FLAG) ==
+ (uint) (flags & UNSIGNED_FLAG)) &&
+ ((new_field->flags & AUTO_INCREMENT_FLAG) ==
+ (uint) (flags & AUTO_INCREMENT_FLAG)) &&
+ (new_field->length == max_length()) &&
+ (new_field->decimals == dec));
+}
+
+
/****************************************************************************
** tiny int
****************************************************************************/
diff --git a/sql/field.h b/sql/field.h
index c6f01ebd79a..3a4118df01e 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -517,6 +517,7 @@ public:
uint32 max_length() { return field_length; }
uint size_of() const { return sizeof(*this); }
uint32 pack_length() const { return (uint32) bin_size; }
+ uint is_equal(create_field *new_field);
};
diff --git a/sql/sp.cc b/sql/sp.cc
index 4c8cc6156b7..e794a461402 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -1537,7 +1537,6 @@ static void sp_update_stmt_used_routines(THD *thd, LEX *lex, SQL_LIST *src,
first_no_prelock - If true, don't add tables or cache routines used by
the body of the first routine (i.e. *start)
will be executed in non-prelocked mode.
- tabs_changed - Set to TRUE some tables were added, FALSE otherwise
NOTE
If some function is missing this won't be reported here.
Instead this fact will be discovered during query execution.
@@ -1550,10 +1549,9 @@ static void sp_update_stmt_used_routines(THD *thd, LEX *lex, SQL_LIST *src,
static int
sp_cache_routines_and_add_tables_aux(THD *thd, LEX *lex,
Sroutine_hash_entry *start,
- bool first_no_prelock, bool *tabs_changed)
+ bool first_no_prelock)
{
int ret= 0;
- bool tabschnd= 0; /* Set if tables changed */
bool first= TRUE;
DBUG_ENTER("sp_cache_routines_and_add_tables_aux");
@@ -1626,16 +1624,13 @@ sp_cache_routines_and_add_tables_aux(THD *thd, LEX *lex,
{
sp_update_stmt_used_routines(thd, lex, &sp->m_sroutines,
rt->belong_to_view);
- tabschnd|=
- sp->add_used_tables_to_table_list(thd, &lex->query_tables_last,
- rt->belong_to_view);
+ (void)sp->add_used_tables_to_table_list(thd, &lex->query_tables_last,
+ rt->belong_to_view);
}
sp->propagate_attributes(lex);
}
first= FALSE;
}
- if (tabs_changed) /* it can be NULL */
- *tabs_changed= tabschnd;
DBUG_RETURN(ret);
}
@@ -1651,20 +1646,18 @@ sp_cache_routines_and_add_tables_aux(THD *thd, LEX *lex,
lex - LEX representing statement
first_no_prelock - If true, don't add tables or cache routines used by
the body of the first routine (i.e. *start)
- tabs_changed - Set to TRUE some tables were added, FALSE otherwise
-
+
RETURN VALUE
0 - success
non-0 - failure
*/
int
-sp_cache_routines_and_add_tables(THD *thd, LEX *lex, bool first_no_prelock,
- bool *tabs_changed)
+sp_cache_routines_and_add_tables(THD *thd, LEX *lex, bool first_no_prelock)
{
return sp_cache_routines_and_add_tables_aux(thd, lex,
(Sroutine_hash_entry *)lex->sroutines_list.first,
- first_no_prelock, tabs_changed);
+ first_no_prelock);
}
@@ -1691,9 +1684,8 @@ sp_cache_routines_and_add_tables_for_view(THD *thd, LEX *lex, TABLE_LIST *view)
(Sroutine_hash_entry **)lex->sroutines_list.next;
sp_update_stmt_used_routines(thd, lex, &view->view->sroutines_list,
view->top_table());
- return sp_cache_routines_and_add_tables_aux(thd, lex,
- *last_cached_routine_ptr, FALSE,
- NULL);
+ return sp_cache_routines_and_add_tables_aux(thd, lex,
+ *last_cached_routine_ptr, FALSE);
}
@@ -1742,8 +1734,7 @@ sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex,
}
}
ret= sp_cache_routines_and_add_tables_aux(thd, lex,
- *last_cached_routine_ptr,
- FALSE, NULL);
+ *last_cached_routine_ptr, FALSE);
}
return ret;
}
diff --git a/sql/sp.h b/sql/sp.h
index 631b8a87aa2..80430791a5a 100644
--- a/sql/sp.h
+++ b/sql/sp.h
@@ -88,8 +88,7 @@ void sp_add_used_routine(LEX *lex, Query_arena *arena,
void sp_remove_not_own_routines(LEX *lex);
void sp_update_sp_used_routines(HASH *dst, HASH *src);
int sp_cache_routines_and_add_tables(THD *thd, LEX *lex,
- bool first_no_prelock,
- bool *tabs_changed);
+ bool first_no_prelock);
int sp_cache_routines_and_add_tables_for_view(THD *thd, LEX *lex,
TABLE_LIST *view);
int sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex,
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 28393e4b964..db11a3442c2 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2855,25 +2855,18 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
statement for which table list for prelocking is already built, let
us cache routines and try to build such table list.
- NOTE: We will mark statement as requiring prelocking only if we will
- have non empty table list. But this does not guarantee that in prelocked
- mode we will have some locked tables, because queries which use only
- derived/information schema tables and views possible. Thus "counter"
- may be still zero for prelocked statement...
*/
if (!thd->prelocked_mode && !thd->lex->requires_prelocking() &&
thd->lex->sroutines_list.elements)
{
- bool first_no_prelocking, need_prelocking, tabs_changed;
+ bool first_no_prelocking, need_prelocking;
TABLE_LIST **save_query_tables_last= thd->lex->query_tables_last;
DBUG_ASSERT(thd->lex->query_tables == *start);
sp_get_prelocking_info(thd, &need_prelocking, &first_no_prelocking);
- if (sp_cache_routines_and_add_tables(thd, thd->lex,
- first_no_prelocking,
- &tabs_changed))
+ if (sp_cache_routines_and_add_tables(thd, thd->lex, first_no_prelocking))
{
/*
Serious error during reading stored routines from mysql.proc table.
@@ -2883,7 +2876,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
result= -1;
goto err;
}
- else if ((tabs_changed || *start) && need_prelocking)
+ else if (need_prelocking)
{
query_tables_last_own= save_query_tables_last;
*start= thd->lex->query_tables;
@@ -3310,11 +3303,6 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen)
in prelocked mode.
*/
DBUG_ASSERT(!thd->prelocked_mode || !thd->lex->requires_prelocking());
- /*
- If statement requires prelocking then it has non-empty table list.
- So it is safe to shortcut.
- */
- DBUG_ASSERT(!thd->lex->requires_prelocking() || tables);
*need_reopen= FALSE;
@@ -3326,7 +3314,7 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen)
thd->set_current_stmt_binlog_row_based_if_mixed();
#endif /*HAVE_ROW_BASED_REPLICATION*/
- if (!tables)
+ if (!tables && !thd->lex->requires_prelocking())
DBUG_RETURN(0);
/*
diff --git a/sql/unireg.cc b/sql/unireg.cc
index f57fe7cf9b8..396ff4fba27 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -24,7 +24,6 @@
str is a (long) to record position where 0 is the first position.
*/
-#define USES_TYPES
#include "mysql_priv.h"
#include <m_ctype.h>
#include <assert.h>
diff --git a/storage/ndb/tools/waiter.cpp b/storage/ndb/tools/waiter.cpp
index cb02d5e7c36..e3d8733b0ed 100644
--- a/storage/ndb/tools/waiter.cpp
+++ b/storage/ndb/tools/waiter.cpp
@@ -92,7 +92,7 @@ int main(int argc, char** argv){
wait_status= NDB_MGM_NODE_STATUS_STARTED;
}
- if (waitClusterStatus(_hostName, wait_status, _timeout) != 0)
+ if (waitClusterStatus(_hostName, wait_status, _timeout*10) != 0)
return NDBT_ProgramExit(NDBT_FAILED);
return NDBT_ProgramExit(NDBT_OK);
}
@@ -311,7 +311,7 @@ waitClusterStatus(const char* _addr,
}
g_info << "Waiting for cluster enter state "
<< ndb_mgm_get_node_status_string(_status)<< endl;
- NdbSleep_SecSleep(1);
+ NdbSleep_MilliSleep(100);
attempts++;
}
return 0;