From abffce9cadb9db491e76f681f8a4c055f5d70958 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Mar 2006 18:09:35 +0400 Subject: [PATCH 1/9] Fix for bug #18306: MySQL crashes and restarts using subquery mysql-test/r/subselect.result: Fix for bug #18306: MySQL crashes and restarts using subquery test case mysql-test/t/subselect.test: Fix for bug #18306: MySQL crashes and restarts using subquery test case sql/opt_range.cc: Fix for bug #18306: MySQL crashes and restarts using subquery Restore thd->mem_root because during the cond->val_int() evaluation we can come across a subselect item which may allocate memory on the thd->mem_root and assumes all the memory allocated has the same life span as the subselect item itself. --- mysql-test/r/subselect.result | 6 ++++++ mysql-test/t/subselect.test | 11 +++++++++++ sql/opt_range.cc | 15 ++++++++++++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index d605e81aa93..d8561915564 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -3163,3 +3163,9 @@ t crash1 crash1 drop table t1; +create table t1 (c int, key(c)); +insert into t1 values (1142477582), (1142455969); +create table t2 (a int, b int); +insert into t2 values (2, 1), (1, 0); +delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1; +drop table t1, t2; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 368020dd721..1ef80bdd7ac 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2074,3 +2074,14 @@ create table t1( f1 int,f2 int); insert into t1 values (1,1),(2,2); select tt.t from (select 'crash1' as t, f2 from t1) as tt left join t1 on tt.t = 'crash2' and tt.f2 = t1.f2 where tt.t = 'crash1'; drop table t1; + +# +# Bug #18306: server crash on delete using subquery. +# + +create table t1 (c int, key(c)); +insert into t1 values (1142477582), (1142455969); +create table t2 (a int, b int); +insert into t2 values (2, 1), (1, 0); +delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1; +drop table t1, t2; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 04cc0baa0aa..634c9db18a8 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3604,9 +3604,18 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) /* Here when simple cond */ if (cond->const_item()) { - if (cond->val_int()) - DBUG_RETURN(new SEL_TREE(SEL_TREE::ALWAYS)); - DBUG_RETURN(new SEL_TREE(SEL_TREE::IMPOSSIBLE)); + /* + During the cond->val_int() evaluation we can come across a subselect + item which may allocate memory on the thd->mem_root and assumes + all the memory allocated has the same life span as the subselect + item itself. So we have to restore the thread's mem_root here. + */ + MEM_ROOT *tmp_root= param->mem_root; + param->thd->mem_root= param->old_root; + tree= cond->val_int() ? new(tmp_root) SEL_TREE(SEL_TREE::ALWAYS) : + new(tmp_root) SEL_TREE(SEL_TREE::IMPOSSIBLE); + param->thd->mem_root= tmp_root; + DBUG_RETURN(tree); } table_map ref_tables= 0; From 5aa14b983277d45ca55bea8f5fcdf5229f054bec Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Mar 2006 17:25:49 +0100 Subject: [PATCH 2/9] config-win.h: If CYBOZU defined, set character sets etc include/config-win.h: If CYBOZU defined, set character sets etc --- include/config-win.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/config-win.h b/include/config-win.h index e1972051e67..03f130ad37e 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -377,8 +377,15 @@ inline double ulonglong2double(ulonglong value) #define shared_memory_buffer_length 16000 #define default_shared_memory_base_name "MYSQL" + +#ifdef CYBOZU +#define MYSQL_DEFAULT_CHARSET_NAME "utf8" +#define MYSQL_DEFAULT_COLLATION_NAME "utf8_general_cs" +#define HAVE_UTF8_GENERAL_CS 1 +#else #define MYSQL_DEFAULT_CHARSET_NAME "latin1" #define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci" +#enfif #define HAVE_SPATIAL 1 #define HAVE_RTREE_KEYS 1 @@ -386,8 +393,10 @@ inline double ulonglong2double(ulonglong value) /* Define charsets you want */ /* #undef HAVE_CHARSET_armscii8 */ /* #undef HAVE_CHARSET_ascii */ +#ifndef CYBOZU #define HAVE_CHARSET_big5 1 #define HAVE_CHARSET_cp1250 1 +#endif /* #undef HAVE_CHARSET_cp1251 */ /* #undef HAVE_CHARSET_cp1256 */ /* #undef HAVE_CHARSET_cp1257 */ @@ -396,26 +405,32 @@ inline double ulonglong2double(ulonglong value) /* #undef HAVE_CHARSET_cp866 */ #define HAVE_CHARSET_cp932 1 /* #undef HAVE_CHARSET_dec8 */ +#ifndef CYBOZU #define HAVE_CHARSET_euckr 1 #define HAVE_CHARSET_gb2312 1 #define HAVE_CHARSET_gbk 1 +#endif /* #undef HAVE_CHARSET_greek */ /* #undef HAVE_CHARSET_hebrew */ /* #undef HAVE_CHARSET_hp8 */ /* #undef HAVE_CHARSET_keybcs2 */ /* #undef HAVE_CHARSET_koi8r */ /* #undef HAVE_CHARSET_koi8u */ +#ifndef CYBOZU #define HAVE_CHARSET_latin1 1 #define HAVE_CHARSET_latin2 1 +#endif /* #undef HAVE_CHARSET_latin5 */ /* #undef HAVE_CHARSET_latin7 */ /* #undef HAVE_CHARSET_macce */ /* #undef HAVE_CHARSET_macroman */ #define HAVE_CHARSET_sjis 1 /* #undef HAVE_CHARSET_swe7 */ +#ifndef CYBOZU #define HAVE_CHARSET_tis620 1 #define HAVE_CHARSET_ucs2 1 #define HAVE_CHARSET_ujis 1 +#endif #define HAVE_CHARSET_utf8 1 #define HAVE_UCA_COLLATIONS 1 From d19fe3871a795f89bd460884923dfd1cf9ed98b5 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Mar 2006 20:05:09 +0100 Subject: [PATCH 3/9] Delete gdbinit file before writing to it Concat type+idx to get a unique gdbinit filename --- mysql-test/mysql-test-run.pl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 94ca0ae6924..a738a87bab3 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2550,11 +2550,11 @@ sub mysqld_start ($$$$$) { if ( $opt_gdb || $opt_manual_gdb) { - gdb_arguments(\$args, \$exe, $type); + gdb_arguments(\$args, \$exe, "$type"."_$idx"); } elsif ( $opt_ddd || $opt_manual_ddd ) { - ddd_arguments(\$args, \$exe, $type); + ddd_arguments(\$args, \$exe, "$type"."_$idx"); } elsif ( $opt_manual_debug ) { @@ -3089,6 +3089,9 @@ sub gdb_arguments { my $str= join(" ", @$$args); my $gdb_init_file= "$opt_tmpdir/gdbinit.$type"; + # Remove the old gdbinit file + unlink($gdb_init_file); + if ( $type eq "client" ) { # write init file for client @@ -3110,7 +3113,7 @@ sub gdb_arguments { if ( $opt_manual_gdb ) { - print "\nTo start gdb for$type, type in another window:\n"; + print "\nTo start gdb for $type, type in another window:\n"; print "cd $glob_mysql_test_dir;\n"; print "gdb -x $gdb_init_file $$exe\n"; @@ -3150,6 +3153,9 @@ sub ddd_arguments { my $str= join(" ", @$$args); my $gdb_init_file= "$opt_tmpdir/gdbinit.$type"; + # Remove the old gdbinit file + unlink($gdb_init_file); + if ( $type eq "client" ) { # write init file for client @@ -3172,7 +3178,7 @@ sub ddd_arguments { if ( $opt_manual_ddd ) { - print "\nTo start ddd for$type, type in another window:\n"; + print "\nTo start ddd for $type, type in another window:\n"; print "cd $glob_mysql_test_dir;\n"; print "ddd -x $gdb_init_file $$exe\n"; From 6662707f74c3a925200bb1b3807f8b879ff2d510 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Mar 2006 20:59:23 +0100 Subject: [PATCH 4/9] Fix type "enfif" -> "endif" --- include/config-win.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/config-win.h b/include/config-win.h index d335ad38feb..b2e1c9831d4 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -415,7 +415,7 @@ inline double ulonglong2double(ulonglong value) #else #define MYSQL_DEFAULT_CHARSET_NAME "latin1" #define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci" -#enfif +#endif #define HAVE_SPATIAL 1 #define HAVE_RTREE_KEYS 1 From 2711b9d5de555a5408b12bd40e4b6b2e23e7a18e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Mar 2006 21:45:00 +0100 Subject: [PATCH 5/9] Remove DBUG print that looks at args[0] even if arg_count is 0 --- sql/item_func.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/sql/item_func.cc b/sql/item_func.cc index 7511b2af8c4..f40f868f75f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2805,9 +2805,6 @@ longlong Item_func_udf_int::val_int() { DBUG_ASSERT(fixed == 1); DBUG_ENTER("Item_func_udf_int::val_int"); - DBUG_PRINT("info",("result_type: %d arg_count: %d", - args[0]->result_type(), arg_count)); - DBUG_RETURN(udf.val_int(&null_value)); } From 636064c0bab4c606bc73b3f4dcacddc5f8d39dd3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Mar 2006 21:48:31 +0100 Subject: [PATCH 6/9] Dump result to .log file at test failure client/mysqltest.c: Dump accumulated result upuntil test failure into a .log file for later examination mysql-test/lib/mtr_report.pl: Inform about the .log file's existence --- client/mysqltest.c | 11 +++++++++-- mysql-test/lib/mtr_report.pl | 10 +++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 37f7418e0ef..33170d32adf 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -427,6 +427,7 @@ static VAR* var_init(VAR* v, const char *name, int name_len, const char *val, static void var_free(void* v); void dump_result_to_reject_file(const char *record_file, char *buf, int size); +void dump_result_to_log_file(const char *record_file, char *buf, int size); int close_connection(struct st_query*); static void set_charset(struct st_query*); @@ -634,9 +635,9 @@ static void die(const char *fmt, ...) } va_end(args); - /* Dump the result that has been accumulated so far to reject file */ + /* Dump the result that has been accumulated so far to .log file */ if (result_file && ds_res.length) - dump_result_to_reject_file(result_file, ds_res.str, ds_res.length); + dump_result_to_log_file(result_file, ds_res.str, ds_res.length); /* Clean up and exit */ free_used_memory(); @@ -3139,6 +3140,12 @@ void dump_result_to_reject_file(const char *record_file, char *buf, int size) str_to_file(fn_format(reject_file, record_file,"",".reject",2), 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); +} + #ifdef __WIN__ diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index 92ce7437365..4587c8bc385 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -36,6 +36,7 @@ sub mtr_show_failed_diff ($) { my $reject_file= "r/$tname.reject"; my $result_file= "r/$tname.result"; + my $log_file= "r/$tname.log"; my $eval_file= "r/$tname.eval"; if ( $::opt_suite ne "main" ) @@ -43,10 +44,11 @@ sub mtr_show_failed_diff ($) { $reject_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$reject_file"; $result_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$result_file"; $eval_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$eval_file"; + $log_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$log_file"; } if ( -f $eval_file ) - { + { $result_file= $eval_file; } elsif ( $::opt_result_ext and @@ -70,6 +72,12 @@ sub mtr_show_failed_diff ($) { print "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html\n"; print "to find the reason to this problem and how to report this.\n\n"; } + + if ( -f $log_file ) + { + print "Result from queries before failure can be found in $log_file\n"; + # FIXME Maybe a tail -f -n 10 $log_file here + } } sub mtr_report_test_name ($) { From e1da710d5b00172a42e56948ccda253e148fb0b9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Mar 2006 22:29:53 +0100 Subject: [PATCH 7/9] Only run in libtool if running in valgrind. Apparently libtool isn't properly setup on all our build hosts. mysql-test/mysql-test-run.pl: Only run in libtool if running in valgrind. --- mysql-test/mysql-test-run.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a738a87bab3..23aeb004c71 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3053,9 +3053,10 @@ sub run_mysqltest ($) { ddd_arguments(\$args, \$exe, "client"); } - if ($glob_use_libtool) + if ($glob_use_libtool and $opt_valgrind) { # Add "libtool --mode-execute" before the test to execute + # if running in valgrind(to avoid valgrinding bash) unshift(@$args, "--mode=execute", $exe); $exe= "libtool"; } From f97d76ac1cf7a46d49a293da2cd4b68e903fd4ca Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Mar 2006 23:09:34 +0100 Subject: [PATCH 8/9] Bug#18474 Unlistable directories yield no info from information_schema, part2 - Make the windows implementation of 'my_dir' behave like the default implementation mysys/my_lib.c: If 'findfirst' returns EINVAL, just continue and return 0 files to read in this dir. --- mysys/my_lib.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 4ca343064d3..522fa56cbf1 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -398,14 +398,6 @@ MY_DIR *my_dir(const char *path, myf MyFlags) tmp_file[2]='*'; tmp_file[3]='\0'; -#ifdef __BORLANDC__ - if ((handle= findfirst(tmp_path,&find,0)) == -1L) - goto error; -#else - if ((handle=_findfirst(tmp_path,&find)) == -1L) - goto error; -#endif - if (!(buffer= my_malloc(ALIGN_SIZE(sizeof(MY_DIR)) + ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)) + sizeof(MEM_ROOT), MyFlags))) @@ -425,7 +417,23 @@ MY_DIR *my_dir(const char *path, myf MyFlags) /* MY_DIR structure is allocated and completly initialized at this point */ result= (MY_DIR*)buffer; - + +#ifdef __BORLANDC__ + if ((handle= findfirst(tmp_path,&find,0)) == -1L) +#else + if ((handle=_findfirst(tmp_path,&find)) == -1L) +#endif + { + DBUG_PRINT("info", ("find_first returned error")); + if (errno != EINVAL) + goto error; + /* + Could not read the directory, no read access. + Probably because by "chmod -r". + continue and return zero files in dir + */ + } + do { #ifdef __BORLANDC__ From a1c46189b88158bdabfa864c9a62a41b21e7f0c2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Apr 2006 09:49:32 +0200 Subject: [PATCH 9/9] Add option --debugger=NAME and --client-debugger=NAME. Add support for "--debugger=windbg" and "--debugger=vcexpress" --- mysql-test/mysql-test-run.pl | 55 ++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 23aeb004c71..389128a7ecf 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -227,6 +227,8 @@ our $opt_client_ddd; our $opt_manual_gdb; our $opt_manual_ddd; our $opt_manual_debug; +our $opt_debugger; +our $opt_client_debugger; our $opt_gprof; our $opt_gprof_dir; @@ -592,6 +594,8 @@ sub command_line_setup () { 'manual-debug' => \$opt_manual_debug, 'ddd' => \$opt_ddd, 'client-ddd' => \$opt_client_ddd, + 'debugger=s' => \$opt_debugger, + 'client-debugger=s' => \$opt_client_debugger, 'strace-client' => \$opt_strace_client, 'master-binary=s' => \$exe_master_mysqld, 'slave-binary=s' => \$exe_slave_mysqld, @@ -774,9 +778,10 @@ sub command_line_setup () { # Check debug related options if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd || - $opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug) + $opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug || + $opt_debugger || $opt_client_debugger ) { - # Indicate that we are using debugger + # Indicate that we are using debugger $glob_debugger= 1; # Increase timeouts $opt_wait_timeout= 300; @@ -2556,6 +2561,10 @@ sub mysqld_start ($$$$$) { { ddd_arguments(\$args, \$exe, "$type"."_$idx"); } + elsif ( $opt_debugger ) + { + debugger_arguments(\$args, \$exe, "$type"."_$idx"); + } elsif ( $opt_manual_debug ) { print "\nStart $type in your debugger\n" . @@ -3052,6 +3061,10 @@ sub run_mysqltest ($) { { ddd_arguments(\$args, \$exe, "client"); } + elsif ( $opt_client_debugger ) + { + debugger_arguments(\$args, \$exe, "client"); + } if ($glob_use_libtool and $opt_valgrind) { @@ -3204,6 +3217,42 @@ sub ddd_arguments { mtr_add_arg($$args, "$save_exe"); } + +# +# Modify the exe and args so that program is run in the selected debugger +# +sub debugger_arguments { + my $args= shift; + my $exe= shift; + my $debugger= $opt_debugger || $opt_client_debugger; + + if ( $debugger eq "vcexpress" or $debugger eq "vc") + { + # vc[express] /debugexe exe arg1 .. argn + + # Add /debugexe and name of the exe before args + unshift(@$$args, "/debugexe"); + unshift(@$$args, "$$exe"); + + } + elsif ( $debugger eq "windbg" ) + { + # windbg exe arg1 .. argn + + # Add name of the exe before args + unshift(@$$args, "$$exe"); + + } + else + { + mtr_error("Unknown argument \"$debugger\" passed to --debugger"); + } + + # Set exe to debuggername + $$exe= $debugger; +} + + # # Modify the exe and args so that program is run in valgrind # @@ -3311,6 +3360,8 @@ Options for debugging the product client-gdb Start mysqltest client in gdb ddd Start mysqld in ddd client-ddd Start mysqltest client in ddd + debugger=NAME Start mysqld in the selected debugger + client-debugger=NAME Start mysqltest in the selected debugger strace-client FIXME master-binary=PATH Specify the master "mysqld" to use slave-binary=PATH Specify the slave "mysqld" to use