From cc21483fcf9767eded085af05c1dd451ddd0b10d Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 1 Dec 2010 11:11:16 +0100 Subject: [PATCH 1/8] Bug #58092 Test "rpl_cross_version" has "copy_file" failing I am not fixing the test failure Adds printing of my_errno when commands fail, could hopefully help --- client/mysqltest.cc | 8 ++++---- mysql-test/r/mysqltest.result | 2 +- mysql-test/t/mysqltest.test | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index b2fcb8fe39e..fbf4563163b 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -1088,8 +1088,8 @@ void handle_command_error(struct st_command *command, uint error) int i; if (command->abort_on_error) - die("command \"%.*s\" failed with error %d", - command->first_word_len, command->query, error); + die("command \"%.*s\" failed with error %d. my_errno=%d", + command->first_word_len, command->query, error, my_errno); i= match_expected_error(command, error, NULL); @@ -1100,8 +1100,8 @@ 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: %d", - command->first_word_len, command->query, error); + die("command \"%.*s\" failed with wrong error: %d. my_errno=%d", + command->first_word_len, command->query, error, my_errno); } else if (command->expected_errors.err[0].type == ERR_ERRNO && command->expected_errors.err[0].code.errnum != 0) diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 013728ebd01..c450369aa11 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -591,7 +591,7 @@ if things work as expected Some data for cat_file command of mysqltest -mysqltest: At line 1: command "cat_file" failed with error 1 +mysqltest: At line 1: command "cat_file" failed with error 1. (my_errno) mysqltest: At line 1: Missing required argument 'filename' to command 'file_exists' mysqltest: At line 1: Missing required argument 'from_file' to command 'copy_file' mysqltest: At line 1: Missing required argument 'to_file' to command 'copy_file' diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index fe04b8c19e0..b9197a7d4b9 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1936,6 +1936,7 @@ EOF cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; +--replace_regex /my_errno=[0-9]*/(my_errno)/ --error 1 --exec echo "cat_file non_existing_file;" | $MYSQL_TEST 2>&1 From 5ac43e27a5ad3ff01cf6158f7d12785ddeab3854 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 9 Dec 2010 12:10:49 +0100 Subject: [PATCH 2/8] Bug #58122 Using DBUG_EXECUTE_IF and normal DBUG printouts not compatible Added option --debug-common which sets 'd' debug flags to the suggested list --- mysql-test/mysql-test-run.pl | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3db8b154fc0..a6179779bf3 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -188,6 +188,8 @@ my $opt_cursor_protocol; my $opt_view_protocol; our $opt_debug; +my $debug_d= "d"; +my $opt_debug_common; our @opt_cases; # The test cases names in argv our $opt_embedded_server; @@ -963,6 +965,7 @@ sub command_line_setup { # Debugging 'debug' => \$opt_debug, + 'debug-common' => \$opt_debug_common, 'gdb' => \$opt_gdb, 'client-gdb' => \$opt_client_gdb, 'manual-gdb' => \$opt_manual_gdb, @@ -1546,6 +1549,18 @@ sub command_line_setup { join(" ", @valgrind_args), "\""); } + if ($opt_debug_common) + { + $opt_debug= 1; + $debug_d= "d,query,info,error,enter,exit"; + } + + if ($opt_debug && $opt_debug ne "1") + { + $debug_d= "d,$opt_debug"; + $debug_d= "d,query,info,error,enter,exit" if $opt_debug eq "std"; + } + mtr_report("Checking supported features..."); check_ndbcluster_support(\%mysqld_variables); @@ -1843,7 +1858,7 @@ sub client_debug_arg($$) { if ( $opt_debug ) { mtr_add_arg($args, - "--debug=d:t:A,%s/log/%s.trace", + "--debug=$debug_d:t:A,%s/log/%s.trace", $path_vardir_trace, $client_name) } } @@ -3008,7 +3023,7 @@ sub mysql_install_db { if ( $opt_debug ) { - mtr_add_arg($args, "--debug=d:t:i:A,%s/log/bootstrap.trace", + mtr_add_arg($args, "--debug=$debug_d:t:i:A,%s/log/bootstrap.trace", $path_vardir_trace); } @@ -4589,7 +4604,7 @@ sub mysqld_start ($$) { if ( $opt_debug ) { - mtr_add_arg($args, "--debug=d:t:i:A,%s/log/%s.trace", + mtr_add_arg($args, "--debug=$debug_d:t:i:A,%s/log/%s.trace", $path_vardir_trace, $mysqld->name()); } @@ -5692,6 +5707,8 @@ Options for debugging the product client-gdb Start mysqltest client in gdb ddd Start mysqld in ddd debug Dump trace output for all servers and client programs + debug-common Same as debug, but sets 'd' debug flags to + "query,info,error,enter,exit" debugger=NAME Start mysqld in the selected debugger gdb Start the mysqld(s) in gdb manual-debug Let user manually start mysqld in debugger, before From 81d29b1d82a48dfbe373c440b06c2f570691983f Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 9 Dec 2010 12:14:00 +0100 Subject: [PATCH 3/8] Bug #58710 Valgrind warnings in mysqltest Var's string value was not 0-terminated if intially null. While at it, also removed some reported memory leaks Added sanity check, setting val_len=0 if val==0 --- client/mysqltest.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index dfd383cc714..a277af82b13 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -2073,6 +2073,8 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val, name_len = strlen(name); if (!val_len && val) val_len = strlen(val) ; + if (!val) + val_len= 0; val_alloc_len = val_len + 16; /* room to grow */ if (!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) + name_len+1, MYF(MY_WME)))) @@ -2093,10 +2095,9 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val, die("Out of memory"); if (val) - { memcpy(tmp_var->str_val, val, val_len); - tmp_var->str_val[val_len]= 0; - } + tmp_var->str_val[val_len]= 0; + var_check_int(tmp_var); tmp_var->name_len = name_len; tmp_var->str_val_len = val_len; @@ -5053,6 +5054,7 @@ void do_close_connection(struct st_command *command) dynstr_append_mem(ds, ";\n", 2); } + dynstr_free(&ds_connection); DBUG_VOID_RETURN; } @@ -5481,6 +5483,7 @@ void do_connect(struct st_command *command) dynstr_free(&ds_port); dynstr_free(&ds_sock); dynstr_free(&ds_options); + dynstr_free(&ds_default_auth); #ifdef HAVE_SMEM dynstr_free(&ds_shm); #endif @@ -5729,6 +5732,7 @@ void do_block(enum block_cmd cmd, struct st_command* command) } v.is_int= TRUE; + var_free(&v2); } else { if (*expr_start != '`' && ! my_isdigit(charset_info, *expr_start)) @@ -7822,7 +7826,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ds, &ds_warnings); dynstr_free(&ds_warnings); - if (command->type == Q_EVAL) + if (command->type == Q_EVAL || command->type == Q_SEND_EVAL) dynstr_free(&eval_query); if (display_result_sorted) From 06790ea7becae1eab1e2dad9d2d7390bf4ed6df3 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 9 Dec 2010 12:15:25 +0100 Subject: [PATCH 4/8] Bug #58695 mysqltest coredumps on "if($x == ){" Add check that there is a RHS of the expression Added to mysqltest.test --- client/mysqltest.cc | 2 ++ mysql-test/r/mysqltest.result | 2 ++ mysql-test/t/mysqltest.test | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index a277af82b13..9806d9bed0f 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5680,6 +5680,8 @@ void do_block(enum block_cmd cmd, struct st_command* command) } while (my_isspace(charset_info, *curr_ptr)) curr_ptr++; + if (curr_ptr == expr_end) + die("Missing right operand in comparison"); /* Strip off trailing white space */ while (my_isspace(charset_info, expr_end[-1])) diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 6892164c225..3073dda1154 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -434,6 +434,8 @@ anything goes mysqltest: At line 2: Only == and != are supported for string values mysqltest: At line 2: Found junk '~= 6' after $variable in condition mysqltest: At line 2: Expression in if/while must beging with $, ` or a number +mysqltest: At line 1: Missing right operand in comparison +mysqltest: At line 1: Missing right operand in comparison counter is 2 counter is 3 counter is 4 diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 186b0e0fbfa..f7d433c70e8 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1354,6 +1354,11 @@ EOF --exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1 remove_file $MYSQL_TMP_DIR/mysqltest.sql; +--error 1 +--exec echo "if (\$var ==) {" | $MYSQL_TEST 2>&1 +--error 1 +--exec echo "if (\$var > ) {" | $MYSQL_TEST 2>&1 + # ---------------------------------------------------------------------------- # Test while with compare conditions # ---------------------------------------------------------------------------- From c1463af64c6ae2596d5298dbc476ffc7e4fe5d52 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 9 Dec 2010 14:04:35 +0100 Subject: [PATCH 5/8] Bug #58282 "mtr --mem" does not work on a machine with libaio installed Workaround: add --loose-skip-innodb-use-native-aio Only on linux if explicitly using --mem or setting $OPT_MEM --- mysql-test/mysql-test-run.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a6179779bf3..74fdae1f8c5 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3030,6 +3030,12 @@ sub mysql_install_db { mtr_add_arg($args, "--lc-messages-dir=%s", $install_lang); mtr_add_arg($args, "--character-sets-dir=%s", $install_chsdir); + # On some old linux kernels, aio on tmpfs is not supported + # Remove this if/when Bug #58421 fixes this in the server + if ($^O eq "linux" && $opt_mem) { + mtr_add_arg($args, "--loose-skip-innodb-use-native-aio"); + } + # InnoDB arguments that affect file location and sizes may # need to be given to the bootstrap process as well as the # server process. @@ -4515,6 +4521,13 @@ sub mysqld_arguments ($$$) { } } + # On some old linux kernels, aio on tmpfs is not supported + # Remove this if/when Bug #58421 fixes this in the server + if ($^O eq "linux" && $opt_mem) + { + mtr_add_arg($args, "--loose-skip-innodb-use-native-aio"); + } + if ( $mysql_version_id >= 50106 && !$opt_user_args) { # Turn on logging to file From b5fdbcb2fec8757347d6a88415ebf428cb328c4d Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 9 Dec 2010 14:40:36 +0100 Subject: [PATCH 6/8] Bug #58608 mysqltestrun --help incongruences Fixed some errors Added note about 'no' prefix to options See also follow-up comment to bug report --- mysql-test/mysql-test-run.pl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 78b7e551918..0d0c1eafb85 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -863,7 +863,7 @@ sub command_line_setup { my $opt_list_options; # Read the command line options - # Note: Keep list, and the order, in sync with usage at end of this file + # Note: Keep list in sync with usage at end of this file Getopt::Long::Configure("pass_through"); my %options=( # Control what engine/variation to run @@ -898,6 +898,7 @@ sub command_line_setup { 'combination=s' => \@opt_combinations, 'skip-combinations' => \&collect_option, 'experimental=s' => \@opt_experimentals, + # skip-im is deprecated and silently ignored 'skip-im' => \&ignore_option, # Specify ports @@ -990,6 +991,7 @@ sub command_line_setup { 'max-connections=i' => \$opt_max_connections, 'help|h' => \$opt_usage, + # list-options is internal, not listed in help 'list-options' => \$opt_list_options, ); @@ -5460,7 +5462,7 @@ Options to control what engine/variation to run defaults-file= Use fixed config template for all tests - defaults_extra_file= Extra config template to add to + defaults-extra-file= Extra config template to add to all generated configs combination= Use at least twice to run tests with specified options to mysqld @@ -5550,7 +5552,7 @@ Options for debugging the product test(s) manual-ddd Let user manually start mysqld in ddd, before running test(s) - strace-client=[path] Create strace output for mysqltest client, optionally + strace-client[=path] Create strace output for mysqltest client, optionally specifying name and path to the trace program to use. Example: $0 --strace-client=ktrace max-save-core Limit the number of core files saved (to avoid filling @@ -5583,7 +5585,7 @@ Options for valgrind Misc options user=USER User for connecting to mysqld(default: $opt_user) comment=STR Write STR to the output - notimer Don't show test case execution time + timer Show test case execution time. verbose More verbose output(use multiple times for even more) verbose-restart Write when and why servers are restarted start Only initialize and start the servers, using the @@ -5623,6 +5625,7 @@ Misc options actions. Disable facility with NUM=0. gcov Collect coverage information after the test. The result is a gcov file per source and header file. + gprof Collect profiling information using gprof. experimental= Refer to list of tests considered experimental; failures will be marked exp-fail instead of fail. report-features First run a "test" that reports mysql features @@ -5631,6 +5634,10 @@ Misc options *previous* test started max-connections=N Max number of open connection to server in mysqltest +Some options that control enabling a feature for normal test runs, +can be turned off by prepending 'no' to the option, e.g. --notimer. +This applies to reorder, timer, check-testcases and warnings. + HERE exit(1); From e70cb01d085dd25ce3cf4e8ad2ace3e9d295f7fb Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 9 Dec 2010 14:42:04 +0100 Subject: [PATCH 7/8] Bug #58522 mtr --debug leaks memory when test fails Backported use of setenv() from 5.5 This will remove the leak on systems that have setenv() I have not fixed the string.c leak, it's a local variable that the cleanup function cannot access. --- client/mysqltest.cc | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index fbf4563163b..f7a90dfb8d4 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -73,6 +73,10 @@ #define QUERY_SEND_FLAG 1 #define QUERY_REAP_FLAG 2 +#ifndef HAVE_SETENV +static int setenv(const char *name, const char *value, int overwrite); +#endif + enum { OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION, OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL, @@ -219,7 +223,6 @@ typedef struct int alloced_len; int int_dirty; /* do not update string if int is updated until first read */ int alloced; - char *env_s; } VAR; /*Perl/shell-like variable registers */ @@ -1962,7 +1965,7 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val, val_len = strlen(val) ; val_alloc_len = val_len + 16; /* room to grow */ if (!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) - + name_len+1, MYF(MY_WME)))) + + name_len+2, MYF(MY_WME)))) die("Out of memory"); tmp_var->name = (name) ? (char*) tmp_var + sizeof(*tmp_var) : 0; @@ -1971,7 +1974,12 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val, if (!(tmp_var->str_val = (char*)my_malloc(val_alloc_len+1, MYF(MY_WME)))) die("Out of memory"); - memcpy(tmp_var->name, name, name_len); + if (name) + { + memcpy(tmp_var->name, name, name_len); + tmp_var->name[name_len]= 0; + } + if (val) { memcpy(tmp_var->str_val, val, val_len); @@ -1982,7 +1990,6 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val, tmp_var->alloced_len = val_alloc_len; tmp_var->int_val = (val) ? atoi(val) : 0; tmp_var->int_dirty = 0; - tmp_var->env_s = 0; return tmp_var; } @@ -2110,20 +2117,15 @@ void var_set(const char *var_name, const char *var_name_end, if (env_var) { - char buf[1024], *old_env_s= v->env_s; if (v->int_dirty) { sprintf(v->str_val, "%d", v->int_val); v->int_dirty= 0; v->str_val_len= strlen(v->str_val); } - my_snprintf(buf, sizeof(buf), "%.*s=%.*s", - v->name_len, v->name, - v->str_val_len, v->str_val); - if (!(v->env_s= my_strdup(buf, MYF(MY_WME)))) - die("Out of memory"); - putenv(v->env_s); - my_free(old_env_s, MYF(MY_ALLOW_ZERO_PTR)); + /* setenv() expects \0-terminated strings */ + DBUG_ASSERT(v->name[v->name_len] == 0); + setenv(v->name, v->str_val, 1); } DBUG_VOID_RETURN; } @@ -9899,3 +9901,18 @@ void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input) delete_dynamic(&lines); DBUG_VOID_RETURN; } + +#ifndef HAVE_SETENV +static int setenv(const char *name, const char *value, int overwrite) +{ + size_t buflen= strlen(name) + strlen(value) + 2; + char *envvar= (char *)malloc(buflen); + if(!envvar) + return ENOMEM; + strcpy(envvar, name); + strcat(envvar, "="); + strcat(envvar, value); + putenv(envvar); + return 0; +} +#endif From 100882710733dc355805e22234c56914ad86add2 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 9 Dec 2010 14:43:42 +0100 Subject: [PATCH 8/8] Bug #58511 mysqltest doesn't always run statements in ps mode mysqltest checks if the stmt is one that should be run in ps mode, but regexp doesn't match if preceeded by /* */ comment. Fix: match function will jump over /*..*/ if found at start --- client/mysqltest.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index f7a90dfb8d4..9772aa7303d 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -7640,6 +7640,16 @@ void init_re(void) int match_re(my_regex_t *re, char *str) { + while (my_isspace(charset_info, *str)) + str++; + if (str[0] == '/' && str[1] == '*') + { + char *comm_end= strstr (str, "*/"); + if (! comm_end) + die("Statement is unterminated comment"); + str= comm_end + 2; + } + int err= my_regexec(re, str, (size_t)0, NULL, 0); if (err == 0)