mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
Merge neptunus.(none):/home/msvensson/mysql/my51-m-bug19535
into neptunus.(none):/home/msvensson/mysql/mysql-5.1-new-maint
This commit is contained in:
commit
39130d15eb
21 changed files with 238 additions and 469 deletions
|
@ -82,9 +82,6 @@
|
|||
#define MAX_EXPECTED_ERRORS 10
|
||||
#define QUERY_SEND 1
|
||||
#define QUERY_REAP 2
|
||||
#ifndef MYSQL_MANAGER_PORT
|
||||
#define MYSQL_MANAGER_PORT 23546
|
||||
#endif
|
||||
#define MAX_SERVER_ARGS 64
|
||||
|
||||
|
||||
|
@ -96,11 +93,10 @@
|
|||
#define RESULT_CONTENT_MISMATCH 1
|
||||
#define RESULT_LENGTH_MISMATCH 2
|
||||
|
||||
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,
|
||||
enum {OPT_SKIP_SAFEMALLOC=256, 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_MARK_PROGRESS};
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
@ -160,11 +156,6 @@ static my_bool sp_protocol= 0, sp_protocol_enabled= 0;
|
|||
static my_bool view_protocol= 0, view_protocol_enabled= 0;
|
||||
static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0;
|
||||
static int parsing_disabled= 0;
|
||||
const char *manager_user="root",*manager_host=0;
|
||||
char *manager_pass=0;
|
||||
int manager_port=MYSQL_MANAGER_PORT;
|
||||
int manager_wait_timeout=3;
|
||||
MYSQL_MANAGER* manager=0;
|
||||
|
||||
static char **default_argv;
|
||||
static const char *load_default_groups[]= { "mysqltest","client",0 };
|
||||
|
@ -335,7 +326,7 @@ Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
|
|||
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
|
||||
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
|
||||
Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG,
|
||||
Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER,
|
||||
Q_SERVER_START, Q_SERVER_STOP,
|
||||
Q_WAIT_FOR_SLAVE_TO_STOP,
|
||||
Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
|
||||
Q_ENABLE_PS_WARNINGS, Q_DISABLE_PS_WARNINGS,
|
||||
|
@ -347,11 +338,10 @@ Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS,
|
|||
Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL,
|
||||
Q_START_TIMER, Q_END_TIMER,
|
||||
Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL,
|
||||
Q_EXIT,
|
||||
Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT,
|
||||
Q_IF,
|
||||
Q_DISABLE_PARSING, Q_ENABLE_PARSING,
|
||||
Q_REPLACE_REGEX,
|
||||
Q_REPLACE_REGEX, Q_DIE,
|
||||
|
||||
Q_UNKNOWN, /* Unknown command. */
|
||||
Q_COMMENT, /* Comments, ignored. */
|
||||
|
@ -411,7 +401,6 @@ const char *command_names[]=
|
|||
"disable_result_log",
|
||||
"server_start",
|
||||
"server_stop",
|
||||
"require_manager",
|
||||
"wait_for_slave_to_stop",
|
||||
"enable_warnings",
|
||||
"disable_warnings",
|
||||
|
@ -434,13 +423,13 @@ const char *command_names[]=
|
|||
"character_set",
|
||||
"disable_ps_protocol",
|
||||
"enable_ps_protocol",
|
||||
"exit",
|
||||
"disable_reconnect",
|
||||
"enable_reconnect",
|
||||
"if",
|
||||
"disable_parsing",
|
||||
"enable_parsing",
|
||||
"replace_regex",
|
||||
"die",
|
||||
0
|
||||
};
|
||||
|
||||
|
@ -610,10 +599,7 @@ static void free_used_memory()
|
|||
{
|
||||
uint i;
|
||||
DBUG_ENTER("free_used_memory");
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (manager)
|
||||
mysql_manager_close(manager);
|
||||
#endif
|
||||
|
||||
close_cons();
|
||||
close_files();
|
||||
hash_free(&var_hash);
|
||||
|
@ -682,17 +668,43 @@ static void die(const char *fmt, ...)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/* Note that we will get some memory leaks when calling this! */
|
||||
|
||||
static void abort_not_supported_test(const char *fname)
|
||||
static void abort_not_supported_test(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
test_file* err_file= cur_file;
|
||||
DBUG_ENTER("abort_not_supported_test");
|
||||
|
||||
/* Print include filestack */
|
||||
fprintf(stderr, "The test '%s' is not supported by this installation\n",
|
||||
fname);
|
||||
if (!silent)
|
||||
printf("skipped\n");
|
||||
file_stack->file_name);
|
||||
fprintf(stderr, "Detected in file %s at line %d\n",
|
||||
err_file->file_name, err_file->lineno);
|
||||
while (err_file != file_stack)
|
||||
{
|
||||
err_file--;
|
||||
fprintf(stderr, "included from %s at line %d\n",
|
||||
err_file->file_name, err_file->lineno);
|
||||
}
|
||||
|
||||
/* Print error message */
|
||||
va_start(args, fmt);
|
||||
if (fmt)
|
||||
{
|
||||
fprintf(stderr, "reason: ");
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
/* Clean up and exit */
|
||||
free_used_memory();
|
||||
my_end(MY_CHECK_ERROR);
|
||||
|
||||
if (!silent)
|
||||
printf("skipped\n");
|
||||
|
||||
exit(62);
|
||||
}
|
||||
|
||||
|
@ -704,13 +716,13 @@ static void verbose_msg(const char *fmt, ...)
|
|||
DBUG_VOID_RETURN;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
fprintf(stderr, "mysqltest: ");
|
||||
if (start_lineno != 0)
|
||||
fprintf(stderr, "At line %u: ", start_lineno);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(args);
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -736,10 +748,10 @@ static int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
|
|||
if (!test_if_hard_path(fname))
|
||||
{
|
||||
strxmov(eval_file, opt_basedir, fname, NullS);
|
||||
fn_format(eval_file, eval_file,"","",4);
|
||||
fn_format(eval_file, eval_file, "", "", MY_UNPACK_FILENAME);
|
||||
}
|
||||
else
|
||||
fn_format(eval_file, fname,"","",4);
|
||||
fn_format(eval_file, fname, "", "", MY_UNPACK_FILENAME);
|
||||
|
||||
if (!my_stat(eval_file, &stat_info, MYF(MY_WME)))
|
||||
die(NullS);
|
||||
|
@ -780,8 +792,9 @@ static int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
|
|||
|
||||
err:
|
||||
if (res && eval_result)
|
||||
str_to_file(fn_format(eval_file, fname, "", ".eval",2), res_ptr,
|
||||
res_len);
|
||||
str_to_file(fn_format(eval_file, fname, "", ".eval",
|
||||
MY_REPLACE_EXT),
|
||||
res_ptr, res_len);
|
||||
|
||||
my_free((gptr) tmp, MYF(0));
|
||||
my_close(fd, MYF(MY_WME));
|
||||
|
@ -811,7 +824,11 @@ static void check_result(DYNAMIC_STRING* ds, const char *fname,
|
|||
DBUG_ENTER("check_result");
|
||||
|
||||
if (res && require_option)
|
||||
abort_not_supported_test(fname);
|
||||
{
|
||||
char reason[FN_REFLEN];
|
||||
fn_format(reason, fname, "", "", MY_REPLACE_EXT | MY_REPLACE_DIR);
|
||||
abort_not_supported_test("Test requires: '%s'", reason);
|
||||
}
|
||||
switch (res) {
|
||||
case RESULT_OK:
|
||||
break; /* ok */
|
||||
|
@ -956,7 +973,7 @@ int open_file(const char *name)
|
|||
strxmov(buff, opt_basedir, name, NullS);
|
||||
name=buff;
|
||||
}
|
||||
fn_format(buff,name,"","",4);
|
||||
fn_format(buff, name, "", "", MY_UNPACK_FILENAME);
|
||||
|
||||
if (cur_file == file_stack_end)
|
||||
die("Source directives are nesting too deep");
|
||||
|
@ -1030,57 +1047,6 @@ int do_wait_for_slave_to_stop(struct st_query *q __attribute__((unused)))
|
|||
return 0;
|
||||
}
|
||||
|
||||
int do_require_manager(struct st_query *query __attribute__((unused)) )
|
||||
{
|
||||
if (!manager)
|
||||
abort_not_supported_test("manager");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static int do_server_op(struct st_query *q, const char *op)
|
||||
{
|
||||
char *p= q->first_argument;
|
||||
char com_buf[256], *com_p;
|
||||
if (!manager)
|
||||
{
|
||||
die("Manager is not initialized, manager commands are not possible");
|
||||
}
|
||||
com_p= strmov(com_buf,op);
|
||||
com_p= strmov(com_p,"_exec ");
|
||||
if (!*p)
|
||||
die("Missing server name in server_%s", op);
|
||||
while (*p && !my_isspace(charset_info, *p))
|
||||
*com_p++= *p++;
|
||||
*com_p++= ' ';
|
||||
com_p= int10_to_str(manager_wait_timeout, com_p, 10);
|
||||
*com_p++= '\n';
|
||||
*com_p= 0;
|
||||
if (mysql_manager_command(manager, com_buf, (int)(com_p-com_buf)))
|
||||
die("Error in command: %s(%d)", manager->last_error, manager->last_errno);
|
||||
while (!manager->eof)
|
||||
{
|
||||
if (mysql_manager_fetch_line(manager, com_buf, sizeof(com_buf)))
|
||||
die("Error fetching result line: %s(%d)", manager->last_error,
|
||||
manager->last_errno);
|
||||
}
|
||||
|
||||
q->last_argument= p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_server_start(struct st_query *q)
|
||||
{
|
||||
return do_server_op(q, "start");
|
||||
}
|
||||
|
||||
int do_server_stop(struct st_query *q)
|
||||
{
|
||||
return do_server_op(q, "stop");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Source and execute the given file
|
||||
|
@ -1919,7 +1885,7 @@ static void set_charset(struct st_query *q)
|
|||
q->last_argument= p;
|
||||
charset_info= get_charset_by_csname(charset_name,MY_CS_PRIMARY,MYF(MY_WME));
|
||||
if (!charset_info)
|
||||
abort_not_supported_test(charset_name);
|
||||
abort_not_supported_test("Test requires charset '%s'", charset_name);
|
||||
}
|
||||
|
||||
static uint get_errcodes(match_err *to,struct st_query *q)
|
||||
|
@ -2473,19 +2439,6 @@ char* safe_get_param(char *str, char** arg, const char *msg)
|
|||
DBUG_RETURN(str);
|
||||
}
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
void init_manager()
|
||||
{
|
||||
if (!(manager=mysql_manager_init(0)))
|
||||
die("Failed in mysql_manager_init()");
|
||||
if (!mysql_manager_connect(manager,manager_host,manager_user,
|
||||
manager_pass,manager_port))
|
||||
die("Could not connect to MySQL manager: %s(%d)",manager->last_error,
|
||||
manager->last_errno);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Connect to a server doing several retries if needed.
|
||||
|
@ -2770,7 +2723,7 @@ int do_connect(struct st_query *q)
|
|||
}
|
||||
#endif
|
||||
if (con_sock && !free_con_sock && *con_sock && *con_sock != FN_LIBCHAR)
|
||||
con_sock=fn_format(buff, con_sock, TMPDIR, "",0);
|
||||
con_sock=fn_format(buff, con_sock, TMPDIR, "", 0);
|
||||
if (!con_db[0])
|
||||
con_db= db;
|
||||
/* Special database to allow one to connect without a database name */
|
||||
|
@ -3287,20 +3240,6 @@ static struct my_option my_long_options[] =
|
|||
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"include", 'i', "Include SQL before each test case.", (gptr*) &opt_include,
|
||||
(gptr*) &opt_include, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"manager-host", OPT_MANAGER_HOST, "Undocumented: Used for debugging.",
|
||||
(gptr*) &manager_host, (gptr*) &manager_host, 0, GET_STR, REQUIRED_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"manager-password", OPT_MANAGER_PASSWD, "Undocumented: Used for debugging.",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"manager-port", OPT_MANAGER_PORT, "Undocumented: Used for debugging.",
|
||||
(gptr*) &manager_port, (gptr*) &manager_port, 0, GET_INT, REQUIRED_ARG,
|
||||
MYSQL_MANAGER_PORT, 0, 0, 0, 0, 0},
|
||||
{"manager-user", OPT_MANAGER_USER, "Undocumented: Used for debugging.",
|
||||
(gptr*) &manager_user, (gptr*) &manager_user, 0, GET_STR, REQUIRED_ARG, 0,
|
||||
0, 0, 0, 0, 0},
|
||||
{"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,
|
||||
|
@ -3397,11 +3336,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
case 'r':
|
||||
record = 1;
|
||||
break;
|
||||
case (int)OPT_MANAGER_PASSWD:
|
||||
my_free(manager_pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||
manager_pass=my_strdup(argument, MYF(MY_FAE));
|
||||
while (*argument) *argument++= 'x'; /* Destroy argument */
|
||||
break;
|
||||
case 'x':
|
||||
{
|
||||
char buff[FN_REFLEN];
|
||||
|
@ -3410,7 +3344,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
strxmov(buff, opt_basedir, argument, NullS);
|
||||
argument= buff;
|
||||
}
|
||||
fn_format(buff, argument, "", "", 4);
|
||||
fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
|
||||
DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
|
||||
if (!(cur_file->file=
|
||||
my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0))))
|
||||
|
@ -3427,7 +3361,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
strxmov(buff, opt_basedir, argument, NullS);
|
||||
argument= buff;
|
||||
}
|
||||
fn_format(buff, argument, "", "", 4);
|
||||
fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
|
||||
timer_file= buff;
|
||||
unlink(timer_file); /* Ignore error, may not exist */
|
||||
break;
|
||||
|
@ -3521,7 +3455,7 @@ static void str_to_file(const char *fname, char *str, int size)
|
|||
strxmov(buff, opt_basedir, fname, NullS);
|
||||
fname= buff;
|
||||
}
|
||||
fn_format(buff,fname,"","",4);
|
||||
fn_format(buff, fname, "", "", MY_UNPACK_FILENAME);
|
||||
|
||||
if ((fd= my_open(buff, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
MYF(MY_WME | MY_FFNF))) < 0)
|
||||
|
@ -3535,19 +3469,24 @@ static void str_to_file(const char *fname, char *str, int size)
|
|||
void dump_result_to_reject_file(const char *record_file, char *buf, int size)
|
||||
{
|
||||
char reject_file[FN_REFLEN];
|
||||
str_to_file(fn_format(reject_file, record_file,"",".reject",2), buf, size);
|
||||
str_to_file(fn_format(reject_file, record_file, "", ".reject",
|
||||
MY_REPLACE_EXT),
|
||||
buf, size);
|
||||
}
|
||||
|
||||
void dump_result_to_log_file(const char *record_file, char *buf, int size)
|
||||
{
|
||||
char log_file[FN_REFLEN];
|
||||
str_to_file(fn_format(log_file, record_file,"",".log",2), buf, size);
|
||||
str_to_file(fn_format(log_file, record_file, "", ".log",
|
||||
MY_REPLACE_EXT),
|
||||
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),
|
||||
str_to_file(fn_format(log_file, record_file, "", ".progress",
|
||||
MY_REPLACE_EXT),
|
||||
ds_progress.str, ds_progress.length);
|
||||
}
|
||||
|
||||
|
@ -4358,7 +4297,9 @@ static void handle_error(const char *query, struct st_query *q,
|
|||
if (err_errno == CR_SERVER_LOST ||
|
||||
err_errno == CR_SERVER_GONE_ERROR)
|
||||
die("require query '%s' failed: %d: %s", query, err_errno, err_error);
|
||||
abort_not_supported_test("failed_query");
|
||||
|
||||
/* Abort the run of this test, pass the failed query as reason */
|
||||
abort_not_supported_test("Query '%s' failed, required functionality not supported", query);
|
||||
}
|
||||
|
||||
if (q->abort_on_error)
|
||||
|
@ -5139,7 +5080,7 @@ static void init_var_hash(MYSQL *mysql)
|
|||
test run completes
|
||||
|
||||
*/
|
||||
static void mark_progress(struct st_query* q, int line)
|
||||
static void mark_progress(struct st_query* q __attribute__((unused)), int line)
|
||||
{
|
||||
char buf[32], *end;
|
||||
ulonglong timer= timer_now();
|
||||
|
@ -5174,7 +5115,7 @@ static void mark_progress(struct st_query* q, int line)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
struct st_query *q;
|
||||
my_bool require_file=0, q_send_flag=0, abort_flag= 0,
|
||||
my_bool require_file=0, q_send_flag=0,
|
||||
query_executed= 0;
|
||||
char save_file[FN_REFLEN];
|
||||
MY_STAT res_info;
|
||||
|
@ -5224,10 +5165,6 @@ int main(int argc, char **argv)
|
|||
cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME));
|
||||
cur_file->lineno= 1;
|
||||
}
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (manager_host)
|
||||
init_manager();
|
||||
#endif
|
||||
init_re();
|
||||
ps_protocol_enabled= ps_protocol;
|
||||
sp_protocol_enabled= sp_protocol;
|
||||
|
@ -5281,7 +5218,7 @@ int main(int argc, char **argv)
|
|||
open_file(opt_include);
|
||||
}
|
||||
|
||||
while (!abort_flag && !read_query(&q))
|
||||
while (!read_query(&q))
|
||||
{
|
||||
int current_line_inc = 1, processed = 0;
|
||||
if (q->type == Q_UNKNOWN || q->type == Q_COMMENT_WITH_COMMAND)
|
||||
|
@ -5319,11 +5256,6 @@ int main(int argc, char **argv)
|
|||
case Q_SLEEP: do_sleep(q, 0); break;
|
||||
case Q_REAL_SLEEP: do_sleep(q, 1); break;
|
||||
case Q_WAIT_FOR_SLAVE_TO_STOP: do_wait_for_slave_to_stop(q); break;
|
||||
case Q_REQUIRE_MANAGER: do_require_manager(q); break;
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
case Q_SERVER_START: do_server_start(q); break;
|
||||
case Q_SERVER_STOP: do_server_stop(q); break;
|
||||
#endif
|
||||
case Q_INC: do_modify_var(q, DO_INC); break;
|
||||
case Q_DEC: do_modify_var(q, DO_DEC); break;
|
||||
case Q_ECHO: do_echo(q); query_executed= 1; break;
|
||||
|
@ -5501,8 +5433,8 @@ int main(int argc, char **argv)
|
|||
parsing_disabled--;
|
||||
break;
|
||||
|
||||
case Q_EXIT:
|
||||
abort_flag= 1;
|
||||
case Q_DIE:
|
||||
die("%s", q->first_argument);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -5622,7 +5554,7 @@ static int read_server_arguments(const char *name)
|
|||
strxmov(buff, opt_basedir, name, NullS);
|
||||
name=buff;
|
||||
}
|
||||
fn_format(buff,name,"","",4);
|
||||
fn_format(buff, name, "", "", MY_UNPACK_FILENAME);
|
||||
|
||||
if (!embedded_server_arg_count)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
--require r/true.require
|
||||
--require r/not_ndb_default.require
|
||||
disable_query_log;
|
||||
select convert(@@table_type using latin1) NOT IN ("ndbcluster","NDBCLUSTER") as "TRUE";
|
||||
enable_query_log;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
--require r/true.require
|
||||
--require r/not_windows.require
|
||||
disable_query_log;
|
||||
select convert(@@version_compile_os using latin1) NOT IN ("Win32","Win64","Windows") as "TRUE";
|
||||
enable_query_log;
|
||||
|
|
20
mysql-test/include/wait_until_connected_again.inc
Normal file
20
mysql-test/include/wait_until_connected_again.inc
Normal file
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# Include this script to wait until the connection to the
|
||||
# server has been restored or timeout occurs
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
let $counter= 100;
|
||||
while ($mysql_errno)
|
||||
{
|
||||
--error 0,2002,2006
|
||||
show status;
|
||||
|
||||
dec $counter;
|
||||
if (!$counter)
|
||||
{
|
||||
--die Server failed to restart
|
||||
}
|
||||
--sleep 0.1
|
||||
}
|
||||
--enable_query_log
|
||||
--enable_result_log
|
|
@ -1,4 +1,4 @@
|
|||
--require r/true.require
|
||||
--require r/windows.require
|
||||
disable_query_log;
|
||||
select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows") as "TRUE";
|
||||
enable_query_log;
|
||||
|
|
|
@ -11,6 +11,7 @@ sub mtr_get_opts_from_file ($);
|
|||
sub mtr_fromfile ($);
|
||||
sub mtr_tofile ($@);
|
||||
sub mtr_tonewfile($@);
|
||||
sub mtr_lastlinefromfile($);
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
|
@ -113,6 +114,20 @@ sub mtr_fromfile ($) {
|
|||
return $text;
|
||||
}
|
||||
|
||||
sub mtr_lastlinefromfile ($) {
|
||||
my $file= shift;
|
||||
my $text;
|
||||
|
||||
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
|
||||
while (my $line= <FILE>)
|
||||
{
|
||||
$text= $line;
|
||||
}
|
||||
close FILE;
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
sub mtr_tofile ($@) {
|
||||
my $file= shift;
|
||||
|
||||
|
@ -129,5 +144,4 @@ sub mtr_tonewfile ($@) {
|
|||
close FILE;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
@ -272,10 +272,10 @@ sub spawn_parent_impl {
|
|||
last;
|
||||
}
|
||||
|
||||
# If one of the processes died, we want to
|
||||
# mark this, and kill the mysqltest process.
|
||||
# One of the child processes died, unless this was expected
|
||||
# mysqltest should be killed and test aborted
|
||||
|
||||
mark_process_dead($ret_pid);
|
||||
check_expected_crash_and_restart($ret_pid);
|
||||
}
|
||||
|
||||
if ( $ret_pid != $pid )
|
||||
|
@ -811,6 +811,81 @@ sub mark_process_dead($)
|
|||
|
||||
}
|
||||
|
||||
#
|
||||
# Loop through our list of processes and look for and entry
|
||||
# with the provided pid, if found check for the file indicating
|
||||
# expected crash and restart it.
|
||||
#
|
||||
sub check_expected_crash_and_restart($)
|
||||
{
|
||||
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;
|
||||
|
||||
# Check if crash expected and restart if it was
|
||||
my $expect_file= "$::opt_vardir/tmp/" . "$mysqld->{'type'}" .
|
||||
"$mysqld->{'idx'}" . ".expect";
|
||||
if ( -f $expect_file )
|
||||
{
|
||||
mtr_verbose("Crash was expected, file $expect_file exists");
|
||||
mysqld_start($mysqld, $mysqld->{'start_opts'},
|
||||
$mysqld->{'start_slave_master_info'});
|
||||
unlink($expect_file);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
# Check if crash expected and restart if it was
|
||||
my $expect_file= "$::opt_vardir/tmp/ndb_mgmd_" . "$cluster->{'type'}" .
|
||||
".expect";
|
||||
if ( -f $expect_file )
|
||||
{
|
||||
mtr_verbose("Crash was expected, file $expect_file exists");
|
||||
ndbmgmd_start($cluster);
|
||||
unlink($expect_file);
|
||||
}
|
||||
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;
|
||||
|
||||
# Check if crash expected and restart if it was
|
||||
my $expect_file= "$::opt_vardir/tmp/ndbd_" . "$cluster->{'type'}" .
|
||||
"$ndbd->{'idx'}" . ".expect";
|
||||
if ( -f $expect_file )
|
||||
{
|
||||
mtr_verbose("Crash was expected, file $expect_file exists");
|
||||
ndbd_start($cluster, $ndbd->{'idx'},
|
||||
$ndbd->{'start_extra_args'});
|
||||
unlink($expect_file);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
mtr_warning("check_expected_crash_and_restart couldn't find an entry for pid: $ret_pid");
|
||||
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# The operating system will keep information about dead children,
|
||||
|
|
|
@ -1806,6 +1806,10 @@ sub ndbd_start ($$$) {
|
|||
# Add pid to list of pids for this cluster
|
||||
$cluster->{'ndbds'}->[$idx]->{'pid'}= $pid;
|
||||
|
||||
# Rememeber options used when starting
|
||||
$cluster->{'ndbds'}->[$idx]->{'start_extra_args'}= $extra_args;
|
||||
$cluster->{'ndbds'}->[$idx]->{'idx'}= $idx;
|
||||
|
||||
mtr_verbose("ndbd_start, pid: $pid");
|
||||
|
||||
return $pid;
|
||||
|
@ -2343,8 +2347,11 @@ 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";
|
||||
|
||||
# Try to get reason from mysqltest.log
|
||||
my $last_line= mtr_lastlinefromfile($path_timefile) if -f $path_timefile;
|
||||
my $reason= mtr_match_prefix($last_line, "reason: ");
|
||||
$tinfo->{'comment'}= defined $reason ? $reason : "Detected by testcase(reason unknown) ";
|
||||
mtr_report_test_skipped($tinfo);
|
||||
}
|
||||
elsif ( $res == 63 )
|
||||
|
@ -2904,6 +2911,7 @@ sub mysqld_start ($$$) {
|
|||
|
||||
# Remember options used when starting
|
||||
$mysqld->{'start_opts'}= $extra_opt;
|
||||
$mysqld->{'start_slave_master_info'}= $slave_master_info;
|
||||
|
||||
mtr_verbose("mysqld pid: $pid");
|
||||
return $pid;
|
||||
|
|
13
mysql-test/r/crash_commit_before.result
Normal file
13
mysql-test/r/crash_commit_before.result
Normal file
|
@ -0,0 +1,13 @@
|
|||
CREATE TABLE t1(a int) engine=innodb;
|
||||
START TRANSACTION;
|
||||
insert into t1 values(9);
|
||||
SET SESSION debug="d,crash_commit_before";
|
||||
COMMIT;
|
||||
ERROR HY000: Lost connection to MySQL server during query
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SELECT * FROM t1;
|
||||
a
|
2
mysql-test/r/not_windows.require
Normal file
2
mysql-test/r/not_windows.require
Normal file
|
@ -0,0 +1,2 @@
|
|||
TRUE
|
||||
1
|
|
@ -1,14 +0,0 @@
|
|||
reset master;
|
||||
reset slave;
|
||||
start slave;
|
||||
show binary logs;
|
||||
Log_name
|
||||
master-bin.000001
|
||||
master-bin.000002
|
||||
drop table if exists t1;
|
||||
create table t1(n int);
|
||||
insert into t1 values (3351);
|
||||
select * from t1;
|
||||
n
|
||||
3351
|
||||
drop table t1;
|
|
@ -1,30 +0,0 @@
|
|||
slave stop;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
slave start;
|
||||
reset master;
|
||||
change master to master_host='127.0.0.1',master_port=9307, master_user='root';
|
||||
start slave;
|
||||
create temporary table t1 (a int);
|
||||
create temporary table t1 (a int);
|
||||
show status like 'slave_open_temp_tables';
|
||||
Variable_name Value
|
||||
Slave_open_temp_tables 2
|
||||
create temporary table t1 (a int);
|
||||
create temporary table t1 (a int);
|
||||
show status like 'slave_open_temp_tables';
|
||||
Variable_name Value
|
||||
Slave_open_temp_tables 4
|
||||
stop slave;
|
||||
insert into t1 values(1);
|
||||
create table t2 as select * from t1;
|
||||
start slave;
|
||||
show status like 'slave_open_temp_tables';
|
||||
Variable_name Value
|
||||
Slave_open_temp_tables 4
|
||||
select * from t2;
|
||||
a
|
||||
1
|
||||
drop table t2;
|
|
@ -1,34 +0,0 @@
|
|||
stop slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
show variables like 'rpl_recovery_rank';
|
||||
Variable_name Value
|
||||
rpl_recovery_rank 1
|
||||
show status like 'Rpl_status';
|
||||
Variable_name Value
|
||||
Rpl_status AUTH_MASTER
|
||||
create table t1(n int);
|
||||
drop table t1;
|
||||
show variables like 'rpl_recovery_rank';
|
||||
Variable_name Value
|
||||
rpl_recovery_rank 2
|
||||
show status like 'Rpl_status';
|
||||
Variable_name Value
|
||||
Rpl_status ACTIVE_SLAVE
|
||||
start slave;
|
||||
show variables like 'rpl_recovery_rank';
|
||||
Variable_name Value
|
||||
rpl_recovery_rank 3
|
||||
show status like 'Rpl_status';
|
||||
Variable_name Value
|
||||
Rpl_status ACTIVE_SLAVE
|
||||
start slave;
|
||||
show variables like 'rpl_recovery_rank';
|
||||
Variable_name Value
|
||||
rpl_recovery_rank 4
|
||||
show status like 'Rpl_status';
|
||||
Variable_name Value
|
||||
Rpl_status ACTIVE_SLAVE
|
|
@ -1,29 +0,0 @@
|
|||
reset master;
|
||||
drop table if exists t1;
|
||||
create table t1 ENGINE=HEAP select 10 as a;
|
||||
insert into t1 values(11);
|
||||
show binlog events from 79;
|
||||
Log_name Pos Event_type Server_id Orig_log_pos Info
|
||||
master-bin.001 79 Query 1 79 use `test`; create table t1 ENGINE=HEAP select 10 as a
|
||||
master-bin.001 154 Query 1 154 use `test`; insert into t1 values(11)
|
||||
reset slave;
|
||||
start slave;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` bigint(2) NOT NULL default '0'
|
||||
) ENGINE=HEAP
|
||||
select * from t1;
|
||||
a
|
||||
10
|
||||
11
|
||||
select * from t1;
|
||||
a
|
||||
select * from t1 limit 10;
|
||||
a
|
||||
show binlog events in 'master-bin.002' from 79;
|
||||
Log_name Pos Event_type Server_id Orig_log_pos Info
|
||||
master-bin.002 79 Query 1 79 use `test`; DELETE FROM `test`.`t1`
|
||||
select * from t1;
|
||||
a
|
||||
drop table t1;
|
2
mysql-test/r/windows.require
Normal file
2
mysql-test/r/windows.require
Normal file
|
@ -0,0 +1,2 @@
|
|||
TRUE
|
||||
1
|
22
mysql-test/t/crash_commit_before.test
Normal file
22
mysql-test/t/crash_commit_before.test
Normal file
|
@ -0,0 +1,22 @@
|
|||
--source include/have_debug.inc
|
||||
|
||||
CREATE TABLE t1(a int) engine=innodb;
|
||||
START TRANSACTION;
|
||||
insert into t1 values(9);
|
||||
|
||||
# Setup the mysqld to crash at certain point
|
||||
SET SESSION debug="d,crash_commit_before";
|
||||
|
||||
# Write file to make mysql-test-run.pl expect crash and restart
|
||||
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/master0.expect
|
||||
|
||||
# Run the crashing query
|
||||
--error 2013
|
||||
COMMIT;
|
||||
|
||||
# Call script that will poll the server waiting for it to be back online again
|
||||
--source include/wait_until_connected_again.inc
|
||||
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
SELECT * FROM t1;
|
|
@ -1,29 +0,0 @@
|
|||
#
|
||||
# Running test with abort-slave-event-count=1
|
||||
# This will force slave to reconnect after every event
|
||||
#
|
||||
|
||||
require_manager;
|
||||
connect (master,localhost,root,,test,0,$MASTER_MYPORT);
|
||||
connect (slave,localhost,root,,test,0,slave.sock);
|
||||
connection master;
|
||||
reset master;
|
||||
server_stop master;
|
||||
server_start master;
|
||||
connection slave;
|
||||
reset slave;
|
||||
start slave;
|
||||
connection master;
|
||||
show binary logs;
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(n int);
|
||||
insert into t1 values (3351);
|
||||
sync_slave_with_master;
|
||||
select * from t1;
|
||||
connection master;
|
||||
drop table t1;
|
||||
sync_slave_with_master;
|
||||
|
||||
# End of 4.1 tests
|
|
@ -1,101 +0,0 @@
|
|||
# This test makes some assumptions about values of thread ids, which should be
|
||||
# true if the servers have been restarted for this test. So we want to
|
||||
# stop/restart servers. Note that if assumptions are wrong, the test will not
|
||||
# fail; it will just fail to test the error-prone scenario.
|
||||
# Using the manager is the only way to have more than one slave server.
|
||||
# So you must run this test with --manager.
|
||||
|
||||
require_manager;
|
||||
server_stop master;
|
||||
server_start master;
|
||||
server_stop slave;
|
||||
server_start slave;
|
||||
# no need for slave_sec (no assumptions on thread ids for this server).
|
||||
|
||||
source include/master-slave.inc;
|
||||
connect (slave_sec,localhost,root,,test,0,slave.sock-1);
|
||||
connection master;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
reset master;
|
||||
save_master_pos;
|
||||
connection slave_sec;
|
||||
eval change master to master_host='127.0.0.1',master_port=$SLAVE_MYPORT, master_user='root';
|
||||
start slave;
|
||||
sync_with_master;
|
||||
|
||||
# :P now we have a chain ready-to-test.
|
||||
|
||||
connection master;
|
||||
create temporary table t1 (a int);
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
connection master1;
|
||||
create temporary table t1 (a int);
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
save_master_pos;
|
||||
|
||||
# First test:
|
||||
|
||||
connection slave_sec;
|
||||
# Before BUG#1686 ("If 2 master threads with same-name temp table, slave makes
|
||||
# bad binlog") was fixed, sync_with_master failed
|
||||
sync_with_master;
|
||||
show status like 'slave_open_temp_tables';
|
||||
|
||||
# 'master' and 'master1' usually have thread id 2-3 or 3-4.
|
||||
# 'slave' and 'slave1' usually have thread id 2-3.
|
||||
connection slave;
|
||||
create temporary table t1 (a int);
|
||||
connection slave1;
|
||||
create temporary table t1 (a int);
|
||||
# So it's likely that in the binlog of slave we get
|
||||
# server_id=of_master thread_id=3 create temp...
|
||||
# server_id=of_slave thread_id=3 create temp...
|
||||
# which would confuse slave-sec unless slave-sec uses server id to distinguish
|
||||
# between temp tables (here thread id is obviously not enough to distinguish).
|
||||
|
||||
save_master_pos;
|
||||
|
||||
# Second test:
|
||||
|
||||
connection slave_sec;
|
||||
# If we did not use the server id to distinguish between temp tables,
|
||||
# sync_with_master would fail
|
||||
sync_with_master;
|
||||
show status like 'slave_open_temp_tables';
|
||||
|
||||
# Third test (BUG#1240 "slave of slave breaks when STOP SLAVE was issud on
|
||||
# parent slave and temp tables").
|
||||
stop slave;
|
||||
connection slave;
|
||||
insert into t1 values(1);
|
||||
create table t2 as select * from t1;
|
||||
save_master_pos;
|
||||
connection slave_sec;
|
||||
start slave;
|
||||
sync_with_master;
|
||||
show status like 'slave_open_temp_tables';
|
||||
select * from t2;
|
||||
|
||||
# clean up
|
||||
connection slave;
|
||||
drop table t2;
|
||||
save_master_pos;
|
||||
connection slave_sec;
|
||||
sync_with_master;
|
||||
|
||||
# On purpose, we don't delete the temporary tables explicitely.
|
||||
# So temp tables remain on slave (remember they are not deleted when the slave
|
||||
# SQL thread terminates). If you run this test with
|
||||
# --valgrind --valgrind-options=--show-reachable=yes
|
||||
# you will see if they get cleaned up at slave's shutdown (that is, if the
|
||||
# memory they use is freed (it should) by mysqld before it terminates).
|
||||
# If they wouldn't be cleaned up, you would see some "still reachable" blocks in
|
||||
# Valgrind.
|
||||
|
||||
# End of 4.1 tests
|
|
@ -1,24 +0,0 @@
|
|||
require_manager;
|
||||
source include/master-slave.inc;
|
||||
connect (slave_sec,localhost,root,,test,0,slave.sock-1);
|
||||
connect (slave_ter,localhost,root,,test,0,slave.sock-2);
|
||||
connection master;
|
||||
show variables like 'rpl_recovery_rank';
|
||||
show status like 'Rpl_status';
|
||||
create table t1(n int);
|
||||
drop table t1;
|
||||
sync_slave_with_master;
|
||||
show variables like 'rpl_recovery_rank';
|
||||
show status like 'Rpl_status';
|
||||
connection slave_sec;
|
||||
start slave;
|
||||
sync_with_master;
|
||||
show variables like 'rpl_recovery_rank';
|
||||
show status like 'Rpl_status';
|
||||
connection slave_ter;
|
||||
start slave;
|
||||
sync_with_master;
|
||||
show variables like 'rpl_recovery_rank';
|
||||
show status like 'Rpl_status';
|
||||
|
||||
# End of 4.1 tests
|
|
@ -1,58 +0,0 @@
|
|||
# Requires statement logging
|
||||
-- source include/have_binlog_format_statement.inc
|
||||
|
||||
# You must run this test with --manager.
|
||||
|
||||
require_manager;
|
||||
|
||||
# Don't know why, but using TCP/IP connections makes this test fail
|
||||
# with "Lost connection to MySQL server during query" when we
|
||||
# issue a query after the server restart.
|
||||
# Maybe this is something awkward in mysqltest or in the manager?
|
||||
# So we use sockets.
|
||||
connect (master,localhost,root,,test,0,$MASTER_MYPORT);
|
||||
connect (slave,localhost,root,,test,0,slave.sock);
|
||||
|
||||
connection master;
|
||||
reset master;
|
||||
drop table if exists t1;
|
||||
# we use CREATE SELECT to verify that DELETE does not get into binlog
|
||||
# before CREATE SELECT
|
||||
create table t1 engine=HEAP select 10 as a;
|
||||
insert into t1 values(11);
|
||||
save_master_pos;
|
||||
--replace_column 2 # 5 #
|
||||
--replace_regex /table_id: [0-9]+/table_id: #/
|
||||
show binlog events from 79;
|
||||
connection slave;
|
||||
reset slave;
|
||||
start slave;
|
||||
sync_with_master;
|
||||
show create table t1;
|
||||
select * from t1; # should be one row
|
||||
|
||||
server_stop master;
|
||||
server_start master;
|
||||
|
||||
connection master;
|
||||
select * from t1;
|
||||
# to check that DELETE is not written twice
|
||||
# (the LIMIT is to not use the query cache)
|
||||
select * from t1 limit 10;
|
||||
save_master_pos;
|
||||
--replace_column 2 # 5 #
|
||||
--replace_regex /table_id: [0-9]+/table_id: #/
|
||||
show binlog events in 'master-bin.002' from 79;
|
||||
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
select * from t1; # should be empty
|
||||
|
||||
# clean up
|
||||
connection master;
|
||||
drop table t1;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
|
||||
# End of 4.1 tests
|
Loading…
Reference in a new issue