List:Commits« Previous MessageNext Message »
From:Bjorn Munch Date:July 26 2011 10:47am
Subject:bzr push into mysql-trunk-mtr branch (bjorn.munch:3094 to 3095)
View as plain text  
 3095 Bjorn Munch	2011-07-26 [merge]
      merge from trunk

    renamed:
      mysql-test/suite/sys_vars/r/default_temp_storage_engine_basic.result => mysql-test/suite/sys_vars/r/default_tmp_storage_engine_basic.result
      mysql-test/suite/sys_vars/t/default_temp_storage_engine_basic.test => mysql-test/suite/sys_vars/t/default_tmp_storage_engine_basic.test
    modified:
      cmake/create_initial_db.cmake.in
      mysql-test/collections/default.weekly
      mysql-test/include/mix1.inc
      mysql-test/lib/mtr_cases.pm
      mysql-test/mysql-test-run.pl
      mysql-test/r/merge.result
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/r/parser.result
      mysql-test/suite/binlog/t/binlog_row_mix_innodb_myisam-master.opt
      mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam-master.opt
      mysql-test/suite/innodb/r/innodb_bug54044.result
      mysql-test/suite/innodb/r/innodb_mysql.result
      mysql-test/suite/innodb/t/innodb_bug54044.test
      mysql-test/suite/perfschema/t/stage_mdl_function.test
      mysql-test/suite/perfschema/t/stage_mdl_global.test
      mysql-test/suite/perfschema/t/stage_mdl_procedure.test
      mysql-test/suite/perfschema/t/stage_mdl_table.test
      mysql-test/suite/sys_vars/r/all_vars.result
      mysql-test/suite/sys_vars/r/innodb_buffer_pool_filename_basic.result
      mysql-test/suite/sys_vars/t/innodb_buffer_pool_filename_basic.test
      mysql-test/t/bootstrap-master.opt
      mysql-test/t/bootstrap.test
      mysql-test/t/ctype_utf8mb4-master.opt
      mysql-test/t/merge.test
      mysql-test/t/parser.test
      sql/mysqld.cc
      sql/mysqld.h
      sql/sql_base.cc
      sql/sql_lex.cc
      sql/sys_vars.cc
      storage/innobase/fil/fil0fil.c
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/include/sync0sync.h
      storage/innobase/include/trx0sys.h
      storage/innobase/include/trx0sys.ic
      storage/innobase/include/trx0trx.ic
      storage/innobase/lock/lock0lock.c
      storage/innobase/read/read0read.c
      storage/innobase/row/row0ins.c
      storage/innobase/row/row0row.c
      storage/innobase/row/row0vers.c
      storage/innobase/srv/srv0srv.c
      storage/innobase/sync/sync0sync.c
      storage/innobase/trx/trx0i_s.c
      storage/innobase/trx/trx0purge.c
      storage/innobase/trx/trx0roll.c
      storage/innobase/trx/trx0rseg.c
      storage/innobase/trx/trx0sys.c
      storage/innobase/trx/trx0trx.c
      storage/myisammrg/ha_myisammrg.cc
      storage/myisammrg/myrg_open.c
      mysql-test/suite/sys_vars/r/default_tmp_storage_engine_basic.result
      mysql-test/suite/sys_vars/t/default_tmp_storage_engine_basic.test
 3094 Bjorn Munch	2011-07-22 [merge]
      null upmerge

    removed:
      mysql-test/std_data/bug57108.cnf
=== modified file 'cmake/create_initial_db.cmake.in'
--- a/cmake/create_initial_db.cmake.in	2011-06-30 15:50:45 +0000
+++ b/cmake/create_initial_db.cmake.in	2011-07-25 15:13:06 +0000
@@ -54,11 +54,11 @@ SET(BOOTSTRAP_COMMAND
   --no-defaults 
   ${CONSOLE}
   --bootstrap
-  --default-storage-engine=myisam
   --lc-messages-dir=${CMAKE_CURRENT_BINARY_DIR}/share
   --basedir=.
   --datadir=.
   --default-storage-engine=MyISAM
+  --default-tmp-storage-engine=MyISAM
   --loose-skip-innodb
   --loose-skip-ndbcluster
   --max_allowed_packet=8M

=== modified file 'mysql-test/collections/default.weekly'
--- a/mysql-test/collections/default.weekly	2011-07-18 10:05:14 +0000
+++ b/mysql-test/collections/default.weekly	2011-07-25 04:38:18 +0000
@@ -45,31 +45,31 @@ perl mysql-test-run.pl --timer --force -
 # Repeat daily run
 # big-test option for normal runs 
 # Default suites in modes normal, binlog format mixed/row,embedded and ps-protocol
-perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=normal  --vardir=var-normal-big  --report-features --skip-test-list=collections/disabled-daily.list --unit-tests
-perl mysql-test-run.pl --force --timer  parallel=auto --experimental=collections/default.experimental --comment=n_mix  --vardir=var-n_mix  --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-daily.list
-perl mysql-test-run.pl --force --timer  parallel=auto --experimental=collections/default.experimental --comment=row  --vardir=var-row  --mysqld=--binlog-format=row --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=normal  --vardir=var-normal-big  --report-features --skip-test-list=collections/disabled-daily.list --unit-tests
+perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=n_mix  --vardir=var-n_mix  --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=row  --vardir=var-row  --mysqld=--binlog-format=row --skip-test-list=collections/disabled-daily.list
 perl mysql-test-run.pl --force --timer   --parallel=auto --experimental=collections/default.experimental --comment=ps_row  --vardir=var-ps_row  --mysqld=--binlog-format=row     --ps-protocol --skip-test-list=collections/disabled-daily.list
-perl mysql-test-run.pl --force --timer  parallel=auto --experimental=collections/default.experimental --comment=embedded  --vardir=var-embedded  --embedded
-perl mysql-test-run.pl --force --timer  parallel=auto --experimental=collections/default.experimental --comment=ps  --vardir=var-ps  --ps-protocol --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=embedded  --vardir=var-embedded  --embedded
+perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=ps  --vardir=var-ps  --ps-protocol --skip-test-list=collections/disabled-daily.list
 
 # Run the suites that are not part of the default - funcs_2, parts, stress, jp, nist
-perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=funcs2-big  --vardir=var-funcs2-big  --suite=funcs_2
-perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=partitions-big  --vardir=var-parts-big --suite=parts
-perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=stress-big --vardir=var-stress-big  --suite=stress
-perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=jp-big --vardir=var-jp-big --suite=jp
-perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=nist-big  --vardir=var-nist-big --suite=nist
-perl mysql-test-run.pl --force --timer --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=nist+ps --vardir=var-ps_nist  --suite=nist  --ps-protocol
+perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=funcs2-big  --vardir=var-funcs2-big  --suite=funcs_2
+perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=partitions-big  --vardir=var-parts-big --suite=parts
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=stress-big --vardir=var-stress-big  --suite=stress
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=jp-big --vardir=var-jp-big --suite=jp
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=nist-big  --vardir=var-nist-big --suite=nist
+perl mysql-test-run.pl --force --timer --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=nist+ps --vardir=var-ps_nist  --suite=nist  --ps-protocol
 
 
 # Additional  replication configurations
 perl mysql-test-run.pl --timer --force --parallel=auto --comment=all_binlog_checksum --experimental=collections/default.experimental --mysqld=--binlog-checksum=CRC32 --vardir=var-all_binlog_checksum --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --force --timer parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_relay --vardir=var-rpl_crash_safe_relay --suite=rpl --mysqld=--relay-log-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
-perl mysql-test-run.pl --force --timer parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_master --vardir=var-rpl_crash_safe_master --suite=rpl --mysqld=--master-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_relay --vardir=var-rpl_crash_safe_relay --suite=rpl --mysqld=--relay-log-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_master --vardir=var-rpl_crash_safe_master --suite=rpl --mysqld=--master-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
 
 #Engine independent tests
-perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 parallel=auto  --comment=eits-tests-myisam-engine-big --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-myisam-engine-big --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam  --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --timer --force parallel=auto --comment=eits-rpl-binlog-row-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=row --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --timer --force parallel=auto  --comment=eits-rpl-binlog-mixed-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 parallel=auto --comment=eits-tests-innodb-engine-big --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-innodb-engine-big --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --timer --force parallel=auto --comment=eits-rpl-binlog-row-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=row --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --timer --force parallel=auto --comment=eits-rpl-binlog-mixed-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 --parallel=auto  --comment=eits-tests-myisam-engine-big --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-myisam-engine-big --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam  --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-row-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=row --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --parallel=auto  --comment=eits-rpl-binlog-mixed-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 --parallel=auto --comment=eits-tests-innodb-engine-big --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-innodb-engine-big --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-row-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=row --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-mixed-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-weekly.list

=== modified file 'mysql-test/include/mix1.inc'
--- a/mysql-test/include/mix1.inc	2011-07-08 12:30:52 +0000
+++ b/mysql-test/include/mix1.inc	2011-07-25 15:13:06 +0000
@@ -26,7 +26,7 @@
 #
 
 eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
-eval SET SESSION DEFAULT_TEMP_STORAGE_ENGINE = $engine_type;
+eval SET SESSION DEFAULT_TMP_STORAGE_ENGINE = $engine_type;
 
 --disable_warnings
 drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4;

=== modified file 'mysql-test/lib/mtr_cases.pm'
--- a/mysql-test/lib/mtr_cases.pm	2011-07-04 12:59:01 +0000
+++ b/mysql-test/lib/mtr_cases.pm	2011-07-25 15:13:06 +0000
@@ -616,12 +616,12 @@ sub optimize_cases {
     foreach my $opt ( @{$tinfo->{master_opt}} ) {
       my $default_engine=
 	mtr_match_prefix($opt, "--default-storage-engine=");
-      my $default_temp_engine=
-	mtr_match_prefix($opt, "--default-temp-storage-engine=");
+      my $default_tmp_engine=
+	mtr_match_prefix($opt, "--default-tmp-storage-engine=");
 
       # Allow use of uppercase, convert to all lower case
       $default_engine =~ tr/A-Z/a-z/;
-      $default_temp_engine =~ tr/A-Z/a-z/;
+      $default_tmp_engine =~ tr/A-Z/a-z/;
 
       if (defined $default_engine){
 
@@ -644,26 +644,26 @@ sub optimize_cases {
 	$tinfo->{'innodb_test'}= 1
 	  if ( $default_engine =~ /^innodb/i );
       }
-      if (defined $default_temp_engine){
+      if (defined $default_tmp_engine){
 
 	#print " $tinfo->{name}\n";
-	#print " - The test asked to use '$default_temp_engine' as temp engine\n";
+	#print " - The test asked to use '$default_tmp_engine' as temp engine\n";
 
-	#my $engine_value= $::mysqld_variables{$default_temp_engine};
+	#my $engine_value= $::mysqld_variables{$default_tmp_engine};
 	#print " - The mysqld_variables says '$engine_value'\n";
 
-	if ( ! exists $::mysqld_variables{$default_temp_engine} and
-	     ! exists $builtin_engines{$default_temp_engine} )
+	if ( ! exists $::mysqld_variables{$default_tmp_engine} and
+	     ! exists $builtin_engines{$default_tmp_engine} )
 	{
 	  $tinfo->{'skip'}= 1;
 	  $tinfo->{'comment'}=
-	    "'$default_temp_engine' not supported";
+	    "'$default_tmp_engine' not supported";
 	}
 
 	$tinfo->{'ndb_test'}= 1
-	  if ( $default_temp_engine =~ /^ndb/i );
+	  if ( $default_tmp_engine =~ /^ndb/i );
 	$tinfo->{'innodb_test'}= 1
-	  if ( $default_temp_engine =~ /^innodb/i );
+	  if ( $default_tmp_engine =~ /^innodb/i );
       }
     }
 
@@ -1014,8 +1014,8 @@ sub collect_one_test_case {
     # the default storage engine is innodb.
     push(@{$tinfo->{'master_opt'}}, "--default-storage-engine=MyISAM");
     push(@{$tinfo->{'slave_opt'}}, "--default-storage-engine=MyISAM");
-    push(@{$tinfo->{'master_opt'}}, "--default-temp-storage-engine=MyISAM");
-    push(@{$tinfo->{'slave_opt'}}, "--default-temp-storage-engine=MyISAM");
+    push(@{$tinfo->{'master_opt'}}, "--default-tmp-storage-engine=MyISAM");
+    push(@{$tinfo->{'slave_opt'}}, "--default-tmp-storage-engine=MyISAM");
   }
 
   if ( $tinfo->{'need_binlog'} )

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2011-07-20 14:40:52 +0000
+++ b/mysql-test/mysql-test-run.pl	2011-07-25 15:13:06 +0000
@@ -1370,11 +1370,11 @@ sub command_line_setup {
       collect_option('default-storage-engine', $1);
       mtr_report("Using default engine '$1'")
     }
-    if ( $arg =~ /default-temp-storage-engine=(\S+)/ )
+    if ( $arg =~ /default-tmp-storage-engine=(\S+)/ )
     {
       # Save this for collect phase
-      collect_option('default-temp-storage-engine', $1);
-      mtr_report("Using default temp engine '$1'")
+      collect_option('default-tmp-storage-engine', $1);
+      mtr_report("Using default tmp engine '$1'")
     }
   }
 

=== modified file 'mysql-test/r/merge.result'
--- a/mysql-test/r/merge.result	2011-03-26 10:56:27 +0000
+++ b/mysql-test/r/merge.result	2011-07-22 15:52:42 +0000
@@ -904,7 +904,8 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Error	Table 'test.t1' doesn't exist
+test.tm1	check	Error	Table 'test.t1' is differently defined or of non-MyISAM type or doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 CREATE TABLE t1(a INT);
@@ -912,7 +913,7 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Error	Table 'test.t2' doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 CREATE TABLE t2(a BLOB);
@@ -920,7 +921,7 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Warning	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 ALTER TABLE t2 MODIFY a INT;
@@ -3635,7 +3636,7 @@ test.t1	analyze	Error	Unable to open und
 test.t1	analyze	error	Corrupt
 CHECK TABLE t1;
 Table	Op	Msg_type	Msg_text
-test.t1	check	Error	Table 'test.t_not_exists' doesn't exist
+test.t1	check	Error	Table 'test.t_not_exists' is differently defined or of non-MyISAM type or doesn't exist
 test.t1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.t1	check	error	Corrupt
 CHECKSUM TABLE t1;
@@ -3651,7 +3652,7 @@ test.t1	optimize	Error	Unable to open un
 test.t1	optimize	error	Corrupt
 REPAIR TABLE t1;
 Table	Op	Msg_type	Msg_text
-test.t1	repair	Error	Table 'test.t_not_exists' doesn't exist
+test.t1	repair	Error	Table 'test.t_not_exists' is differently defined or of non-MyISAM type or doesn't exist
 test.t1	repair	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.t1	repair	error	Corrupt
 REPAIR TABLE t1 USE_FRM;
@@ -3678,6 +3679,40 @@ ERROR HY000: Table 't1' was locked with
 UNLOCK TABLES;
 DROP TABLE m1, t1;
 #
+# Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL
+#                           PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1"
+#
+drop tables if exists t1, t2, t3, t4, m1;
+create table t1(id int) engine=myisam;
+create view t3 as select 1 as id;
+create table t4(id int) engine=memory;
+create table m1(id int) engine=merge union=(t1,t2,t3,t4);
+select * from m1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+# The below CHECK and REPAIR TABLE statements should
+# report all problems with underlying tables: 
+# - absence of 't2',
+# - missing base table for 't3',
+# - wrong engine of 't4'.
+check table m1;
+Table	Op	Msg_type	Msg_text
+test.m1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	Error	Table 'test.t3' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	Error	Table 'test.t4' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	error	Corrupt
+repair table m1;
+Table	Op	Msg_type	Msg_text
+test.m1	repair	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	Error	Table 'test.t3' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	Error	Table 'test.t4' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	error	Corrupt
+# Clean-up.
+drop tables m1, t1, t4;
+drop view t3;
+End of 5.5 tests
+#
 # Additional coverage for refactoring which is made as part
 # of fix for bug #27480 "Extend CREATE TEMPORARY TABLES privilege
 # to allow temp table operations".
@@ -3766,4 +3801,3 @@ ERROR HY000: Unable to open underlying t
 DROP TRIGGER trg1;
 DROP TABLE t1;
 DROP TABLE m1;
-End of 6.0 tests

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2011-07-22 07:56:14 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2011-07-25 15:13:06 +0000
@@ -123,11 +123,11 @@ The following options may be given as th
  The DATETIME format (ignored)
  --default-storage-engine=name 
  The default storage engine for new tables
- --default-temp-storage-engine=name 
- The default storage engine for new explict temporary
- tables
  --default-time-zone=name 
  Set the default time zone.
+ --default-tmp-storage-engine=name 
+ The default storage engine for new explict temporary
+ tables
  --default-week-format=# 
  The default week format used by WEEK() functions
  --delay-key-write[=name] 
@@ -810,8 +810,8 @@ console FALSE
 date-format %Y-%m-%d
 datetime-format %Y-%m-%d %H:%i:%s
 default-storage-engine InnoDB
-default-temp-storage-engine InnoDB
 default-time-zone (No default value)
+default-tmp-storage-engine InnoDB
 default-week-format 0
 delay-key-write ON
 delayed-insert-limit 100

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	2011-07-22 07:56:14 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2011-07-25 15:13:06 +0000
@@ -123,11 +123,11 @@ The following options may be given as th
  The DATETIME format (ignored)
  --default-storage-engine=name 
  The default storage engine for new tables
- --default-temp-storage-engine=name 
- The default storage engine for new explict temporary
- tables
  --default-time-zone=name 
  Set the default time zone.
+ --default-tmp-storage-engine=name 
+ The default storage engine for new explict temporary
+ tables
  --default-week-format=# 
  The default week format used by WEEK() functions
  --delay-key-write[=name] 
@@ -814,8 +814,8 @@ console FALSE
 date-format %Y-%m-%d
 datetime-format %Y-%m-%d %H:%i:%s
 default-storage-engine InnoDB
-default-temp-storage-engine InnoDB
 default-time-zone (No default value)
+default-tmp-storage-engine InnoDB
 default-week-format 0
 delay-key-write ON
 delayed-insert-limit 100

=== modified file 'mysql-test/r/parser.result'
--- a/mysql-test/r/parser.result	2010-09-09 13:04:25 +0000
+++ b/mysql-test/r/parser.result	2011-07-25 10:54:06 +0000
@@ -655,3 +655,7 @@ drop tablespace ndb_ts1 engine=myisam;
 ERROR HY000: Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP'
 drop tablespace ndb_ts1;
 ERROR HY000: Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP'
+CREATE TABLE t (id INT PRIMARY KEY);
+ALTER TABLE t RENAME TO `t1';;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`t1'' at line 1
+DROP TABLE t;

=== modified file 'mysql-test/suite/binlog/t/binlog_row_mix_innodb_myisam-master.opt'
--- a/mysql-test/suite/binlog/t/binlog_row_mix_innodb_myisam-master.opt	2011-06-21 10:05:48 +0000
+++ b/mysql-test/suite/binlog/t/binlog_row_mix_innodb_myisam-master.opt	2011-07-25 15:13:06 +0000
@@ -1 +1 @@
---innodb_lock_wait_timeout=2 --default-storage-engine=MyISAM --default-temp-storage-engine=MyISAM
+--innodb_lock_wait_timeout=2 --default-storage-engine=MyISAM --default-tmp-storage-engine=MyISAM

=== modified file 'mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam-master.opt'
--- a/mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam-master.opt	2011-06-21 10:05:48 +0000
+++ b/mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam-master.opt	2011-07-25 15:13:06 +0000
@@ -1 +1 @@
---innodb_lock_wait_timeout=2 --binlog-direct-non-transactional-updates=FALSE --default-storage-engine=MyISAM --default-temp-storage-engine=MyISAM
+--innodb_lock_wait_timeout=2 --binlog-direct-non-transactional-updates=FALSE --default-storage-engine=MyISAM --default-tmp-storage-engine=MyISAM

=== modified file 'mysql-test/suite/innodb/r/innodb_bug54044.result'
--- a/mysql-test/suite/innodb/r/innodb_bug54044.result	2011-07-21 15:11:09 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug54044.result	2011-07-22 09:32:04 +0000
@@ -6,7 +6,7 @@ table_54044	CREATE TEMPORARY TABLE `tabl
   `IF(NULL  IS NOT NULL, NULL, NULL)` binary(0) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
 DROP TABLE table_54044;
-CREATE TABLE TMP ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL);
-ERROR HY000: Can't create table 'test.TMP' (errno: -1)
-CREATE TABLE TMP ENGINE = INNODB AS SELECT GREATEST(NULL, NULL);
-ERROR HY000: Can't create table 'test.TMP' (errno: -1)
+CREATE TABLE tmp ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL);
+ERROR HY000: Can't create table 'test.tmp' (errno: -1)
+CREATE TABLE tmp ENGINE = INNODB AS SELECT GREATEST(NULL, NULL);
+ERROR HY000: Can't create table 'test.tmp' (errno: -1)

=== modified file 'mysql-test/suite/innodb/r/innodb_mysql.result'
--- a/mysql-test/suite/innodb/r/innodb_mysql.result	2011-07-20 14:40:52 +0000
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result	2011-07-25 15:13:06 +0000
@@ -1,7 +1,7 @@
 set global innodb_support_xa=default;
 set session innodb_support_xa=default;
 SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB;
-SET SESSION DEFAULT_TEMP_STORAGE_ENGINE = InnoDB;
+SET SESSION DEFAULT_TMP_STORAGE_ENGINE = InnoDB;
 drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4;
 drop procedure if exists p1;
 create table t1 (

=== modified file 'mysql-test/suite/innodb/t/innodb_bug54044.test'
--- a/mysql-test/suite/innodb/t/innodb_bug54044.test	2011-07-21 15:11:09 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug54044.test	2011-07-22 09:32:04 +0000
@@ -14,6 +14,6 @@ DROP TABLE table_54044;
 # using NULL datatype
 
 --error ER_CANT_CREATE_TABLE
-CREATE TABLE TMP ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL);
+CREATE TABLE tmp ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL);
 --error ER_CANT_CREATE_TABLE
-CREATE TABLE TMP ENGINE = INNODB AS SELECT GREATEST(NULL, NULL);
+CREATE TABLE tmp ENGINE = INNODB AS SELECT GREATEST(NULL, NULL);

=== modified file 'mysql-test/suite/perfschema/t/stage_mdl_function.test'
--- a/mysql-test/suite/perfschema/t/stage_mdl_function.test	2011-07-21 16:27:14 +0000
+++ b/mysql-test/suite/perfschema/t/stage_mdl_function.test	2011-07-25 14:05:36 +0000
@@ -38,7 +38,14 @@ drop function test.f1;
 
 --connection default
 
-# Wait for the drop function to block
+# user1: Wait for the statement to complete
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+  and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the drop function to block
 let $wait_condition=
   select count(*) = 1 from performance_schema.threads
   where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'

=== modified file 'mysql-test/suite/perfschema/t/stage_mdl_global.test'
--- a/mysql-test/suite/perfschema/t/stage_mdl_global.test	2011-07-21 16:27:14 +0000
+++ b/mysql-test/suite/perfschema/t/stage_mdl_global.test	2011-07-25 14:05:36 +0000
@@ -30,7 +30,14 @@ insert into test.t1 values (1), (2), (3)
 
 --connection default
 
-# Wait for the insert to block
+# user1: Wait for the statement to complete
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+  and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the insert to block
 let $wait_condition=
   select count(*) = 1 from performance_schema.threads
   where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'

=== modified file 'mysql-test/suite/perfschema/t/stage_mdl_procedure.test'
--- a/mysql-test/suite/perfschema/t/stage_mdl_procedure.test	2011-07-21 16:27:14 +0000
+++ b/mysql-test/suite/perfschema/t/stage_mdl_procedure.test	2011-07-25 14:05:36 +0000
@@ -52,7 +52,14 @@ drop procedure test.p1;
 
 --connection default
 
-# Wait for the drop procedure to block
+# user1: Wait for the statement to complete
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+  and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the drop procedure to block
 let $wait_condition=
   select count(*) = 1 from performance_schema.threads
   where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'

=== modified file 'mysql-test/suite/perfschema/t/stage_mdl_table.test'
--- a/mysql-test/suite/perfschema/t/stage_mdl_table.test	2011-07-21 16:27:14 +0000
+++ b/mysql-test/suite/perfschema/t/stage_mdl_table.test	2011-07-25 14:05:36 +0000
@@ -35,7 +35,14 @@ alter table test.t1 add column (b int);
 
 --connection default
 
-# Wait for the alter to block
+# user1: Wait for the statement to complete
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+  and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the alter to block
 let $wait_condition=
   select count(*) = 1 from performance_schema.threads
   where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'

=== modified file 'mysql-test/suite/sys_vars/r/all_vars.result'
--- a/mysql-test/suite/sys_vars/r/all_vars.result	2011-07-19 12:19:21 +0000
+++ b/mysql-test/suite/sys_vars/r/all_vars.result	2011-07-26 04:05:46 +0000
@@ -28,6 +28,8 @@ INNODB_MONITOR_RESET_ALL
 INNODB_MONITOR_RESET_ALL
 INNODB_PRINT_ALL_DEADLOCKS
 INNODB_PRINT_ALL_DEADLOCKS
+INNODB_ROLLBACK_SEGMENTS
+INNODB_ROLLBACK_SEGMENTS
 INNODB_STATS_METHOD
 INNODB_STATS_METHOD
 INNODB_STATS_PERSISTENT_SAMPLE_PAGES

=== renamed file 'mysql-test/suite/sys_vars/r/default_temp_storage_engine_basic.result' => 'mysql-test/suite/sys_vars/r/default_tmp_storage_engine_basic.result'
--- a/mysql-test/suite/sys_vars/r/default_temp_storage_engine_basic.result	2011-06-21 10:05:48 +0000
+++ b/mysql-test/suite/sys_vars/r/default_tmp_storage_engine_basic.result	2011-07-25 15:13:06 +0000
@@ -1,113 +1,113 @@
-SET @start_global_value = @@global.default_temp_storage_engine;
+SET @start_global_value = @@global.default_tmp_storage_engine;
 SELECT @start_global_value;
 @start_global_value
 InnoDB
-SET @start_session_value = @@session.default_temp_storage_engine;
+SET @start_session_value = @@session.default_tmp_storage_engine;
 SELECT @start_session_value;
 @start_session_value
 InnoDB
 '#--------------------FN_DYNVARS_005_01-------------------------#'
-SET @@global.default_temp_storage_engine = INNODB;
-SET @@global.default_temp_storage_engine = DEFAULT;
-SELECT @@global.default_temp_storage_engine;
-@@global.default_temp_storage_engine
-InnoDB
-SET @@session.default_temp_storage_engine = INNODB;
-SET @@session.default_temp_storage_engine = DEFAULT;
-SELECT @@session.default_temp_storage_engine;
-@@session.default_temp_storage_engine
+SET @@global.default_tmp_storage_engine = INNODB;
+SET @@global.default_tmp_storage_engine = DEFAULT;
+SELECT @@global.default_tmp_storage_engine;
+@@global.default_tmp_storage_engine
+InnoDB
+SET @@session.default_tmp_storage_engine = INNODB;
+SET @@session.default_tmp_storage_engine = DEFAULT;
+SELECT @@session.default_tmp_storage_engine;
+@@session.default_tmp_storage_engine
 InnoDB
 '#--------------------FN_DYNVARS_005_02-------------------------#'
-SET @@global.default_temp_storage_engine = MYISAM;
-SELECT @@global.default_temp_storage_engine;
-@@global.default_temp_storage_engine
+SET @@global.default_tmp_storage_engine = MYISAM;
+SELECT @@global.default_tmp_storage_engine;
+@@global.default_tmp_storage_engine
 MyISAM
-SET @@global.default_temp_storage_engine = MERGE;
-SELECT @@global.default_temp_storage_engine;
-@@global.default_temp_storage_engine
+SET @@global.default_tmp_storage_engine = MERGE;
+SELECT @@global.default_tmp_storage_engine;
+@@global.default_tmp_storage_engine
 MRG_MYISAM
-SET @@global.default_temp_storage_engine = MEMORY;
-SELECT @@global.default_temp_storage_engine;
-@@global.default_temp_storage_engine
+SET @@global.default_tmp_storage_engine = MEMORY;
+SELECT @@global.default_tmp_storage_engine;
+@@global.default_tmp_storage_engine
 MEMORY
-SET @@global.default_temp_storage_engine = INNODB;
-SELECT @@global.default_temp_storage_engine;
-@@global.default_temp_storage_engine
+SET @@global.default_tmp_storage_engine = INNODB;
+SELECT @@global.default_tmp_storage_engine;
+@@global.default_tmp_storage_engine
 InnoDB
 '#--------------------FN_DYNVARS_005_03-------------------------#'
-SET @@session.default_temp_storage_engine = MYISAM;
-SELECT @@session.default_temp_storage_engine;
-@@session.default_temp_storage_engine
+SET @@session.default_tmp_storage_engine = MYISAM;
+SELECT @@session.default_tmp_storage_engine;
+@@session.default_tmp_storage_engine
 MyISAM
-SET @@session.default_temp_storage_engine = MERGE;
-SELECT @@session.default_temp_storage_engine;
-@@session.default_temp_storage_engine
+SET @@session.default_tmp_storage_engine = MERGE;
+SELECT @@session.default_tmp_storage_engine;
+@@session.default_tmp_storage_engine
 MRG_MYISAM
-SET @@session.default_temp_storage_engine = MEMORY;
-SELECT @@session.default_temp_storage_engine;
-@@session.default_temp_storage_engine
+SET @@session.default_tmp_storage_engine = MEMORY;
+SELECT @@session.default_tmp_storage_engine;
+@@session.default_tmp_storage_engine
 MEMORY
-SET @@session.default_temp_storage_engine = INNODB;
-SELECT @@session.default_temp_storage_engine;
-@@session.default_temp_storage_engine
+SET @@session.default_tmp_storage_engine = INNODB;
+SELECT @@session.default_tmp_storage_engine;
+@@session.default_tmp_storage_engine
 InnoDB
 '#------------------FN_DYNVARS_005_04-----------------------#'
-SET @@global.default_temp_storage_engine = 8199;
-ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
-SET @@global.default_temp_storage_engine = NULL;
-ERROR 42000: Variable 'default_temp_storage_engine' can't be set to the value of 'NULL'
-SET @@global.default_temp_storage_engine = -1024;
-ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
-SET @@global.default_temp_storage_engine = 65530.34;
-ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
-SET @@global.default_temp_storage_engine = FILE;
+SET @@global.default_tmp_storage_engine = 8199;
+ERROR 42000: Incorrect argument type to variable 'default_tmp_storage_engine'
+SET @@global.default_tmp_storage_engine = NULL;
+ERROR 42000: Variable 'default_tmp_storage_engine' can't be set to the value of 'NULL'
+SET @@global.default_tmp_storage_engine = -1024;
+ERROR 42000: Incorrect argument type to variable 'default_tmp_storage_engine'
+SET @@global.default_tmp_storage_engine = 65530.34;
+ERROR 42000: Incorrect argument type to variable 'default_tmp_storage_engine'
+SET @@global.default_tmp_storage_engine = FILE;
 ERROR 42000: Unknown storage engine 'FILE'
-SET @@session.default_temp_storage_engine = 8199;
-ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
-SET @@session.default_temp_storage_engine = 65530.34;
-ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
-SET @@session.default_temp_storage_engine = RECORD;
+SET @@session.default_tmp_storage_engine = 8199;
+ERROR 42000: Incorrect argument type to variable 'default_tmp_storage_engine'
+SET @@session.default_tmp_storage_engine = 65530.34;
+ERROR 42000: Incorrect argument type to variable 'default_tmp_storage_engine'
+SET @@session.default_tmp_storage_engine = RECORD;
 ERROR 42000: Unknown storage engine 'RECORD'
 '#------------------FN_DYNVARS_005_05-----------------------#'
-SELECT @@global.default_temp_storage_engine =
+SELECT @@global.default_tmp_storage_engine =
 VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
-WHERE VARIABLE_NAME='default_temp_storage_engine';
-@@global.default_temp_storage_engine =
+WHERE VARIABLE_NAME='default_tmp_storage_engine';
+@@global.default_tmp_storage_engine =
 VARIABLE_VALUE
 1
 '#------------------FN_DYNVARS_005_06-----------------------#'
-SELECT @@session.default_temp_storage_engine =
+SELECT @@session.default_tmp_storage_engine =
 VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES
-WHERE VARIABLE_NAME='default_temp_storage_engine';
-@@session.default_temp_storage_engine =
+WHERE VARIABLE_NAME='default_tmp_storage_engine';
+@@session.default_tmp_storage_engine =
 VARIABLE_VALUE
 1
 '#------------------FN_DYNVARS_005_07-----------------------#'
-SET @@global.default_temp_storage_engine = TRUE;
-ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
-SET @@global.default_temp_storage_engine = FALSE;
-ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
+SET @@global.default_tmp_storage_engine = TRUE;
+ERROR 42000: Incorrect argument type to variable 'default_tmp_storage_engine'
+SET @@global.default_tmp_storage_engine = FALSE;
+ERROR 42000: Incorrect argument type to variable 'default_tmp_storage_engine'
 '#---------------------FN_DYNVARS_001_8----------------------#'
-SET @@default_temp_storage_engine = MYISAM;
-SELECT @@default_temp_storage_engine = @@local.default_temp_storage_engine;
-@@default_temp_storage_engine = @@local.default_temp_storage_engine
+SET @@default_tmp_storage_engine = MYISAM;
+SELECT @@default_tmp_storage_engine = @@local.default_tmp_storage_engine;
+@@default_tmp_storage_engine = @@local.default_tmp_storage_engine
 1
-SELECT @@local.default_temp_storage_engine = @@session.default_temp_storage_engine;
-@@local.default_temp_storage_engine = @@session.default_temp_storage_engine
+SELECT @@local.default_tmp_storage_engine = @@session.default_tmp_storage_engine;
+@@local.default_tmp_storage_engine = @@session.default_tmp_storage_engine
 1
 '#---------------------FN_DYNVARS_001_9----------------------#'
-SET default_temp_storage_engine = MEMORY;
-SELECT @@default_temp_storage_engine;
-@@default_temp_storage_engine
+SET default_tmp_storage_engine = MEMORY;
+SELECT @@default_tmp_storage_engine;
+@@default_tmp_storage_engine
 MEMORY
-SELECT local.default_temp_storage_engine;
+SELECT local.default_tmp_storage_engine;
 ERROR 42S02: Unknown table 'local' in field list
-SELECT session.default_temp_storage_engine;
+SELECT session.default_tmp_storage_engine;
 ERROR 42S02: Unknown table 'session' in field list
-SELECT default_temp_storage_engine = @@session.default_temp_storage_engine;
-ERROR 42S22: Unknown column 'default_temp_storage_engine' in 'field list'
-SET @@default_temp_storage_engine = @start_global_value;
-SET default_temp_storage_engine = MyISAM;
+SELECT default_tmp_storage_engine = @@session.default_tmp_storage_engine;
+ERROR 42S22: Unknown column 'default_tmp_storage_engine' in 'field list'
+SET @@default_tmp_storage_engine = @start_global_value;
+SET default_tmp_storage_engine = MyISAM;
 SET default_storage_engine = MyISAM;
 CREATE TABLE t1 (a INT);
 CREATE TEMPORARY TABLE t2 (b INT);
@@ -122,7 +122,7 @@ t2	CREATE TEMPORARY TABLE `t2` (
   `b` int(11) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 DROP TABLE t1, t2;
-SET default_temp_storage_engine = InnoDB;
+SET default_tmp_storage_engine = InnoDB;
 CREATE TABLE t1 (a INT);
 CREATE TEMPORARY TABLE t2 (b INT);
 SHOW CREATE TABLE t1;
@@ -150,7 +150,7 @@ t2	CREATE TEMPORARY TABLE `t2` (
   `b` int(11) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
 DROP TABLE t1, t2;
-SET default_temp_storage_engine = DEFAULT;
+SET default_tmp_storage_engine = DEFAULT;
 SET default_storage_engine = DEFAULT;
 CREATE TABLE t1 (a INT);
 CREATE TEMPORARY TABLE t2 (b INT);
@@ -165,11 +165,11 @@ t2	CREATE TEMPORARY TABLE `t2` (
   `b` int(11) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
 DROP TABLE t1, t2;
-SET @@global.default_temp_storage_engine = @start_global_value;
-SELECT @@global.default_temp_storage_engine;
-@@global.default_temp_storage_engine
-InnoDB
-SET @@session.default_temp_storage_engine = @start_session_value;
-SELECT @@session.default_temp_storage_engine;
-@@session.default_temp_storage_engine
+SET @@global.default_tmp_storage_engine = @start_global_value;
+SELECT @@global.default_tmp_storage_engine;
+@@global.default_tmp_storage_engine
+InnoDB
+SET @@session.default_tmp_storage_engine = @start_session_value;
+SELECT @@session.default_tmp_storage_engine;
+@@session.default_tmp_storage_engine
 InnoDB

=== modified file 'mysql-test/suite/sys_vars/r/innodb_buffer_pool_filename_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_buffer_pool_filename_basic.result	2011-06-23 06:48:48 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_buffer_pool_filename_basic.result	2011-07-25 17:25:37 +0000
@@ -3,6 +3,7 @@ SELECT @orig;
 @orig
 ib_buffer_pool
 SET GLOBAL innodb_buffer_pool_dump_now = ON;
+SET @orig = @@global.innodb_buffer_pool_filename;
 SET GLOBAL innodb_buffer_pool_filename = 'innodb_foobar_dump';
 SET GLOBAL innodb_buffer_pool_dump_now = ON;
 SET GLOBAL innodb_buffer_pool_filename = @orig;

=== renamed file 'mysql-test/suite/sys_vars/t/default_temp_storage_engine_basic.test' => 'mysql-test/suite/sys_vars/t/default_tmp_storage_engine_basic.test'
--- a/mysql-test/suite/sys_vars/t/default_temp_storage_engine_basic.test	2011-06-21 10:05:48 +0000
+++ b/mysql-test/suite/sys_vars/t/default_tmp_storage_engine_basic.test	2011-07-25 15:13:06 +0000
@@ -3,7 +3,7 @@
 --source include/load_sysvars.inc
 
 ######################################################################
-#           START OF default_temp_storage_engine TESTS               #
+#           START OF default_tmp_storage_engine TESTS               #
 ######################################################################
 
 
@@ -11,84 +11,84 @@
 #                 Save initial value                        #
 #############################################################
 
-SET @start_global_value = @@global.default_temp_storage_engine;
+SET @start_global_value = @@global.default_tmp_storage_engine;
 SELECT @start_global_value;
-SET @start_session_value = @@session.default_temp_storage_engine;
+SET @start_session_value = @@session.default_tmp_storage_engine;
 SELECT @start_session_value;
 
 
 --echo '#--------------------FN_DYNVARS_005_01-------------------------#'
 ######################################################################
-#     Display the DEFAULT value of default_temp_storage_engine       #
+#     Display the DEFAULT value of default_tmp_storage_engine       #
 ######################################################################
 
-SET @@global.default_temp_storage_engine = INNODB;
-SET @@global.default_temp_storage_engine = DEFAULT;
-SELECT @@global.default_temp_storage_engine;
-
-SET @@session.default_temp_storage_engine = INNODB;
-SET @@session.default_temp_storage_engine = DEFAULT;
-SELECT @@session.default_temp_storage_engine;
+SET @@global.default_tmp_storage_engine = INNODB;
+SET @@global.default_tmp_storage_engine = DEFAULT;
+SELECT @@global.default_tmp_storage_engine;
+
+SET @@session.default_tmp_storage_engine = INNODB;
+SET @@session.default_tmp_storage_engine = DEFAULT;
+SELECT @@session.default_tmp_storage_engine;
 
 
 --echo '#--------------------FN_DYNVARS_005_02-------------------------#'
 ########################################################################
-# Change the value of default_temp_storage_engine to a valid value for GLOBAL Scope #
+# Change the value of default_tmp_storage_engine to a valid value for GLOBAL Scope #
 ########################################################################
 
-SET @@global.default_temp_storage_engine = MYISAM;
-SELECT @@global.default_temp_storage_engine;
-SET @@global.default_temp_storage_engine = MERGE;
-SELECT @@global.default_temp_storage_engine;
-SET @@global.default_temp_storage_engine = MEMORY;
-SELECT @@global.default_temp_storage_engine;
-SET @@global.default_temp_storage_engine = INNODB;
-SELECT @@global.default_temp_storage_engine;
+SET @@global.default_tmp_storage_engine = MYISAM;
+SELECT @@global.default_tmp_storage_engine;
+SET @@global.default_tmp_storage_engine = MERGE;
+SELECT @@global.default_tmp_storage_engine;
+SET @@global.default_tmp_storage_engine = MEMORY;
+SELECT @@global.default_tmp_storage_engine;
+SET @@global.default_tmp_storage_engine = INNODB;
+SELECT @@global.default_tmp_storage_engine;
 
 
 --echo '#--------------------FN_DYNVARS_005_03-------------------------#'
 #########################################################################
-# Change the value of default_temp_storage_engine to a valid value for SESSION Scope #
+# Change the value of default_tmp_storage_engine to a valid value for SESSION Scope #
 #########################################################################
  
-SET @@session.default_temp_storage_engine = MYISAM;
-SELECT @@session.default_temp_storage_engine;
-SET @@session.default_temp_storage_engine = MERGE;
-SELECT @@session.default_temp_storage_engine;
-SET @@session.default_temp_storage_engine = MEMORY;
-SELECT @@session.default_temp_storage_engine;
-SET @@session.default_temp_storage_engine = INNODB;
-SELECT @@session.default_temp_storage_engine;
+SET @@session.default_tmp_storage_engine = MYISAM;
+SELECT @@session.default_tmp_storage_engine;
+SET @@session.default_tmp_storage_engine = MERGE;
+SELECT @@session.default_tmp_storage_engine;
+SET @@session.default_tmp_storage_engine = MEMORY;
+SELECT @@session.default_tmp_storage_engine;
+SET @@session.default_tmp_storage_engine = INNODB;
+SELECT @@session.default_tmp_storage_engine;
 
 
 --echo '#------------------FN_DYNVARS_005_04-----------------------#'
 ##################################################################
-# Change the value of default_temp_storage_engine to an invalid value         #
+# Change the value of default_tmp_storage_engine to an invalid value         #
 ##################################################################
 
 --Error ER_WRONG_TYPE_FOR_VAR
-SET @@global.default_temp_storage_engine = 8199;
+SET @@global.default_tmp_storage_engine = 8199;
 
 --Error ER_WRONG_VALUE_FOR_VAR
-SET @@global.default_temp_storage_engine = NULL;
+SET @@global.default_tmp_storage_engine = NULL;
 
 --Error ER_WRONG_TYPE_FOR_VAR
-SET @@global.default_temp_storage_engine = -1024;
+SET @@global.default_tmp_storage_engine = -1024;
 
 --Error ER_WRONG_TYPE_FOR_VAR
-SET @@global.default_temp_storage_engine = 65530.34;
+SET @@global.default_tmp_storage_engine = 65530.34;
 
 --Error ER_UNKNOWN_STORAGE_ENGINE
-SET @@global.default_temp_storage_engine = FILE;
+SET @@global.default_tmp_storage_engine = FILE;
 
 --Error ER_WRONG_TYPE_FOR_VAR
-SET @@session.default_temp_storage_engine = 8199;
+SET @@session.default_tmp_storage_engine = 8199;
 
 --Error ER_WRONG_TYPE_FOR_VAR
-SET @@session.default_temp_storage_engine = 65530.34;
+SET @@session.default_tmp_storage_engine = 65530.34;
 
 --Error ER_UNKNOWN_STORAGE_ENGINE
-SET @@session.default_temp_storage_engine = RECORD;
+SET @@session.default_tmp_storage_engine = RECORD;
 
 
 --echo '#------------------FN_DYNVARS_005_05-----------------------#'
@@ -97,18 +97,18 @@ SET @@session.default_temp_storage_engin
 ####################################################################
 
 
-SELECT @@global.default_temp_storage_engine =
+SELECT @@global.default_tmp_storage_engine =
  VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
-  WHERE VARIABLE_NAME='default_temp_storage_engine';
+  WHERE VARIABLE_NAME='default_tmp_storage_engine';
 
 --echo '#------------------FN_DYNVARS_005_06-----------------------#'
 ####################################################################
 #  Check if the value in SESSION Table matches value in variable   #
 ####################################################################
 
-SELECT @@session.default_temp_storage_engine =
+SELECT @@session.default_tmp_storage_engine =
  VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES
-  WHERE VARIABLE_NAME='default_temp_storage_engine';
+  WHERE VARIABLE_NAME='default_tmp_storage_engine';
 
 
 --echo '#------------------FN_DYNVARS_005_07-----------------------#'
@@ -117,10 +117,10 @@ SELECT @@session.default_temp_storage_en
 ####################################################################
 
 --Error ER_WRONG_TYPE_FOR_VAR
-SET @@global.default_temp_storage_engine = TRUE;
+SET @@global.default_tmp_storage_engine = TRUE;
 
 --Error ER_WRONG_TYPE_FOR_VAR
-SET @@global.default_temp_storage_engine = FALSE;
+SET @@global.default_tmp_storage_engine = FALSE;
 
 
 --echo '#---------------------FN_DYNVARS_001_8----------------------#'
@@ -129,29 +129,29 @@ SET @@global.default_temp_storage_engine
 #  SCOPE points to same session variable                      #
 ###############################################################
 
-SET @@default_temp_storage_engine = MYISAM;
-SELECT @@default_temp_storage_engine = @@local.default_temp_storage_engine;
-SELECT @@local.default_temp_storage_engine = @@session.default_temp_storage_engine;
+SET @@default_tmp_storage_engine = MYISAM;
+SELECT @@default_tmp_storage_engine = @@local.default_tmp_storage_engine;
+SELECT @@local.default_tmp_storage_engine = @@session.default_tmp_storage_engine;
 
 
 --echo '#---------------------FN_DYNVARS_001_9----------------------#'
 #########################################################################
-#   Check if default_temp_storage_engine can be accessed with and without @@ sign    #
+#   Check if default_tmp_storage_engine can be accessed with and without @@ sign    #
 #########################################################################
 
-SET default_temp_storage_engine = MEMORY;
-SELECT @@default_temp_storage_engine;
+SET default_tmp_storage_engine = MEMORY;
+SELECT @@default_tmp_storage_engine;
 --Error ER_UNKNOWN_TABLE
-SELECT local.default_temp_storage_engine;
+SELECT local.default_tmp_storage_engine;
 --Error ER_UNKNOWN_TABLE
-SELECT session.default_temp_storage_engine;
+SELECT session.default_tmp_storage_engine;
 --Error ER_BAD_FIELD_ERROR
-SELECT default_temp_storage_engine = @@session.default_temp_storage_engine;
+SELECT default_tmp_storage_engine = @@session.default_tmp_storage_engine;
 
 # check the old obsolete name
-SET @@default_temp_storage_engine = @start_global_value;
+SET @@default_tmp_storage_engine = @start_global_value;
 
-SET default_temp_storage_engine = MyISAM;
+SET default_tmp_storage_engine = MyISAM;
 SET default_storage_engine = MyISAM;
 CREATE TABLE t1 (a INT);
 CREATE TEMPORARY TABLE t2 (b INT);
@@ -159,7 +159,7 @@ SHOW CREATE TABLE t1;
 SHOW CREATE TABLE t2;
 DROP TABLE t1, t2;
 
-SET default_temp_storage_engine = InnoDB;
+SET default_tmp_storage_engine = InnoDB;
 CREATE TABLE t1 (a INT);
 CREATE TEMPORARY TABLE t2 (b INT);
 SHOW CREATE TABLE t1;
@@ -173,7 +173,7 @@ SHOW CREATE TABLE t1;
 SHOW CREATE TABLE t2;
 DROP TABLE t1, t2;
 
-SET default_temp_storage_engine = DEFAULT;
+SET default_tmp_storage_engine = DEFAULT;
 SET default_storage_engine = DEFAULT;
 CREATE TABLE t1 (a INT);
 CREATE TEMPORARY TABLE t2 (b INT);
@@ -185,13 +185,13 @@ DROP TABLE t1, t2;
 #     Restore initial value        #
 ####################################
 
-SET @@global.default_temp_storage_engine = @start_global_value;
-SELECT @@global.default_temp_storage_engine;
-SET @@session.default_temp_storage_engine = @start_session_value;
-SELECT @@session.default_temp_storage_engine;
+SET @@global.default_tmp_storage_engine = @start_global_value;
+SELECT @@global.default_tmp_storage_engine;
+SET @@session.default_tmp_storage_engine = @start_session_value;
+SELECT @@session.default_tmp_storage_engine;
 
 
 #############################################################
-#       END OF default_temp_storage_engine TESTS            #
+#       END OF default_tmp_storage_engine TESTS            #
 #############################################################
 

=== modified file 'mysql-test/suite/sys_vars/t/innodb_buffer_pool_filename_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_filename_basic.test	2011-06-23 06:48:48 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_filename_basic.test	2011-07-25 17:25:37 +0000
@@ -4,7 +4,7 @@
 
 -- source include/have_innodb.inc
 
-# Check the default value and save for later restoration
+# Check the default value
 SET @orig = @@global.innodb_buffer_pool_filename;
 SELECT @orig;
 
@@ -24,6 +24,15 @@ let $wait_condition =
 
 # Try with a non-default filename
 
+# Restart the server so that the status gets reset to something other than
+# 'Buffer pool(s) dump completed at ', otherwise the following wait_condition
+# gets satisfied before the following dump has completed and --file_exists
+# fails
+-- source include/restart_mysqld.inc
+
+# Save for later restoration
+SET @orig = @@global.innodb_buffer_pool_filename;
+
 SET GLOBAL innodb_buffer_pool_filename = 'innodb_foobar_dump';
 
 SET GLOBAL innodb_buffer_pool_dump_now = ON;

=== modified file 'mysql-test/t/bootstrap-master.opt'
--- a/mysql-test/t/bootstrap-master.opt	2011-06-21 10:05:48 +0000
+++ b/mysql-test/t/bootstrap-master.opt	2011-07-25 15:13:06 +0000
@@ -1,3 +1,3 @@
 --default-storage-engine=MyISAM 
---default-temp-storage-engine=MyISAM 
+--default-tmp-storage-engine=MyISAM 
 --skip-innodb 

=== modified file 'mysql-test/t/bootstrap.test'
--- a/mysql-test/t/bootstrap.test	2011-06-21 10:05:48 +0000
+++ b/mysql-test/t/bootstrap.test	2011-07-25 15:13:06 +0000
@@ -8,7 +8,7 @@ drop table if exists t1;
 
 # Add the datadir to the bootstrap command
 let $MYSQLD_DATADIR= `select @@datadir`;
-let $MYSQLD_BOOTSTRAP_CMD= $MYSQLD_BOOTSTRAP_CMD --datadir=$MYSQLD_DATADIR --default-storage-engine=MyISAM --default-temp-storage-engine=MyISAM --skip-innodb;
+let $MYSQLD_BOOTSTRAP_CMD= $MYSQLD_BOOTSTRAP_CMD --datadir=$MYSQLD_DATADIR --default-storage-engine=MyISAM --default-tmp-storage-engine=MyISAM --skip-innodb;
 #
 # Check that --bootstrap reads from stdin
 #

=== modified file 'mysql-test/t/ctype_utf8mb4-master.opt'
--- a/mysql-test/t/ctype_utf8mb4-master.opt	2011-06-21 10:05:48 +0000
+++ b/mysql-test/t/ctype_utf8mb4-master.opt	2011-07-25 15:13:06 +0000
@@ -1,2 +1,2 @@
 --default-storage-engine=MyISAM
---default-temp-storage-engine=MyISAM
+--default-tmp-storage-engine=MyISAM

=== modified file 'mysql-test/t/merge.test'
--- a/mysql-test/t/merge.test	2011-03-26 10:56:27 +0000
+++ b/mysql-test/t/merge.test	2011-07-22 15:52:42 +0000
@@ -2800,6 +2800,34 @@ DROP TABLE m1, t1;
 
 
 --echo #
+--echo # Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL
+--echo #                           PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1"
+--echo #
+--disable_warnings
+drop tables if exists t1, t2, t3, t4, m1;
+--enable_warnings
+create table t1(id int) engine=myisam;
+create view t3 as select 1 as id;
+create table t4(id int) engine=memory;
+create table m1(id int) engine=merge union=(t1,t2,t3,t4);
+--error ER_WRONG_MRG_TABLE
+select * from m1;
+--echo # The below CHECK and REPAIR TABLE statements should
+--echo # report all problems with underlying tables: 
+--echo # - absence of 't2',
+--echo # - missing base table for 't3',
+--echo # - wrong engine of 't4'.
+check table m1;
+repair table m1;
+--echo # Clean-up.
+drop tables m1, t1, t4;
+drop view t3;
+
+
+--echo End of 5.5 tests
+
+
+--echo #
 --echo # Additional coverage for refactoring which is made as part
 --echo # of fix for bug #27480 "Extend CREATE TEMPORARY TABLES privilege
 --echo # to allow temp table operations".
@@ -2877,7 +2905,6 @@ DROP TRIGGER trg1;
 DROP TABLE t1;
 DROP TABLE m1;
 
---echo End of 6.0 tests
 
 --disable_result_log
 --disable_query_log

=== modified file 'mysql-test/t/parser.test'
--- a/mysql-test/t/parser.test	2010-06-17 16:58:30 +0000
+++ b/mysql-test/t/parser.test	2011-07-25 10:54:06 +0000
@@ -776,3 +776,12 @@ drop logfile group ndb_lg1;
 drop tablespace ndb_ts1 engine=myisam;
 -- error ER_ILLEGAL_HA_CREATE_OPTION
 drop tablespace ndb_ts1;
+
+#
+# Bug#12546960 - 60993: NAME QUOTED WITH QUOTE INSTEAD OF BACKTICK 
+#                       GIVES NO SYNTAX ERROR
+#
+CREATE TABLE t (id INT PRIMARY KEY);
+--error ER_PARSE_ERROR
+--query ALTER TABLE t RENAME TO `t1';
+DROP TABLE t;

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-07-22 08:10:35 +0000
+++ b/sql/mysqld.cc	2011-07-25 15:13:06 +0000
@@ -339,7 +339,7 @@ static char *lc_time_names_name;
 char *my_bind_addr_str;
 static char *default_collation_name;
 char *default_storage_engine;
-char *default_temp_storage_engine;
+char *default_tmp_storage_engine;
 static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME;
 static I_List<THD> thread_cache;
 static bool binlog_format_used= false;
@@ -3343,7 +3343,7 @@ int init_common_variables()
 #else
   default_storage_engine= const_cast<char *>("InnoDB");
 #endif
-  default_temp_storage_engine= default_storage_engine;
+  default_tmp_storage_engine= default_storage_engine;
 
   /*
     Add server status variables to the dynamic list of
@@ -4402,7 +4402,7 @@ a file name for --log-bin-index option",
   if (initialize_storage_engine(default_storage_engine, "",
                                 &global_system_variables.table_plugin))
     unireg_abort(1);
-  if (initialize_storage_engine(default_temp_storage_engine, " temp",
+  if (initialize_storage_engine(default_tmp_storage_engine, " temp",
                                 &global_system_variables.temp_table_plugin))
     unireg_abort(1);
 
@@ -6168,9 +6168,9 @@ struct my_option my_long_options[]=
   {"default-storage-engine", 0, "The default storage engine for new tables",
    &default_storage_engine, 0, 0, GET_STR, REQUIRED_ARG,
    0, 0, 0, 0, 0, 0 },
-  {"default-temp-storage-engine", 0, 
+  {"default-tmp-storage-engine", 0, 
     "The default storage engine for new explict temporary tables",
-   &default_temp_storage_engine, 0, 0, GET_STR, REQUIRED_ARG,
+   &default_tmp_storage_engine, 0, 0, GET_STR, REQUIRED_ARG,
    0, 0, 0, 0, 0, 0 },
   {"default-time-zone", 0, "Set the default time zone.",
    &default_tz_name, &default_tz_name,

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2011-07-21 16:27:14 +0000
+++ b/sql/mysqld.h	2011-07-25 15:13:06 +0000
@@ -129,7 +129,7 @@ extern my_bool opt_enable_shared_memory;
 extern char *default_tz_name;
 extern Time_zone *default_tz;
 extern char *default_storage_engine;
-extern char *default_temp_storage_engine;
+extern char *default_tmp_storage_engine;
 extern bool opt_endinfo, using_udf_functions;
 extern my_bool locked_in_memory;
 extern bool opt_using_transactions;

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2011-07-20 14:40:52 +0000
+++ b/sql/sql_base.cc	2011-07-22 15:52:42 +0000
@@ -88,6 +88,69 @@ bool No_such_table_error_handler::safely
   return ((m_handled_errors > 0) && (m_unhandled_errors == 0));
 }
 
+
+/**
+  This internal handler is used to trap ER_NO_SUCH_TABLE and
+  ER_WRONG_MRG_TABLE errors during CHECK/REPAIR TABLE for MERGE
+  tables.
+*/
+
+class Repair_mrg_table_error_handler : public Internal_error_handler
+{
+public:
+  Repair_mrg_table_error_handler()
+    : m_handled_errors(false), m_unhandled_errors(false)
+  {}
+
+  bool handle_condition(THD *thd,
+                        uint sql_errno,
+                        const char* sqlstate,
+                        MYSQL_ERROR::enum_warning_level level,
+                        const char* msg,
+                        MYSQL_ERROR ** cond_hdl);
+
+  /**
+    Returns TRUE if there were ER_NO_SUCH_/WRONG_MRG_TABLE and there
+    were no unhandled errors. FALSE otherwise.
+  */
+  bool safely_trapped_errors()
+  {
+    /*
+      Check for m_handled_errors is here for extra safety.
+      It can be useful in situation when call to open_table()
+      fails because some error which was suppressed by another
+      error handler (e.g. in case of MDL deadlock which we
+      decided to solve by back-off and retry).
+    */
+    return (m_handled_errors && (! m_unhandled_errors));
+  }
+
+private:
+  bool m_handled_errors;
+  bool m_unhandled_errors;
+};
+
+
+bool
+Repair_mrg_table_error_handler::handle_condition(THD *,
+                                                 uint sql_errno,
+                                                 const char*,
+                                                 MYSQL_ERROR::enum_warning_level level,
+                                                 const char*,
+                                                 MYSQL_ERROR ** cond_hdl)
+{
+  *cond_hdl= NULL;
+  if (sql_errno == ER_NO_SUCH_TABLE || sql_errno == ER_WRONG_MRG_TABLE)
+  {
+    m_handled_errors= true;
+    return TRUE;
+  }
+
+  m_unhandled_errors= true;
+  return FALSE;
+}
+
+
 /**
   @defgroup Data_Dictionary Data Dictionary
   @{
@@ -4430,6 +4493,24 @@ open_and_process_table(THD *thd, LEX *le
     thd->pop_internal_handler();
     safe_to_ignore_table= no_such_table_handler.safely_trapped_errors();
   }
+  else if (tables->parent_l && (thd->open_options & HA_OPEN_FOR_REPAIR))
+  {
+    /*
+      Also fail silently for underlying tables of a MERGE table if this
+      table is opened for CHECK/REPAIR TABLE statement. This is needed
+      to provide complete list of problematic underlying tables in
+      CHECK/REPAIR TABLE output.
+    */
+    Repair_mrg_table_error_handler repair_mrg_table_handler;
+    thd->push_internal_handler(&repair_mrg_table_handler);
+
+    error= open_temporary_table(thd, tables);
+    if (!error && !tables->table)
+      error= open_table(thd, tables, new_frm_mem, ot_ctx);
+
+    thd->pop_internal_handler();
+    safe_to_ignore_table= repair_mrg_table_handler.safely_trapped_errors();
+  }
   else
   {
     if (tables->parent_l)

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2011-07-07 09:45:10 +0000
+++ b/sql/sql_lex.cc	2011-07-25 10:54:06 +0000
@@ -1219,8 +1219,12 @@ int lex_one_token(void *arg, void *yythd
     {
       uint double_quotes= 0;
       char quote_char= c;                       // Used char
-      while ((c=lip->yyGet()))
+      for(;;)
       {
+        c= lip->yyGet();
+        if (c == 0)
+          return ABORT_SYM;                     // Unmatched quotes
+
 	int var_length;
 	if ((var_length= my_mbcharlen(cs, c)) == 1)
 	{

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2011-07-19 15:11:15 +0000
+++ b/sql/sys_vars.cc	2011-07-25 15:13:06 +0000
@@ -2500,10 +2500,10 @@ static Sys_var_plugin Sys_default_storag
        MYSQL_STORAGE_ENGINE_PLUGIN, DEFAULT(&default_storage_engine),
        NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_not_null));
 
-static Sys_var_plugin Sys_default_temp_storage_engine(
-       "default_temp_storage_engine", "The default storage engine for new explict temporary tables",
+static Sys_var_plugin Sys_default_tmp_storage_engine(
+       "default_tmp_storage_engine", "The default storage engine for new explict temporary tables",
        SESSION_VAR(temp_table_plugin), NO_CMD_LINE,
-       MYSQL_STORAGE_ENGINE_PLUGIN, DEFAULT(&default_temp_storage_engine),
+       MYSQL_STORAGE_ENGINE_PLUGIN, DEFAULT(&default_tmp_storage_engine),
        NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_not_null));
 
 //  Alias for @@default_storage_engine

=== modified file 'storage/innobase/fil/fil0fil.c'
--- a/storage/innobase/fil/fil0fil.c	2011-07-19 00:25:20 +0000
+++ b/storage/innobase/fil/fil0fil.c	2011-07-25 09:54:47 +0000
@@ -2717,7 +2717,6 @@ fil_create_new_single_table_tablespace(
 	char*			path;
 	ibool			success;
 	os_file_create_t	create_mode;
-	os_file_create_t	error_ignore;
 
 	ut_a(space_id > 0);
 	ut_a(space_id < SRV_LOG_SPACE_FIRST_ID);
@@ -2740,8 +2739,6 @@ fil_create_new_single_table_tablespace(
 	path. It might not have the same value as the one when building the
 	table definition */
 
-	error_ignore = srv_file_per_table ? OS_FILE_ON_ERROR_NO_EXIT : 0;
-
 	create_mode = srv_file_per_table
 		    ? OS_FILE_CREATE | OS_FILE_ON_ERROR_NO_EXIT
 		    : OS_FILE_CREATE;

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2011-07-19 15:07:48 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2011-07-26 03:21:33 +0000
@@ -292,15 +292,14 @@ static PSI_mutex_info all_innodb_mutexes
 	{&lock_sys_wait_mutex_key, "lock_wait_mutex", 0},
 	{&trx_mutex_key, "trx_mutex", 0},
 	{&srv_sys_tasks_mutex_key, "srv_threads_mutex", 0},
-	{&read_view_mutex_key, "read_view_mutex", 0},
-
 	/* mutex with os_fast_mutex_ interfaces */
 #  ifndef PFS_SKIP_EVENT_MUTEX
 	{&event_os_mutex_key, "event_os_mutex", 0},
 #  endif /* PFS_SKIP_EVENT_MUTEX */
 	{&os_mutex_key, "os_mutex", 0},
 	{&srv_conc_mutex_key, "srv_conc_mutex", 0},
-	{&ut_list_mutex_key, "ut_list_mutex", 0}
+	{&ut_list_mutex_key, "ut_list_mutex", 0},
+	{&trx_sys_mutex_key, "trx_sys_mutex", 0},
 };
 # endif /* UNIV_PFS_MUTEX */
 
@@ -325,7 +324,6 @@ static PSI_rwlock_info all_innodb_rwlock
 	{&trx_i_s_cache_lock_key, "trx_i_s_cache_lock", 0},
 	{&trx_purge_latch_key, "trx_purge_latch", 0},
 	{&index_tree_rw_lock_key, "index_tree_rw_lock", 0},
-	{&trx_sys_rw_lock_key, "trx_sys_lock", 0},
 	{&dict_table_stats_latch_key, "dict_table_stats", 0},
 	{&hash_table_rw_lock_key, "hash table locks", 0}
 };
@@ -2001,9 +1999,9 @@ read view to it if there is no read view
 Why a deadlock of threads is not possible: the query cache calls this function
 at the start of a SELECT processing. Then the calling thread cannot be
 holding any InnoDB semaphores. The calling thread is holding the
-query cache mutex, and this function will reserve the InnoDB trx_sys->lock.
+query cache mutex, and this function will reserve the InnoDB trx_sys->mutex.
 Thus, the 'rank' in sync0sync.h of the MySQL query cache mutex is above
-the InnoDB trx_sys->lock.
+the InnoDB trx_sys->mutex.
 @return TRUE if permitted, FALSE if not; note that the value FALSE
 does not mean we should invalidate the query cache: invalidation is
 called explicitly */
@@ -2891,7 +2889,7 @@ innobase_start_trx_and_assign_read_view(
 	trx = check_trx_exists(thd);
 
 	/* This is just to play safe: release a possible FIFO ticket and
-	search latch. Since we can potentially reserve the trx_sys->lock,
+	search latch. Since we can potentially reserve the trx_sys->mutex,
 	we have to release the search system latch first to obey the latching
 	order. */
 
@@ -2936,7 +2934,7 @@ innobase_commit(
 
 	trx = check_trx_exists(thd);
 
-	/* Since we will reserve the trx_sys->lock, we have to release
+	/* Since we will reserve the trx_sys->mutex, we have to release
 	the search system latch first to obey the latching order. */
 
 	if (trx->has_search_latch) {
@@ -3075,7 +3073,7 @@ innobase_rollback(
 	trx = check_trx_exists(thd);
 
 	/* Release a possible FIFO ticket and search latch. Since we will
-	reserve the trx_sys->lock, we have to release the search system
+	reserve the trx_sys->mutex, we have to release the search system
 	latch first to obey the latching order. */
 
 	innobase_release_stat_resources(trx);
@@ -3115,7 +3113,7 @@ innobase_rollback_trx(
 	DBUG_PRINT("trans", ("aborting transaction"));
 
 	/* Release a possible FIFO ticket and search latch. Since we will
-	reserve the trx_sys->lock, we have to release the search system
+	reserve the trx_sys->mutex, we have to release the search system
 	latch first to obey the latching order. */
 
 	innobase_release_stat_resources(trx);
@@ -3156,7 +3154,7 @@ innobase_rollback_to_savepoint(
 	trx = check_trx_exists(thd);
 
 	/* Release a possible FIFO ticket and search latch. Since we will
-	reserve the trx_sys->lock, we have to release the search system
+	reserve the trx_sys->mutex, we have to release the search system
 	latch first to obey the latching order. */
 
 	innobase_release_stat_resources(trx);
@@ -3227,7 +3225,7 @@ innobase_savepoint(
 	trx = check_trx_exists(thd);
 
 	/* Release a possible FIFO ticket and search latch. Since we will
-	reserve the trx_sys->lock, we have to release the search system
+	reserve the trx_sys->mutex, we have to release the search system
 	latch first to obey the latching order. */
 
 	innobase_release_stat_resources(trx);
@@ -9491,7 +9489,7 @@ ha_innobase::external_lock(
 	prebuilt->mysql_has_locked = FALSE;
 
 	/* Release a possible FIFO ticket and search latch. Since we
-	may reserve the trx_sys->lock, we have to release the search
+	may reserve the trx_sys->mutex, we have to release the search
 	system latch first to obey the latching order. */
 
 	innobase_release_stat_resources(trx);
@@ -10691,7 +10689,7 @@ innobase_xa_prepare(
 	thd_get_xid(thd, (MYSQL_XID*) &trx->xid);
 
 	/* Release a possible FIFO ticket and search latch. Since we will
-	reserve the trx_sys->lock, we have to release the search system
+	reserve the trx_sys->mutex, we have to release the search system
 	latch first to obey the latching order. */
 
 	innobase_release_stat_resources(trx);
@@ -12496,6 +12494,15 @@ static MYSQL_SYSVAR_ULONG(undo_logs, srv
   1,			/* Minimum value */
   TRX_SYS_N_RSEGS, 0);	/* Maximum value */
 
+/* Alias for innodb_undo_logs, this config variable is deprecated. */
+static MYSQL_SYSVAR_ULONG(rollback_segments, srv_undo_logs,
+  PLUGIN_VAR_OPCMDARG,
+  "Number of undo logs to use (deprecated).",
+  NULL, NULL,
+  TRX_SYS_N_RSEGS,	/* Default setting */
+  1,			/* Minimum value */
+  TRX_SYS_N_RSEGS, 0);	/* Maximum value */
+
 static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode,
   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
   "The AUTOINC lock modes supported by InnoDB:               "
@@ -12677,6 +12684,7 @@ static struct st_mysql_sys_var* innobase
 #endif /* defined UNIV_DEBUG || defined UNIV_PERF_DEBUG */
   MYSQL_SYSVAR(print_all_deadlocks),
   MYSQL_SYSVAR(undo_logs),
+  MYSQL_SYSVAR(rollback_segments),
   MYSQL_SYSVAR(undo_directory),
   MYSQL_SYSVAR(undo_tablespaces),
   MYSQL_SYSVAR(sync_array_size),

=== modified file 'storage/innobase/include/sync0sync.h'
--- a/storage/innobase/include/sync0sync.h	2011-06-16 09:26:09 +0000
+++ b/storage/innobase/include/sync0sync.h	2011-07-26 03:21:33 +0000
@@ -111,7 +111,7 @@ extern mysql_pfs_key_t	trx_undo_mutex_ke
 extern mysql_pfs_key_t	trx_mutex_key;
 extern mysql_pfs_key_t	lock_sys_mutex_key;
 extern mysql_pfs_key_t	lock_sys_wait_mutex_key;
-extern mysql_pfs_key_t	read_view_mutex_key;
+extern mysql_pfs_key_t	trx_sys_mutex_key;
 extern mysql_pfs_key_t	srv_sys_mutex_key;
 extern mysql_pfs_key_t	srv_sys_tasks_mutex_key;
 extern mysql_pfs_key_t	srv_conc_mutex_key;
@@ -604,7 +604,7 @@ V
 lock_sys_mutex				Mutex protecting lock_sys_t
 |
 V
-trx_sys->lock				RW-lock protecting trx_sys_t
+trx_sys->mutex				Mutex protecting trx_sys_t
 |
 V
 Threads mutex				Background thread scheduling mutex
@@ -688,7 +688,6 @@ or row lock! */
 #define SYNC_LOCK_SYS		299
 #define SYNC_TRX_SYS		298
 #define SYNC_TRX		297
-#define SYNC_READ_VIEW		296
 #define SYNC_THREADS		295
 #define SYNC_REC_LOCK		294
 #define SYNC_TRX_SYS_HEADER	290

=== modified file 'storage/innobase/include/trx0sys.h'
--- a/storage/innobase/include/trx0sys.h	2011-07-19 00:25:20 +0000
+++ b/storage/innobase/include/trx0sys.h	2011-07-26 03:21:33 +0000
@@ -132,8 +132,7 @@ ib_bh_t*
 trx_sys_init_at_db_start(void);
 /*==========================*/
 /*****************************************************************//**
-Creates the trx_sys instance and initializes ib_bh, lock and
-read_view_mutex. */
+Creates the trx_sys instance and initializes ib_bh and mutex. */
 UNIV_INTERN
 void
 trx_sys_create(void);
@@ -674,9 +673,9 @@ struct trx_doublewrite_struct{
 /** The transaction system central memory data structure. */
 struct trx_sys_struct{
 
-	rw_lock_t	lock;		/*!< read-write lock protecting most
-					fields in this structure except when
-					noted otherwise */
+	mutex_t		mutex;		/*!< mutex protecting most fields in
+					this structure except when noted
+					otherwise */
 	ulint		n_mysql_trx;	/*!< Number of transactions currently
 					allocated for MySQL */
 	ulint		n_prepared_trx;	/*!< Number of transactions currently
@@ -702,7 +701,6 @@ struct trx_sys_struct{
 					list (update undo logs for committed
 					transactions), protected by
 					rseg->mutex */
-	mutex_t		read_view_mutex;/*!< Protects the view_list */
 	UT_LIST_BASE_NODE_T(read_view_t) view_list;
 					/*!< List of read views sorted
 					on trx no, biggest first */

=== modified file 'storage/innobase/include/trx0sys.ic'
--- a/storage/innobase/include/trx0sys.ic	2011-07-19 00:25:20 +0000
+++ b/storage/innobase/include/trx0sys.ic	2011-07-26 03:21:33 +0000
@@ -231,7 +231,7 @@ trx_read_trx_id(
 
 /****************************************************************//**
 Looks for the trx handle with the given id in trx_list.
-The caller must be holding trx_sys->lock.
+The caller must be holding trx_sys->mutex.
 @return	the trx handle or NULL if not found;
 the pointer must not be dereferenced unless lock_sys->mutex was
 acquired before calling this function and is still being held */
@@ -245,9 +245,7 @@ trx_get_on_id(
 	ulint		len;
 	trx_t*		first;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	len = UT_LIST_GET_LEN(trx_sys->trx_list);
 
@@ -310,9 +308,7 @@ trx_list_get_min_trx_id_low(void)
 	trx_id_t	id;
 	const trx_t*	trx;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	trx = UT_LIST_GET_LAST(trx_sys->trx_list);
 	ut_ad(trx == NULL || trx->in_trx_list);
@@ -334,11 +330,13 @@ trx_assert_recovered(
 {
 	const trx_t*	trx;
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
+
 	trx = trx_get_on_id(trx_id);
 	ut_a(trx);
 	ut_a(trx->is_recovered);
-	rw_lock_s_unlock(&trx_sys->lock);
+
+	mutex_exit(&trx_sys->mutex);
 
 	return(TRUE);
 }
@@ -357,19 +355,19 @@ trx_list_get_min_trx_id(void)
 {
 	trx_id_t	id;
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	id = trx_list_get_min_trx_id_low();
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(id);
 }
 
 /****************************************************************//**
 Checks if a transaction with the given id is active. Caller must hold
-trx_sys->lock in shared mode. If the caller is not holding
-lock_sys->mutex, the transaction may already have been committed.
+trx_sys->mutex. If the caller is not holding lock_sys->mutex, the
+transaction may already have been committed.
 @return	transaction instance if active, or NULL;
 the pointer must not be dereferenced unless lock_sys->mutex was
 acquired before calling this function and is still being held */
@@ -383,9 +381,7 @@ trx_is_active_low(
 {
 	trx_t*		trx;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	if (trx_id < trx_list_get_min_trx_id_low()) {
 
@@ -429,11 +425,11 @@ trx_is_active(
 {
 	trx_t*		trx;
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	trx = trx_is_active_low(trx_id, corrupt);
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(trx);
 }
@@ -446,9 +442,7 @@ trx_id_t
 trx_sys_get_new_trx_id(void)
 /*========================*/
 {
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_EX));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	/* VERY important: after the database is started, max_trx_id value is
 	divisible by TRX_SYS_TRX_ID_WRITE_MARGIN, and the following if
@@ -474,17 +468,16 @@ trx_id_t
 trx_sys_get_max_trx_id(void)
 /*========================*/
 {
+	ut_ad(!mutex_own(&trx_sys->mutex));
+
 #if UNIV_WORD_SIZE < DATA_TRX_ID_LEN
 	trx_id_t	max_trx_id;
 	/* Avoid torn reads. */
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 	max_trx_id = trx_sys->max_trx_id;
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 	return(max_trx_id);
 #else
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(!rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
 	/* Perform a dirty read. Callers should be prepared for stale
 	values, and we know that the value fits in a machine word, so
 	that it will be read and written atomically. */
@@ -502,11 +495,11 @@ trx_sys_get_n_trx(void)
 {
 	ulint	n_trx;
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	n_trx = UT_LIST_GET_LEN(trx_sys->trx_list);
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(n_trx);
 }

=== modified file 'storage/innobase/include/trx0trx.ic'
--- a/storage/innobase/include/trx0trx.ic	2011-02-03 22:18:48 +0000
+++ b/storage/innobase/include/trx0trx.ic	2011-07-26 03:21:33 +0000
@@ -25,7 +25,7 @@ Created 3/26/1996 Heikki Tuuri
 
 /**********************************************************************//**
 Determines if a transaction is in the given state.
-The caller must hold trx_sys->lock, or it must be the thread
+The caller must hold trx_sys->mutex, or it must be the thread
 that is serving a running transaction.
 A running transaction must be in trx_sys->trx_list.
 @return	TRUE if trx->state == state */

=== modified file 'storage/innobase/lock/lock0lock.c'
--- a/storage/innobase/lock/lock0lock.c	2011-07-13 05:08:21 +0000
+++ b/storage/innobase/lock/lock0lock.c	2011-07-26 03:21:33 +0000
@@ -1640,10 +1640,8 @@ lock_sec_rec_some_has_impl(
 	trx_id_t	max_trx_id;
 	const page_t*	page = page_align(rec);
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(!rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
 	ut_ad(!lock_mutex_own());
+	ut_ad(!mutex_own(&trx_sys->mutex));
 	ut_ad(!dict_index_is_clust(index));
 	ut_ad(page_rec_is_user_rec(rec));
 	ut_ad(rec_offs_validate(rec, index, offsets));
@@ -3463,7 +3461,7 @@ lock_deadlock_trx_print(
 	n_lock_struct = UT_LIST_GET_LEN(trx->lock.trx_locks);
 	heap_size = mem_heap_get_size(trx->lock.lock_heap);
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	trx_print_low(lock_latest_err_file, trx, max_query_len,
 		      n_lock_rec, n_lock_struct, heap_size);
@@ -3473,7 +3471,7 @@ lock_deadlock_trx_print(
 			      n_lock_rec, n_lock_struct, heap_size);
 	}
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 }
 
 /*********************************************************************//**
@@ -4703,7 +4701,7 @@ lock_remove_recovered_trx_record_locks(
 	ut_a(table != NULL);
 	ut_ad(lock_mutex_own());
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	for (trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
 	     trx != NULL;
@@ -4747,7 +4745,7 @@ lock_remove_recovered_trx_record_locks(
 		++n_recovered_trx;
 	}
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(n_recovered_trx);
 }
@@ -5075,7 +5073,7 @@ lock_print_info_all_transactions(
 
 	ut_ad(lock_mutex_own());
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	/* First print info on non-active transactions */
 
@@ -5086,7 +5084,7 @@ lock_print_info_all_transactions(
 		ut_ad(trx->in_mysql_trx_list);
 
 		/* trx->state cannot change from or to NOT_STARTED
-		while we are holding the trx_sys->lock. It may change
+		while we are holding the trx_sys->mutex. It may change
 		from ACTIVE to PREPARED, but it may not change to
 		COMMITTED, because we are holding the lock_sys->mutex. */
 		if (trx_state_eq(trx, TRX_STATE_NOT_STARTED)) {
@@ -5097,7 +5095,7 @@ lock_print_info_all_transactions(
 
 loop:
 	/* Since we temporarily release lock_sys->mutex and
-	trx_sys->lock when reading a database page in below,
+	trx_sys->mutex when reading a database page in below,
 	variable trx may be obsolete now and we must loop
 	through the trx list to get probably the same trx,
 	or some other trx. */
@@ -5111,7 +5109,7 @@ loop:
 	if (trx == NULL) {
 
 		lock_mutex_exit();
-		rw_lock_s_unlock(&trx_sys->lock);
+		mutex_exit(&trx_sys->mutex);
 
 		ut_ad(lock_validate());
 
@@ -5197,7 +5195,7 @@ loop:
 			}
 
 			lock_mutex_exit();
-			rw_lock_s_unlock(&trx_sys->lock);
+			mutex_exit(&trx_sys->mutex);
 
 			mtr_start(&mtr);
 
@@ -5210,7 +5208,7 @@ loop:
 
 			lock_mutex_enter();
 
-			rw_lock_s_lock(&trx_sys->lock);
+			mutex_enter(&trx_sys->mutex);
 
 			goto loop;
 		}
@@ -5290,16 +5288,14 @@ lock_table_queue_validate(
 	const lock_t*	lock;
 
 	ut_ad(lock_mutex_own());
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	for (lock = UT_LIST_GET_FIRST(table->locks);
 	     lock != NULL;
 	     lock = UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock)) {
 
 		/* lock->trx->state cannot change from or to NOT_STARTED
-		while we are holding the trx_sys->lock. It may change
+		while we are holding the trx_sys->mutex. It may change
 		from ACTIVE to PREPARED, but it may not change to
 		COMMITTED, because we are holding the lock_sys->mutex. */
 		ut_ad(trx_assert_started(lock->trx));
@@ -5345,16 +5341,12 @@ lock_rec_queue_validate(
 	ut_ad(rec_offs_validate(rec, index, offsets));
 	ut_ad(!page_rec_is_comp(rec) == !rec_offs_comp(offsets));
 	ut_ad(lock_mutex_own() == locked_lock_trx_sys);
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED)
-	      == locked_lock_trx_sys);
-#endif /* UNIV_SYNC_DEBUG */
 
 	heap_no = page_rec_get_heap_no(rec);
 
 	if (!locked_lock_trx_sys) {
 		lock_mutex_enter();
-		rw_lock_s_lock(&trx_sys->lock);
+		mutex_enter(&trx_sys->mutex);
 	}
 
 	if (!page_rec_is_user_rec(rec)) {
@@ -5431,7 +5423,7 @@ lock_rec_queue_validate(
 func_exit:
 	if (!locked_lock_trx_sys) {
 		lock_mutex_exit();
-		rw_lock_s_unlock(&trx_sys->lock);
+		mutex_exit(&trx_sys->mutex);
 	}
 
 	return(TRUE);
@@ -5457,13 +5449,9 @@ lock_rec_validate_page(
 	rec_offs_init(offsets_);
 
 	ut_ad(!lock_mutex_own());
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(!rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-	ut_ad(!rw_lock_own(&trx_sys->lock, RW_LOCK_EX));
-#endif /* UNIV_SYNC_DEBUG */
 
 	lock_mutex_enter();
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 loop:
 	lock = lock_rec_get_first_on_page_addr(buf_block_get_space(block),
 					       buf_block_get_page_no(block));
@@ -5528,7 +5516,7 @@ loop:
 
 function_exit:
 	lock_mutex_exit();
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	if (UNIV_LIKELY_NULL(heap)) {
 		mem_heap_free(heap);
@@ -5550,7 +5538,7 @@ lock_validate(void)
 
 	lock_mutex_enter();
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	for (trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
 	     trx != NULL;
@@ -5599,7 +5587,7 @@ lock_validate(void)
 			}
 
 			lock_mutex_exit();
-			rw_lock_s_unlock(&trx_sys->lock);
+			mutex_exit(&trx_sys->mutex);
 
 			/* The lock and the block that it is referring
 			to may be freed at this point. We pass
@@ -5621,13 +5609,13 @@ lock_validate(void)
 			limit++;
 
 			lock_mutex_enter();
-			rw_lock_s_lock(&trx_sys->lock);
+			mutex_enter(&trx_sys->mutex);
 		}
 	}
 
 	lock_mutex_exit();
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(TRUE);
 }
@@ -6531,10 +6519,10 @@ lock_trx_release_locks(
 	trx_t*	trx)	/*!< in/out: transaction */
 {
 	if (UNIV_UNLIKELY(trx_state_eq(trx, TRX_STATE_PREPARED))) {
-		rw_lock_x_lock(&trx_sys->lock);
+		mutex_enter(&trx_sys->mutex);
 		ut_a(trx_sys->n_prepared_trx > 0);
 		trx_sys->n_prepared_trx--;
-		rw_lock_x_unlock(&trx_sys->lock);
+		mutex_exit(&trx_sys->mutex);
 	} else {
 		ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE));
 	}
@@ -6652,7 +6640,7 @@ lock_table_locks_check(
 	ut_a(table != NULL);
 	ut_ad(lock_mutex_own());
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	for (trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
 	     trx != NULL;
@@ -6676,7 +6664,7 @@ lock_table_locks_check(
 		}
 	}
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(NULL);
 }

=== modified file 'storage/innobase/read/read0read.c'
--- a/storage/innobase/read/read0read.c	2011-01-24 10:28:28 +0000
+++ b/storage/innobase/read/read0read.c	2011-07-26 03:21:33 +0000
@@ -167,11 +167,10 @@ For details see: row_vers_old_has_index_
 Some additional issues:
 
 What if trx_sys->view_list == NULL and some transaction T1 and Purge both
-try to open read_view at same time. Both can get trx_sys->lock in S mode.
+try to open read_view at same time. Only one can acquire trx_sys->mutex.
 In which order will the views be opened? Should it matter? If no, why?
 
-The order does not matter. Since both purge and transaction T1 will get the
-trx_sys->lock in S mode, no new transactions can be created and no running
+The order does not matter. No new transactions can be created and no running
 transaction can commit or rollback (or free views).
 */
 
@@ -186,9 +185,7 @@ read_view_validate(
 {
 	ulint	i;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	/* Check that the view->trx_ids array is in descending order. */
 	for (i = 1; i < view->n_trx_ids; ++i) {
@@ -209,11 +206,7 @@ read_view_list_validate(void)
 	const read_view_t*	view;
 	const read_view_t*	prev_view = NULL;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
-
-	mutex_enter(&trx_sys->read_view_mutex);
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	for (view = UT_LIST_GET_FIRST(trx_sys->view_list);
 	     view != NULL;
@@ -223,8 +216,6 @@ read_view_list_validate(void)
 		     || prev_view->low_limit_no >= view->low_limit_no);
 	}
 
-	mutex_exit(&trx_sys->read_view_mutex);
-
 	return(TRUE);
 }
 #endif
@@ -267,10 +258,7 @@ read_view_clone(
 	read_view_t*	clone;
 	read_view_t*	new_view;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
-	ut_ad(mutex_own(&trx_sys->read_view_mutex));
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	/* Allocate space for two views. */
 
@@ -308,13 +296,9 @@ read_view_add(
 	read_view_t*	elem;
 	read_view_t*	prev_elem;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 	ut_ad(read_view_validate(view));
 
-	mutex_enter(&trx_sys->read_view_mutex);
-
 	/* Find the correct slot for insertion. */
 	for (elem = UT_LIST_GET_FIRST(trx_sys->view_list), prev_elem = NULL;
 	     elem != NULL && view->low_limit_no < elem->low_limit_no;
@@ -329,8 +313,6 @@ read_view_add(
 			view_list, trx_sys->view_list, prev_elem, view);
 	}
 
-	mutex_exit(&trx_sys->read_view_mutex);
-
 	ut_ad(read_view_list_validate());
 }
 
@@ -351,9 +333,7 @@ read_view_open_now_low(
 	read_view_t*	view;
 	ulint		n_trx = UT_LIST_GET_LEN(trx_sys->trx_list);
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	view = read_view_create_low(n_trx, heap);
 
@@ -377,7 +357,7 @@ read_view_open_now_low(
 		ut_ad(trx->in_trx_list);
 
 		/* trx->state cannot change from or to NOT_STARTED
-		while we are holding the trx_sys->lock. It may change
+		while we are holding the trx_sys->mutex. It may change
 		from ACTIVE to PREPARED or COMMITTED. */
 
 		if (trx->id != cr_trx_id
@@ -392,7 +372,7 @@ read_view_open_now_low(
 			transaction starts, we initialize trx->no to
 			IB_ULONGLONG_MAX. */
 
-			/* trx->no is protected by trx_sys->lock, which
+			/* trx->no is protected by trx_sys->mutex, which
 			we are holding. It is assigned by trx_commit()
 			before lock_trx_release_locks() assigns
 			trx->state = TRX_STATE_COMMITTED_IN_MEMORY. */
@@ -434,11 +414,11 @@ read_view_open_now(
 {
 	read_view_t*	view;
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	view = read_view_open_now_low(cr_trx_id, heap);
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(view);
 }
@@ -462,19 +442,15 @@ read_view_purge_open(
 	trx_id_t	creator_trx_id;
 	ulint		insert_done	= 0;
 
-	rw_lock_s_lock(&trx_sys->lock);
-
-	mutex_enter(&trx_sys->read_view_mutex);
+	mutex_enter(&trx_sys->mutex);
 
 	oldest_view = UT_LIST_GET_LAST(trx_sys->view_list);
 
 	if (oldest_view == NULL) {
 
-		mutex_exit(&trx_sys->read_view_mutex);
-
 		view = read_view_open_now_low(0, heap);
 
-		rw_lock_s_unlock(&trx_sys->lock);
+		mutex_exit(&trx_sys->mutex);
 
 		return(view);
 	}
@@ -483,8 +459,6 @@ read_view_purge_open(
 
 	oldest_view = read_view_clone(oldest_view, heap);
 
-	mutex_exit(&trx_sys->read_view_mutex);
-
 	ut_ad(read_view_validate(oldest_view));
 
 	ut_a(oldest_view->creator_trx_id > 0);
@@ -532,7 +506,7 @@ read_view_purge_open(
 
 	read_view_add(view);
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(view);
 }
@@ -546,24 +520,15 @@ read_view_remove(
 	read_view_t*	view)	/*!< in: read view */
 {
 	/* We acquire an S lock for the debug validate code. */
-	ut_d(rw_lock_s_lock(&trx_sys->lock));
+	mutex_enter(&trx_sys->mutex);
 
 	ut_ad(read_view_validate(view));
 
-	ut_d(rw_lock_s_unlock(&trx_sys->lock));
-
-	mutex_enter(&trx_sys->read_view_mutex);
-
 	UT_LIST_REMOVE(view_list, trx_sys->view_list, view);
 
-	mutex_exit(&trx_sys->read_view_mutex);
-
-	/* We acquire an S lock for the debug validate code. */
-	ut_d(rw_lock_s_lock(&trx_sys->lock));
-
 	ut_ad(read_view_list_validate());
 
-	ut_d(rw_lock_s_unlock(&trx_sys->lock));
+	mutex_exit(&trx_sys->mutex);
 }
 
 /*********************************************************************//**
@@ -656,7 +621,7 @@ read_cursor_view_create_for_mysql(
 
 	cr_trx->n_mysql_tables_in_use = 0;
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	n_trx = UT_LIST_GET_LEN(trx_sys->trx_list);
 
@@ -681,7 +646,7 @@ read_cursor_view_create_for_mysql(
 	     trx = UT_LIST_GET_NEXT(trx_list, trx)) {
 
 		/* trx->state cannot change from or to NOT_STARTED
-		while we are holding the trx_sys->lock. It may change
+		while we are holding the trx_sys->mutex. It may change
 		from ACTIVE to PREPARED or COMMITTED. */
 		if (!trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY)) {
 			ut_a(n_trx < view->n_trx_ids);
@@ -694,7 +659,7 @@ read_cursor_view_create_for_mysql(
 			transaction starts, we initialize trx->no to
 			IB_ULONGLONG_MAX. */
 
-			/* trx->no is protected by trx_sys->lock, which
+			/* trx->no is protected by trx_sys->mutex, which
 			we are holding. It is assigned by trx_commit()
 			before lock_trx_release_locks() assigns
 			trx->state = TRX_STATE_COMMITTED_IN_MEMORY. */
@@ -718,7 +683,7 @@ read_cursor_view_create_for_mysql(
 
 	read_view_add(view);
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(curview);
 }
@@ -761,7 +726,7 @@ read_cursor_set_for_mysql(
 {
 	ut_a(trx);
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	if (UNIV_LIKELY(curview != NULL)) {
 		trx->read_view = curview->read_view;
@@ -771,5 +736,5 @@ read_cursor_set_for_mysql(
 
 	ut_ad(read_view_validate(trx->read_view));
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 }

=== modified file 'storage/innobase/row/row0ins.c'
--- a/storage/innobase/row/row0ins.c	2011-06-16 09:26:09 +0000
+++ b/storage/innobase/row/row0ins.c	2011-07-26 03:21:33 +0000
@@ -626,7 +626,7 @@ row_ins_foreign_trx_print(
 	heap_size = mem_heap_get_size(trx->lock.lock_heap);
 	lock_mutex_exit();
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	mutex_enter(&dict_foreign_err_mutex);
 	rewind(dict_foreign_err_file);
@@ -636,7 +636,7 @@ row_ins_foreign_trx_print(
 	trx_print_low(dict_foreign_err_file, trx, 600,
 		      n_lock_rec, n_lock_struct, heap_size);
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	ut_ad(mutex_own(&dict_foreign_err_mutex));
 }

=== modified file 'storage/innobase/row/row0row.c'
--- a/storage/innobase/row/row0row.c	2011-07-08 13:40:10 +0000
+++ b/storage/innobase/row/row0row.c	2011-07-26 03:21:33 +0000
@@ -233,10 +233,7 @@ row_build(
 
 	ut_ad(index && rec && heap);
 	ut_ad(dict_index_is_clust(index));
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(!rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-	ut_ad(!rw_lock_own(&trx_sys->lock, RW_LOCK_EX));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(!mutex_own(&trx_sys->mutex));
 
 	if (!offsets) {
 		offsets = rec_get_offsets(rec, index, offsets_,

=== modified file 'storage/innobase/row/row0vers.c'
--- a/storage/innobase/row/row0vers.c	2011-06-16 09:26:09 +0000
+++ b/storage/innobase/row/row0vers.c	2011-07-26 03:21:33 +0000
@@ -273,11 +273,8 @@ row_vers_impl_x_locked(
 	trx_id_t	trx_id;
 	mtr_t		mtr;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(!rw_lock_own(&purge_sys->latch, RW_LOCK_SHARED));
-	ut_ad(!rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
 	ut_ad(!lock_mutex_own());
+	ut_ad(!mutex_own(&trx_sys->mutex));
 
 	mtr_start(&mtr);
 
@@ -676,17 +673,17 @@ row_vers_build_for_semi_consistent_read(
 			rec_trx_id = version_trx_id;
 		}
 
-		rw_lock_s_lock(&trx_sys->lock);
+		mutex_enter(&trx_sys->mutex);
 		version_trx = trx_get_on_id(version_trx_id);
 		/* version_trx->state cannot change from or to
-		NOT_STARTED while we are holding the trx_sys->lock.
+		NOT_STARTED while we are holding the trx_sys->mutex.
 		It may change from ACTIVE to PREPARED or COMMITTED. */
 		if (version_trx
 		    && trx_state_eq(version_trx,
 				    TRX_STATE_COMMITTED_IN_MEMORY)) {
 			version_trx = NULL;
 		}
-		rw_lock_s_unlock(&trx_sys->lock);
+		mutex_exit(&trx_sys->mutex);
 
 		if (!version_trx) {
 

=== modified file 'storage/innobase/srv/srv0srv.c'
--- a/storage/innobase/srv/srv0srv.c	2011-07-20 04:43:44 +0000
+++ b/storage/innobase/srv/srv0srv.c	2011-07-26 03:21:33 +0000
@@ -1211,7 +1211,7 @@ srv_printf_innodb_monitor(
 		(long) srv_conc_n_threads,
 		srv_conc_get_waiting_threads());
 
-	/* This is a dirty read, without holding trx_sys->read_view_mutex. */
+	/* This is a dirty read, without holding trx_sys->mutex. */
 	fprintf(file, "%lu read views open inside InnoDB\n",
 		UT_LIST_GET_LEN(trx_sys->view_list));
 

=== modified file 'storage/innobase/sync/sync0sync.c'
--- a/storage/innobase/sync/sync0sync.c	2011-06-16 09:26:09 +0000
+++ b/storage/innobase/sync/sync0sync.c	2011-07-26 03:21:33 +0000
@@ -1221,7 +1221,6 @@ sync_thread_add_level(
 	case SYNC_SEARCH_SYS:
 	case SYNC_SEARCH_SYS_CONF:
 	case SYNC_THREADS:
-	case SYNC_READ_VIEW:
 	case SYNC_LOCK_SYS:
 	case SYNC_LOCK_WAIT_SYS:
 	case SYNC_TRX_SYS:

=== modified file 'storage/innobase/trx/trx0i_s.c'
--- a/storage/innobase/trx/trx0i_s.c	2011-03-28 09:15:58 +0000
+++ b/storage/innobase/trx/trx0i_s.c	2011-07-26 03:21:33 +0000
@@ -174,7 +174,7 @@ struct trx_i_s_cache_struct {
 	ha_storage_t*	storage;	/*!< storage for external volatile
 					data that may become unavailable
 					when we release
-					lock_sys->mutex or trx_sys->lock */
+					lock_sys->mutex or trx_sys->mutex */
 	ulint		mem_allocd;	/*!< the amount of memory
 					allocated with mem_alloc*() */
 	ibool		is_truncated;	/*!< this is TRUE if the memory
@@ -1281,9 +1281,7 @@ fetch_data_into_cache(
 	i_s_locks_row_t*	requested_lock_row;
 
 	ut_ad(lock_mutex_own());
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	trx_i_s_cache_clear(cache);
 
@@ -1347,11 +1345,11 @@ trx_i_s_possibly_fetch_data_into_cache(
 
 	lock_mutex_enter();
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	fetch_data_into_cache(cache);
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	lock_mutex_exit();
 

=== modified file 'storage/innobase/trx/trx0purge.c'
--- a/storage/innobase/trx/trx0purge.c	2011-07-19 00:25:20 +0000
+++ b/storage/innobase/trx/trx0purge.c	2011-07-26 03:21:33 +0000
@@ -263,11 +263,9 @@ trx_purge_add_update_undo_to_history(
 #ifdef HAVE_ATOMIC_BUILTINS
 	os_atomic_increment_ulint(&trx_sys->rseg_history_len, 1);
 #else
-	rw_lock_x_lock(&trx_sys->lock);
-
+	mutex_enter(&trx_sys->mutex);
 	++trx_sys->rseg_history_len;
-
-	rw_lock_x_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 #endif /* HAVE_ATOMIC_BUILTINS */
 
 	srv_wake_purge_thread_if_not_active();
@@ -371,11 +369,9 @@ trx_purge_free_segment(
 #ifdef HAVE_ATOMIC_BUILTINS
 	os_atomic_decrement_ulint(&trx_sys->rseg_history_len, n_removed_logs);
 #else
-	rw_lock_x_lock(&trx_sys->lock);
-
+	mutex_enter(&trx_sys->mutex);
 	trx_sys->rseg_history_len -= n_removed_logs;
-
-	rw_lock_x_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 #endif /* HAVE_ATOMIC_BUILTINS */
 
 	do {
@@ -460,11 +456,9 @@ loop:
 		os_atomic_decrement_ulint(
 			&trx_sys->rseg_history_len, n_removed_logs);
 #else
-		rw_lock_x_lock(&trx_sys->lock);
-
+		mutex_enter(&trx_sys->mutex);
 		trx_sys->rseg_history_len -= n_removed_logs;
-
-		rw_lock_x_unlock(&trx_sys->lock);
+		mutex_exit(&trx_sys->mutex);	
 #endif /* HAVE_ATOMIC_BUILTINS */
 
 		flst_truncate_end(rseg_hdr + TRX_RSEG_HISTORY,
@@ -593,7 +587,7 @@ trx_purge_rseg_get_next_history_log(
 		mutex_exit(&(rseg->mutex));
 		mtr_commit(&mtr);
 
-		rw_lock_s_lock(&trx_sys->lock);
+		mutex_enter(&trx_sys->mutex);
 
 		/* Add debug code to track history list corruption reported
 		on the MySQL mailing list on Nov 9, 2004. The fut0lst.c
@@ -615,7 +609,7 @@ trx_purge_rseg_get_next_history_log(
 				(ulong) trx_sys->rseg_history_len);
 		}
 
-		rw_lock_s_unlock(&trx_sys->lock);
+		mutex_exit(&trx_sys->mutex);
 
 		return;
 	}
@@ -1095,7 +1089,7 @@ trx_purge_dml_delay(void)
 	'consistent read view', then the DML statements cannot be delayed.
 	Also, srv_max_purge_lag <= 0 means 'infinity'. Note: we do a dirty
 	read of the trx_sys_t data structure here, without holding
-	trx_sys->read_view_mutex. */
+	trx_sys->mutex. */
 	if (srv_max_purge_lag > 0
 	    && !UT_LIST_GET_LAST(trx_sys->view_list)) {
 		float	ratio = (float) trx_sys->rseg_history_len

=== modified file 'storage/innobase/trx/trx0roll.c'
--- a/storage/innobase/trx/trx0roll.c	2011-04-05 11:12:48 +0000
+++ b/storage/innobase/trx/trx0roll.c	2011-07-26 03:21:33 +0000
@@ -161,7 +161,7 @@ trx_rollback_for_mysql(
 /*===================*/
 	trx_t*	trx)	/*!< in/out: transaction */
 {
-	/* We are reading trx->state without holding trx_sys->lock
+	/* We are reading trx->state without holding trx_sys->mutex
 	here, because the rollback should be invoked for a running
 	active MySQL transaction (or recovered prepared transaction)
 	that is associated with the current thread. */
@@ -213,7 +213,7 @@ trx_rollback_last_sql_stat_for_mysql(
 {
 	int	err;
 
-	/* We are reading trx->state without holding trx_sys->lock
+	/* We are reading trx->state without holding trx_sys->mutex
 	here, because the statement rollback should be invoked for a
 	running active MySQL transaction that is associated with the
 	current thread. */
@@ -381,7 +381,7 @@ trx_rollback_to_savepoint_for_mysql(
 {
 	trx_named_savept_t*	savep;
 
-	/* We are reading trx->state without holding trx_sys->lock
+	/* We are reading trx->state without holding trx_sys->mutex
 	here, because the savepoint rollback should be invoked for a
 	running active MySQL transaction that is associated with the
 	current thread. */
@@ -550,7 +550,7 @@ trx_rollback_active(
 
 	ut_a(thr == que_fork_start_command(fork));
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	trx_roll_crash_recv_trx	= trx;
 
@@ -560,7 +560,7 @@ trx_rollback_active(
 
 	rows_to_undo = trx_roll_max_undo_no;
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	if (rows_to_undo > 1000000000) {
 		rows_to_undo = rows_to_undo / 1000000;
@@ -645,7 +645,7 @@ Rollback or clean up any resurrected inc
 that the caller holds the trx_sys_t::lock in S mode and it will release the
 lock if it does a clean up or rollback.
 @return TRUE if the transaction was cleaned up or rolled back
-and trx_sys->lock was released. */
+and trx_sys->mutex was released. */
 static
 ibool
 trx_rollback_resurrected(
@@ -654,9 +654,7 @@ trx_rollback_resurrected(
 	ibool	all)	/*!< in: FALSE=roll back dictionary transactions;
 			TRUE=roll back all non-PREPARED transactions */
 {
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	/* The trx->is_recovered flag and trx->state are set
 	atomically under the protection of the trx->mutex (and
@@ -672,7 +670,7 @@ trx_rollback_resurrected(
 
 	switch (trx->state) {
 	case TRX_STATE_COMMITTED_IN_MEMORY:
-		rw_lock_s_unlock(&trx_sys->lock);
+		mutex_exit(&trx_sys->mutex);
 		trx_mutex_exit(trx);
 		fprintf(stderr,
 			"InnoDB: Cleaning up trx with id " TRX_ID_FMT "\n",
@@ -682,7 +680,7 @@ trx_rollback_resurrected(
 	case TRX_STATE_ACTIVE:
 		trx_mutex_exit(trx);
 		if (all || trx_get_dict_operation(trx) != TRX_DICT_OP_NONE) {
-			rw_lock_s_unlock(&trx_sys->lock);
+			mutex_exit(&trx_sys->mutex);
 			trx_rollback_active(trx);
 			return(TRUE);
 		}
@@ -732,7 +730,7 @@ trx_rollback_or_clean_recovered(
 	recovered transactions to clean up or recover. */
 
 	do {
-		rw_lock_s_lock(&trx_sys->lock);
+		mutex_enter(&trx_sys->mutex);
 
 		for (trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
 		     trx != NULL;
@@ -741,18 +739,18 @@ trx_rollback_or_clean_recovered(
 			ut_ad(trx->in_trx_list);
 
 			/* If this function does a cleanup or rollback
-			then it will release the trx_sys->lock, therefore
+			then it will release the trx_sys->mutex, therefore
 			we need to reacquire it before retrying the loop. */
 
 			if (trx_rollback_resurrected(trx, all)) {
 
-				rw_lock_s_lock(&trx_sys->lock);
+				mutex_enter(&trx_sys->mutex);
 
 				break;
 			}
 		}
 
-		rw_lock_s_unlock(&trx_sys->lock);
+		mutex_exit(&trx_sys->mutex);
 
 	} while (trx != NULL);
 

=== modified file 'storage/innobase/trx/trx0rseg.c'
--- a/storage/innobase/trx/trx0rseg.c	2011-07-19 00:25:20 +0000
+++ b/storage/innobase/trx/trx0rseg.c	2011-07-26 03:21:33 +0000
@@ -309,7 +309,7 @@ trx_rseg_create(
 	mtr_start(&mtr);
 
 	/* To obey the latching order, acquire the file space
-	x-latch before the trx_sys->lock. */
+	x-latch before the trx_sys->mutex. */
 	mtr_x_lock(fil_space_get_latch(space, NULL), &mtr);
 
 	slot_no = trx_sysf_rseg_find_free(&mtr);

=== modified file 'storage/innobase/trx/trx0sys.c'
--- a/storage/innobase/trx/trx0sys.c	2011-07-19 00:25:20 +0000
+++ b/storage/innobase/trx/trx0sys.c	2011-07-26 03:21:33 +0000
@@ -132,13 +132,7 @@ static const ulint	FILE_FORMAT_NAME_N
 /* Key to register the mutex with performance schema */
 UNIV_INTERN mysql_pfs_key_t	trx_doublewrite_mutex_key;
 UNIV_INTERN mysql_pfs_key_t	file_format_max_mutex_key;
-/* Key to register the trx_sys->read_view_mutex with performance schema */
-UNIV_INTERN mysql_pfs_key_t	read_view_mutex_key;
-#endif /* UNIV_PFS_MUTEX */
-
-#ifdef UNIV_PFS_RWLOCK
-/* Key to register the trx_sys->lock with performance schema */
-UNIV_INTERN mysql_pfs_key_t	trx_sys_rw_lock_key;
+UNIV_INTERN mysql_pfs_key_t	trx_sys_mutex_key;
 #endif /* UNIV_PFS_RWLOCK */
 
 #ifndef UNIV_HOTBACKUP
@@ -648,9 +642,7 @@ trx_in_trx_list(
 {
 	const trx_t*	trx;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	ut_ad(trx_assert_started(in_trx));
 
@@ -675,10 +667,7 @@ trx_sys_flush_max_trx_id(void)
 	mtr_t		mtr;
 	trx_sysf_t*	sys_header;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED)
-	      || rw_lock_own(&trx_sys->lock, RW_LOCK_EX));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	mtr_start(&mtr);
 
@@ -1034,7 +1023,7 @@ trx_sys_init_at_db_start(void)
 	the debug code (assertions). We are still running in single threaded
 	bootstrap mode. */
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	if (UT_LIST_GET_LEN(trx_sys->trx_list) > 0) {
 		const trx_t*	trx;
@@ -1065,7 +1054,7 @@ trx_sys_init_at_db_start(void)
 			(ullint) trx_sys->max_trx_id);
 	}
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	UT_LIST_INIT(trx_sys->view_list);
 
@@ -1075,8 +1064,7 @@ trx_sys_init_at_db_start(void)
 }
 
 /*****************************************************************//**
-Creates the trx_sys instance and initializes ib_bh, lock and
-read_view_mutex. */
+Creates the trx_sys instance and initializes ib_bh and mutex. */
 UNIV_INTERN
 void
 trx_sys_create(void)
@@ -1086,10 +1074,7 @@ trx_sys_create(void)
 
 	trx_sys = mem_zalloc(sizeof(*trx_sys));
 
-	rw_lock_create(trx_sys_rw_lock_key, &trx_sys->lock, SYNC_TRX_SYS);
-
-	mutex_create(
-		read_view_mutex_key, &trx_sys->read_view_mutex, SYNC_READ_VIEW);
+	mutex_create(trx_sys_mutex_key, &trx_sys->mutex, SYNC_TRX_SYS);
 }
 
 /*****************************************************************//**
@@ -1669,7 +1654,7 @@ trx_sys_close(void)
 	/* Check that all read views are closed except read view owned
 	by a purge. */
 
-	mutex_enter(&trx_sys->read_view_mutex);
+	mutex_enter(&trx_sys->mutex);
 
 	if (UT_LIST_GET_LEN(trx_sys->view_list) > 1) {
 		fprintf(stderr,
@@ -1679,7 +1664,7 @@ trx_sys_close(void)
 			UT_LIST_GET_LEN(trx_sys->view_list) - 1);
 	}
 
-	mutex_exit(&trx_sys->read_view_mutex);
+	mutex_exit(&trx_sys->mutex);
 
 	sess_close(trx_dummy_sess);
 	trx_dummy_sess = NULL;
@@ -1698,7 +1683,7 @@ trx_sys_close(void)
 	mem_free(trx_doublewrite);
 	trx_doublewrite = NULL;
 
-	rw_lock_x_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	/* Only prepared transactions may be left in the system. Free them. */
 	ut_a(UT_LIST_GET_LEN(trx_sys->trx_list) == trx_sys->n_prepared_trx);
@@ -1707,8 +1692,6 @@ trx_sys_close(void)
 		trx_free_prepared(trx);
 	}
 
-	mutex_free(&trx_sys->read_view_mutex);
-
 	/* There can't be any active transactions. */
 	for (i = 0; i < TRX_SYS_N_RSEGS; ++i) {
 		trx_rseg_t*	rseg;
@@ -1738,9 +1721,9 @@ trx_sys_close(void)
 	ut_a(UT_LIST_GET_LEN(trx_sys->view_list) == 0);
 	ut_a(UT_LIST_GET_LEN(trx_sys->mysql_trx_list) == 0);
 
-	rw_lock_x_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
-	rw_lock_free(&trx_sys->lock);
+	mutex_free(&trx_sys->mutex);
 
 	mem_free(trx_sys);
 
@@ -1757,14 +1740,14 @@ trx_sys_any_active_transactions(void)
 {
 	ulint	total_trx = 0;
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	total_trx = UT_LIST_GET_LEN(trx_sys->trx_list)
 		+ trx_sys->n_mysql_trx;
 	ut_a(total_trx >= trx_sys->n_prepared_trx);
 	total_trx -= trx_sys->n_prepared_trx;
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(total_trx);
 }
@@ -1780,10 +1763,7 @@ trx_sys_validate_trx_list(void)
 	const trx_t*	trx;
 	const trx_t*	prev_trx = NULL;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_EX)
-	      || rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	for (trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
 	     trx != NULL;

=== modified file 'storage/innobase/trx/trx0trx.c'
--- a/storage/innobase/trx/trx0trx.c	2011-07-19 00:25:20 +0000
+++ b/storage/innobase/trx/trx0trx.c	2011-07-26 03:21:33 +0000
@@ -172,14 +172,14 @@ trx_allocate_for_mysql(void)
 
 	trx = trx_allocate_for_background();
 
-	rw_lock_x_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	trx_sys->n_mysql_trx++;
 
 	ut_d(trx->in_mysql_trx_list = TRUE);
 	UT_LIST_ADD_FIRST(mysql_trx_list, trx_sys->mysql_trx_list, trx);
 
-	rw_lock_x_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(trx);
 }
@@ -297,9 +297,7 @@ trx_free_prepared(
 /*==============*/
 	trx_t*	trx)	/*!< in, own: trx object */
 {
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_EX));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	ut_a(trx_state_eq(trx, TRX_STATE_PREPARED));
 	ut_a(trx->magic_n == TRX_MAGIC_N);
@@ -319,7 +317,7 @@ trx_free_for_mysql(
 /*===============*/
 	trx_t*	trx)	/*!< in, own: trx object */
 {
-	rw_lock_x_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	ut_ad(trx->in_mysql_trx_list);
 	ut_d(trx->in_mysql_trx_list = FALSE);
@@ -329,7 +327,7 @@ trx_free_for_mysql(
 
 	trx_sys->n_mysql_trx--;
 
-	rw_lock_x_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	trx_free_for_background(trx);
 }
@@ -404,7 +402,7 @@ trx_resurrect_insert(
 	trx->is_recovered = TRUE;
 
 	/* This is single-threaded startup code, we do not need the
-	protection of trx->mutex or trx_sys->lock here. */
+	protection of trx->mutex or trx_sys->mutex here. */
 
 	if (undo->state != TRX_UNDO_ACTIVE) {
 
@@ -471,11 +469,11 @@ trx_resurrect_update_in_prepared_state(
 	const trx_undo_t*	undo)	/*!< in: update UNDO record */
 {
 	/* This is single-threaded startup code, we do not need the
-	protection of trx->mutex or trx_sys->lock here. */
+	protection of trx->mutex or trx_sys->mutex here. */
 
 	if (undo->state == TRX_UNDO_PREPARED) {
 		fprintf(stderr,
-			"InnoDB: Transaction " TRX_ID_FMT 
+			"InnoDB: Transaction " TRX_ID_FMT
 			" was in the XA prepared state.\n", trx->id);
 
 		if (srv_force_recovery == 0) {
@@ -516,7 +514,7 @@ trx_resurrect_update(
 	trx->is_recovered = TRUE;
 
 	/* This is single-threaded startup code, we do not need the
-	protection of trx->mutex or trx_sys->lock here. */
+	protection of trx->mutex or trx_sys->mutex here. */
 
 	if (undo->state != TRX_UNDO_ACTIVE) {
 		trx_resurrect_update_in_prepared_state(trx, undo);
@@ -594,9 +592,9 @@ trx_lists_init_at_db_start(void)
 			ibool	trx_created;
 
 			/* Check the trx_sys->trx_list first. */
-			rw_lock_s_lock(&trx_sys->lock);
+			mutex_enter(&trx_sys->mutex);
 			trx = trx_get_on_id(undo->trx_id);
-			rw_lock_s_unlock(&trx_sys->lock);
+			mutex_exit(&trx_sys->mutex);
 
 			if (trx == NULL) {
 				trx = trx_allocate_for_background();
@@ -695,11 +693,11 @@ trx_start_low(
 	ut_a(ib_vector_is_empty(trx->autoinc_locks));
 	ut_a(ib_vector_is_empty(trx->lock.table_locks));
 
-	rw_lock_x_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	/* If this transaction came from trx_allocate_for_mysql(),
 	trx->in_mysql_trx_list would hold. In that case, the trx->state
-	change must be protected by the trx_sys->lock, so that
+	change must be protected by the trx_sys->mutex, so that
 	lock_print_info_all_transactions() will have a consistent view. */
 
 	trx->state = TRX_STATE_ACTIVE;
@@ -712,7 +710,7 @@ trx_start_low(
 
 	ut_ad(trx_sys_validate_trx_list());
 
-	rw_lock_x_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	MONITOR_INC(MONITOR_TRX_ACTIVE);
 }
@@ -731,7 +729,7 @@ trx_serialisation_number_get(
 
 	ut_ad(mutex_own(&rseg->mutex));
 
-	rw_lock_x_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	trx->no = trx_sys_get_new_trx_id();
 
@@ -754,14 +752,14 @@ trx_serialisation_number_get(
 		difference because this code path is only taken when the
 		rbs is empty. */
 
-		rw_lock_x_unlock(&trx_sys->lock);
+		mutex_exit(&trx_sys->mutex);
 
 		ptr = ib_bh_push(purge_sys->ib_bh, &rseg_queue);
 		ut_a(ptr);
 
 		mutex_exit(&purge_sys->bh_mutex);
 	} else {
-		rw_lock_x_unlock(&trx_sys->lock);
+		mutex_exit(&trx_sys->mutex);
 	}
 }
 
@@ -892,20 +890,20 @@ trx_commit(
 	now that it no longer holds any user locks. */
 
 	ut_ad(trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY));
-	rw_lock_x_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 	ut_ad(trx->in_trx_list);
 	ut_d(trx->in_trx_list = FALSE);
 	UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx);
 
 	/* If this transaction came from trx_allocate_for_mysql(),
 	trx->in_mysql_trx_list would hold. In that case, the
-	trx->state change must be protected by trx_sys->lock, so that
+	trx->state change must be protected by trx_sys->mutex, so that
 	lock_print_info_all_transactions() will have a consistent view. */
 
 	trx->state = TRX_STATE_NOT_STARTED;
 	ut_ad(trx_sys_validate_trx_list());
 	MONITOR_INC(MONITOR_TRX_COMMIT);
-	rw_lock_x_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	if (trx->global_read_view != NULL) {
 		read_view_remove(trx->global_read_view);
@@ -1017,13 +1015,13 @@ trx_cleanup_at_db_startup(
 	trx->undo_no = 0;
 	trx->last_sql_stat_start.least_undo_no = 0;
 
-	rw_lock_x_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx);
 	ut_ad(trx->in_trx_list);
 	ut_d(trx->in_trx_list = FALSE);
 
-	rw_lock_x_unlock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	/* Change the transaction state without mutex protection, now
 	that it no longer is in the trx_list. Recovered transactions
@@ -1070,7 +1068,7 @@ trx_commit_or_rollback_prepare(
 /*===========================*/
 	trx_t*	trx)		/*!< in/out: transaction */
 {
-	/* We are reading trx->state without holding trx_sys->lock
+	/* We are reading trx->state without holding trx_sys->mutex
 	here, because the commit or rollback should be invoked for a
 	running (or recovered prepared) transaction that is associated
 	with the current thread. */
@@ -1289,7 +1287,7 @@ trx_mark_sql_stat_end(
 
 /**********************************************************************//**
 Prints info about a transaction.
-Caller must hold trx_sys->lock. */
+Caller must hold trx_sys->mutex. */
 UNIV_INTERN
 void
 trx_print_low(
@@ -1311,14 +1309,12 @@ trx_print_low(
 	ibool		newline;
 	const char*	op_info;
 
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	fprintf(f, "TRANSACTION " TRX_ID_FMT, (ullint) trx->id);
 
 	/* trx->state cannot change from or to NOT_STARTED while we
-	are holding the trx_sys->lock. It may change from ACTIVE to
+	are holding the trx_sys->mutex. It may change from ACTIVE to
 	PREPARED or COMMITTED. */
 	switch (trx->state) {
 	case TRX_STATE_NOT_STARTED:
@@ -1416,7 +1412,7 @@ state_ok:
 
 /**********************************************************************//**
 Prints info about a transaction.
-The caller must hold lock_sys->mutex and trx_sys->lock.
+The caller must hold lock_sys->mutex and trx_sys->mutex.
 When possible, use trx_print() instead. */
 UNIV_INTERN
 void
@@ -1428,9 +1424,7 @@ trx_print_latched(
 					or 0 to use the default max length */
 {
 	ut_ad(lock_mutex_own());
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	trx_print_low(f, trx, max_query_len,
 		      lock_number_of_rows_locked(&trx->lock),
@@ -1440,7 +1434,7 @@ trx_print_latched(
 
 /**********************************************************************//**
 Prints info about a transaction.
-Acquires and releases lock_sys->mutex and trx_sys->lock. */
+Acquires and releases lock_sys->mutex and trx_sys->mutex. */
 UNIV_INTERN
 void
 trx_print(
@@ -1460,16 +1454,16 @@ trx_print(
 	heap_size = mem_heap_get_size(trx->lock.lock_heap);
 	lock_mutex_exit();
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 	trx_print_low(f, trx, max_query_len,
 		      n_lock_rec, n_lock_struct, heap_size);
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 }
 
 #ifdef UNIV_DEBUG
 /**********************************************************************//**
 Asserts that a transaction has been started.
-The caller must hold trx_sys->lock.
+The caller must hold trx_sys->mutex.
 @return TRUE if started */
 UNIV_INTERN
 ibool
@@ -1477,12 +1471,10 @@ trx_assert_started(
 /*===============*/
 	const trx_t*	trx)	/*!< in: transaction */
 {
-# ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_SHARED));
-# endif /* UNIV_SYNC_DEBUG */
+	ut_ad(mutex_own(&trx_sys->mutex));
 
 	/* trx->state cannot change from or to NOT_STARTED while we
-	are holding trx_sys->lock. It may change from ACTIVE to
+	are holding trx_sys->mutex. It may change from ACTIVE to
 	PREPARED. Unless we are holding lock_sys->mutex, it may also
 	change to COMMITTED. */
 
@@ -1603,10 +1595,10 @@ trx_prepare(
 
 	/*--------------------------------------*/
 	ut_a(trx->state == TRX_STATE_ACTIVE);
-	rw_lock_x_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 	trx->state = TRX_STATE_PREPARED;
 	trx_sys->n_prepared_trx++;
-	rw_lock_x_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 	/*--------------------------------------*/
 
 	if (lsn) {
@@ -1689,14 +1681,14 @@ trx_recover_for_mysql(
 	/* We should set those transactions which are in the prepared state
 	to the xid_list */
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	for (trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
 	     trx != NULL;
 	     trx = UT_LIST_GET_NEXT(trx_list, trx)) {
 
 		/* trx->state cannot change from or to NOT_STARTED
-		while we are holding the trx_sys->lock. It may change
+		while we are holding the trx_sys->mutex. It may change
 		to PREPARED, but not if trx->is_recovered. It may also
 		change to COMMITTED. */
 		if (trx_state_eq(trx, TRX_STATE_PREPARED)) {
@@ -1729,7 +1721,7 @@ trx_recover_for_mysql(
 		}
 	}
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	if (count > 0){
 		ut_print_timestamp(stderr);
@@ -1761,7 +1753,7 @@ trx_get_trx_by_xid(
 		return(NULL);
 	}
 
-	rw_lock_s_lock(&trx_sys->lock);
+	mutex_enter(&trx_sys->mutex);
 
 	for (trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
 	     trx != NULL;
@@ -1787,7 +1779,7 @@ trx_get_trx_by_xid(
 		}
 	}
 
-	rw_lock_s_unlock(&trx_sys->lock);
+	mutex_exit(&trx_sys->mutex);
 
 	return(trx);
 }

=== modified file 'storage/myisammrg/ha_myisammrg.cc'
--- a/storage/myisammrg/ha_myisammrg.cc	2011-07-04 00:25:46 +0000
+++ b/storage/myisammrg/ha_myisammrg.cc	2011-07-22 15:52:42 +0000
@@ -155,9 +155,14 @@ extern "C" void myrg_print_wrong_table(c
   buf[db.length]= '.';
   memcpy(buf + db.length + 1, name.str, name.length);
   buf[db.length + name.length + 1]= 0;
-  push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                      ER_ADMIN_WRONG_MRG_TABLE, ER(ER_ADMIN_WRONG_MRG_TABLE),
-                      buf);
+  /*
+    Push an error to be reported as part of CHECK/REPAIR result-set.
+    Note that calling my_error() from handler is a hack which is kept
+    here to avoid refactoring. Normally engines should report errors
+    through return value which will be interpreted by caller using
+    handler::print_error() call.
+  */
+  my_error(ER_ADMIN_WRONG_MRG_TABLE, MYF(0), buf);
 }
 
 
@@ -594,8 +599,7 @@ public:
 
   @return       pointer to open MyISAM table structure
     @retval     !=NULL                  OK, returning pointer
-    @retval     NULL, my_errno == 0     Ok, no more child tables
-    @retval     NULL, my_errno != 0     error
+    @retval     NULL,                   Error.
 
   @detail
     This function retrieves the MyISAM table handle from the
@@ -615,22 +619,23 @@ extern "C" MI_INFO *myisammrg_attach_chi
   MI_INFO       *myisam= NULL;
   DBUG_ENTER("myisammrg_attach_children_callback");
 
-  if (!child_l)
-  {
-    DBUG_PRINT("myrg", ("No more children to attach"));
-    my_errno= 0; /* Ok, no more child tables. */
-    goto end;
-  }
+  /*
+    Number of children in the list and MYRG_INFO::tables_count,
+    which is used by caller of this function, should always match.
+  */
+  DBUG_ASSERT(child_l);
+
   child= child_l->table;
 
+  /* Prepare for next child. */
+  param->next();
+
   if (!child)
   {
-    DBUG_PRINT("myrg", ("Child table does not exist"));
-    my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
+    DBUG_PRINT("error", ("failed to open underlying table '%s'.'%s'",
+                         child_l->db, child_l->table_name));
     goto end;
   }
-  /* Prepare for next child. */
-  param->next();
 
   /*
     Do a quick compatibility check. The table def version is set when
@@ -661,7 +666,6 @@ extern "C" MI_INFO *myisammrg_attach_chi
   {
     DBUG_PRINT("error", ("temporary table mismatch parent: %d  child: %d",
                          parent->s->tmp_table, child->s->tmp_table));
-    my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
     goto end;
   }
 
@@ -672,12 +676,27 @@ extern "C" MI_INFO *myisammrg_attach_chi
     DBUG_PRINT("error", ("no MyISAM handle for child table: '%s'.'%s' 0x%lx",
                          child->s->db.str, child->s->table_name.str,
                          (long) child));
-    my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
   }
-  DBUG_PRINT("myrg", ("MyISAM handle: 0x%lx  my_errno: %d",
-                      my_errno ? 0L : (long) myisam, my_errno));
+
+  DBUG_PRINT("myrg", ("MyISAM handle: 0x%lx", (long) myisam));
 
  end:
+
+  if (!myisam &&
+      (current_thd->open_options & HA_OPEN_FOR_REPAIR))
+  {
+    char buf[2*NAME_LEN + 1 + 1];
+    strxnmov(buf, sizeof(buf) - 1, child_l->db, ".", child_l->table_name, NULL);
+    /*
+      Push an error to be reported as part of CHECK/REPAIR result-set.
+      Note that calling my_error() from handler is a hack which is kept
+      here to avoid refactoring. Normally engines should report errors
+      through return value which will be interpreted by caller using
+      handler::print_error() call.
+    */
+    my_error(ER_ADMIN_WRONG_MRG_TABLE, MYF(0), buf);
+  }
+
   DBUG_RETURN(myisam);
 }
 
@@ -791,12 +810,6 @@ int ha_myisammrg::attach_children(void)
   /* Must call this with children list in place. */
   DBUG_ASSERT(this->table->pos_in_table_list->next_global == this->children_l);
 
-  /*
-    'my_errno' is set by myisammrg_attach_children_callback() in
-    case of an error.
-  */
-  my_errno= 0;
-
   if (myrg_attach_children(this->file, this->test_if_locked |
                            current_thd->open_options,
                            myisammrg_attach_children_callback, &param,

=== modified file 'storage/myisammrg/myrg_open.c'
--- a/storage/myisammrg/myrg_open.c	2011-06-30 15:50:45 +0000
+++ b/storage/myisammrg/myrg_open.c	2011-07-22 15:52:42 +0000
@@ -385,6 +385,7 @@ int myrg_attach_children(MYRG_INFO *m_in
   uint       UNINIT_VAR(key_parts);
   uint       min_keys;
   my_bool    bad_children= FALSE;
+  my_bool    first_child= TRUE;
   DBUG_ENTER("myrg_attach_children");
   DBUG_PRINT("myrg", ("handle_locking: %d", handle_locking));
 
@@ -399,16 +400,26 @@ int myrg_attach_children(MYRG_INFO *m_in
   errpos= 0;
   file_offset= 0;
   min_keys= 0;
-  child_nr= 0;
-  while ((myisam= (*callback)(callback_param)))
+  for (child_nr= 0; child_nr < m_info->tables; child_nr++)
   {
+    if (! (myisam= (*callback)(callback_param)))
+    {
+      if (handle_locking & HA_OPEN_FOR_REPAIR)
+      {
+        /* An appropriate error should've been already pushed by callback. */
+        bad_children= TRUE;
+        continue;
+      }
+      goto bad_children;
+    }
+
     DBUG_PRINT("myrg", ("child_nr: %u  table: '%s'",
                         child_nr, myisam->filename));
-    DBUG_ASSERT(child_nr < m_info->tables);
 
     /* Special handling when the first child is attached. */
-    if (!child_nr)
+    if (first_child)
     {
+      first_child= FALSE;
       m_info->reclength= myisam->s->base.reclength;
       min_keys=  myisam->s->base.keys;
       key_parts= myisam->s->base.key_parts;
@@ -456,14 +467,11 @@ int myrg_attach_children(MYRG_INFO *m_in
     for (idx= 0; idx < key_parts; idx++)
       m_info->rec_per_key_part[idx]+= (myisam->s->state.rec_per_key_part[idx] /
                                        m_info->tables);
-    child_nr++;
   }
 
   if (bad_children)
     goto bad_children;
-  /* Note: callback() resets my_errno, so it is safe to check it here */
-  if (my_errno == HA_ERR_WRONG_MRG_TABLE_DEF)
-    goto err;
+
   if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L)
   {
     my_errno= HA_ERR_RECORD_FILE_FULL;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-mtr branch (bjorn.munch:3094 to 3095) Bjorn Munch26 Jul