Commit 554b1f01 authored by msvensson@neptunus.(none)'s avatar msvensson@neptunus.(none)

Merge neptunus.(none):/home/msvensson/mysql/mysql-5.1

into  neptunus.(none):/home/msvensson/mysql/mysql-5.1-new-maint
parents ae052828 e6348e02
...@@ -82,9 +82,6 @@ ...@@ -82,9 +82,6 @@
#define MAX_EXPECTED_ERRORS 10 #define MAX_EXPECTED_ERRORS 10
#define QUERY_SEND 1 #define QUERY_SEND 1
#define QUERY_REAP 2 #define QUERY_REAP 2
#ifndef MYSQL_MANAGER_PORT
#define MYSQL_MANAGER_PORT 23546
#endif
#define MAX_SERVER_ARGS 64 #define MAX_SERVER_ARGS 64
...@@ -96,11 +93,10 @@ ...@@ -96,11 +93,10 @@
#define RESULT_CONTENT_MISMATCH 1 #define RESULT_CONTENT_MISMATCH 1
#define RESULT_LENGTH_MISMATCH 2 #define RESULT_LENGTH_MISMATCH 2
enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD, enum {OPT_SKIP_SAFEMALLOC=256, OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT,
OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT, OPT_SKIP_SAFEMALLOC, OPT_SSL_CA, OPT_SSL_CAPATH, OPT_SSL_CIPHER, OPT_PS_PROTOCOL,
OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
OPT_SSL_CIPHER,OPT_PS_PROTOCOL,OPT_SP_PROTOCOL,OPT_CURSOR_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}; OPT_MARK_PROGRESS};
/* ************************************************************************ */ /* ************************************************************************ */
...@@ -160,11 +156,6 @@ static my_bool sp_protocol= 0, sp_protocol_enabled= 0; ...@@ -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 view_protocol= 0, view_protocol_enabled= 0;
static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0; static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0;
static int parsing_disabled= 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 char **default_argv;
static const char *load_default_groups[]= { "mysqltest","client",0 }; static const char *load_default_groups[]= { "mysqltest","client",0 };
...@@ -180,7 +171,7 @@ typedef struct ...@@ -180,7 +171,7 @@ typedef struct
static test_file file_stack[MAX_INCLUDE_DEPTH]; static test_file file_stack[MAX_INCLUDE_DEPTH];
static test_file* cur_file; static test_file* cur_file;
static test_file* file_stack_end; static test_file* file_stack_end;
uint start_lineno; /* Start line of query */ uint start_lineno= 0; /* Start line of query */
/* Stores regex substitutions */ /* Stores regex substitutions */
...@@ -335,7 +326,6 @@ Q_RPL_PROBE, Q_ENABLE_RPL_PARSE, ...@@ -335,7 +326,6 @@ Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT, Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG, Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG, Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG,
Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER,
Q_WAIT_FOR_SLAVE_TO_STOP, Q_WAIT_FOR_SLAVE_TO_STOP,
Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS, Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
Q_ENABLE_PS_WARNINGS, Q_DISABLE_PS_WARNINGS, Q_ENABLE_PS_WARNINGS, Q_DISABLE_PS_WARNINGS,
...@@ -347,11 +337,10 @@ Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS, ...@@ -347,11 +337,10 @@ Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS,
Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL,
Q_START_TIMER, Q_END_TIMER, Q_START_TIMER, Q_END_TIMER,
Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL, Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL,
Q_EXIT,
Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT, Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT,
Q_IF, Q_IF,
Q_DISABLE_PARSING, Q_ENABLE_PARSING, Q_DISABLE_PARSING, Q_ENABLE_PARSING,
Q_REPLACE_REGEX, Q_REPLACE_REGEX, Q_DIE,
Q_UNKNOWN, /* Unknown command. */ Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */ Q_COMMENT, /* Comments, ignored. */
...@@ -409,9 +398,6 @@ const char *command_names[]= ...@@ -409,9 +398,6 @@ const char *command_names[]=
/* Enable/disable that the _result_ from a query is logged to result file */ /* Enable/disable that the _result_ from a query is logged to result file */
"enable_result_log", "enable_result_log",
"disable_result_log", "disable_result_log",
"server_start",
"server_stop",
"require_manager",
"wait_for_slave_to_stop", "wait_for_slave_to_stop",
"enable_warnings", "enable_warnings",
"disable_warnings", "disable_warnings",
...@@ -434,13 +420,13 @@ const char *command_names[]= ...@@ -434,13 +420,13 @@ const char *command_names[]=
"character_set", "character_set",
"disable_ps_protocol", "disable_ps_protocol",
"enable_ps_protocol", "enable_ps_protocol",
"exit",
"disable_reconnect", "disable_reconnect",
"enable_reconnect", "enable_reconnect",
"if", "if",
"disable_parsing", "disable_parsing",
"enable_parsing", "enable_parsing",
"replace_regex", "replace_regex",
"die",
0 0
}; };
...@@ -610,10 +596,7 @@ static void free_used_memory() ...@@ -610,10 +596,7 @@ static void free_used_memory()
{ {
uint i; uint i;
DBUG_ENTER("free_used_memory"); DBUG_ENTER("free_used_memory");
#ifndef EMBEDDED_LIBRARY
if (manager)
mysql_manager_close(manager);
#endif
close_cons(); close_cons();
close_files(); close_files();
hash_free(&var_hash); hash_free(&var_hash);
...@@ -660,7 +643,7 @@ static void die(const char *fmt, ...) ...@@ -660,7 +643,7 @@ static void die(const char *fmt, ...)
if (cur_file && cur_file != file_stack) if (cur_file && cur_file != file_stack)
fprintf(stderr, "In included file \"%s\": ", fprintf(stderr, "In included file \"%s\": ",
cur_file->file_name); cur_file->file_name);
if (start_lineno != 0) if (start_lineno > 0)
fprintf(stderr, "At line %u: ", start_lineno); fprintf(stderr, "At line %u: ", start_lineno);
vfprintf(stderr, fmt, args); vfprintf(stderr, fmt, args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
...@@ -682,17 +665,43 @@ static void die(const char *fmt, ...) ...@@ -682,17 +665,43 @@ static void die(const char *fmt, ...)
exit(1); 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"); DBUG_ENTER("abort_not_supported_test");
/* Print include filestack */
fprintf(stderr, "The test '%s' is not supported by this installation\n", fprintf(stderr, "The test '%s' is not supported by this installation\n",
fname); file_stack->file_name);
if (!silent) fprintf(stderr, "Detected in file %s at line %d\n",
printf("skipped\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(); free_used_memory();
my_end(MY_CHECK_ERROR); my_end(MY_CHECK_ERROR);
if (!silent)
printf("skipped\n");
exit(62); exit(62);
} }
...@@ -704,13 +713,13 @@ static void verbose_msg(const char *fmt, ...) ...@@ -704,13 +713,13 @@ static void verbose_msg(const char *fmt, ...)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
va_start(args, fmt); va_start(args, fmt);
fprintf(stderr, "mysqltest: "); fprintf(stderr, "mysqltest: ");
if (start_lineno != 0) if (start_lineno != 0)
fprintf(stderr, "At line %u: ", start_lineno); fprintf(stderr, "At line %u: ", start_lineno);
vfprintf(stderr, fmt, args); vfprintf(stderr, fmt, args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
va_end(args); va_end(args);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -736,10 +745,10 @@ static int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) ...@@ -736,10 +745,10 @@ static int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
if (!test_if_hard_path(fname)) if (!test_if_hard_path(fname))
{ {
strxmov(eval_file, opt_basedir, fname, NullS); strxmov(eval_file, opt_basedir, fname, NullS);
fn_format(eval_file, eval_file,"","",4); fn_format(eval_file, eval_file, "", "", MY_UNPACK_FILENAME);
} }
else 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))) if (!my_stat(eval_file, &stat_info, MYF(MY_WME)))
die(NullS); die(NullS);
...@@ -780,8 +789,9 @@ static int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) ...@@ -780,8 +789,9 @@ static int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
err: err:
if (res && eval_result) if (res && eval_result)
str_to_file(fn_format(eval_file, fname, "", ".eval",2), res_ptr, str_to_file(fn_format(eval_file, fname, "", ".eval",
res_len); MY_REPLACE_EXT),
res_ptr, res_len);
my_free((gptr) tmp, MYF(0)); my_free((gptr) tmp, MYF(0));
my_close(fd, MYF(MY_WME)); my_close(fd, MYF(MY_WME));
...@@ -811,7 +821,11 @@ static void check_result(DYNAMIC_STRING* ds, const char *fname, ...@@ -811,7 +821,11 @@ static void check_result(DYNAMIC_STRING* ds, const char *fname,
DBUG_ENTER("check_result"); DBUG_ENTER("check_result");
if (res && require_option) 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) { switch (res) {
case RESULT_OK: case RESULT_OK:
break; /* ok */ break; /* ok */
...@@ -956,7 +970,7 @@ int open_file(const char *name) ...@@ -956,7 +970,7 @@ int open_file(const char *name)
strxmov(buff, opt_basedir, name, NullS); strxmov(buff, opt_basedir, name, NullS);
name=buff; name=buff;
} }
fn_format(buff,name,"","",4); fn_format(buff, name, "", "", MY_UNPACK_FILENAME);
if (cur_file == file_stack_end) if (cur_file == file_stack_end)
die("Source directives are nesting too deep"); die("Source directives are nesting too deep");
...@@ -1030,57 +1044,6 @@ int do_wait_for_slave_to_stop(struct st_query *q __attribute__((unused))) ...@@ -1030,57 +1044,6 @@ int do_wait_for_slave_to_stop(struct st_query *q __attribute__((unused)))
return 0; 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 Source and execute the given file
...@@ -1919,7 +1882,7 @@ static void set_charset(struct st_query *q) ...@@ -1919,7 +1882,7 @@ static void set_charset(struct st_query *q)
q->last_argument= p; q->last_argument= p;
charset_info= get_charset_by_csname(charset_name,MY_CS_PRIMARY,MYF(MY_WME)); charset_info= get_charset_by_csname(charset_name,MY_CS_PRIMARY,MYF(MY_WME));
if (!charset_info) 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) static uint get_errcodes(match_err *to,struct st_query *q)
...@@ -2473,19 +2436,6 @@ char* safe_get_param(char *str, char** arg, const char *msg) ...@@ -2473,19 +2436,6 @@ char* safe_get_param(char *str, char** arg, const char *msg)
DBUG_RETURN(str); 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. Connect to a server doing several retries if needed.
...@@ -2770,7 +2720,7 @@ int do_connect(struct st_query *q) ...@@ -2770,7 +2720,7 @@ int do_connect(struct st_query *q)
} }
#endif #endif
if (con_sock && !free_con_sock && *con_sock && *con_sock != FN_LIBCHAR) 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]) if (!con_db[0])
con_db= db; con_db= db;
/* Special database to allow one to connect without a database name */ /* Special database to allow one to connect without a database name */
...@@ -3287,20 +3237,6 @@ static struct my_option my_long_options[] = ...@@ -3287,20 +3237,6 @@ static struct my_option my_long_options[] =
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"include", 'i', "Include SQL before each test case.", (gptr*) &opt_include, {"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}, (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, {"mark-progress", OPT_MARK_PROGRESS,
"Write linenumber and elapsed time to <testname>.progress ", "Write linenumber and elapsed time to <testname>.progress ",
(gptr*) &opt_mark_progress, (gptr*) &opt_mark_progress, 0, (gptr*) &opt_mark_progress, (gptr*) &opt_mark_progress, 0,
...@@ -3397,11 +3333,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -3397,11 +3333,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'r': case 'r':
record = 1; record = 1;
break; 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': case 'x':
{ {
char buff[FN_REFLEN]; char buff[FN_REFLEN];
...@@ -3410,7 +3341,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -3410,7 +3341,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
strxmov(buff, opt_basedir, argument, NullS); strxmov(buff, opt_basedir, argument, NullS);
argument= buff; argument= buff;
} }
fn_format(buff, argument, "", "", 4); fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0); DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
if (!(cur_file->file= if (!(cur_file->file=
my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0)))) my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0))))
...@@ -3427,7 +3358,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -3427,7 +3358,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
strxmov(buff, opt_basedir, argument, NullS); strxmov(buff, opt_basedir, argument, NullS);
argument= buff; argument= buff;
} }
fn_format(buff, argument, "", "", 4); fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
timer_file= buff; timer_file= buff;
unlink(timer_file); /* Ignore error, may not exist */ unlink(timer_file); /* Ignore error, may not exist */
break; break;
...@@ -3521,7 +3452,7 @@ static void str_to_file(const char *fname, char *str, int size) ...@@ -3521,7 +3452,7 @@ static void str_to_file(const char *fname, char *str, int size)
strxmov(buff, opt_basedir, fname, NullS); strxmov(buff, opt_basedir, fname, NullS);
fname= buff; 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, if ((fd= my_open(buff, O_WRONLY | O_CREAT | O_TRUNC,
MYF(MY_WME | MY_FFNF))) < 0) MYF(MY_WME | MY_FFNF))) < 0)
...@@ -3535,19 +3466,24 @@ static void str_to_file(const char *fname, char *str, int size) ...@@ -3535,19 +3466,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) void dump_result_to_reject_file(const char *record_file, char *buf, int size)
{ {
char reject_file[FN_REFLEN]; 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) void dump_result_to_log_file(const char *record_file, char *buf, int size)
{ {
char log_file[FN_REFLEN]; 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) void dump_progress(const char *record_file)
{ {
char log_file[FN_REFLEN]; 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); ds_progress.str, ds_progress.length);
} }
...@@ -4358,7 +4294,9 @@ static void handle_error(const char *query, struct st_query *q, ...@@ -4358,7 +4294,9 @@ static void handle_error(const char *query, struct st_query *q,
if (err_errno == CR_SERVER_LOST || if (err_errno == CR_SERVER_LOST ||
err_errno == CR_SERVER_GONE_ERROR) err_errno == CR_SERVER_GONE_ERROR)
die("require query '%s' failed: %d: %s", query, err_errno, err_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) if (q->abort_on_error)
...@@ -5139,7 +5077,7 @@ static void init_var_hash(MYSQL *mysql) ...@@ -5139,7 +5077,7 @@ static void init_var_hash(MYSQL *mysql)
test run completes 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; char buf[32], *end;
ulonglong timer= timer_now(); ulonglong timer= timer_now();
...@@ -5174,7 +5112,7 @@ static void mark_progress(struct st_query* q, int line) ...@@ -5174,7 +5112,7 @@ static void mark_progress(struct st_query* q, int line)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
struct st_query *q; 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; query_executed= 0;
char save_file[FN_REFLEN]; char save_file[FN_REFLEN];
MY_STAT res_info; MY_STAT res_info;
...@@ -5224,10 +5162,6 @@ int main(int argc, char **argv) ...@@ -5224,10 +5162,6 @@ int main(int argc, char **argv)
cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME)); cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME));
cur_file->lineno= 1; cur_file->lineno= 1;
} }
#ifndef EMBEDDED_LIBRARY
if (manager_host)
init_manager();
#endif
init_re(); init_re();
ps_protocol_enabled= ps_protocol; ps_protocol_enabled= ps_protocol;
sp_protocol_enabled= sp_protocol; sp_protocol_enabled= sp_protocol;
...@@ -5281,7 +5215,7 @@ int main(int argc, char **argv) ...@@ -5281,7 +5215,7 @@ int main(int argc, char **argv)
open_file(opt_include); open_file(opt_include);
} }
while (!abort_flag && !read_query(&q)) while (!read_query(&q))
{ {
int current_line_inc = 1, processed = 0; int current_line_inc = 1, processed = 0;
if (q->type == Q_UNKNOWN || q->type == Q_COMMENT_WITH_COMMAND) if (q->type == Q_UNKNOWN || q->type == Q_COMMENT_WITH_COMMAND)
...@@ -5319,11 +5253,6 @@ int main(int argc, char **argv) ...@@ -5319,11 +5253,6 @@ int main(int argc, char **argv)
case Q_SLEEP: do_sleep(q, 0); break; case Q_SLEEP: do_sleep(q, 0); break;
case Q_REAL_SLEEP: do_sleep(q, 1); 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_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_INC: do_modify_var(q, DO_INC); break;
case Q_DEC: do_modify_var(q, DO_DEC); break; case Q_DEC: do_modify_var(q, DO_DEC); break;
case Q_ECHO: do_echo(q); query_executed= 1; break; case Q_ECHO: do_echo(q); query_executed= 1; break;
...@@ -5501,8 +5430,8 @@ int main(int argc, char **argv) ...@@ -5501,8 +5430,8 @@ int main(int argc, char **argv)
parsing_disabled--; parsing_disabled--;
break; break;
case Q_EXIT: case Q_DIE:
abort_flag= 1; die("%s", q->first_argument);
break; break;
default: default:
...@@ -5622,7 +5551,7 @@ static int read_server_arguments(const char *name) ...@@ -5622,7 +5551,7 @@ static int read_server_arguments(const char *name)
strxmov(buff, opt_basedir, name, NullS); strxmov(buff, opt_basedir, name, NullS);
name=buff; name=buff;
} }
fn_format(buff,name,"","",4); fn_format(buff, name, "", "", MY_UNPACK_FILENAME);
if (!embedded_server_arg_count) if (!embedded_server_arg_count)
{ {
......
--require r/true.require --require r/not_ndb_default.require
disable_query_log; disable_query_log;
select convert(@@table_type using latin1) NOT IN ("ndbcluster","NDBCLUSTER") as "TRUE"; select convert(@@table_type using latin1) NOT IN ("ndbcluster","NDBCLUSTER") as "TRUE";
enable_query_log; enable_query_log;
--require r/true.require --require r/not_windows.require
disable_query_log; disable_query_log;
select convert(@@version_compile_os using latin1) NOT IN ("Win32","Win64","Windows") as "TRUE"; select convert(@@version_compile_os using latin1) NOT IN ("Win32","Win64","Windows") as "TRUE";
enable_query_log; enable_query_log;
#
# 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
--require r/true.require --require r/windows.require
disable_query_log; disable_query_log;
select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows") as "TRUE"; select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows") as "TRUE";
enable_query_log; enable_query_log;
...@@ -11,6 +11,7 @@ sub mtr_get_opts_from_file ($); ...@@ -11,6 +11,7 @@ sub mtr_get_opts_from_file ($);
sub mtr_fromfile ($); sub mtr_fromfile ($);
sub mtr_tofile ($@); sub mtr_tofile ($@);
sub mtr_tonewfile($@); sub mtr_tonewfile($@);
sub mtr_lastlinefromfile($);
############################################################################## ##############################################################################
# #
...@@ -113,6 +114,20 @@ sub mtr_fromfile ($) { ...@@ -113,6 +114,20 @@ sub mtr_fromfile ($) {
return $text; 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 ($@) { sub mtr_tofile ($@) {
my $file= shift; my $file= shift;
...@@ -129,5 +144,4 @@ sub mtr_tonewfile ($@) { ...@@ -129,5 +144,4 @@ sub mtr_tonewfile ($@) {
close FILE; close FILE;
} }
1; 1;
...@@ -272,10 +272,10 @@ sub spawn_parent_impl { ...@@ -272,10 +272,10 @@ sub spawn_parent_impl {
last; last;
} }
# If one of the processes died, we want to # One of the child processes died, unless this was expected
# mark this, and kill the mysqltest process. # mysqltest should be killed and test aborted
mark_process_dead($ret_pid); check_expected_crash_and_restart($ret_pid);
} }
if ( $ret_pid != $pid ) if ( $ret_pid != $pid )
...@@ -811,6 +811,81 @@ sub mark_process_dead($) ...@@ -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, # The operating system will keep information about dead children,
......
...@@ -1806,6 +1806,10 @@ sub ndbd_start ($$$) { ...@@ -1806,6 +1806,10 @@ sub ndbd_start ($$$) {
# Add pid to list of pids for this cluster # Add pid to list of pids for this cluster
$cluster->{'ndbds'}->[$idx]->{'pid'}= $pid; $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"); mtr_verbose("ndbd_start, pid: $pid");
return $pid; return $pid;
...@@ -2343,8 +2347,11 @@ sub run_testcase ($) { ...@@ -2343,8 +2347,11 @@ sub run_testcase ($) {
elsif ( $res == 62 ) elsif ( $res == 62 )
{ {
# Testcase itself tell us to skip this one # 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); mtr_report_test_skipped($tinfo);
} }
elsif ( $res == 63 ) elsif ( $res == 63 )
...@@ -2904,6 +2911,7 @@ sub mysqld_start ($$$) { ...@@ -2904,6 +2911,7 @@ sub mysqld_start ($$$) {
# Remember options used when starting # Remember options used when starting
$mysqld->{'start_opts'}= $extra_opt; $mysqld->{'start_opts'}= $extra_opt;
$mysqld->{'start_slave_master_info'}= $slave_master_info;
mtr_verbose("mysqld pid: $pid"); mtr_verbose("mysqld pid: $pid");
return $pid; return $pid;
......
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
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;
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;
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
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;
--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;
...@@ -41,5 +41,5 @@ rpl_sp_effects : BUG#19862 2006-06-15 mkindahl ...@@ -41,5 +41,5 @@ rpl_sp_effects : BUG#19862 2006-06-15 mkindahl
rpl_ndb_idempotent : BUG#21298 2006-07-27 msvensson rpl_ndb_idempotent : BUG#21298 2006-07-27 msvensson
rpl_row_basic_7ndb : BUG#21298 2006-07-27 msvensson rpl_row_basic_7ndb : BUG#21298 2006-07-27 msvensson
rpl_truncate_7ndb : BUG#21298 2006-07-27 msvensson rpl_truncate_7ndb : BUG#21298 2006-07-27 msvensson
crash_commit_before : 2006-08-02 msvensson
rpl_ndb_dd_advance : BUG#18679 2006-07-28 jimw (Test fails randomly) rpl_ndb_dd_advance : BUG#18679 2006-07-28 jimw (Test fails randomly)
#
# 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
# 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
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
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment