From a7a2db66cc45621be67acf43e1f0a127e7746329 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Mar 2006 10:30:36 +0100 Subject: [PATCH 1/4] Make mysql-test-run.pl restore the db(s) to a known state before continuing after test case failure mysql-test/mysql-test-run.pl: Take a snapshot of the data dirs just after all db's have been installed and usedthat snasphot to restore the db(s) to a known state after a test case has failed. Thus avoiding subsequent test cases to fail because of previous test failures. --- mysql-test/mysql-test-run.pl | 147 ++++++++++++++++++++++++++--------- 1 file changed, 110 insertions(+), 37 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index f56d66365c9..a4a71c20012 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -154,6 +154,7 @@ our $path_charsetsdir; our $path_client_bindir; our $path_language; our $path_timefile; +our $path_snapshot; our $path_manager_log; # Used by mysqldadmin our $path_slave_load_tmpdir; # What is this?! our $path_mysqltest_log; @@ -308,10 +309,12 @@ our $opt_with_ndbcluster; our $exe_ndb_mgm; our $path_ndb_tools_dir; -our $path_ndb_backup_dir; +our $path_ndb_data_dir; our $file_ndb_testrun_log; our $flag_ndb_status_ok= 1; +our @data_dir_lst; + ###################################################################### # # Function declarations @@ -388,9 +391,10 @@ sub main () { { kill_and_cleanup(); mysql_install_db(); - -# mysql_loadstd(); FIXME copying from "std_data" .frm and -# .MGR but there are none?! + if ( $opt_force ) + { + save_installed_db(); + } } } @@ -949,6 +953,22 @@ sub command_line_setup () { $path_timefile= "$opt_vardir/log/mysqltest-time"; $path_mysqltest_log= "$opt_vardir/log/mysqltest.log"; + + $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/"; + + # Make a list of all data_dirs + @data_dir_lst = ( + $master->[0]->{'path_myddir'}, + $master->[1]->{'path_myddir'}, + $slave->[0]->{'path_myddir'}, + $slave->[1]->{'path_myddir'}, + $slave->[2]->{'path_myddir'}); + + foreach my $instance (@{$instance_manager->{'instances'}}) + { + push(@data_dir_lst, $instance->{'path_datadir'}); + } + } @@ -1086,8 +1106,7 @@ sub executable_setup () { $exe_master_mysqld= $exe_master_mysqld || $exe_mysqld; $exe_slave_mysqld= $exe_slave_mysqld || $exe_mysqld; - $path_ndb_backup_dir= - "$opt_vardir/ndbcluster-$opt_ndbcluster_port"; + $path_ndb_data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port"; $file_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log"; } @@ -1265,21 +1284,7 @@ sub kill_and_cleanup () { mkpath("$opt_vardir/tmp"); mkpath($opt_tmpdir) if $opt_tmpdir ne "$opt_vardir/tmp"; - # FIXME do we really need to create these all, or are they - # created for us when tables are created? - - my @data_dir_lst = ( - $master->[0]->{'path_myddir'}, - $master->[1]->{'path_myddir'}, - $slave->[0]->{'path_myddir'}, - $slave->[1]->{'path_myddir'}, - $slave->[2]->{'path_myddir'}); - - foreach my $instance (@{$instance_manager->{'instances'}}) - { - push(@data_dir_lst, $instance->{'path_datadir'}); - } - + # Remove old and create new data dirs foreach my $data_dir (@data_dir_lst) { rmtree("$data_dir"); @@ -2024,10 +2029,9 @@ sub run_testcase ($) { report_failure_and_restart($tinfo); } # Save info from this testcase run to mysqltest.log + my $testcase_log= mtr_fromfile($path_timefile) if -f $path_timefile; mtr_tofile($path_mysqltest_log,"CURRENT TEST $tname\n"); - my $testcase_log= mtr_fromfile($path_timefile); - mtr_tofile($path_mysqltest_log, - $testcase_log); + mtr_tofile($path_mysqltest_log, $testcase_log); } # ---------------------------------------------------------------------- @@ -2041,6 +2045,76 @@ sub run_testcase ($) { } } +sub copy_dir($$) { + my $from_dir= shift; + my $to_dir= shift; + + mkpath("$to_dir"); + opendir(DIR, "$from_dir") + or mtr_error("Can't find $from_dir$!"); + for(readdir(DIR)) { + next if "$_" eq "." or "$_" eq ".."; + if ( -d "$from_dir/$_" ) + { + copy_dir("$from_dir/$_", "$to_dir/$_"); + next; + } + copy("$from_dir/$_", "$to_dir/$_"); + } + closedir(DIR); + +} + +# +# Save a snapshot of the installed test db(s) +# I.e take a snapshot of the var/ dir +# +sub save_installed_db () { + + mtr_report("Saving snapshot of installed databases"); + rmtree($path_snapshot); + + foreach my $data_dir (@data_dir_lst) + { + my $name= basename($data_dir); + print "$data_dir\n"; + copy_dir("$data_dir", "$path_snapshot/$name"); + } +} + +# +# Restore snapshot of the installed test db(s) +# if the snapshot exists +# +sub restore_installed_db () { + + if ( -d $path_snapshot) + { + kill_running_server (); + + mtr_report("Restoring snapshot of databases"); + + foreach my $data_dir (@data_dir_lst) + { + my $name= basename($data_dir); + print "$data_dir\n"; + rmtree("$data_dir"); + copy_dir("$path_snapshot/$name", "$data_dir"); + } + if ($opt_with_ndbcluster) + { + # Remove the ndb_*_fs dirs, forcing a clean start of ndb + rmtree("$path_ndb_data_dir/ndb_1_fs"); + rmtree("$path_ndb_data_dir/ndb_2_fs"); + } + } + else + { + # No snapshot existed, just stop all processes + stop_masters_slaves(); + } +} + sub report_failure_and_restart ($) { my $tinfo= shift; @@ -2048,26 +2122,24 @@ sub report_failure_and_restart ($) { mtr_report_test_failed($tinfo); mtr_show_failed_diff($tinfo->{'name'}); print "\n"; - if ( ! $opt_force ) + if ( $opt_force ) { - my $test_mode= join(" ", @::glob_test_mode) || "default"; - print "Aborting: $tinfo->{'name'} failed in $test_mode mode. "; - print "To continue, re-run with '--force'.\n"; - if ( ! $opt_gdb and ! $glob_use_running_server and - ! $opt_ddd and ! $glob_use_embedded_server ) - { - stop_masters_slaves(); - } - mtr_exit(1); + # Restore the snapshot of the installed test db + restore_installed_db(); + print "Resuming Tests\n\n"; + return; } - # FIXME always terminate on failure?! + my $test_mode= join(" ", @::glob_test_mode) || "default"; + print "Aborting: $tinfo->{'name'} failed in $test_mode mode. "; + print "To continue, re-run with '--force'.\n"; if ( ! $opt_gdb and ! $glob_use_running_server and ! $opt_ddd and ! $glob_use_embedded_server ) { stop_masters_slaves(); } - print "Resuming Tests\n\n"; + mtr_exit(1); + } @@ -2758,7 +2830,8 @@ sub run_mysqltest ($) { $ENV{'NDB_STATUS_OK'}= $flag_ndb_status_ok; $ENV{'NDB_MGM'}= $exe_ndb_mgm; - $ENV{'NDB_BACKUP_DIR'}= $path_ndb_backup_dir; + $ENV{'NDB_BACKUP_DIR'}= $path_ndb_data_dir; + $ENV{'NDB_DATA_DIR'}= $path_ndb_data_dir; $ENV{'NDB_TOOLS_DIR'}= $path_ndb_tools_dir; $ENV{'NDB_TOOLS_OUTPUT'}= $file_ndb_testrun_log; $ENV{'NDB_CONNECTSTRING'}= $opt_ndbconnectstring; From 9f4f77ab9035342bf5da39e53f8f1e41568ef09f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Mar 2006 11:06:14 +0100 Subject: [PATCH 2/4] Remove printouts mysql-test/mysql-test-run.pl: Remove extra printouts --- mysql-test/mysql-test-run.pl | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a4a71c20012..6d03529d509 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2077,7 +2077,6 @@ sub save_installed_db () { foreach my $data_dir (@data_dir_lst) { my $name= basename($data_dir); - print "$data_dir\n"; copy_dir("$data_dir", "$path_snapshot/$name"); } } @@ -2097,7 +2096,6 @@ sub restore_installed_db () { foreach my $data_dir (@data_dir_lst) { my $name= basename($data_dir); - print "$data_dir\n"; rmtree("$data_dir"); copy_dir("$path_snapshot/$name", "$data_dir"); } From 9865f74f173f85da93779f4a5c74affee2730219 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Mar 2006 11:30:16 +0100 Subject: [PATCH 3/4] Remove also slave clusters data on restart after test failure mysql-test/mysql-test-run.pl: Setup path the slave clusters data dir Remove slave clusters data dir on restart after test case failure --- mysql-test/mysql-test-run.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index de6476b696c..441a23d774c 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -322,6 +322,7 @@ our $opt_ndb_extra_test= 0; our $exe_ndb_mgm; our $path_ndb_tools_dir; our $path_ndb_data_dir; +our $path_ndb_slave_data_dir; our $file_ndb_testrun_log; our $flag_ndb_status_ok= 1; our $flag_ndb_slave_status_ok= 1; @@ -1148,6 +1149,7 @@ sub executable_setup () { $exe_slave_mysqld= $exe_slave_mysqld || $exe_mysqld; $path_ndb_data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port"; + $path_ndb_slave_data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port_slave"; $file_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log"; } @@ -2321,6 +2323,12 @@ sub restore_installed_db () { # Remove the ndb_*_fs dirs, forcing a clean start of ndb rmtree("$path_ndb_data_dir/ndb_1_fs"); rmtree("$path_ndb_data_dir/ndb_2_fs"); + + if ( $opt_with_ndbcluster_slave ) + { + # Remove also the ndb_*_fs dirs for slave cluster + rmtree("$path_ndb_slave_data_dir/ndb_1_fs"); + } } } else From 0c63aee7f9a46ca3e12615533677e64dda9819ba Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Mar 2006 14:50:16 +0100 Subject: [PATCH 4/4] Bug # 17173 - Partitions: less than search fails Bug # 17894 - Comparison with "less than" operator fails with range partition The problem here was that on queries such as < 3, the range given is NULL < n < 3. The null part works correctly where the null value is stored in rec[0] and the field is marked as being null. However, when the 3 is processed, the 3 is places on rec[0] but the null flag is left uncleared. partition_range.result: Results block for bug #17894 partition_range.test: Test block for bug #17894 partition_list.result: Results block for bug #17173 partition_list.test: Test block for bug #17173 opt_range.cc: call set_notnull to clear any null flag that may have been set sql/opt_range.cc: call set_notnull to clear any null flag that may have been set mysql-test/t/partition_list.test: Test block for bug #17173 mysql-test/r/partition_list.result: Results block for bug #17173 mysql-test/t/partition_range.test: Test block for bug #17894 mysql-test/r/partition_range.result: Results block for bug #17894 --- mysql-test/r/partition_list.result | 11 +++++++++++ mysql-test/r/partition_range.result | 26 ++++++++++++++++++++++++++ mysql-test/t/partition_list.test | 14 ++++++++++++++ mysql-test/t/partition_range.test | 27 +++++++++++++++++++++++++++ sql/opt_range.cc | 1 + 5 files changed, 79 insertions(+) diff --git a/mysql-test/r/partition_list.result b/mysql-test/r/partition_list.result index 21c23fd68ea..26974e5221d 100644 --- a/mysql-test/r/partition_list.result +++ b/mysql-test/r/partition_list.result @@ -180,3 +180,14 @@ primary key(a,b)) partition by list (a) (partition x1 values in (1,2,9,4) tablespace ts1); drop table t1; +CREATE TABLE t1 (s1 int) PARTITION BY LIST (s1) +(PARTITION p1 VALUES IN (1), +PARTITION p2 VALUES IN (2), +PARTITION p3 VALUES IN (3), +PARTITION p4 VALUES IN (4), +PARTITION p5 VALUES IN (5)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +SELECT COUNT(*) FROM t1 WHERE s1 < 3; +COUNT(*) +2 +DROP TABLE t1; diff --git a/mysql-test/r/partition_range.result b/mysql-test/r/partition_range.result index 4f92e127fe0..fc9350f5902 100644 --- a/mysql-test/r/partition_range.result +++ b/mysql-test/r/partition_range.result @@ -337,3 +337,29 @@ a b c 1 1 1 4 1 1 drop table t1; +CREATE TABLE t1 (c1 int default NULL, c2 varchar(30) default NULL, +c3 date default NULL) engine=myisam +PARTITION BY RANGE (year(c3)) (PARTITION p0 VALUES LESS THAN (1995), +PARTITION p1 VALUES LESS THAN (1996) , PARTITION p2 VALUES LESS THAN (1997) , +PARTITION p3 VALUES LESS THAN (1998) , PARTITION p4 VALUES LESS THAN (1999) , +PARTITION p5 VALUES LESS THAN (2000) , PARTITION p6 VALUES LESS THAN (2001) , +PARTITION p7 VALUES LESS THAN (2002) , PARTITION p8 VALUES LESS THAN (2003) , +PARTITION p9 VALUES LESS THAN (2004) , PARTITION p10 VALUES LESS THAN (2010), +PARTITION p11 VALUES LESS THAN MAXVALUE ); +INSERT INTO t1 VALUES (1, 'testing partitions', '1995-07-17'), +(3, 'testing partitions','1995-07-31'), +(5, 'testing partitions','1995-08-13'), +(7, 'testing partitions','1995-08-26'), +(9, 'testing partitions','1995-09-09'), +(0, 'testing partitions','2000-07-10'), +(2, 'testing partitions','2000-07-23'), +(4, 'testing partitions','2000-08-05'), +(6, 'testing partitions','2000-08-19'), +(8, 'testing partitions','2000-09-01'); +SELECT COUNT(*) FROM t1 WHERE c3 BETWEEN '1996-12-31' AND '2000-12-31'; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c3 < '2000-12-31'; +COUNT(*) +10 +DROP TABLE t1; diff --git a/mysql-test/t/partition_list.test b/mysql-test/t/partition_list.test index af99321dcb2..3e0eaa45f32 100644 --- a/mysql-test/t/partition_list.test +++ b/mysql-test/t/partition_list.test @@ -110,3 +110,17 @@ partition by list (a) (partition x1 values in (1,2,9,4) tablespace ts1); drop table t1; + +# +#Bug #17173 Partitions: less-than search fails +# +CREATE TABLE t1 (s1 int) PARTITION BY LIST (s1) +(PARTITION p1 VALUES IN (1), +PARTITION p2 VALUES IN (2), +PARTITION p3 VALUES IN (3), +PARTITION p4 VALUES IN (4), +PARTITION p5 VALUES IN (5)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +SELECT COUNT(*) FROM t1 WHERE s1 < 3; +DROP TABLE t1; + diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test index 9a81914ed2d..a4d8c3740b7 100644 --- a/mysql-test/t/partition_range.test +++ b/mysql-test/t/partition_range.test @@ -361,3 +361,30 @@ subpartition by hash (a+b) SELECT * from t1; drop table t1; + +# +# Bug #17894 Comparison with "less than" operator fails with Range partition +# +CREATE TABLE t1 (c1 int default NULL, c2 varchar(30) default NULL, +c3 date default NULL) engine=myisam +PARTITION BY RANGE (year(c3)) (PARTITION p0 VALUES LESS THAN (1995), +PARTITION p1 VALUES LESS THAN (1996) , PARTITION p2 VALUES LESS THAN (1997) , +PARTITION p3 VALUES LESS THAN (1998) , PARTITION p4 VALUES LESS THAN (1999) , +PARTITION p5 VALUES LESS THAN (2000) , PARTITION p6 VALUES LESS THAN (2001) , +PARTITION p7 VALUES LESS THAN (2002) , PARTITION p8 VALUES LESS THAN (2003) , +PARTITION p9 VALUES LESS THAN (2004) , PARTITION p10 VALUES LESS THAN (2010), +PARTITION p11 VALUES LESS THAN MAXVALUE ); +INSERT INTO t1 VALUES (1, 'testing partitions', '1995-07-17'), +(3, 'testing partitions','1995-07-31'), +(5, 'testing partitions','1995-08-13'), +(7, 'testing partitions','1995-08-26'), +(9, 'testing partitions','1995-09-09'), +(0, 'testing partitions','2000-07-10'), +(2, 'testing partitions','2000-07-23'), +(4, 'testing partitions','2000-08-05'), +(6, 'testing partitions','2000-08-19'), +(8, 'testing partitions','2000-09-01'); +SELECT COUNT(*) FROM t1 WHERE c3 BETWEEN '1996-12-31' AND '2000-12-31'; +SELECT COUNT(*) FROM t1 WHERE c3 < '2000-12-31'; +DROP TABLE t1; + diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 06ca4958d2c..4e89107d406 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2430,6 +2430,7 @@ void store_key_image_to_rec(Field *field, char *ptr, uint len) field->set_null(); return; } + field->set_notnull(); ptr++; } field->set_key_image(ptr, len);