From c0966c4fccd74ea5ef60e81026b3d3088335ad93 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 Aug 2006 20:58:00 +0200 Subject: [PATCH 1/6] Only install the first masters db and copy it for the other Gives slightly faster startup mysql-test/lib/mtr_misc.pl: Add verbose message --- mysql-test/lib/mtr_misc.pl | 2 ++ mysql-test/mysql-test-run.pl | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl index 0ab09a40b37..dd9d24ebc8e 100644 --- a/mysql-test/lib/mtr_misc.pl +++ b/mysql-test/lib/mtr_misc.pl @@ -139,6 +139,8 @@ sub mtr_copy_dir($$) { my $from_dir= shift; my $to_dir= shift; +# mtr_verbose("Copying from $from_dir to $to_dir"); + mkpath("$to_dir"); opendir(DIR, "$from_dir") or mtr_error("Can't find $from_dir$!"); diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3c4e10c9363..b3dd5a26085 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -357,6 +357,7 @@ sub run_benchmarks ($); sub initialize_servers (); sub mysql_install_db (); sub install_db ($$); +sub copy_install_db ($$); sub run_testcase ($); sub run_testcase_stop_servers ($$$); sub run_testcase_start_servers ($); @@ -2237,7 +2238,7 @@ sub mysql_install_db () { # FIXME not exactly true I think, needs improvements install_db('master', $master->[0]->{'path_myddir'}); - install_db('master', $master->[1]->{'path_myddir'}); + copy_install_db('master', $master->[1]->{'path_myddir'}); if ( $use_slaves ) { @@ -2302,6 +2303,18 @@ sub mysql_install_db () { } +sub copy_install_db ($$) { + my $type= shift; + my $data_dir= shift; + + mtr_report("Installing \u$type Database"); + + # Just copy the installed db from first master + mtr_copy_dir($master->[0]->{'path_myddir'}, $data_dir); + +} + + sub install_db ($$) { my $type= shift; my $data_dir= shift; @@ -2456,7 +2469,7 @@ sub im_prepare_data_dir($) { foreach my $instance (@{$instance_manager->{'instances'}}) { - install_db( + copy_install_db( 'im_mysqld_' . $instance->{'server_id'}, $instance->{'path_datadir'}); } From edc0e9fba8e721f6e04cf1051a4413b1b885d18c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Sep 2006 10:01:47 +0200 Subject: [PATCH 2/6] Use "--skip-innodb" if running with testcases that does not need innodb Decreases test time when running a selected number of tests mysql-test/lib/mtr_cases.pl: Remove fixme, it's fiexd now mysql-test/mysql-test-run.pl: Use "--skip-innodb" if running with testcases that does not need innodb --- mysql-test/lib/mtr_cases.pl | 8 -------- mysql-test/mysql-test-run.pl | 10 +++++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index b0ba27e6736..daed111dfce 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -469,14 +469,6 @@ sub collect_one_test_case($$$$$$$) { { mtr_options_from_test_file($tinfo,"$testdir/${tname}.test"); - if ( ! $tinfo->{'innodb_test'} ) - { - # mtr_verbose("Adding '--skip-innodb' to $tinfo->{'name'}"); - # FIXME activate the --skip-innodb only when running with - # selected test cases - # push(@{$tinfo->{'master_opt'}}, "--skip-innodb"); - } - if ( $tinfo->{'big_test'} and ! $::opt_big_test ) { $tinfo->{'skip'}= 1; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b3dd5a26085..cb7d8a16b90 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -258,6 +258,7 @@ our $opt_result_ext; our $opt_skip; our $opt_skip_rpl; our $use_slaves; +our $use_innodb; our $opt_skip_test; our $opt_skip_im; @@ -428,6 +429,7 @@ sub main () { $need_ndbcluster||= $test->{ndb_test}; $need_im||= $test->{component_id} eq 'im'; $use_slaves||= $test->{slave_num}; + $use_innodb||= $test->{'innodb_test'}; } $opt_skip_ndbcluster= $opt_skip_ndbcluster_slave= 1 unless $need_ndbcluster; @@ -2236,8 +2238,9 @@ sub initialize_servers () { sub mysql_install_db () { - # FIXME not exactly true I think, needs improvements install_db('master', $master->[0]->{'path_myddir'}); + + # FIXME check if testcase really is using second master copy_install_db('master', $master->[1]->{'path_myddir'}); if ( $use_slaves ) @@ -2252,10 +2255,8 @@ sub mysql_install_db () { im_prepare_env($instance_manager); } - my $cluster_started_ok= 1; # Assume it can be started - if (ndbcluster_start_install($clusters->[0]) || $use_slaves && ndbcluster_start_install($clusters->[1])) { @@ -2263,7 +2264,6 @@ sub mysql_install_db () { $cluster_started_ok= 0; } - foreach my $cluster (@{$clusters}) { @@ -2903,7 +2903,7 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--datadir=%s", $prefix, $master->[$idx]->{'path_myddir'}); - if ( $idx > 0 ) + if ( $idx > 0 or !$use_innodb) { mtr_add_arg($args, "%s--skip-innodb", $prefix); } From 1bb1679c19614f3a2883e76fd03b09a216be4892 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Sep 2006 10:21:08 +0200 Subject: [PATCH 3/6] Add target to make "mtr", shortcut for running test suite BitKeeper/etc/ignore: Added mysql-test/mtr to the ignore list --- .bzrignore | 1 + mysql-test/Makefile.am | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.bzrignore b/.bzrignore index 6dd06504096..4325a9177fa 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1059,3 +1059,4 @@ vio/test-sslserver vio/viotest-ssl libmysql/libmysql.ver libmysqld/sql_locale.cc +mysql-test/mtr diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index cd939417e64..1e6eb12f7b2 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -34,7 +34,7 @@ benchdir_root= $(prefix) testdir = $(benchdir_root)/mysql-test EXTRA_SCRIPTS = mysql-test-run.sh install_test_db.sh $(PRESCRIPTS) EXTRA_DIST = $(EXTRA_SCRIPTS) -GENSCRIPTS = mysql-test-run install_test_db +GENSCRIPTS = mysql-test-run install_test_db mtr PRESCRIPTS = mysql-test-run.pl test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS) test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem \ @@ -105,6 +105,11 @@ std_data/server-cert.pem: std_data/server-key.pem: @CP@ $(top_srcdir)/SSL/$(@F) $(srcdir)/std_data +# mtr - a shortcut for executing mysql-test-run.pl +mtr: + $(RM) -f mtr + $(LN_S) mysql-test-run.pl mtr + SUFFIXES = .sh .sh: From 2c2f39f7233572b99f81163338022e648716edf1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Sep 2006 12:27:28 +0200 Subject: [PATCH 4/6] Turn off reorder as default --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index cb7d8a16b90..3d1bb2dce25 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -216,7 +216,7 @@ our $opt_embedded_server; our $opt_extern; our $opt_fast; our $opt_force; -our $opt_reorder= 1; +our $opt_reorder= 0; our $opt_enable_disabled; our $opt_gcov; From 6b71aaa2565962e9c6e0126634bf4eb57aad0672 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Sep 2006 16:51:37 +0200 Subject: [PATCH 5/6] Move test that requires innodb to "mysql_innodb" --- mysql-test/r/auto_increment.result | 46 ------------------------------ mysql-test/r/innodb_mysql.result | 46 ++++++++++++++++++++++++++++++ mysql-test/t/auto_increment.test | 36 ----------------------- mysql-test/t/innodb_mysql.test | 37 ++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 82 deletions(-) diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index 1f13264ee55..54c2df34a7f 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -446,52 +446,6 @@ INSERT INTO t1 VALUES(1, 1); ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment; ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY' DROP TABLE t1; -CREATE TABLE `t2` ( -`k` int(11) NOT NULL auto_increment, -`a` int(11) default NULL, -`c` int(11) default NULL, -PRIMARY KEY (`k`), -UNIQUE KEY `idx_1` (`a`) -) ENGINE=InnoDB; -insert into t2 ( a ) values ( 6 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -insert into t2 ( a ) values ( 7 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -select last_insert_id(); -last_insert_id() -2 -select * from t2; -k a c -1 6 NULL -2 7 NULL -insert into t2 ( a ) values ( 6 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -select last_insert_id(); -last_insert_id() -1 -select * from t2; -k a c -1 6 1 -2 7 NULL -insert ignore into t2 values (null,6,1),(10,8,1); -select last_insert_id(); -last_insert_id() -1 -insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); -select last_insert_id(); -last_insert_id() -11 -select * from t2; -k a c -1 6 1 -2 7 NULL -10 8 1 -11 15 1 -12 20 1 -drop table t2; create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c)); insert into t1 values(null,1,1,now()); insert into t1 values(null,0,0,null); diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 9f177e99a17..c5f3ed296e2 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -367,3 +367,49 @@ Warnings: Warning 1071 Specified key was too long; max key length is 765 bytes insert into t1 values('aaa'); drop table t1; +CREATE TABLE `t2` ( +`k` int(11) NOT NULL auto_increment, +`a` int(11) default NULL, +`c` int(11) default NULL, +PRIMARY KEY (`k`), +UNIQUE KEY `idx_1` (`a`) +) ENGINE=InnoDB; +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +insert into t2 ( a ) values ( 7 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +last_insert_id() +2 +select * from t2; +k a c +1 6 NULL +2 7 NULL +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +last_insert_id() +1 +select * from t2; +k a c +1 6 1 +2 7 NULL +insert ignore into t2 values (null,6,1),(10,8,1); +select last_insert_id(); +last_insert_id() +1 +insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); +select last_insert_id(); +last_insert_id() +11 +select * from t2; +k a c +1 6 1 +2 7 NULL +10 8 1 +11 15 1 +12 20 1 +drop table t2; diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index 7cef1bad784..f869dc06187 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -304,42 +304,6 @@ INSERT INTO t1 VALUES(1, 1); ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment; DROP TABLE t1; -# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY -# UPDATE": now LAST_INSERT_ID() will return the id of the updated -# row. -CREATE TABLE `t2` ( - `k` int(11) NOT NULL auto_increment, - `a` int(11) default NULL, - `c` int(11) default NULL, - PRIMARY KEY (`k`), - UNIQUE KEY `idx_1` (`a`) -) ENGINE=InnoDB; - insert into t2 ( a ) values ( 6 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -insert into t2 ( a ) values ( 7 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -select last_insert_id(); -select * from t2; -insert into t2 ( a ) values ( 6 ) on duplicate key update c = -ifnull( c, -0 ) + 1; -select last_insert_id(); -select * from t2; - -# Test of LAST_INSERT_ID() when autogenerated will fail: -# last_insert_id() should not change -insert ignore into t2 values (null,6,1),(10,8,1); -select last_insert_id(); -# First and second autogenerated will fail, last_insert_id() should -# point to third -insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); -select last_insert_id(); -select * from t2; - -drop table t2; - # Test of REPLACE when it does INSERT+DELETE and not UPDATE: # see if it sets LAST_INSERT_ID() ok create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c)); diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index 2be53b58a39..4c84dc2faee 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -320,3 +320,40 @@ create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb character set utf8 collate utf8_general_ci; insert into t1 values('aaa'); drop table t1; + +# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY +# UPDATE": now LAST_INSERT_ID() will return the id of the updated +# row. +CREATE TABLE `t2` ( + `k` int(11) NOT NULL auto_increment, + `a` int(11) default NULL, + `c` int(11) default NULL, + PRIMARY KEY (`k`), + UNIQUE KEY `idx_1` (`a`) +) ENGINE=InnoDB; + insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +insert into t2 ( a ) values ( 7 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +select * from t2; +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +select * from t2; + +# Test of LAST_INSERT_ID() when autogenerated will fail: +# last_insert_id() should not change +insert ignore into t2 values (null,6,1),(10,8,1); +select last_insert_id(); +# First and second autogenerated will fail, last_insert_id() should +# point to third +insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); +select last_insert_id(); +select * from t2; + +drop table t2; + From 73fe10d53811c21cbf87ff1e337ec749b87d3832 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Sep 2006 16:56:46 +0200 Subject: [PATCH 6/6] Turn on reorder as default. --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3d1bb2dce25..cb7d8a16b90 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -216,7 +216,7 @@ our $opt_embedded_server; our $opt_extern; our $opt_fast; our $opt_force; -our $opt_reorder= 0; +our $opt_reorder= 1; our $opt_enable_disabled; our $opt_gcov;