diff options
Diffstat (limited to 'client/mysqltest.cc')
-rw-r--r-- | client/mysqltest.cc | 398 |
1 files changed, 277 insertions, 121 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index c2f72d600d3..26a304a1489 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -33,7 +33,7 @@ And many others */ -#define MTEST_VERSION "3.3" +#define MTEST_VERSION "3.4" #include "client_priv.h" #include <mysql_version.h> @@ -78,6 +78,8 @@ static my_bool non_blocking_api_enabled= 0; #define MAX_DELIMITER_LENGTH 16 #define DEFAULT_MAX_CONN 64 +#define DIE_BUFF_SIZE 8192 + /* Flags controlling send and reap */ #define QUERY_SEND_FLAG 1 #define QUERY_REAP_FLAG 2 @@ -108,6 +110,7 @@ static int opt_port= 0; static int opt_max_connect_retries; static int opt_result_format_version; static int opt_max_connections= DEFAULT_MAX_CONN; +static int error_count= 0; static my_bool opt_compress= 0, silent= 0, verbose= 0; static my_bool debug_info_flag= 0, debug_check_flag= 0; static my_bool tty_password= 0; @@ -124,7 +127,7 @@ static my_bool disable_connect_log= 1; static my_bool disable_warnings= 0, disable_column_names= 0; static my_bool prepare_warnings_enabled= 0; static my_bool disable_info= 1; -static my_bool abort_on_error= 1; +static my_bool abort_on_error= 1, opt_continue_on_error= 0; static my_bool server_initialized= 0; static my_bool is_windows= 0; static char **default_argv; @@ -563,14 +566,15 @@ const char *from, int len); static void cleanup_and_exit(int exit_code) __attribute__((noreturn)); -void die(const char *fmt, ...) - ATTRIBUTE_FORMAT(printf, 1, 2) __attribute__((noreturn)); -void abort_not_supported_test(const char *fmt, ...) - ATTRIBUTE_FORMAT(printf, 1, 2) __attribute__((noreturn)); -void verbose_msg(const char *fmt, ...) - ATTRIBUTE_FORMAT(printf, 1, 2); -void log_msg(const char *fmt, ...) - ATTRIBUTE_FORMAT(printf, 1, 2); +void really_die(const char *msg) __attribute__((noreturn)); +void report_or_die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); +void die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2) + __attribute__((noreturn)); +static void make_error_message(char *buf, size_t len, const char *fmt, va_list args); +void abort_not_supported_test(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2) + __attribute__((noreturn)); +void verbose_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); +void log_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); VAR* var_from_env(const char *, const char *); VAR* var_init(VAR* v, const char *name, int name_len, const char *val, @@ -816,6 +820,9 @@ void handle_error(struct st_command*, void handle_no_error(struct st_command*); void revert_properties(); +static void handle_no_active_connection(struct st_command* command, + struct st_connection *cn, DYNAMIC_STRING *ds); + #ifdef EMBEDDED_LIBRARY #define EMB_SEND_QUERY 1 @@ -987,7 +994,10 @@ void do_eval(DYNAMIC_STRING *query_eval, const char *query, else { if (!(v= var_get(p, &p, 0, 0))) - die("Bad variable in eval"); + { + report_or_die( "Bad variable in eval"); + return; + } dynstr_append_mem(query_eval, v->str_val, v->str_val_len); } break; @@ -1274,9 +1284,13 @@ void handle_command_error(struct st_command *command, uint error, int i; if (command->abort_on_error) - die("command \"%.*s\" failed with error: %u my_errno: %d errno: %d", + { + report_or_die("command \"%.*s\" failed with error: %u my_errno: %d " + "errno: %d", command->first_word_len, command->query, error, my_errno, sys_errno); + return; + } i= match_expected_error(command, error, NULL); @@ -1289,14 +1303,17 @@ void handle_command_error(struct st_command *command, uint error, DBUG_VOID_RETURN; } if (command->expected_errors.count > 0) - die("command \"%.*s\" failed with wrong error: %u my_errno: %d errno: %d", - command->first_word_len, command->query, error, my_errno, sys_errno); + report_or_die("command \"%.*s\" failed with wrong error: %u " + "my_errno: %d errno: %d", + command->first_word_len, command->query, error, my_errno, + sys_errno); } else if (command->expected_errors.err[0].type == ERR_ERRNO && command->expected_errors.err[0].code.errnum != 0) { /* Error code we wanted was != 0, i.e. not an expected success */ - die("command \"%.*s\" succeeded - should have failed with errno %d...", + report_or_die("command \"%.*s\" succeeded - should have failed with " + "errno %d...", command->first_word_len, command->query, command->expected_errors.err[0].code.errnum); } @@ -1441,50 +1458,59 @@ static void cleanup_and_exit(int exit_code) exit(exit_code); } -void print_file_stack() +size_t print_file_stack(char *s, const char *end) { + char *start= s; struct st_test_file* err_file= cur_file; if (err_file == file_stack) - return; + return 0; for (;;) { err_file--; - fprintf(stderr, "included from %s at line %d:\n", - err_file->file_name, err_file->lineno); + s+= my_snprintf(s, end - s, "included from %s at line %d:\n", + err_file->file_name, err_file->lineno); if (err_file == file_stack) break; } + return s - start; } -void die(const char *fmt, ...) -{ - static int dying= 0; - va_list args; - DBUG_ENTER("die"); - DBUG_PRINT("enter", ("start_lineno: %d", start_lineno)); - fflush(stdout); - /* Print the error message */ - fprintf(stderr, "mysqltest: "); +static void make_error_message(char *buf, size_t len, const char *fmt, va_list args) +{ + char *s= buf, *end= buf + len; + s+= my_snprintf(s, end - s, "mysqltest: "); if (cur_file && cur_file != file_stack) { - fprintf(stderr, "In included file \"%s\": \n", - cur_file->file_name); - print_file_stack(); + s+= my_snprintf(s, end - s, "In included file \"%s\": \n", + cur_file->file_name); + s+= print_file_stack(s, end); } if (start_lineno > 0) - fprintf(stderr, "At line %u: ", start_lineno); - if (fmt) - { - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - } - else - fprintf(stderr, "unknown error"); - fprintf(stderr, "\n"); + s+= my_snprintf(s, end -s, "At line %u: ", start_lineno); + if (!fmt) + fmt= "unknown error"; + + s+= my_vsnprintf(s, end - s, fmt, args); + s+= my_snprintf(s, end -s, "\n", start_lineno); +} + +void die(const char *fmt, ...) +{ + char buff[DIE_BUFF_SIZE]; + va_list args; + va_start(args, fmt); + make_error_message(buff, sizeof(buff), fmt, args); + really_die(buff); +} + +void really_die(const char *msg) +{ + static int dying= 0; + fflush(stdout); + fprintf(stderr, "%s", msg); fflush(stderr); /* @@ -1508,6 +1534,28 @@ void die(const char *fmt, ...) cleanup_and_exit(1); } +void report_or_die(const char *fmt, ...) +{ + va_list args; + DBUG_ENTER("report_or_die"); + + char buff[DIE_BUFF_SIZE]; + + va_start(args, fmt); + make_error_message(buff, sizeof(buff), fmt, args); + va_end(args); + + if (opt_continue_on_error) + { + /* Just log the error and continue */ + replace_dynstr_append(&ds_res, buff); + error_count++; + DBUG_VOID_RETURN; + } + + really_die(buff); +} + void abort_not_supported_test(const char *fmt, ...) { @@ -1520,7 +1568,10 @@ void abort_not_supported_test(const char *fmt, ...) file_stack->file_name); fprintf(stderr, "Detected in file %s at line %d\n", cur_file->file_name, cur_file->lineno); - print_file_stack(); + + char buff[DIE_BUFF_SIZE]; + print_file_stack(buff, buff + sizeof(buff)); + fprintf(stderr, "%s", buff); /* Print error message */ va_start(args, fmt); @@ -1652,7 +1703,10 @@ static int run_command(char* cmd, DBUG_PRINT("enter", ("cmd: %s", cmd)); if (!(res_file= popen(cmd, "r"))) - die("popen(\"%s\", \"r\") failed", cmd); + { + report_or_die("popen(\"%s\", \"r\") failed", cmd); + return -1; + } while (fgets(buf, sizeof(buf), res_file)) { @@ -1752,7 +1806,10 @@ static int diff_check(const char *diff_name) if (!(res_file= popen(buf, "r"))) die("popen(\"%s\", \"r\") failed", buf); - /* if diff is not present, nothing will be in stdout to increment have_diff */ + /* + if diff is not present, nothing will be in stdout to increment + have_diff + */ if (fgets(buf, sizeof(buf), res_file)) have_diff= 1; @@ -2065,7 +2122,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) void check_result() { - const char* mess= "Result content mismatch\n"; + const char *mess= 0; DBUG_ENTER("check_result"); DBUG_ASSERT(result_file_name); @@ -2073,9 +2130,13 @@ void check_result() switch (compare_files(log_file.file_name(), result_file_name)) { case RESULT_OK: - break; /* ok */ + if (!error_count) + break; /* ok */ + mess= "Got errors while running test"; + /* Fallthrough */ case RESULT_LENGTH_MISMATCH: - mess= "Result length mismatch\n"; + if (!mess) + mess= "Result length mismatch\n"; /* Fallthrough */ case RESULT_CONTENT_MISMATCH: { @@ -2085,6 +2146,10 @@ void check_result() */ char reject_file[FN_REFLEN]; size_t reject_length; + + if (!mess) + mess= "Result content mismatch\n"; + dirname_part(reject_file, result_file_name, &reject_length); if (access(reject_file, W_OK) == 0) @@ -2184,8 +2249,8 @@ static int strip_surrounding(char* str, char c1, char c2) static void strip_parentheses(struct st_command *command) { if (strip_surrounding(command->first_argument, '(', ')')) - die("%.*s - argument list started with '%c' must be ended with '%c'", - command->first_word_len, command->query, '(', ')'); + die("%.*s - argument list started with '%c' must be ended with '%c'", + command->first_word_len, command->query, '(', ')'); } @@ -2504,6 +2569,19 @@ void var_query_set(VAR *var, const char *query, const char** query_end) DBUG_ENTER("var_query_set"); LINT_INIT(res); + if (!mysql) + { + struct st_command command; + memset(&command, 0, sizeof(command)); + command.query= (char*)query; + command.first_word_len= (*query_end - query); + command.first_argument= command.query + command.first_word_len; + command.end= (char*)*query_end; + command.abort_on_error= 1; /* avoid uninitialized variables */ + handle_no_active_connection(&command, cur_con, &ds_res); + DBUG_VOID_RETURN; + } + /* Only white space or ) allowed past ending ` */ while (end > query && *end != '`') { @@ -2522,8 +2600,8 @@ void var_query_set(VAR *var, const char *query, const char** query_end) if (mysql_real_query(mysql, ds_query.str, ds_query.length)) { - handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), - mysql_sqlstate(mysql), &ds_res); + handle_error(curr_command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), &ds_res); /* If error was acceptable, return empty string */ dynstr_free(&ds_query); eval_expr(var, "", 0); @@ -2531,7 +2609,12 @@ void var_query_set(VAR *var, const char *query, const char** query_end) } if (!(res= mysql_store_result(mysql))) - die("Query '%s' didn't return a result set", ds_query.str); + { + report_or_die("Query '%s' didn't return a result set", ds_query.str); + dynstr_free(&ds_query); + eval_expr(var, "", 0); + return; + } dynstr_free(&ds_query); if ((row= mysql_fetch_row(res)) && row[0]) @@ -2678,6 +2761,12 @@ void var_set_query_get_value(struct st_command *command, VAR *var) DBUG_ENTER("var_set_query_get_value"); LINT_INIT(res); + if (!mysql) + { + handle_no_active_connection(command, cur_con, &ds_res); + DBUG_VOID_RETURN; + } + strip_parentheses(command); DBUG_PRINT("info", ("query: %s", command->query)); check_command_args(command, command->first_argument, query_get_value_args, @@ -2700,16 +2789,23 @@ void var_set_query_get_value(struct st_command *command, VAR *var) /* Run the query */ if (mysql_real_query(mysql, ds_query.str, ds_query.length)) { - handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), - mysql_sqlstate(mysql), &ds_res); + handle_error(curr_command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), &ds_res); /* If error was acceptable, return empty string */ dynstr_free(&ds_query); + dynstr_free(&ds_col); eval_expr(var, "", 0); DBUG_VOID_RETURN; } if (!(res= mysql_store_result(mysql))) - die("Query '%s' didn't return a result set", ds_query.str); + { + report_or_die("Query '%s' didn't return a result set", ds_query.str); + dynstr_free(&ds_query); + dynstr_free(&ds_col); + eval_expr(var, "", 0); + return; + } { /* Find column number from the given column name */ @@ -2729,8 +2825,11 @@ void var_set_query_get_value(struct st_command *command, VAR *var) if (col_no == -1) { mysql_free_result(res); - die("Could not find column '%s' in the result of '%s'", - ds_col.str, ds_query.str); + report_or_die("Could not find column '%s' in the result of '%s'", + ds_col.str, ds_query.str); + dynstr_free(&ds_query); + dynstr_free(&ds_col); + return; } DBUG_PRINT("info", ("Found column %d with name '%s'", i, fields[i].name)); @@ -2838,6 +2937,7 @@ void eval_expr(VAR *v, const char *p, const char **p_end, command.first_word_len= len; command.first_argument= command.query + len; command.end= (char*)*p_end; + command.abort_on_error= 1; /* avoid uninitialized variables */ var_set_query_get_value(&command, v); DBUG_VOID_RETURN; } @@ -3169,7 +3269,10 @@ void do_exec(struct st_command *command) while (*cmd && my_isspace(charset_info, *cmd)) cmd++; if (!*cmd) - die("Missing argument in exec"); + { + report_or_die("Missing argument in exec"); + return; + } command->last_argument= command->end; init_dynamic_string(&ds_cmd, 0, command->query_len+256, 256); @@ -3201,10 +3304,12 @@ void do_exec(struct st_command *command) DBUG_PRINT("info", ("Executing '%s' as '%s'", command->first_argument, ds_cmd.str)); - if (!(res_file= my_popen(&ds_cmd, "r")) && command->abort_on_error) + if (!(res_file= my_popen(&ds_cmd, "r"))) { dynstr_free(&ds_cmd); - die("popen(\"%s\", \"r\") failed", command->first_argument); + if (command->abort_on_error) + report_or_die("popen(\"%s\", \"r\") failed", command->first_argument); + return; } ds_result= &ds_res; @@ -3241,11 +3346,12 @@ void do_exec(struct st_command *command) if (command->abort_on_error) { - log_msg("exec of '%s' failed, error: %d, status: %d, errno: %d", - ds_cmd.str, error, status, errno); + report_or_die("exec of '%s' failed, error: %d, status: %d, errno: %d\n" + "Output from before failure:\n%s\n", + ds_cmd.str, error, status, errno, + ds_res.str); dynstr_free(&ds_cmd); - die("command \"%s\" failed\n\nOutput from before failure:\n%s\n", - command->first_argument, ds_res.str); + return; } DBUG_PRINT("info", @@ -3260,8 +3366,8 @@ void do_exec(struct st_command *command) { dynstr_free(&ds_cmd); if (command->expected_errors.count > 0) - die("command \"%s\" failed with wrong error: %d", - command->first_argument, status); + report_or_die("command \"%s\" failed with wrong error: %d", + command->first_argument, status); } } else if (command->expected_errors.err[0].type == ERR_ERRNO && @@ -3271,8 +3377,10 @@ void do_exec(struct st_command *command) log_msg("exec of '%s failed, error: %d, errno: %d", ds_cmd.str, error, errno); dynstr_free(&ds_cmd); - die("command \"%s\" succeeded - should have failed with errno %d...", - command->first_argument, command->expected_errors.err[0].code.errnum); + report_or_die("command \"%s\" succeeded - should have failed with " + "errno %d...", + command->first_argument, + command->expected_errors.err[0].code.errnum); } dynstr_free(&ds_cmd); @@ -3306,7 +3414,8 @@ int do_modify_var(struct st_command *command, const char *p= command->first_argument; VAR* v; if (!*p) - die("Missing argument to %.*s", command->first_word_len, command->query); + die("Missing argument to %.*s", command->first_word_len, + command->query); if (*p != '$') die("The argument to %.*s must be a variable (start with $)", command->first_word_len, command->query); @@ -3372,7 +3481,10 @@ void do_system(struct st_command *command) DBUG_ENTER("do_system"); if (strlen(command->first_argument) == 0) - die("Missing arguments to system, nothing to do!"); + { + report_or_die("Missing arguments to system, nothing to do!"); + return; + } init_dynamic_string(&ds_cmd, 0, command->query_len + 64, 256); @@ -3393,12 +3505,14 @@ void do_system(struct st_command *command) if (my_system(&ds_cmd)) { if (command->abort_on_error) - die("system command '%s' failed", command->first_argument); - - /* If ! abort_on_error, log message and continue */ - dynstr_append(&ds_res, "system command '"); - replace_dynstr_append(&ds_res, command->first_argument); - dynstr_append(&ds_res, "' failed\n"); + report_or_die("system command '%s' failed", command->first_argument); + else + { + /* If ! abort_on_error, log message and continue */ + dynstr_append(&ds_res, "system command '"); + replace_dynstr_append(&ds_res, command->first_argument); + dynstr_append(&ds_res, "' failed\n"); + } } command->last_argument= command->end; @@ -3945,12 +4059,12 @@ void read_until_delimiter(DYNAMIC_STRING *ds, No characters except \n are allowed on the same line as the command */ - die("Trailing characters found after command"); + report_or_die("Trailing characters found after command"); } if (feof(cur_file->file)) - die("End of file encountered before '%s' delimiter was found", - ds_delimiter->str); + report_or_die("End of file encountered before '%s' delimiter was found", + ds_delimiter->str); if (match_delimiter(c, ds_delimiter->str, ds_delimiter->length)) { @@ -4354,8 +4468,13 @@ void do_perl(struct st_command *command) /* Format the "perl <filename>" command */ my_snprintf(buf, sizeof(buf), "perl %s", temp_file_path); - if (!(res_file= popen(buf, "r")) && command->abort_on_error) - die("popen(\"%s\", \"r\") failed", buf); + if (!(res_file= popen(buf, "r"))) + { + if (command->abort_on_error) + die("popen(\"%s\", \"r\") failed", buf); + dynstr_free(&ds_delimiter); + return; + } while (fgets(buf, sizeof(buf), res_file)) { @@ -4510,14 +4629,14 @@ void do_sync_with_master2(struct st_command *command, long offset) information is not initialized, the arguments are incorrect, or an error has occured */ - die("%.*s failed: '%s' returned NULL "\ + die("%.*s failed: '%s' returned NULL " \ "indicating slave SQL thread failure", command->first_word_len, command->query, query_buf); } if (result == -1) - die("%.*s failed: '%s' returned -1 "\ + die("%.*s failed: '%s' returned -1 " \ "indicating timeout after %d seconds", command->first_word_len, command->query, query_buf, timeout); else @@ -4812,7 +4931,8 @@ int do_sleep(struct st_command *command, my_bool real_sleep) while (my_isspace(charset_info, *p)) p++; if (!*p) - die("Missing argument to %.*s", command->first_word_len, command->query); + die("Missing argument to %.*s", command->first_word_len, + command->query); sleep_start= p; /* Check that arg starts with a digit, not handled by my_strtod */ if (!my_isdigit(charset_info, *sleep_start)) @@ -4884,16 +5004,21 @@ int query_get_string(MYSQL* mysql, const char* query, MYSQL_ROW row; if (mysql_query(mysql, query)) - die("'%s' failed: %d %s", query, - mysql_errno(mysql), mysql_error(mysql)); + { + report_or_die("'%s' failed: %d %s", query, + mysql_errno(mysql), mysql_error(mysql)); + return 1; + } if ((res= mysql_store_result(mysql)) == NULL) - die("Failed to store result: %d %s", - mysql_errno(mysql), mysql_error(mysql)); + { + report_or_die("Failed to store result: %d %s", + mysql_errno(mysql), mysql_error(mysql)); + return 1; + } if ((row= mysql_fetch_row(res)) == NULL) { mysql_free_result(res); - ds= 0; return 1; } init_dynamic_string(ds, (row[column] ? row[column] : "NULL"), ~0, 32); @@ -5165,7 +5290,7 @@ void do_get_errcodes(struct st_command *command) while (*p && p != end) { if (!my_isdigit(charset_info, *p)) - die("Invalid argument to error: '%s' - "\ + die("Invalid argument to error: '%s' - " \ "the errno may only consist of digits[0-9]", command->first_argument); p++; @@ -6088,7 +6213,7 @@ void do_block(enum block_cmd cmd, struct st_command* command) eval_expr(&v2, curr_ptr, &expr_end); if ((operand!=EQ_OP && operand!=NE_OP) && ! (v.is_int && v2.is_int)) - die ("Only == and != are supported for string values"); + die("Only == and != are supported for string values"); /* Now we overwrite the first variable with 0 or 1 (for false or true) */ @@ -6446,7 +6571,7 @@ int read_line(char *buf, int size) *p++= c; } } - die("The input buffer is too small for this query.x\n" \ + die("The input buffer is too small for this query.x\n" \ "check your query or increase MAX_QUERY and recompile"); DBUG_RETURN(0); } @@ -6679,6 +6804,12 @@ static struct my_option my_long_options[] = {"compress", 'C', "Use the compressed server/client protocol.", &opt_compress, &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"continue-on-error", 0, + "Continue test even if we got an error. " + "This is mostly useful when testing a storage engine to see what from a test file it can execute, " + "or to find all syntax errors in a newly created big test file", + &opt_continue_on_error, &opt_continue_on_error, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"cursor-protocol", 0, "Use cursors for prepared statements.", &cursor_protocol, &cursor_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -7010,7 +7141,8 @@ int parse_args(int argc, char **argv) { /* Check that the result file exists */ if (result_file_name && access(result_file_name, F_OK) != 0) - die("The specified result file '%s' does not exist", result_file_name); + die("The specified result file '%s' does not exist", + result_file_name); } return 0; @@ -7337,8 +7469,8 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt, } if (error != MYSQL_NO_DATA) - die("mysql_fetch didn't end with MYSQL_NO_DATA from statement: error: %d", - error); + die("mysql_fetch didn't end with MYSQL_NO_DATA from statement: " + "error: %d", error); if (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) die("mysql_fetch didn't end with MYSQL_NO_DATA from statement: %d %s", mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); @@ -7486,6 +7618,22 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql) /* + Handle situation where query is sent but there is no active connection + (e.g directly after disconnect). + + We emulate MySQL-compatible behaviour of sending something on a closed + connection. +*/ +static void handle_no_active_connection(struct st_command *command, + struct st_connection *cn, DYNAMIC_STRING *ds) +{ + handle_error(command, 2006, "MySQL server has gone away", "000000", ds); + cn->pending= FALSE; + var_set_errno(2006); +} + + +/* Run query using MySQL C API SYNOPSIS @@ -7511,11 +7659,7 @@ void run_query_normal(struct st_connection *cn, struct st_command *command, if (!mysql) { - /* Emulate old behaviour of sending something on a closed connection */ - handle_error(command, 2006, "MySQL server has gone away", - "000000", ds); - cn->pending= FALSE; - var_set_errno(2006); + handle_no_active_connection(command, cn, ds); DBUG_VOID_RETURN; } @@ -7670,7 +7814,8 @@ static int match_expected_error(struct st_command *command, NULL is quite likely, but not in conjunction with a SQL-state expect! */ if (unlikely(err_sqlstate == NULL)) - die("expecting a SQL-state (%s) from query '%s' which cannot produce one...", + die("expecting a SQL-state (%s) from query '%s' which cannot " + "produce one...", command->expected_errors.err[i].code.sqlstate, command->query); if (strncmp(command->expected_errors.err[i].code.sqlstate, @@ -7724,7 +7869,11 @@ void handle_error(struct st_command *command, } if (command->abort_on_error) - die("query '%s' failed: %d: %s", command->query, err_errno, err_error); + { + report_or_die("query '%s' failed: %d: %s", command->query, err_errno, + err_error); + DBUG_VOID_RETURN; + } DBUG_PRINT("info", ("expected_errors.count: %d", command->expected_errors.count)); @@ -7770,13 +7919,15 @@ void handle_error(struct st_command *command, if (command->expected_errors.count > 0) { if (command->expected_errors.err[0].type == ERR_ERRNO) - die("query '%s' failed with wrong errno %d: '%s', instead of %d...", - command->query, err_errno, err_error, - command->expected_errors.err[0].code.errnum); + report_or_die("query '%s' failed with wrong errno %d: '%s', instead of " + "%d...", + command->query, err_errno, err_error, + command->expected_errors.err[0].code.errnum); else - die("query '%s' failed with wrong sqlstate %s: '%s', instead of %s...", - command->query, err_sqlstate, err_error, - command->expected_errors.err[0].code.sqlstate); + report_or_die("query '%s' failed with wrong sqlstate %s: '%s', " + "instead of %s...", + command->query, err_sqlstate, err_error, + command->expected_errors.err[0].code.sqlstate); } revert_properties(); @@ -7803,15 +7954,17 @@ void handle_no_error(struct st_command *command) command->expected_errors.err[0].code.errnum != 0) { /* Error code we wanted was != 0, i.e. not an expected success */ - die("query '%s' succeeded - should have failed with errno %d...", - command->query, command->expected_errors.err[0].code.errnum); + report_or_die("query '%s' succeeded - should have failed with errno %d...", + command->query, command->expected_errors.err[0].code.errnum); } else if (command->expected_errors.err[0].type == ERR_SQLSTATE && strcmp(command->expected_errors.err[0].code.sqlstate,"00000") != 0) { /* SQLSTATE we wanted was != "00000", i.e. not an expected success */ - die("query '%s' succeeded - should have failed with sqlstate %s...", - command->query, command->expected_errors.err[0].code.sqlstate); + report_or_die("query '%s' succeeded - should have failed with " + "sqlstate %s...", + command->query, + command->expected_errors.err[0].code.sqlstate); } DBUG_VOID_RETURN; } @@ -8109,10 +8262,10 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) DBUG_ENTER("run_query"); if (cn->pending && (flags & QUERY_SEND_FLAG)) - die ("Cannot run query on connection between send and reap"); + die("Cannot run query on connection between send and reap"); if (!(flags & QUERY_SEND_FLAG) && !cn->pending) - die ("Cannot reap on a connection without pending send"); + die("Cannot reap on a connection without pending send"); init_dynamic_string(&ds_warnings, NULL, 0, 256); ds_warn= &ds_warnings; @@ -8308,13 +8461,14 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) if (sp_created) { if (util_query(mysql, "DROP PROCEDURE mysqltest_tmp_sp ")) - die("Failed to drop sp: %d: %s", mysql_errno(mysql), mysql_error(mysql)); + report_or_die("Failed to drop sp: %d: %s", mysql_errno(mysql), + mysql_error(mysql)); } if (view_created) { if (util_query(mysql, "DROP VIEW mysqltest_tmp_v ")) - die("Failed to drop view: %d: %s", + report_or_die("Failed to drop view: %d: %s", mysql_errno(mysql), mysql_error(mysql)); } @@ -8478,9 +8632,10 @@ void get_command_type(struct st_command* command) else { /* -- "comment" that didn't contain a mysqltest command */ - die("Found line beginning with -- that didn't contain "\ - "a valid mysqltest command, check your syntax or "\ + report_or_die("Found line beginning with -- that didn't contain " \ + "a valid mysqltest command, check your syntax or " \ "use # if you intended to write a comment"); + command->type= Q_COMMENT; } } @@ -9209,7 +9364,7 @@ int main(int argc, char **argv) if (parsing_disabled == 0) parsing_disabled= 1; else - die("Parsing is already disabled"); + report_or_die("Parsing is already disabled"); break; case Q_ENABLE_PARSING: /* @@ -9219,7 +9374,7 @@ int main(int argc, char **argv) if (parsing_disabled == 1) parsing_disabled= 0; else - die("Parsing is already enabled"); + report_or_die("Parsing is already enabled"); break; case Q_DIE: /* Abort test with error code and error message */ @@ -9423,7 +9578,8 @@ void do_get_replace_column(struct st_command *command) if (!(column_number= atoi(to)) || column_number > MAX_COLUMNS) die("Wrong column number to replace_column in '%s'", command->query); if (!*from) - die("Wrong number of arguments to replace_column in '%s'", command->query); + die("Wrong number of arguments to replace_column in '%s'", + command->query); to= get_string(&buff, &from, command); my_free(replace_column[column_number-1]); replace_column[column_number-1]= my_strdup(to, MYF(MY_WME | MY_FAE)); |