List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:April 14 2011 2:19am
Subject:bzr push into mysql-trunk branch (chris.powers:3278 to 3280) WL#4896
View as plain text  
 3280 cpowers	2011-04-13 [merge]
      WL#4896 "Performance Schema Net IO"
      
      Merge with mysql-trunk

    removed:
      extra/yassl/src/template_instnt.cpp
      extra/yassl/taocrypt/src/template_instnt.cpp
      mysql-test/suite/bugs/
      mysql-test/suite/bugs/combinations
      mysql-test/suite/bugs/data/
      mysql-test/suite/bugs/data/rpl_bug12691.dat
      mysql-test/suite/bugs/r/
      mysql-test/suite/bugs/r/bug57108.result
      mysql-test/suite/bugs/r/rpl_bug12691.result
      mysql-test/suite/bugs/r/rpl_bug31582.result
      mysql-test/suite/bugs/r/rpl_bug31583.result
      mysql-test/suite/bugs/r/rpl_bug33029.result
      mysql-test/suite/bugs/r/rpl_bug38205.result
      mysql-test/suite/bugs/t/
      mysql-test/suite/bugs/t/bug57108-master.opt
      mysql-test/suite/bugs/t/bug57108.test
      mysql-test/suite/bugs/t/rpl_bug12691.test
      mysql-test/suite/bugs/t/rpl_bug31582.test
      mysql-test/suite/bugs/t/rpl_bug31583.test
      mysql-test/suite/bugs/t/rpl_bug33029.test
      mysql-test/suite/bugs/t/rpl_bug38205.test
      mysql-test/suite/sys_vars/r/max_long_data_size_basic.result
      mysql-test/suite/sys_vars/t/max_long_data_size_basic.test
    added:
      unittest/gunit/sql_plist-t.cc
    renamed:
      mysql-test/suite/bugs/r/rpl_bug23533.result => mysql-test/suite/binlog/r/binlog_bug23533.result
      mysql-test/suite/bugs/r/rpl_bug36391.result => mysql-test/suite/binlog/r/binlog_bug36391.result
      mysql-test/suite/bugs/r/rpl_bug37426.result => mysql-test/suite/rpl/r/rpl_bug37426.result
      mysql-test/suite/bugs/t/rpl_bug23533.test => mysql-test/suite/binlog/t/binlog_bug23533.test
      mysql-test/suite/bugs/t/rpl_bug36391-master.opt => mysql-test/suite/binlog/t/binlog_bug36391-master.opt
      mysql-test/suite/bugs/t/rpl_bug36391.test => mysql-test/suite/binlog/t/binlog_bug36391.test
      mysql-test/suite/bugs/t/rpl_bug37426.test => mysql-test/suite/rpl/t/rpl_bug37426.test
    modified:
      client/client_priv.h
      client/mysqlslap.c
      cmake/os/WindowsCache.cmake
      cmake/ssl.cmake
      config.h.cmake
      configure.cmake
      extra/yassl/CMakeLists.txt
      extra/yassl/src/crypto_wrapper.cpp
      extra/yassl/src/yassl_int.cpp
      extra/yassl/taocrypt/CMakeLists.txt
      extra/yassl/taocrypt/src/algebra.cpp
      extra/yassl/taocrypt/src/integer.cpp
      include/my_global.h
      include/violite.h
      mysql-test/collections/default.experimental
      mysql-test/collections/default.weekly
      mysql-test/extra/rpl_tests/rpl_extra_col_master.test
      mysql-test/include/ctype_numconv.inc
      mysql-test/include/func_in.inc
      mysql-test/include/mix1.inc
      mysql-test/include/mtr_warnings.sql
      mysql-test/include/order_by.inc
      mysql-test/include/subquery_mat.inc
      mysql-test/lib/mtr_misc.pl
      mysql-test/mysql-test-run.pl
      mysql-test/r/alter_table.result
      mysql-test/r/ctype_binary.result
      mysql-test/r/ctype_cp1251.result
      mysql-test/r/ctype_latin1.result
      mysql-test/r/ctype_ucs.result
      mysql-test/r/ctype_utf8.result
      mysql-test/r/func_group.result
      mysql-test/r/func_in_icp.result
      mysql-test/r/func_in_icp_mrr.result
      mysql-test/r/func_in_mrr.result
      mysql-test/r/func_in_mrr_cost.result
      mysql-test/r/func_in_none.result
      mysql-test/r/innodb_icp_all.result
      mysql-test/r/innodb_mysql_lock.result
      mysql-test/r/innodb_mysql_sync.result
      mysql-test/r/lowercase_table2.result
      mysql-test/r/myisam_icp_all.result
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/r/mysqlslap.result
      mysql-test/r/order_by_all.result
      mysql-test/r/order_by_icp_mrr.result
      mysql-test/r/order_by_none.result
      mysql-test/r/plugin_auth.result
      mysql-test/r/show_check.result
      mysql-test/r/sp-destruct.result
      mysql-test/r/subquery_all.result
      mysql-test/r/subquery_all_jcl6.result
      mysql-test/r/subquery_mat.result
      mysql-test/r/subquery_mat_all.result
      mysql-test/r/subquery_mat_none.result
      mysql-test/r/subquery_nomat_nosj_jcl6.result
      mysql-test/r/variables-big.result
      mysql-test/r/variables.result
      mysql-test/r/view.result
      mysql-test/r/xa.result
      mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result
      mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result
      mysql-test/suite/rpl/r/rpl_migration_crash_safe.result
      mysql-test/suite/rpl/r/rpl_rotate_logs.result
      mysql-test/suite/rpl/t/rpl_migration_crash_safe.test
      mysql-test/suite/rpl/t/rpl_rotate_logs.test
      mysql-test/suite/sys_vars/r/master_info_repository_basic.result
      mysql-test/suite/sys_vars/r/relay_log_info_repository_basic.result
      mysql-test/suite/sys_vars/t/master_info_repository_basic.test
      mysql-test/suite/sys_vars/t/relay_log_info_repository_basic.test
      mysql-test/t/alter_table.test
      mysql-test/t/func_group.test
      mysql-test/t/innodb_mysql_lock.test
      mysql-test/t/innodb_mysql_sync.test
      mysql-test/t/lowercase_table2.test
      mysql-test/t/mysqlslap.test
      mysql-test/t/plugin_auth.test
      mysql-test/t/show_check.test
      mysql-test/t/sp-destruct.test
      mysql-test/t/variables.test
      mysql-test/t/view.test
      mysql-test/t/xa.test
      mysys/charset.c
      mysys/my_init.c
      mysys/my_thr_init.c
      mysys/mysys_priv.h
      plugin/auth/auth_socket.c
      scripts/mysql_install_db.pl.in
      scripts/mysql_install_db.sh
      scripts/mysql_system_tables_fix.sql
      sql/binlog.cc
      sql/field.cc
      sql/filesort.cc
      sql/hostname.cc
      sql/item.cc
      sql/item.h
      sql/item_buff.cc
      sql/item_cmpfunc.cc
      sql/item_func.cc
      sql/item_func.h
      sql/item_strfunc.cc
      sql/item_sum.cc
      sql/keycaches.cc
      sql/mdl.h
      sql/mysqld.cc
      sql/opt_range.cc
      sql/rpl_info.cc
      sql/rpl_info.h
      sql/rpl_info_factory.cc
      sql/rpl_info_factory.h
      sql/rpl_info_file.cc
      sql/rpl_info_file.h
      sql/rpl_info_handler.cc
      sql/rpl_info_handler.h
      sql/rpl_info_table.cc
      sql/rpl_info_table.h
      sql/rpl_info_table_access.cc
      sql/rpl_info_values.cc
      sql/rpl_mi.cc
      sql/rpl_mi.h
      sql/rpl_reporting.cc
      sql/rpl_rli.cc
      sql/rpl_rli.h
      sql/rpl_slave.cc
      sql/rpl_slave.h
      sql/share/errmsg-utf8.txt
      sql/sql_acl.cc
      sql/sql_base.h
      sql/sql_binlog.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_insert.cc
      sql/sql_join_cache.cc
      sql/sql_plist.h
      sql/sql_select.cc
      sql/sql_show.cc
      sql/sql_table.cc
      sql/sql_update.cc
      sql/sys_vars.cc
      sql/sys_vars.h
      sql/table.cc
      sql/table.h
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/handler/handler0alter.cc
      storage/innobase/include/sync0arr.h
      storage/innobase/include/trx0roll.h
      storage/innobase/row/row0merge.c
      storage/innobase/row/row0mysql.c
      storage/innobase/srv/srv0srv.c
      storage/innobase/sync/sync0arr.c
      storage/innobase/trx/trx0roll.c
      storage/perfschema/ha_perfschema.h
      storage/perfschema/pfs.h
      storage/perfschema/pfs_atomic.h
      storage/perfschema/pfs_column_types.h
      storage/perfschema/pfs_column_values.h
      storage/perfschema/pfs_con_slice.h
      storage/perfschema/pfs_defaults.h
      storage/perfschema/pfs_engine_table.h
      storage/perfschema/pfs_events_statements.h
      storage/perfschema/pfs_global.h
      storage/perfschema/pfs_instr.h
      storage/perfschema/pfs_server.h
      storage/perfschema/pfs_setup_actor.cc
      storage/perfschema/pfs_timer.h
      unittest/gunit/CMakeLists.txt
      vio/viosocket.c
      mysql-test/suite/binlog/r/binlog_bug23533.result
      mysql-test/suite/binlog/r/binlog_bug36391.result
      mysql-test/suite/rpl/r/rpl_bug37426.result
      mysql-test/suite/binlog/t/binlog_bug23533.test
      mysql-test/suite/binlog/t/binlog_bug36391.test
      mysql-test/suite/rpl/t/rpl_bug37426.test
 3279 cpowers	2011-04-13
      WL#4896 "Performance Schema Net IO"
      
      Updates per code review:
      - Support singleton (global) socket instances
      - Optimize comparison of owning thread
      - Generic instance visitor, suitable for any class

    modified:
      sql/mysqld.cc
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_instr.cc
      storage/perfschema/pfs_instr.h
      storage/perfschema/pfs_instr_class.cc
      storage/perfschema/pfs_instr_class.h
      storage/perfschema/pfs_stat.h
      storage/perfschema/pfs_visitor.cc
      storage/perfschema/pfs_visitor.h
      storage/perfschema/table_ews_by_thread_by_event_name.cc
 3278 cpowers	2011-04-02
      WL#4896 "Performance Schema Net IO"
      
      - Refinements to deferred aggregation

    modified:
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_instr.cc
      storage/perfschema/pfs_stat.h
      storage/perfschema/pfs_visitor.cc
=== modified file 'client/client_priv.h'
--- a/client/client_priv.h	2011-02-21 11:33:20 +0000
+++ b/client/client_priv.h	2011-04-08 07:07:57 +0000
@@ -75,6 +75,7 @@ enum options_client
   OPT_SLAP_POST_SYSTEM,
   OPT_SLAP_COMMIT,
   OPT_SLAP_DETACH,
+  OPT_SLAP_NO_DROP,
   OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID,
   OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
   OPT_AUTO_VERTICAL_OUTPUT,

=== modified file 'client/mysqlslap.c'
--- a/client/mysqlslap.c	2011-01-16 04:02:29 +0000
+++ b/client/mysqlslap.c	2011-04-08 07:07:57 +0000
@@ -128,7 +128,7 @@ const char *delimiter= "\n";
 
 const char *create_schema_string= "mysqlslap";
 
-static my_bool opt_preserve= TRUE;
+static my_bool opt_preserve= TRUE, opt_no_drop= FALSE;
 static my_bool debug_info_flag= 0, debug_check_flag= 0;
 static my_bool opt_only_print= FALSE;
 static my_bool opt_compress= FALSE, tty_password= FALSE,
@@ -609,6 +609,8 @@ static struct my_option my_long_options[
     REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"iterations", 'i', "Number of times to run the tests.", &iterations,
     &iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
+  {"no-drop", OPT_SLAP_NO_DROP, "Do not drop the schema after the test.",
+   &opt_no_drop, &opt_no_drop, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"number-char-cols", 'x', 
     "Number of VARCHAR columns to create in table if specifying --auto-generate-sql.",
     &num_char_cols_opt, &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG,
@@ -1151,8 +1153,11 @@ get_options(int *argc,char ***argv)
   if (!user)
     user= (char *)"root";
 
-  /* If something is created we clean it up, otherwise we leave schemas alone */
-  if (create_string || auto_generate_sql)
+  /*
+    If something is created and --no-drop is not specified, we drop the
+    schema.
+  */
+  if (!opt_no_drop && (create_string || auto_generate_sql))
     opt_preserve= FALSE;
 
   if (auto_generate_sql && (create_string || user_supplied_query))

=== modified file 'cmake/os/WindowsCache.cmake'
--- a/cmake/os/WindowsCache.cmake	2010-11-19 23:59:28 +0000
+++ b/cmake/os/WindowsCache.cmake	2011-04-13 19:16:45 +0000
@@ -77,9 +77,6 @@ SET(HAVE_FTRUNCATE CACHE  INTERNAL "")
 SET(HAVE_GETADDRINFO 1 CACHE  INTERNAL "")
 SET(HAVE_GETCWD 1 CACHE  INTERNAL "")
 SET(HAVE_GETHOSTBYADDR_R CACHE  INTERNAL "")
-SET(HAVE_GETHOSTBYNAME_R CACHE  INTERNAL "")
-SET(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE CACHE  INTERNAL "")
-SET(HAVE_GETHOSTBYNAME_R_RETURN_INT CACHE  INTERNAL "")
 SET(HAVE_GETHRTIME CACHE  INTERNAL "")
 SET(HAVE_GETLINE CACHE  INTERNAL "")
 SET(HAVE_GETNAMEINFO CACHE  INTERNAL "")

=== modified file 'cmake/ssl.cmake'
--- a/cmake/ssl.cmake	2010-07-19 14:17:07 +0000
+++ b/cmake/ssl.cmake	2011-04-04 08:47:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Sun Microsystems, Inc
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,16 +27,8 @@ MACRO (MYSQL_USE_BUNDLED_SSL)
   SET(SSL_INTERNAL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL)
   SET(SSL_DEFINES "-DHAVE_YASSL -DYASSL_PURE_C -DYASSL_PREFIX -DHAVE_OPENSSL -DYASSL_THREAD_SAFE")
   CHANGE_SSL_SETTINGS("bundled")
-  #Remove -fno-implicit-templates 
-  #(yassl sources cannot  be compiled with  it)
-  SET(SAVE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
-  IF(CMAKE_CXX_FLAGS)
-  STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS 
-    ${CMAKE_CXX_FLAGS})
-  ENDIF()
   ADD_SUBDIRECTORY(extra/yassl)
   ADD_SUBDIRECTORY(extra/yassl/taocrypt)
-  SET(CMAKE_CXX_FLAGS ${SAVE_CXX_FLAGS})
   GET_TARGET_PROPERTY(src yassl SOURCES)
   FOREACH(file ${src})
     SET(SSL_SOURCES ${SSL_SOURCES} ${CMAKE_SOURCE_DIR}/extra/yassl/${file})

=== modified file 'config.h.cmake'
--- a/config.h.cmake	2011-02-23 21:13:48 +0000
+++ b/config.h.cmake	2011-04-14 01:36:24 +0000
@@ -40,7 +40,6 @@
 #cmakedefine HAVE_FNMATCH_H 1
 #cmakedefine HAVE_FPU_CONTROL_H 1
 #cmakedefine HAVE_GRP_H 1
-#cmakedefine HAVE_EXPLICIT_TEMPLATE_INSTANTIATION 1
 #cmakedefine HAVE_IA64INTRIN_H 1
 #cmakedefine HAVE_IEEEFP_H 1
 #cmakedefine HAVE_INTTYPES_H 1
@@ -157,7 +156,6 @@
 #cmakedefine HAVE_GETADDRINFO 1
 #cmakedefine HAVE_GETCWD 1
 #cmakedefine HAVE_GETHOSTBYADDR_R 1
-#cmakedefine HAVE_GETHOSTBYNAME_R 1
 #cmakedefine HAVE_GETHRTIME 1
 #cmakedefine HAVE_GETLINE 1
 #cmakedefine HAVE_GETNAMEINFO 1
@@ -448,8 +446,6 @@
 
 
 #cmakedefine HAVE_SOLARIS_STYLE_GETHOST 1
-#cmakedefine HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE 1
-#cmakedefine HAVE_GETHOSTBYNAME_R_RETURN_INT 1
 
 #cmakedefine MY_ATOMIC_MODE_DUMMY 1
 #cmakedefine MY_ATOMIC_MODE_RWLOCKS 1

=== modified file 'configure.cmake'
--- a/configure.cmake	2011-02-02 18:31:39 +0000
+++ b/configure.cmake	2011-04-13 19:16:45 +0000
@@ -1,5 +1,4 @@
-
-# Copyright (C) 2009 Sun Microsystems,Inc
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -67,15 +66,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
   # MySQL "canonical" GCC flags. At least -fno-rtti flag affects
   # ABI and cannot be simply removed. 
   SET(CMAKE_CXX_FLAGS 
-    "${CMAKE_CXX_FLAGS} -fno-implicit-templates -fno-exceptions -fno-rtti")
-  IF(CMAKE_CXX_FLAGS)
-    STRING(REGEX MATCH "fno-implicit-templates" NO_IMPLICIT_TEMPLATES
-      ${CMAKE_CXX_FLAGS})
-    IF (NO_IMPLICIT_TEMPLATES)
-      SET(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION TRUE)
-    ENDIF()
-  ENDIF()
-
+    "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
   IF (CMAKE_EXE_LINKER_FLAGS MATCHES " -static " 
      OR CMAKE_EXE_LINKER_FLAGS MATCHES " -static$")
      SET(HAVE_DLOPEN FALSE CACHE "Disable dlopen due to -static flag" FORCE)
@@ -350,7 +341,6 @@ CHECK_FUNCTION_EXISTS (fseeko HAVE_FSEEK
 CHECK_FUNCTION_EXISTS (fsync HAVE_FSYNC)
 CHECK_FUNCTION_EXISTS (getcwd HAVE_GETCWD)
 CHECK_FUNCTION_EXISTS (gethostbyaddr_r HAVE_GETHOSTBYADDR_R)
-CHECK_FUNCTION_EXISTS (gethostbyname_r HAVE_GETHOSTBYNAME_R)
 CHECK_FUNCTION_EXISTS (gethrtime HAVE_GETHRTIME)
 CHECK_FUNCTION_EXISTS (getnameinfo HAVE_GETNAMEINFO)
 CHECK_FUNCTION_EXISTS (getpass HAVE_GETPASS)
@@ -921,44 +911,6 @@ CHECK_CXX_SOURCE_COMPILES("
   "
   HAVE_SOLARIS_STYLE_GETHOST)
 
-CHECK_CXX_SOURCE_COMPILES("
-    #undef inline
-    #if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
-    #define _REENTRANT
-    #endif
-    #include <pthread.h>
-    #include <sys/types.h>
-    #include <sys/socket.h>
-    #include <netinet/in.h>
-    #include <arpa/inet.h>
-    #include <netdb.h>
-    int main()
-    {
-       int ret = gethostbyname_r((const char *) 0,
-	(struct hostent*) 0, (char*) 0, 0, (struct hostent **) 0, (int *) 0);
-      return 0;
-    }"
-    HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
-
-CHECK_CXX_SOURCE_COMPILES("
-    #undef inline
-    #if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
-    #define _REENTRANT
-    #endif
-    #include <pthread.h>
-    #include <sys/types.h>
-    #include <sys/socket.h>
-    #include <netinet/in.h>
-    #include <arpa/inet.h>
-    #include <netdb.h>
-    int main()
-    {
-      int ret = gethostbyname_r((const char *) 0, (struct hostent*) 0, (struct hostent_data*) 0);
-      return 0;
-    }"
-    HAVE_GETHOSTBYNAME_R_RETURN_INT)
-
-
 # Use of ALARMs to wakeup on timeout on sockets
 #
 # This feature makes use of a mutex and is a scalability hog we

=== modified file 'extra/yassl/CMakeLists.txt'
--- a/extra/yassl/CMakeLists.txt	2010-12-29 00:26:31 +0000
+++ b/extra/yassl/CMakeLists.txt	2011-04-04 08:47:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,20 +20,11 @@ INCLUDE_DIRECTORIES(
  ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL)
 
 ADD_DEFINITIONS(${SSL_DEFINES})
-IF(CMAKE_COMPILER_IS_GNUXX)
-  #Remove -fno-implicit-templates 
-  #(yassl sources cannot  be compiled with  it)
-  STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS
-${CMAKE_CXX_FLAGS})
-ENDIF()
+
 SET(YASSL_SOURCES  src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp 
 				src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp 
 				src/yassl_imp.cpp src/yassl_int.cpp)
 
-IF(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION)
-  SET(YASSL_SOURCES ${YASSL_SOURCES} src/template_instnt.cpp)
-ENDIF()
-
 ADD_CONVENIENCE_LIBRARY(yassl ${YASSL_SOURCES})
 RESTRICT_SYMBOL_EXPORTS(yassl)
 

=== modified file 'extra/yassl/src/crypto_wrapper.cpp'
--- a/extra/yassl/src/crypto_wrapper.cpp	2010-07-02 18:30:47 +0000
+++ b/extra/yassl/src/crypto_wrapper.cpp	2011-04-04 08:47:25 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (C) 2000-2007 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -11,10 +10,8 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; see the file COPYING. If not, write to the
-   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-   MA  02110-1301  USA.
-*/
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 /*  The crypto wrapper source implements the policies for the cipher
  *  components used by SSL.
@@ -991,24 +988,4 @@ x509* PemToDer(FILE* file, CertType type
 } // namespace
 
 
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-namespace yaSSL {
-template void ysDelete<DiffieHellman::DHImpl>(DiffieHellman::DHImpl*);
-template void ysDelete<Integer::IntegerImpl>(Integer::IntegerImpl*);
-template void ysDelete<RSA::RSAImpl>(RSA::RSAImpl*);
-template void ysDelete<DSS::DSSImpl>(DSS::DSSImpl*);
-template void ysDelete<RandomPool::RandomImpl>(RandomPool::RandomImpl*);
-template void ysDelete<AES::AESImpl>(AES::AESImpl*);
-template void ysDelete<RC4::RC4Impl>(RC4::RC4Impl*);
-template void ysDelete<DES_EDE::DES_EDEImpl>(DES_EDE::DES_EDEImpl*);
-template void ysDelete<DES::DESImpl>(DES::DESImpl*);
-template void ysDelete<HMAC_RMD::HMAC_RMDImpl>(HMAC_RMD::HMAC_RMDImpl*);
-template void ysDelete<HMAC_SHA::HMAC_SHAImpl>(HMAC_SHA::HMAC_SHAImpl*);
-template void ysDelete<HMAC_MD5::HMAC_MD5Impl>(HMAC_MD5::HMAC_MD5Impl*);
-template void ysDelete<RMD::RMDImpl>(RMD::RMDImpl*);
-template void ysDelete<SHA::SHAImpl>(SHA::SHAImpl*);
-template void ysDelete<MD5::MD5Impl>(MD5::MD5Impl*);
-}
-#endif // HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-
 #endif // !USE_CRYPTOPP_LIB

=== removed file 'extra/yassl/src/template_instnt.cpp'
--- a/extra/yassl/src/template_instnt.cpp	2009-05-15 12:57:51 +0000
+++ b/extra/yassl/src/template_instnt.cpp	1970-01-01 00:00:00 +0000
@@ -1,110 +0,0 @@
-/*
-   Copyright (C) 2000-2007 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; see the file COPYING. If not, write to the
-   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-   MA  02110-1301  USA.
-*/
-
-
-/*  Explicit template instantiation requests 
- */
-
-
-#include "runtime.hpp"
-#include "handshake.hpp"
-#include "yassl_int.hpp"
-#include "crypto_wrapper.hpp"
-#include "hmac.hpp"
-#include "md5.hpp"
-#include "sha.hpp"
-#include "ripemd.hpp"
-#include "openssl/ssl.h"
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-
-namespace mySTL {
-template class list<unsigned char*>;
-template yaSSL::del_ptr_zero for_each(mySTL::list<unsigned char*>::iterator, mySTL::list<unsigned char*>::iterator, yaSSL::del_ptr_zero);
-template pair<int, yaSSL::Message* (*)()>* uninit_copy<mySTL::pair<int, yaSSL::Message* (*)()>*, mySTL::pair<int, yaSSL::Message* (*)()>*>(mySTL::pair<int, yaSSL::Message* (*)()>*, mySTL::pair<int, yaSSL::Message* (*)()>*, mySTL::pair<int, yaSSL::Message* (*)()>*);
-template pair<int, yaSSL::HandShakeBase* (*)()>* uninit_copy<mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*, mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*>(mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*, mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*, mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*);
-template void destroy<mySTL::pair<int, yaSSL::Message* (*)()>*>(mySTL::pair<int, yaSSL::Message* (*)()>*, mySTL::pair<int, yaSSL::Message* (*)()>*);
-template void destroy<mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*>(mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*, mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*);
-template pair<int, yaSSL::ServerKeyBase* (*)()>* uninit_copy<mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*>(mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*);
-template void destroy<mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*>(mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*);
-template pair<int, yaSSL::ClientKeyBase* (*)()>* uninit_copy<mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*>(mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*);
-template class list<TaoCrypt::Signer*>;
-template class list<yaSSL::SSL_SESSION*>;
-template class list<yaSSL::input_buffer*>;
-template class list<yaSSL::output_buffer*>;
-template class list<yaSSL::x509*>;
-template class list<yaSSL::Digest*>;
-template class list<yaSSL::BulkCipher*>;
-template void destroy<mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*>(mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*);
-template yaSSL::del_ptr_zero for_each<mySTL::list<TaoCrypt::Signer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<TaoCrypt::Signer*>::iterator, mySTL::list<TaoCrypt::Signer*>::iterator, yaSSL::del_ptr_zero);
-template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::SSL_SESSION*>::iterator, mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::del_ptr_zero);
-template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::input_buffer*>::iterator, mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::del_ptr_zero);
-template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::output_buffer*>::iterator, mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::del_ptr_zero);
-template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::x509*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::x509*>::iterator, mySTL::list<yaSSL::x509*>::iterator, yaSSL::del_ptr_zero);
-template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::Digest*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::Digest*>::iterator, mySTL::list<yaSSL::Digest*>::iterator, yaSSL::del_ptr_zero);
-template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::BulkCipher*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::BulkCipher*>::iterator, mySTL::list<yaSSL::BulkCipher*>::iterator, yaSSL::del_ptr_zero);
-template bool list<yaSSL::ThreadError>::erase(list<yaSSL::ThreadError>::iterator);
-template void list<yaSSL::ThreadError>::push_back(yaSSL::ThreadError);
-template void list<yaSSL::ThreadError>::pop_front();
-template void list<yaSSL::ThreadError>::pop_back();
-template list<yaSSL::ThreadError>::~list();
-template pair<int, yaSSL::Message* (*)()>* GetArrayMemory<pair<int, yaSSL::Message* (*)()> >(size_t);
-template void FreeArrayMemory<pair<int, yaSSL::Message* (*)()> >(pair<int, yaSSL::Message* (*)()>*);
-template pair<int, yaSSL::HandShakeBase* (*)()>* GetArrayMemory<pair<int, yaSSL::HandShakeBase* (*)()> >(size_t);
-template void FreeArrayMemory<pair<int, yaSSL::HandShakeBase* (*)()> >(pair<int, yaSSL::HandShakeBase* (*)()>*);
-template pair<int, yaSSL::ServerKeyBase* (*)()>* GetArrayMemory<pair<int, yaSSL::ServerKeyBase* (*)()> >(size_t);
-template void FreeArrayMemory<pair<int, yaSSL::ServerKeyBase* (*)()> >(pair<int, yaSSL::ServerKeyBase* (*)()>*);
-template pair<int, yaSSL::ClientKeyBase* (*)()>* GetArrayMemory<pair<int, yaSSL::ClientKeyBase* (*)()> >(size_t);
-template void FreeArrayMemory<pair<int, yaSSL::ClientKeyBase* (*)()> >(pair<int, yaSSL::ClientKeyBase* (*)()>*);
-}
-
-namespace yaSSL {
-template void ysDelete<SSL_CTX>(yaSSL::SSL_CTX*);
-template void ysDelete<SSL>(yaSSL::SSL*);
-template void ysDelete<BIGNUM>(yaSSL::BIGNUM*);
-template void ysDelete<unsigned char>(unsigned char*);
-template void ysDelete<DH>(yaSSL::DH*);
-template void ysDelete<TaoCrypt::Signer>(TaoCrypt::Signer*);
-template void ysDelete<SSL_SESSION>(yaSSL::SSL_SESSION*);
-template void ysDelete<input_buffer>(input_buffer*);
-template void ysDelete<output_buffer>(output_buffer*);
-template void ysDelete<x509>(x509*);
-template void ysDelete<Auth>(Auth*);
-template void ysDelete<HandShakeBase>(HandShakeBase*);
-template void ysDelete<ServerKeyBase>(ServerKeyBase*);
-template void ysDelete<ClientKeyBase>(ClientKeyBase*);
-template void ysDelete<SSL_METHOD>(SSL_METHOD*);
-template void ysDelete<DiffieHellman>(DiffieHellman*);
-template void ysDelete<BulkCipher>(BulkCipher*);
-template void ysDelete<Digest>(Digest*);
-template void ysDelete<X509>(X509*);
-template void ysDelete<Message>(Message*);
-template void ysDelete<sslFactory>(sslFactory*);
-template void ysDelete<Sessions>(Sessions*);
-template void ysDelete<Errors>(Errors*);
-template void ysArrayDelete<unsigned char>(unsigned char*);
-template void ysArrayDelete<char>(char*);
-
-template int min<int>(int, int);
-template uint16 min<uint16>(uint16, uint16);
-template unsigned int min<unsigned int>(unsigned int, unsigned int);
-template unsigned long min<unsigned long>(unsigned long, unsigned long);
-}
-
-#endif // HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-

=== modified file 'extra/yassl/src/yassl_int.cpp'
--- a/extra/yassl/src/yassl_int.cpp	2011-03-29 08:01:07 +0000
+++ b/extra/yassl/src/yassl_int.cpp	2011-04-04 08:47:25 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -11,11 +10,8 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; see the file COPYING. If not, write to the
-   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-   MA  02110-1301  USA.
-*/
-
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 /* yaSSL internal source implements SSL supporting types not specified in the
  * draft along with type conversion functions.
@@ -2568,14 +2564,3 @@ extern "C" void yaSSL_CleanUp()
     yaSSL::sessionsInstance = 0;
     yaSSL::errorsInstance = 0;
 }
-
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-namespace mySTL {
-template yaSSL::yassl_int_cpp_local1::SumData for_each<mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData>(mySTL::list<yaSSL::input_buffer*>::iterator, mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData);
-template yaSSL::yassl_int_cpp_local1::SumBuffer for_each<mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer>(mySTL::list<yaSSL::output_buffer*>::iterator, mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer);
-template mySTL::list<yaSSL::SSL_SESSION*>::iterator find_if<mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::yassl_int_cpp_local2::sess_match>(mySTL::list<yaSSL::SSL_SESSION*>::iterator, mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::yassl_int_cpp_local2::sess_match);
-template mySTL::list<yaSSL::ThreadError>::iterator find_if<mySTL::list<yaSSL::ThreadError>::iterator, yaSSL::yassl_int_cpp_local2::thr_match>(mySTL::list<yaSSL::ThreadError>::iterator, mySTL::list<yaSSL::ThreadError>::iterator, yaSSL::yassl_int_cpp_local2::thr_match);
-}
-#endif
-

=== modified file 'extra/yassl/taocrypt/CMakeLists.txt'
--- a/extra/yassl/taocrypt/CMakeLists.txt	2010-12-29 00:26:31 +0000
+++ b/extra/yassl/taocrypt/CMakeLists.txt	2011-04-04 08:47:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,10 +27,6 @@ SET(TAOCRYPT_SOURCES		src/aes.cpp src/ae
 				include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp
 				include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp)
 
-IF(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION)
-  SET(TAOCRYPT_SOURCES ${TAOCRYPT_SOURCES} src/template_instnt.cpp)
-ENDIF()
-
 ADD_CONVENIENCE_LIBRARY(taocrypt ${TAOCRYPT_SOURCES})
 RESTRICT_SYMBOL_EXPORTS(taocrypt)
 

=== modified file 'extra/yassl/taocrypt/src/algebra.cpp'
--- a/extra/yassl/taocrypt/src/algebra.cpp	2010-07-02 18:30:47 +0000
+++ b/extra/yassl/taocrypt/src/algebra.cpp	2011-04-04 08:47:25 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (C) 2000-2007 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -11,10 +10,8 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; see the file COPYING. If not, write to the
-   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-   MA  02110-1301  USA.
-*/
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 /* based on Wei Dai's algebra.cpp from CryptoPP */
 #undef  NDEBUG
@@ -326,14 +323,3 @@ void AbstractRing::SimultaneousExponenti
 
 
 } // namespace
-
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-namespace mySTL {
-template TaoCrypt::WindowSlider* uninit_copy<TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*>(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*);
-template void destroy<TaoCrypt::WindowSlider*>(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*);
-template TaoCrypt::WindowSlider* GetArrayMemory<TaoCrypt::WindowSlider>(size_t);
-template void FreeArrayMemory<TaoCrypt::WindowSlider>(TaoCrypt::WindowSlider*);
-}
-#endif
-

=== modified file 'extra/yassl/taocrypt/src/integer.cpp'
--- a/extra/yassl/taocrypt/src/integer.cpp	2010-07-02 18:30:47 +0000
+++ b/extra/yassl/taocrypt/src/integer.cpp	2011-04-04 08:47:25 +0000
@@ -1,5 +1,4 @@
-/*
-   Copyright (C) 2000-2007 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -11,12 +10,8 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; see the file COPYING. If not, write to the
-   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-   MA  02110-1301  USA.
-*/
-
-
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 /* based on Wei Dai's integer.cpp from CryptoPP */
 
@@ -3953,18 +3948,5 @@ Integer CRT(const Integer &xp, const Int
     // isn't operator overloading great?
     return p * (u * (xq-xp) % q) + xp;
 }
-
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-#ifndef TAOCRYPT_NATIVE_DWORD_AVAILABLE
-template hword DivideThreeWordsByTwo<hword, Word>(hword*, hword, hword, Word*);
-#endif
-template word DivideThreeWordsByTwo<word, DWord>(word*, word, word, DWord*);
-#ifdef SSE2_INTRINSICS_AVAILABLE
-template class AlignedAllocator<word>;
-#endif
-#endif
-
-
 } // namespace
 

=== removed file 'extra/yassl/taocrypt/src/template_instnt.cpp'
--- a/extra/yassl/taocrypt/src/template_instnt.cpp	2007-01-29 15:54:40 +0000
+++ b/extra/yassl/taocrypt/src/template_instnt.cpp	1970-01-01 00:00:00 +0000
@@ -1,82 +0,0 @@
-/*
-   Copyright (C) 2000-2007 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; see the file COPYING. If not, write to the
-   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-   MA  02110-1301  USA.
-*/
-
-
-/*  Explicit template instantiation requests 
- */
-
-
-#include "runtime.hpp"
-#include "integer.hpp"
-#include "rsa.hpp"
-#include "sha.hpp"
-#include "md5.hpp"
-#include "hmac.hpp"
-#include "ripemd.hpp"
-#include "pwdbased.hpp"
-#include "algebra.hpp"
-#include "vector.hpp"
-#include "hash.hpp"
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-namespace TaoCrypt {
-
-#if defined(SSE2_INTRINSICS_AVAILABLE)
-template AlignedAllocator<unsigned int>::pointer StdReallocate<unsigned int, AlignedAllocator<unsigned int> >(AlignedAllocator<unsigned int>&, unsigned int*, AlignedAllocator<unsigned int>::size_type, AlignedAllocator<unsigned int>::size_type, bool);
-#endif
-
-template class RSA_Decryptor<RSA_BlockType2>;
-template class RSA_Encryptor<RSA_BlockType1>;
-template class RSA_Encryptor<RSA_BlockType2>;
-template void tcDelete<HASH>(HASH*);
-template void tcDelete<Integer>(Integer*);
-template void tcArrayDelete<byte>(byte*);
-template AllocatorWithCleanup<byte>::pointer StdReallocate<byte, AllocatorWithCleanup<byte> >(AllocatorWithCleanup<byte>&, byte*, AllocatorWithCleanup<byte>::size_type, AllocatorWithCleanup<byte>::size_type, bool);
-template void tcArrayDelete<word>(word*);
-template AllocatorWithCleanup<word>::pointer StdReallocate<word, AllocatorWithCleanup<word> >(AllocatorWithCleanup<word>&, word*, AllocatorWithCleanup<word>::size_type, AllocatorWithCleanup<word>::size_type, bool);
-
-#ifndef TAOCRYPT_SLOW_WORD64 // defined when word != word32
-template void tcArrayDelete<word32>(word32*);
-template AllocatorWithCleanup<word32>::pointer StdReallocate<word32, AllocatorWithCleanup<word32> >(AllocatorWithCleanup<word32>&, word32*, AllocatorWithCleanup<word32>::size_type, AllocatorWithCleanup<word32>::size_type, bool);
-#endif
-
-template void tcArrayDelete<char>(char*);
-
-template class PBKDF2_HMAC<SHA>;
-template class HMAC<MD5>;
-template class HMAC<SHA>;
-template class HMAC<RIPEMD160>;
-
-}
-
-namespace mySTL {
-template vector<TaoCrypt::Integer>* uninit_fill_n<vector<TaoCrypt::Integer>*, size_t, vector<TaoCrypt::Integer> >(vector<TaoCrypt::Integer>*, size_t, vector<TaoCrypt::Integer> const&);
-template void destroy<vector<TaoCrypt::Integer>*>(vector<TaoCrypt::Integer>*, vector<TaoCrypt::Integer>*);
-template TaoCrypt::Integer* uninit_copy<TaoCrypt::Integer*, TaoCrypt::Integer*>(TaoCrypt::Integer*, TaoCrypt::Integer*, TaoCrypt::Integer*);
-template TaoCrypt::Integer* uninit_fill_n<TaoCrypt::Integer*, size_t, TaoCrypt::Integer>(TaoCrypt::Integer*, size_t, TaoCrypt::Integer const&);
-template void destroy<TaoCrypt::Integer*>(TaoCrypt::Integer*, TaoCrypt::Integer*);
-template TaoCrypt::byte* GetArrayMemory<TaoCrypt::byte>(size_t);
-template void FreeArrayMemory<TaoCrypt::byte>(TaoCrypt::byte*);
-template TaoCrypt::Integer* GetArrayMemory<TaoCrypt::Integer>(size_t);
-template void FreeArrayMemory<TaoCrypt::Integer>(TaoCrypt::Integer*);
-template vector<TaoCrypt::Integer>* GetArrayMemory<vector<TaoCrypt::Integer> >(size_t);
-template void FreeArrayMemory<vector<TaoCrypt::Integer> >(vector<TaoCrypt::Integer>*);
-template void FreeArrayMemory<void>(void*);
-}
-
-#endif

=== modified file 'include/my_global.h'
--- a/include/my_global.h	2011-03-29 12:56:34 +0000
+++ b/include/my_global.h	2011-04-13 19:16:45 +0000
@@ -126,6 +126,7 @@
 /* Define missing access() modes. */
 #define F_OK 0
 #define W_OK 2
+#define R_OK 4                        /* Test for read permission.  */
 
 /* Define missing file locking constants. */
 #define F_RDLCK 1
@@ -296,9 +297,6 @@ C_MODE_END
 #undef HAVE_PWRITE
 #endif
 
-#ifdef UNDEF_HAVE_GETHOSTBYNAME_R		/* For OSF4.x */
-#undef HAVE_GETHOSTBYNAME_R
-#endif
 #ifdef UNDEF_HAVE_INITGROUPS			/* For AIX 4.3 */
 #undef HAVE_INITGROUPS
 #endif

=== modified file 'include/violite.h'
--- a/include/violite.h	2011-03-09 21:28:05 +0000
+++ b/include/violite.h	2011-04-14 01:36:24 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -94,6 +94,8 @@ ssize_t vio_pending(Vio *vio);
 my_bool vio_get_normalized_ip_string(const struct sockaddr *addr, int addr_length,
                                      char *ip_string, size_t ip_string_size);
 
+my_bool vio_is_no_name_error(int err_code);
+
 int vio_getnameinfo(const struct sockaddr *sa,
                     char *hostname, size_t hostname_size,
                     char *port, size_t port_size,

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2011-03-17 11:33:17 +0000
+++ b/mysql-test/collections/default.experimental	2011-04-13 21:03:10 +0000
@@ -2,12 +2,15 @@
 # in alphabetical order. This also helps with merge conflict resolution.
 
 binlog.binlog_multi_engine               # joro : NDB tests marked as experimental as agreed with bochklin
+binlog.binlog_bug23533                   # WL#5867: skozlov: test case moved from unused bugs suite
+binlog.binlog_bug36391                   # WL#5867: skozlov: test case moved from unused bugs suite
 
 funcs_1.charset_collation_1              # depends on compile-time decisions
 
 main.func_math @freebsd                  # Bug#43020 2010-05-04 alik main.func_math fails on FreeBSD in PB2
 main.gis-rtree @freebsd                  # Bug#38965 2010-05-04 alik test cases gis-rtree, type_float, type_newdecimal fail in embedded server
 main.lock_multi_bug38499                 # Bug#47448 2009-09-19 alik main.lock_multi_bug38499 times out sporadically
+main.mysqlbinlog_raw_mode                # BUG#11761610 2011-04-11 sven fails on pb2
 main.mysqlslap @windows                  # Bug#54024 2010-08-10 alik mysqlslap fails sporadically starting from Dahlia
 main.outfile_loaddata @solaris           # Bug#46895 2010-01-20 alik Test "outfile_loaddata" fails (reproducible)
 main.signal_demo3 @solaris               # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
@@ -20,10 +23,11 @@ rpl.rpl_innodb_bug28430
 rpl.rpl_row_sp011  @solaris              # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 rpl.rpl_delayed_slave                    # BUG#57514 rpl_delayed_slave fails sporadically in pb
 rpl.rpl_seconds_behind_master            # BUG#58053 2010-11-24 luis fails sporadically on pb2
+rpl.rpl_show_slave_running               # BUG#12346048 2011-04-11 sven fails sporadically on pb2
+rpl.rpl_bug37426                         # WL#5867: skozlov: test case moved from unused bugs suite
 
 sys_vars.max_sp_recursion_depth_func @solaris # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 sys_vars.plugin_dir_basic                     # Bug#52223 2010-11-24 alik Test "plugin_dir_basic" does not support RPM build (test) directory structure
-sys_vars.slow_query_log_func @solaris         # Bug#54819 2010-06-26 alik sys_vars.slow_query_log_func fails sporadically on Solaris 10
 sys_vars.wait_timeout_func                    # Bug#41255 2010-04-26 alik wait_timeout_func fails
 
 # BUG #59055 : All ndb tests should be removed from the repository

=== modified file 'mysql-test/collections/default.weekly'
--- a/mysql-test/collections/default.weekly	2011-03-10 04:29:36 +0000
+++ b/mysql-test/collections/default.weekly	2011-04-06 04:31:38 +0000
@@ -6,3 +6,40 @@ perl mysql-test-run.pl --timer --force -
 perl mysql-test-run.pl --timer --force --debug-server --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 --debug-server --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 --debug-server --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
+
+
+
+# Non debug runs of all the tests run in the daily and weekly collections
+
+perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=normal               --vardir=var-normal                                                                  --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=funcs2               --vardir=var-funcs2              --suite=funcs_2
+perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=partitions           --vardir=var-parts               --suite=parts
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=stress               --vardir=var-stress              --suite=stress
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=jp                   --vardir=var-jp                  --suite=jp
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=nist                 --vardir=var-nist                --suite=nist
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=nist+ps              --vardir=var-ps_nist             --suite=nist                                        --ps-protocol
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_checksum  --vardir=var-rpl_binlog_checksum --suite=rpl,binlog --mysqld=--binlog-checksum=CRC32 --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
+
+
+perl mysql-test-run.pl --timer --force --parallel=auto  --comment=big-tests --experimental=collections/default.experimental --vardir=var-big-tests --big-test --testcase-timeout=60 --suite-timeout=600 main.alter_table-big main.archive-big main.count_distinct3 main.create-big main.events_stress main.events_time_zone main.information_schema-big main.log_tables-big main.merge-big main.mysqlbinlog_row_big main.read_many_rows_innodb main.ssl-big main.sum_distinct-big main.type_newdecimal-big main.variables-big parts.part_supported_sql_func_innodb parts.partition_alter1_1_2_innodb parts.partition_alter1_2_innodb parts.partition_alter2_1_1_innodb parts.partition_alter2_1_2_innodb parts.partition_alter2_2_2_innodb parts.partition_alter4_innodb funcs_1.myisam_views-big --skip-test-list=collections/disabled-weekly.list
+
+perl mysql-test-run.pl --timer --force --parallel=auto  --comment=eits-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-myisam-engine --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 --parallel=auto --comment=eits-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-stmt-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 --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 --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

=== modified file 'mysql-test/extra/rpl_tests/rpl_extra_col_master.test'
--- a/mysql-test/extra/rpl_tests/rpl_extra_col_master.test	2011-02-23 20:01:27 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_extra_col_master.test	2011-03-31 13:52:53 +0000
@@ -122,11 +122,13 @@ SELECT f1,f2,f3,f4,f5,f6,f7,f8,f9,
 
 #connection slave;
 
+--disable_query_log
 call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 2 type mismatch.* 1535");
-call mtr.add_suppression("Slave SQL.*Error .Can.t DROP .c7.; check that column.key exists. on query.* 1091");
-call mtr.add_suppression("Slave SQL.*Error .Unknown column .c7. in .t15.. on query.* 1054");
-call mtr.add_suppression("Slave SQL.*Error .Key column .c6. doesn.t exist in table. on query.* 1072");
+call mtr.add_suppression("Slave.*Can.t DROP .c7.; check that column.key exists.* Error_code: 1091");
+call mtr.add_suppression("Slave.*Unknown column .c7. in .t15.* Error_code: 1054");
+call mtr.add_suppression("Slave.*Key column .c6. doesn.t exist in table.* Error_code: 1072");
 call mtr.add_suppression("Slave SQL.*Column 2 of table .test.t1.. cannot be converted from type.* Error_code: 1677");
+--enable_query_log
 
 sync_slave_with_master;
 --echo

=== modified file 'mysql-test/include/ctype_numconv.inc'
--- a/mysql-test/include/ctype_numconv.inc	2011-02-10 13:41:16 +0000
+++ b/mysql-test/include/ctype_numconv.inc	2011-04-08 13:41:38 +0000
@@ -1777,6 +1777,22 @@ SELECT
   HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
   HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
  
+--echo #
+--echo # Bug#11926811 / Bug#60625 Illegal mix of collations
+--echo #
+SELECT @@collation_connection;
+DELIMITER //;
+CREATE PROCEDURE p1()
+BEGIN
+  DECLARE v_LastPaymentDate DATETIME DEFAULT NULL;
+  SELECT v_LastPaymentDate < NOW();
+  EXPLAIN EXTENDED SELECT v_LastPaymentDate < NOW();
+  SHOW WARNINGS;
+  EXPLAIN EXTENDED SELECT CONCAT(v_LastPaymentDate, NOW());
+END//
+DELIMITER ;//
+CALL p1;
+DROP PROCEDURE p1;
 
 --echo #
 --echo # Bug#52159 returning time type from function and empty left join causes debug assertion

=== modified file 'mysql-test/include/func_in.inc'
--- a/mysql-test/include/func_in.inc	2011-01-14 08:20:08 +0000
+++ b/mysql-test/include/func_in.inc	2011-04-12 10:31:30 +0000
@@ -598,4 +598,15 @@ SELECT * FROM t1
 
 DROP TABLE t1,subq;
 
+--echo #
+--echo # Bug #11766270  59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+--echo #
+
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+--enable_metadata
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+--disable_metadata
+DROP TABLE t1;
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/include/mix1.inc'
--- a/mysql-test/include/mix1.inc	2010-12-10 09:27:55 +0000
+++ b/mysql-test/include/mix1.inc	2011-03-30 13:33:29 +0000
@@ -634,6 +634,10 @@ drop table t1;
 drop table bug29807;
 create table bug29807 (a int);
 drop table bug29807;
+--disable_query_log
+call mtr.add_suppression("InnoDB: Error: table .test...bug29807. does not exist in the InnoDB internal");
+call mtr.add_suppression("Cannot find or open table test\/bug29807 from");
+--enable_query_log
 
 
 #

=== modified file 'mysql-test/include/mtr_warnings.sql'
--- a/mysql-test/include/mtr_warnings.sql	2011-02-23 20:01:27 +0000
+++ b/mysql-test/include/mtr_warnings.sql	2011-04-06 10:36:10 +0000
@@ -71,7 +71,7 @@ SET @@collation_connection = @collation_
 -- Insert patterns that should always be suppressed
 --
 INSERT INTO global_suppressions VALUES
- ("'SELECT UNIX_TIMESTAMP\\(\\)' failed on master"),
+ (".SELECT UNIX_TIMESTAMP... failed on master"),
  ("Aborted connection"),
  ("Client requested master to start replication from impossible position"),
  ("Could not find first log file name in binary log"),
@@ -128,7 +128,6 @@ INSERT INTO global_suppressions VALUES
  ("Sort aborted"),
  ("Time-out in NDB"),
  ("Warning:\s+One can only use the --user.*root"),
- ("Warning:\s+Setting lower_case_table_names=2"),
  ("Warning:\s+Table:.* on (delete|rename)"),
  ("You have an error in your SQL syntax"),
  ("deprecated"),
@@ -141,59 +140,25 @@ INSERT INTO global_suppressions VALUES
  ("slave SQL thread aborted"),
  ("Slave: .*Duplicate entry"),
 
- /*
-   Special case, made as specific as possible, for:
-   Bug #28436: Incorrect position in SHOW BINLOG EVENTS causes
-   server coredump
- */
-
- ("Error in Log_event::read_log_event\\\(\\\): 'Sanity check failed', data_len: 258, event_type: 49"),
-
  ("Statement may not be safe to log in statement format"),
 
- /* test case for Bug#bug29807 copies a stray frm into database */
- ("InnoDB: Error: table `test`.`bug29807` does not exist in the InnoDB internal"),
- ("Cannot find or open table test\/bug29807 from"),
-
  /* innodb foreign key tests that fail in ALTER or RENAME produce this */
  ("InnoDB: Error: in ALTER TABLE `test`.`t[123]`"),
  ("InnoDB: Error: in RENAME TABLE table `test`.`t1`"),
  ("InnoDB: Error: table `test`.`t[123]` does not exist in the InnoDB internal"),
 
- /* Test case for Bug#14233 produces the following warnings: */
- ("Stored routine 'test'.'bug14233_1': invalid value in column mysql.proc"),
- ("Stored routine 'test'.'bug14233_2': invalid value in column mysql.proc"),
- ("Stored routine 'test'.'bug14233_3': invalid value in column mysql.proc"),
-
  /*
    BUG#32080 - Excessive warnings on Solaris: setrlimit could not
    change the size of core files
   */
  ("setrlimit could not change the size of core files to 'infinity'"),
 
- /*
-   rpl_extrColmaster_*.test, the slave thread produces warnings
-   when it get updates to a table that has more columns on the
-   master
-  */
- ("Slave: Unknown column 'c7' in 't15' Error_code: 1054"),
- ("Slave: Can't DROP 'c7'.* 1091"),
- ("Slave: Key column 'c6'.* 1072"),
  ("The slave I.O thread stops because a fatal error is encountered when it tries to get the value of SERVER_UUID variable from master.*"),
  ("The initialization command '.*' failed with the following error.*"),
- ("The slave I.O thread stops because a fatal error is encountered when it try to get the value of SERVER_ID variable from master."),
- (".SELECT UNIX_TIMESTAMP... failed on master, do not trust column Seconds_Behind_Master of SHOW SLAVE STATUS"),
 
  /*It will print a warning if a new UUID of server is generated.*/
  ("No existing UUID has been found, so we assume that this is the first time that this server has been started.*"),
 
- /* Special case for Bug #26402 in show_check.test
-    - Question marks are not valid file name parts on Windows. Ignore
-      this error message.
-  */
- ("Can't find file: '.\\\\test\\\\\\?{8}.frm'"),
- ("Slave: Unknown table 'test.t1' Error_code: 1051"),
-
  /* Added 2009-08-XX after fixing Bug #42408 */
 
  ("Although a path was specified for the .* option, log tables are used"),
@@ -240,6 +205,12 @@ INSERT INTO global_suppressions VALUES
   */
  ("Found lock of type 6 that is write and read locked"),
 
+ /*
+   Warning message is printed out whenever a slave is started with
+   a configuration that is not crash-safe.
+ */
+ (".*If a crash happens this configuration does not guarantee.*"),
+
  ("THE_LAST_SUPPRESSION")||
 
 

=== modified file 'mysql-test/include/order_by.inc'
--- a/mysql-test/include/order_by.inc	2011-02-07 09:46:53 +0000
+++ b/mysql-test/include/order_by.inc	2011-03-30 13:33:29 +0000
@@ -847,8 +847,7 @@ CALL mtr.add_suppression("Out of sort me
 --error ER_OUT_OF_SORTMEMORY
 select * from t1 order by b;
 drop table t1;
-
-
+call mtr.add_suppression("Out of sort memory; increase server sort buffer size");
 --echo #
 --echo # Bug #39844: Query Crash Mysql Server 5.0.67
 --echo #

=== modified file 'mysql-test/include/subquery_mat.inc'
--- a/mysql-test/include/subquery_mat.inc	2011-02-14 11:21:26 +0000
+++ b/mysql-test/include/subquery_mat.inc	2011-04-01 11:06:48 +0000
@@ -847,3 +847,38 @@ eval $query;
 DROP TABLE t1, t2;
 
 --echo # End Bug#59833
+
+--echo #
+--echo # Bug#11852644 - CRASH IN ITEM_REF::SAVE_IN_FIELD ON SELECT DISTINCT
+--echo #
+
+CREATE TABLE t1 (
+  col_varchar_key varchar(1) DEFAULT NULL,
+  col_varchar_nokey varchar(1) DEFAULT NULL,
+  KEY col_varchar_key (col_varchar_key)) 
+;
+
+INSERT INTO t1 VALUES
+('v','v'),('r','r');
+
+CREATE TABLE t2 (
+  col_varchar_key varchar(1) DEFAULT NULL,
+  col_varchar_nokey varchar(1) DEFAULT NULL,
+  KEY col_varchar_key(col_varchar_key)) 
+;
+
+INSERT INTO t2 VALUES
+('r','r'),('c','c');
+
+CREATE VIEW v3 AS SELECT * FROM t2;
+
+SELECT DISTINCT alias2.col_varchar_key 
+FROM t1 AS alias1 JOIN v3 AS alias2 
+ON alias2.col_varchar_key = alias1.col_varchar_key
+HAVING col_varchar_key IN (SELECT col_varchar_nokey FROM t2)
+;
+
+DROP TABLE t1, t2;
+DROP VIEW v3;
+
+--echo # End Bug#11852644

=== modified file 'mysql-test/lib/mtr_misc.pl'
--- a/mysql-test/lib/mtr_misc.pl	2011-01-18 11:09:49 +0000
+++ b/mysql-test/lib/mtr_misc.pl	2011-04-07 08:39:10 +0000
@@ -1,5 +1,5 @@
 # -*- cperl -*-
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -36,6 +36,7 @@ sub start_timer($);
 sub has_expired($);
 sub init_timers();
 sub mark_time_used($);
+sub mark_time_idle();
 sub add_total_times($);
 sub print_times_used($$);
 sub print_total_times($);
@@ -224,6 +225,7 @@ my %time_used= (
   'ch-warn' => 0,
   'test'    => 0,
   'init'    => 0,
+  'admin'   => 0,
 );
 
 my %time_text= (
@@ -232,7 +234,8 @@ my %time_text= (
  'check'   => "Check-testcase",
  'ch-warn' => "Check for warnings",
  'test'    => "Test execution",
- 'init'    => "Initialization etc.",
+ 'init'    => "Initialization/cleanup",
+ 'admin'   => "Test administration",
 );
 
 # Counts number of reports from workers
@@ -255,6 +258,10 @@ sub mark_time_used($) {
   $last_timer_set= $curr_time;
 }
 
+sub mark_time_idle() {
+  $last_timer_set= gettimeofday() if $opt_report_times;
+}
+
 sub add_total_times($) {
   my ($dummy, $num, @line)= split (" ", $_[0]);
 

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2011-03-23 11:37:04 +0000
+++ b/mysql-test/mysql-test-run.pl	2011-04-07 08:39:10 +0000
@@ -220,9 +220,12 @@ our %gprof_dirs;
 our $glob_debugger= 0;
 our $opt_gdb;
 our $opt_client_gdb;
+our $opt_dbx;
+our $opt_client_dbx;
 our $opt_ddd;
 our $opt_client_ddd;
 our $opt_manual_gdb;
+our $opt_manual_dbx;
 our $opt_manual_ddd;
 our $opt_manual_debug;
 our $opt_debugger;
@@ -547,7 +550,9 @@ sub run_test_server ($$$) {
   my $s= IO::Select->new();
   $s->add($server);
   while (1) {
+    mark_time_used('admin');
     my @ready = $s->can_read(1); # Wake up once every second
+    mark_time_idle();
     foreach my $sock (@ready) {
       if ($sock == $server) {
 	# New client connected
@@ -889,7 +894,7 @@ sub run_worker ($) {
       if ( $opt_gprof ) {
 	gprof_collect (find_mysqld($basedir), keys %gprof_dirs);
       }
-      mark_time_used('init');
+      mark_time_used('admin');
       print_times_used($server, $thread_num);
       exit($valgrind_reports);
     }
@@ -1003,6 +1008,9 @@ sub command_line_setup {
              'ddd'                      => \$opt_ddd,
              'client-ddd'               => \$opt_client_ddd,
              'manual-ddd'               => \$opt_manual_ddd,
+             'dbx'                      => \$opt_dbx,
+	     'client-dbx'               => \$opt_client_dbx,
+	     'manual-dbx'               => \$opt_manual_dbx,
 	     'debugger=s'               => \$opt_debugger,
 	     'client-debugger=s'        => \$opt_client_debugger,
              'strace-client:s'          => \$opt_strace_client,
@@ -1428,6 +1436,12 @@ sub command_line_setup {
       $opt_ddd= undef;
     }
 
+    if ($opt_dbx) {
+      mtr_warning("Silently converting --dbx to --client-dbx in embedded mode");
+      $opt_client_dbx= $opt_dbx;
+      $opt_dbx= undef;
+    }
+
     if ($opt_debugger)
     {
       mtr_warning("Silently converting --debugger to --client-debugger in embedded mode");
@@ -1436,7 +1450,7 @@ sub command_line_setup {
     }
 
     if ( $opt_gdb || $opt_ddd || $opt_manual_gdb || $opt_manual_ddd ||
-	 $opt_manual_debug || $opt_debugger )
+	 $opt_manual_debug || $opt_debugger || $opt_dbx || $opt_manual_dbx)
     {
       mtr_error("You need to use the client debug options for the",
 		"embedded server. Ex: --client-gdb");
@@ -1464,6 +1478,7 @@ sub command_line_setup {
   # --------------------------------------------------------------------------
   if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd ||
        $opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug ||
+       $opt_dbx || $opt_client_dbx || $opt_manual_dbx ||
        $opt_debugger || $opt_client_debugger )
   {
     # Indicate that we are using debugger
@@ -3764,7 +3779,7 @@ sub run_testcase ($) {
 
   do_before_run_mysqltest($tinfo);
 
-  mark_time_used('init');
+  mark_time_used('admin');
 
   if ( $opt_check_testcases and check_testcase($tinfo, "before") ){
     # Failed to record state of server or server crashed
@@ -4706,6 +4721,9 @@ sub mysqld_start ($$) {
   {
     ddd_arguments(\$args, \$exe, $mysqld->name());
   }
+  if ( $opt_dbx || $opt_manual_dbx ) {
+    dbx_arguments(\$args, \$exe, $mysqld->name());
+  }
   elsif ( $opt_debugger )
   {
     debugger_arguments(\$args, \$exe, $mysqld->name());
@@ -5257,7 +5275,7 @@ sub start_mysqltest ($) {
   my $exe= $exe_mysqltest;
   my $args;
 
-  mark_time_used('init');
+  mark_time_used('admin');
 
   mtr_init_args(\$args);
 
@@ -5404,6 +5422,9 @@ sub start_mysqltest ($) {
   {
     ddd_arguments(\$args, \$exe, "client");
   }
+  if ( $opt_client_dbx ) {
+    dbx_arguments(\$args, \$exe, "client");
+  }
   elsif ( $opt_client_debugger )
   {
     debugger_arguments(\$args, \$exe, "client");
@@ -5438,23 +5459,11 @@ sub gdb_arguments {
   # Remove the old gdbinit file
   unlink($gdb_init_file);
 
-  if ( $type eq "client" )
-  {
-    # write init file for client
-    mtr_tofile($gdb_init_file,
-	       "set args $str\n" .
-	       "break main\n");
-  }
-  else
-  {
-    # write init file for mysqld
-    mtr_tofile($gdb_init_file,
-	       "set args $str\n" .
-	       "break mysql_parse\n" .
-	       "commands 1\n" .
-	       "disable 1\n" .
-	       "end\n");
-  }
+  # write init file for mysqld or client
+  mtr_tofile($gdb_init_file,
+	     "set args $str\n" .
+	     "break main\n" .
+	     "run");
 
   if ( $opt_manual_gdb )
   {
@@ -5501,24 +5510,12 @@ sub ddd_arguments {
   # Remove the old gdbinit file
   unlink($gdb_init_file);
 
-  if ( $type eq "client" )
-  {
-    # write init file for client
-    mtr_tofile($gdb_init_file,
-	       "set args $str\n" .
-	       "break main\n");
-  }
-  else
-  {
-    # write init file for mysqld
-    mtr_tofile($gdb_init_file,
-	       "file ../sql/mysqld\n" .
-	       "set args $str\n" .
-	       "break mysql_parse\n" .
-	       "commands 1\n" .
-	       "disable 1\n" .
-	       "end");
-  }
+  # write init file for mysqld or client
+  mtr_tofile($gdb_init_file,
+	     "file $$exe\n" .
+	     "set args $str\n" .
+	     "break main\n" .
+	     "run");
 
   if ( $opt_manual_ddd )
   {
@@ -5548,6 +5545,46 @@ sub ddd_arguments {
 
 
 #
+# Modify the exe and args so that program is run in dbx in xterm
+#
+sub dbx_arguments {
+  my $args= shift;
+  my $exe=  shift;
+  my $type= shift;
+
+  # Put $args into a single string
+  my $str= join " ", @$$args;
+
+  if ( $opt_manual_dbx ) {
+    print "\nTo start dbx for $type, type in another window:\n";
+    print "cd $glob_mysql_test_dir; dbx -c \"stop in main; " .
+          "run $str\" $$exe\n";
+
+    # Indicate the exe should not be started
+    $$exe= undef;
+    return;
+  }
+
+  $$args= [];
+  mtr_add_arg($$args, "-title");
+  mtr_add_arg($$args, "$type");
+  mtr_add_arg($$args, "-e");
+
+  if ( $exe_libtool ) {
+    mtr_add_arg($$args, $exe_libtool);
+    mtr_add_arg($$args, "--mode=execute");
+  }
+
+  mtr_add_arg($$args, "dbx");
+  mtr_add_arg($$args, "-c");
+  mtr_add_arg($$args, "stop in main; run $str");
+  mtr_add_arg($$args, "$$exe");
+
+  $$exe= "xterm";
+}
+
+
+#
 # Modify the exe and args so that program is run in the selected debugger
 #
 sub debugger_arguments {
@@ -5578,18 +5615,6 @@ sub debugger_arguments {
     $$exe= $debugger;
 
   }
-  elsif ( $debugger eq "dbx" )
-  {
-    # xterm -e dbx -r exe arg1 .. argn
-
-    unshift(@$$args, $$exe);
-    unshift(@$$args, "-r");
-    unshift(@$$args, $debugger);
-    unshift(@$$args, "-e");
-
-    $$exe= "xterm";
-
-  }
   else
   {
     mtr_error("Unknown argument \"$debugger\" passed to --debugger");
@@ -5891,6 +5916,7 @@ Options for debugging the product
   client-ddd            Start mysqltest client in ddd
   client-debugger=NAME  Start mysqltest in the selected debugger
   client-gdb            Start mysqltest client in gdb
+  client-dbx            Start mysqltest client in dbx
   ddd                   Start mysqld in ddd
   debug                 Dump trace output for all servers and client programs
   debug-common          Same as debug, but sets 'd' debug flags to
@@ -5899,12 +5925,15 @@ Options for debugging the product
                         tracing
   debugger=NAME         Start mysqld in the selected debugger
   gdb                   Start the mysqld(s) in gdb
+  dbx                   Start the mysqld(s) in dbx
   manual-debug          Let user manually start mysqld in debugger, before
                         running test(s)
   manual-gdb            Let user manually start mysqld in gdb, before running
                         test(s)
   manual-ddd            Let user manually start mysqld in ddd, before running
                         test(s)
+  manual-dbx            Let user manually start mysqld in dbx, before running
+                        test(s)
   strace-client[=path]  Create strace output for mysqltest client, optionally
                         specifying name and path to the trace program to use.
                         Example: $0 --strace-client=ktrace

=== modified file 'mysql-test/r/alter_table.result'
--- a/mysql-test/r/alter_table.result	2011-02-21 11:34:23 +0000
+++ b/mysql-test/r/alter_table.result	2011-04-13 07:13:13 +0000
@@ -1391,3 +1391,16 @@ CREATE DATABASE db1 CHARACTER SET utf8;
 CREATE TABLE db1.t1 (bar TINYTEXT, KEY (bar(100)));
 ALTER TABLE db1.t1 ADD baz INT;
 DROP DATABASE db1;
+#
+# Bug#11938039 RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME
+#              CLAUSE FAILS OR ABORTS SERVER.
+#
+drop table if exists t1;
+create table t1 (a int);
+prepare stmt1 from 'alter table t1 alter column a set default 1, rename to t2';
+execute stmt1;
+rename table t2 to t1;
+# The below statement should succeed and not emit error or abort server.
+execute stmt1;
+deallocate prepare stmt1;
+drop table t2;

=== modified file 'mysql-test/r/ctype_binary.result'
--- a/mysql-test/r/ctype_binary.result	2011-02-10 08:47:05 +0000
+++ b/mysql-test/r/ctype_binary.result	2011-04-08 13:41:38 +0000
@@ -2830,6 +2830,32 @@ HEX(DATE_SUB(CAST('2007-08-03 17:33:00'
 field_str1	field1_str2	field_date	field_datetime
 323030372D30382D30322032333A35393A3030	323030372D30382D30332031373A33323A3030	323030372D30382D3032	323030372D30382D30332031373A33323A3030
 #
+# Bug#11926811 / Bug#60625 Illegal mix of collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+binary
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE v_LastPaymentDate DATETIME DEFAULT NULL;
+SELECT v_LastPaymentDate < NOW();
+EXPLAIN EXTENDED SELECT v_LastPaymentDate < NOW();
+SHOW WARNINGS;
+EXPLAIN EXTENDED SELECT CONCAT(v_LastPaymentDate, NOW());
+END//
+CALL p1;
+v_LastPaymentDate < NOW()
+NULL
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Level	Code	Message
+Note	1003	select (v_LastPaymentDate@0 < now()) AS `v_LastPaymentDate < NOW()`
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Warnings:
+Note	1003	select concat(v_LastPaymentDate@0,now()) AS `CONCAT(v_LastPaymentDate, NOW())`
+DROP PROCEDURE p1;
+#
 # Bug#52159 returning time type from function and empty left join causes debug assertion
 #
 CREATE FUNCTION f1() RETURNS TIME RETURN 1;

=== modified file 'mysql-test/r/ctype_cp1251.result'
--- a/mysql-test/r/ctype_cp1251.result	2011-02-18 07:43:02 +0000
+++ b/mysql-test/r/ctype_cp1251.result	2011-04-08 13:41:38 +0000
@@ -3222,6 +3222,32 @@ HEX(DATE_SUB(CAST('2007-08-03 17:33:00'
 field_str1	field1_str2	field_date	field_datetime
 323030372D30382D30322032333A35393A3030	323030372D30382D30332031373A33323A3030	323030372D30382D3032	323030372D30382D30332031373A33323A3030
 #
+# Bug#11926811 / Bug#60625 Illegal mix of collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+cp1251_general_ci
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE v_LastPaymentDate DATETIME DEFAULT NULL;
+SELECT v_LastPaymentDate < NOW();
+EXPLAIN EXTENDED SELECT v_LastPaymentDate < NOW();
+SHOW WARNINGS;
+EXPLAIN EXTENDED SELECT CONCAT(v_LastPaymentDate, NOW());
+END//
+CALL p1;
+v_LastPaymentDate < NOW()
+NULL
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Level	Code	Message
+Note	1003	select (v_LastPaymentDate@0 < now()) AS `v_LastPaymentDate < NOW()`
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Warnings:
+Note	1003	select concat(convert(v_LastPaymentDate@0 using cp1251),now()) AS `CONCAT(v_LastPaymentDate, NOW())`
+DROP PROCEDURE p1;
+#
 # Bug#52159 returning time type from function and empty left join causes debug assertion
 #
 CREATE FUNCTION f1() RETURNS TIME RETURN 1;

=== modified file 'mysql-test/r/ctype_latin1.result'
--- a/mysql-test/r/ctype_latin1.result	2011-03-04 15:55:18 +0000
+++ b/mysql-test/r/ctype_latin1.result	2011-04-08 13:41:38 +0000
@@ -3249,6 +3249,32 @@ HEX(DATE_SUB(CAST('2007-08-03 17:33:00'
 field_str1	field1_str2	field_date	field_datetime
 323030372D30382D30322032333A35393A3030	323030372D30382D30332031373A33323A3030	323030372D30382D3032	323030372D30382D30332031373A33323A3030
 #
+# Bug#11926811 / Bug#60625 Illegal mix of collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+latin1_swedish_ci
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE v_LastPaymentDate DATETIME DEFAULT NULL;
+SELECT v_LastPaymentDate < NOW();
+EXPLAIN EXTENDED SELECT v_LastPaymentDate < NOW();
+SHOW WARNINGS;
+EXPLAIN EXTENDED SELECT CONCAT(v_LastPaymentDate, NOW());
+END//
+CALL p1;
+v_LastPaymentDate < NOW()
+NULL
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Level	Code	Message
+Note	1003	select (v_LastPaymentDate@0 < now()) AS `v_LastPaymentDate < NOW()`
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Warnings:
+Note	1003	select concat(v_LastPaymentDate@0,now()) AS `CONCAT(v_LastPaymentDate, NOW())`
+DROP PROCEDURE p1;
+#
 # Bug#52159 returning time type from function and empty left join causes debug assertion
 #
 CREATE FUNCTION f1() RETURNS TIME RETURN 1;

=== modified file 'mysql-test/r/ctype_ucs.result'
--- a/mysql-test/r/ctype_ucs.result	2011-03-04 14:59:32 +0000
+++ b/mysql-test/r/ctype_ucs.result	2011-04-08 13:41:38 +0000
@@ -4149,6 +4149,32 @@ HEX(DATE_SUB(CAST('2007-08-03 17:33:00'
 field_str1	field1_str2	field_date	field_datetime
 0032003000300037002D00300038002D00300032002000320033003A00350039003A00300030	0032003000300037002D00300038002D00300033002000310037003A00330032003A00300030	323030372D30382D3032	323030372D30382D30332031373A33323A3030
 #
+# Bug#11926811 / Bug#60625 Illegal mix of collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+ucs2_general_ci
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE v_LastPaymentDate DATETIME DEFAULT NULL;
+SELECT v_LastPaymentDate < NOW();
+EXPLAIN EXTENDED SELECT v_LastPaymentDate < NOW();
+SHOW WARNINGS;
+EXPLAIN EXTENDED SELECT CONCAT(v_LastPaymentDate, NOW());
+END//
+CALL p1;
+v_LastPaymentDate < NOW()
+NULL
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Level	Code	Message
+Note	1003	select (v_LastPaymentDate@0 < now()) AS `v_LastPaymentDate < NOW()`
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Warnings:
+Note	1003	select concat(convert(v_LastPaymentDate@0 using ucs2),convert(now() using ucs2)) AS `CONCAT(v_LastPaymentDate, NOW())`
+DROP PROCEDURE p1;
+#
 # Bug#52159 returning time type from function and empty left join causes debug assertion
 #
 CREATE FUNCTION f1() RETURNS TIME RETURN 1;

=== modified file 'mysql-test/r/ctype_utf8.result'
--- a/mysql-test/r/ctype_utf8.result	2011-03-04 15:55:18 +0000
+++ b/mysql-test/r/ctype_utf8.result	2011-04-08 13:41:38 +0000
@@ -5052,6 +5052,32 @@ HEX(DATE_SUB(CAST('2007-08-03 17:33:00'
 field_str1	field1_str2	field_date	field_datetime
 323030372D30382D30322032333A35393A3030	323030372D30382D30332031373A33323A3030	323030372D30382D3032	323030372D30382D30332031373A33323A3030
 #
+# Bug#11926811 / Bug#60625 Illegal mix of collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8_general_ci
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE v_LastPaymentDate DATETIME DEFAULT NULL;
+SELECT v_LastPaymentDate < NOW();
+EXPLAIN EXTENDED SELECT v_LastPaymentDate < NOW();
+SHOW WARNINGS;
+EXPLAIN EXTENDED SELECT CONCAT(v_LastPaymentDate, NOW());
+END//
+CALL p1;
+v_LastPaymentDate < NOW()
+NULL
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Level	Code	Message
+Note	1003	select (v_LastPaymentDate@0 < now()) AS `v_LastPaymentDate < NOW()`
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+Warnings:
+Note	1003	select concat(convert(v_LastPaymentDate@0 using utf8),now()) AS `CONCAT(v_LastPaymentDate, NOW())`
+DROP PROCEDURE p1;
+#
 # Bug#52159 returning time type from function and empty left join causes debug assertion
 #
 CREATE FUNCTION f1() RETURNS TIME RETURN 1;

=== modified file 'mysql-test/r/func_group.result'
--- a/mysql-test/r/func_group.result	2011-02-02 09:21:41 +0000
+++ b/mysql-test/r/func_group.result	2011-04-12 10:31:30 +0000
@@ -1737,6 +1737,26 @@ SELECT MIN(GET_LOCK('aaaaaaaaaaaaaaaaa',
 SELECT MIN(GET_LOCK('aaaaaaaaaaaaaaaaa',0) / '0b1111111111111111111111111111111111111111111111111111111111111111111111111' ^ (RAND()));
 SELECT RELEASE_LOCK('aaaaaaaaaaaaaaaaa');
 #
+# Bug #11766094 - 59132: MIN() AND MAX() REMOVE UNSIGNEDNESS 
+#
+CREATE TABLE t1 (a BIGINT UNSIGNED);
+INSERT INTO t1 VALUES (18446668621106209655);
+SELECT MAX(LENGTH(a)), LENGTH(MAX(a)), MIN(a), MAX(a), CONCAT(MIN(a)), CONCAT(MAX(a)) FROM t1;
+MAX(LENGTH(a))	LENGTH(MAX(a))	MIN(a)	MAX(a)	CONCAT(MIN(a))	CONCAT(MAX(a))
+20	20	18446668621106209655	18446668621106209655	18446668621106209655	18446668621106209655
+DROP TABLE t1;
+#
+# Bug #11766270  59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+#
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def				MAX(f1)	MAX(f1)	13	4	4	Y	32864	0	63
+MAX(f1)
+2001
+DROP TABLE t1;
+#
 End of 5.1 tests
 #
 # Bug#52123 Assertion failed: aggregator == aggr->Aggrtype(),

=== modified file 'mysql-test/r/func_in_icp.result'
--- a/mysql-test/r/func_in_icp.result	2011-01-14 08:20:08 +0000
+++ b/mysql-test/r/func_in_icp.result	2011-04-12 10:31:30 +0000
@@ -806,5 +806,16 @@ WHERE 1+NULL NOT IN
 (SELECT i FROM subq WHERE subq.pk = t1.pk);
 pk	i
 DROP TABLE t1,subq;
+#
+# Bug #11766270  59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+#
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def				MAX(f1)	MAX(f1)	13	4	4	Y	32864	0	63
+MAX(f1)
+2001
+DROP TABLE t1;
 End of 5.1 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/func_in_icp_mrr.result'
--- a/mysql-test/r/func_in_icp_mrr.result	2011-01-14 08:20:08 +0000
+++ b/mysql-test/r/func_in_icp_mrr.result	2011-04-12 10:31:30 +0000
@@ -806,5 +806,16 @@ WHERE 1+NULL NOT IN
 (SELECT i FROM subq WHERE subq.pk = t1.pk);
 pk	i
 DROP TABLE t1,subq;
+#
+# Bug #11766270  59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+#
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def				MAX(f1)	MAX(f1)	13	4	4	Y	32864	0	63
+MAX(f1)
+2001
+DROP TABLE t1;
 End of 5.1 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/func_in_mrr.result'
--- a/mysql-test/r/func_in_mrr.result	2011-01-14 08:20:08 +0000
+++ b/mysql-test/r/func_in_mrr.result	2011-04-12 10:31:30 +0000
@@ -806,5 +806,16 @@ WHERE 1+NULL NOT IN
 (SELECT i FROM subq WHERE subq.pk = t1.pk);
 pk	i
 DROP TABLE t1,subq;
+#
+# Bug #11766270  59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+#
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def				MAX(f1)	MAX(f1)	13	4	4	Y	32864	0	63
+MAX(f1)
+2001
+DROP TABLE t1;
 End of 5.1 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/func_in_mrr_cost.result'
--- a/mysql-test/r/func_in_mrr_cost.result	2011-01-14 08:20:08 +0000
+++ b/mysql-test/r/func_in_mrr_cost.result	2011-04-12 10:31:30 +0000
@@ -806,5 +806,16 @@ WHERE 1+NULL NOT IN
 (SELECT i FROM subq WHERE subq.pk = t1.pk);
 pk	i
 DROP TABLE t1,subq;
+#
+# Bug #11766270  59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+#
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def				MAX(f1)	MAX(f1)	13	4	4	Y	32864	0	63
+MAX(f1)
+2001
+DROP TABLE t1;
 End of 5.1 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/func_in_none.result'
--- a/mysql-test/r/func_in_none.result	2011-01-14 08:20:08 +0000
+++ b/mysql-test/r/func_in_none.result	2011-04-12 10:31:30 +0000
@@ -805,5 +805,16 @@ WHERE 1+NULL NOT IN
 (SELECT i FROM subq WHERE subq.pk = t1.pk);
 pk	i
 DROP TABLE t1,subq;
+#
+# Bug #11766270  59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+#
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def				MAX(f1)	MAX(f1)	13	4	4	Y	32864	0	63
+MAX(f1)
+2001
+DROP TABLE t1;
 End of 5.1 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/innodb_icp_all.result'
--- a/mysql-test/r/innodb_icp_all.result	2011-03-21 07:13:12 +0000
+++ b/mysql-test/r/innodb_icp_all.result	2011-03-29 08:10:26 +0000
@@ -776,5 +776,100 @@ Warning	1364	Field 'COL1000' doesn't hav
 SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate();
 col999
 DROP TABLE t1;
+#
+# Bug#11873324 "WRONG RESULT WITH ICP AND STRAIGHT_JOIN"
+#
+CREATE TABLE t1 (  
+pk INTEGER NOT NULL,
+i1 INTEGER,
+PRIMARY KEY (pk),
+KEY col_int_key (i1)
+);
+INSERT INTO t1 VALUES (14,NULL), (18,133);
+CREATE TABLE t2 (  
+pk INTEGER NOT NULL,
+i1 INTEGER,
+c1 VARCHAR(1),
+PRIMARY KEY (pk),
+KEY col_int_key (i1)
+);
+INSERT INTO t2 VALUES (1,7,'f');
+EXPLAIN SELECT t1.i1
+FROM t1
+WHERE t1.i1 NOT IN
+( SELECT STRAIGHT_JOIN SUBQUERY_t1.pk
+FROM t1 AS SUBQUERY_t1
+JOIN t2 AS SUBQUERY_t2
+ON SUBQUERY_t2.i1 = SUBQUERY_t1.pk
+WHERE SUBQUERY_t1.i1 > 0
+OR SUBQUERY_t2.c1 = 'a'
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	index	NULL	col_int_key	5	NULL	2	Using where; Using index
+2	DEPENDENT SUBQUERY	SUBQUERY_t1	eq_ref	PRIMARY,col_int_key	PRIMARY	4	func	1	Using where; Full scan on NULL key
+2	DEPENDENT SUBQUERY	SUBQUERY_t2	ref	col_int_key	col_int_key	5	func	1	Using where; Full scan on NULL key
+SELECT t1.i1
+FROM t1
+WHERE t1.i1 NOT IN
+( SELECT STRAIGHT_JOIN SUBQUERY_t1.pk
+FROM t1 AS SUBQUERY_t1
+JOIN t2 AS SUBQUERY_t2
+ON SUBQUERY_t2.i1 = SUBQUERY_t1.pk
+WHERE SUBQUERY_t1.i1 > 0
+OR SUBQUERY_t2.c1 = 'a'
+);
+i1
+NULL
+133
+DROP TABLE t1,t2;
+#
+# Bug#11876420 "MISSING ROW IN RESULT WITH SUBQUERY + IN + XOR + 
+#               NULL VALUES AND ICP ENABLED"
+# 
+CREATE TABLE t1 (  
+i1 INTEGER,
+c1 VARCHAR(1),
+KEY col_varchar_key (c1)
+);
+INSERT INTO t1 VALUES (1,'j'), (0,'e'), (210,'f'), (8,'v'), (7,'x'),
+(5,'m'), (NULL,'c');
+CREATE TABLE t2 (  
+i1 INTEGER,
+c1 VARCHAR(1),
+KEY col_varchar_key (c1)
+);
+INSERT INTO t2 VALUES (8,NULL);
+CREATE TABLE t3 (  
+i1 INTEGER,
+c1 VARCHAR(1),
+KEY col_varchar_key (c1)
+) ENGINE=InnoDB;
+INSERT INTO t3 VALUES (NULL,'w'), (1,NULL), (2,'d');
+EXPLAIN SELECT i1
+FROM t3
+WHERE c1 IN
+( SELECT t1.c1
+FROM t2 JOIN t1
+ON t2.i1 >= t1.i1
+WHERE t1.c1 > t2.c1
+)
+XOR i1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	3	Using where
+2	DEPENDENT SUBQUERY	t2	ALL	col_varchar_key	NULL	NULL	NULL	1	
+2	DEPENDENT SUBQUERY	t1	ref_or_null	col_varchar_key	col_varchar_key	4	func	2	Using where; Full scan on NULL key
+SELECT i1
+FROM t3
+WHERE c1 IN
+( SELECT t1.c1
+FROM t2 JOIN t1
+ON t2.i1 >= t1.i1
+WHERE t1.c1 > t2.c1
+)
+XOR i1;
+i1
+1
+2
+DROP TABLE t1, t2, t3;
 set default_storage_engine= @save_storage_engine;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/innodb_mysql_lock.result'
--- a/mysql-test/r/innodb_mysql_lock.result	2010-06-26 20:23:28 +0000
+++ b/mysql-test/r/innodb_mysql_lock.result	2011-04-13 18:43:08 +0000
@@ -148,3 +148,25 @@ COMMIT;
 # Connection default
 DROP TABLE t1, t2;
 DROP VIEW v1;
+#
+# Bug#11815600 [ERROR] INNODB COULD NOT FIND INDEX PRIMARY
+#              KEY NO 0 FOR TABLE IN ERROR LOG 
+#
+DROP TABLE IF EXISTS t1;
+# Connection default
+CREATE TABLE t1 (id INT PRIMARY KEY, value INT) ENGINE = InnoDB;
+INSERT INTO t1 VALUES (1, 12345);
+START TRANSACTION;
+SELECT * FROM t1;
+id	value
+1	12345
+# Connection con1
+SET lock_wait_timeout=1;
+ALTER TABLE t1 ADD INDEX idx(value);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# Connection default
+SELECT * FROM t1;
+id	value
+1	12345
+COMMIT;
+DROP TABLE t1;

=== modified file 'mysql-test/r/innodb_mysql_sync.result'
--- a/mysql-test/r/innodb_mysql_sync.result	2011-03-07 13:30:49 +0000
+++ b/mysql-test/r/innodb_mysql_sync.result	2011-04-13 18:43:08 +0000
@@ -94,74 +94,6 @@ SET DEBUG_SYNC= 'RESET';
 # Bug#42230 during add index, cannot do queries on storage engines
 #           that implement add_index
 #
-DROP DATABASE IF EXISTS db1;
-DROP TABLE IF EXISTS t1;
-# Test 1: Secondary index, should not block reads (original test case).
-# Connection default
-CREATE DATABASE db1;
-CREATE TABLE db1.t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT) engine=innodb;
-INSERT INTO db1.t1(value) VALUES (1), (2);
-SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
-# Sending:
-ALTER TABLE db1.t1 ADD INDEX(value);
-# Connection con1
-SET DEBUG_SYNC= "now WAIT_FOR manage";
-USE db1;
-SELECT * FROM t1;
-id	value
-1	1
-2	2
-SET DEBUG_SYNC= "now SIGNAL query";
-# Connection default
-# Reaping: ALTER TABLE db1.t1 ADD INDEX(value)
-DROP DATABASE db1;
-# Test 2: Primary index (implicit), should block reads.
-CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
-SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
-# Sending:
-ALTER TABLE t1 ADD UNIQUE INDEX(a);
-# Connection con1
-SET DEBUG_SYNC= "now WAIT_FOR manage";
-USE test;
-# Sending:
-SELECT * FROM t1;
-# Connection con2
-# Waiting for SELECT to be blocked by the metadata lock on t1
-SET DEBUG_SYNC= "now SIGNAL query";
-# Connection default
-# Reaping: ALTER TABLE t1 ADD UNIQUE INDEX(a)
-# Connection con1
-# Reaping: SELECT * FROM t1
-a	b
-# Test 3: Primary index (explicit), should block reads.
-# Connection default
-ALTER TABLE t1 DROP INDEX a;
-SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
-# Sending:
-ALTER TABLE t1 ADD PRIMARY KEY (a);
-# Connection con1
-SET DEBUG_SYNC= "now WAIT_FOR manage";
-# Sending:
-SELECT * FROM t1;
-# Connection con2
-# Waiting for SELECT to be blocked by the metadata lock on t1
-SET DEBUG_SYNC= "now SIGNAL query";
-# Connection default
-# Reaping: ALTER TABLE t1 ADD PRIMARY KEY (a)
-# Connection con1
-# Reaping: SELECT * FROM t1
-a	b
-# Test 4: Secondary unique index, should not block reads.
-# Connection default
-SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
-# Sending:
-ALTER TABLE t1 ADD UNIQUE (b);
-# Connection con1
-SET DEBUG_SYNC= "now WAIT_FOR manage";
-SELECT * FROM t1;
-a	b
-SET DEBUG_SYNC= "now SIGNAL query";
-# Connection default
-# Reaping: ALTER TABLE t1 ADD UNIQUE (b)
-SET DEBUG_SYNC= "RESET";
-DROP TABLE t1;
+#
+# DISABLED due to Bug#11815600
+#

=== modified file 'mysql-test/r/lowercase_table2.result'
--- a/mysql-test/r/lowercase_table2.result	2010-07-21 15:20:29 +0000
+++ b/mysql-test/r/lowercase_table2.result	2011-04-06 15:11:43 +0000
@@ -175,6 +175,35 @@ TABLE_SCHEMA	TABLE_NAME
 mysqltest_lc2	myUC
 use test;
 drop database mysqltest_LC2;
+#
+# Bug #11758687: 50924: object names not resolved correctly 
+#   on lctn2 systems
+#
+CREATE DATABASE BUP_XPFM_COMPAT_DB2;
+CREATE TABLE BUP_XPFM_COMPAT_DB2.TABLE2 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TABLE BUP_XPFM_COMPAT_DB2.table1 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TABLE bup_xpfm_compat_db2.table3 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.trigger1 AFTER INSERT
+ON BUP_XPFM_COMPAT_DB2.table1 FOR EACH ROW
+update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.TRIGGER2 AFTER INSERT
+ON BUP_XPFM_COMPAT_DB2.TABLE2 FOR EACH ROW
+update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.TrigGer3 AFTER INSERT
+ON BUP_XPFM_COMPAT_DB2.TaBle3 FOR EACH ROW
+update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+SELECT trigger_schema, trigger_name, event_object_table FROM
+INFORMATION_SCHEMA.TRIGGERS
+WHERE trigger_schema COLLATE utf8_bin = 'BUP_XPFM_COMPAT_DB2'
+  ORDER BY trigger_schema, trigger_name;
+trigger_schema	trigger_name	event_object_table
+BUP_XPFM_COMPAT_DB2	trigger1	table1
+BUP_XPFM_COMPAT_DB2	TRIGGER2	TABLE2
+BUP_XPFM_COMPAT_DB2	TrigGer3	table3
+DROP DATABASE BUP_XPFM_COMPAT_DB2;
 # End of 5.1 tests
 #
 # Test for bug #44738 "fill_schema_table_from_frm() opens tables without

=== modified file 'mysql-test/r/myisam_icp_all.result'
--- a/mysql-test/r/myisam_icp_all.result	2011-03-21 07:13:12 +0000
+++ b/mysql-test/r/myisam_icp_all.result	2011-03-29 08:10:26 +0000
@@ -774,4 +774,98 @@ Warning	1364	Field 'COL1000' doesn't hav
 SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate();
 col999
 DROP TABLE t1;
+#
+# Bug#11873324 "WRONG RESULT WITH ICP AND STRAIGHT_JOIN"
+#
+CREATE TABLE t1 (  
+pk INTEGER NOT NULL,
+i1 INTEGER,
+PRIMARY KEY (pk),
+KEY col_int_key (i1)
+);
+INSERT INTO t1 VALUES (14,NULL), (18,133);
+CREATE TABLE t2 (  
+pk INTEGER NOT NULL,
+i1 INTEGER,
+c1 VARCHAR(1),
+PRIMARY KEY (pk),
+KEY col_int_key (i1)
+);
+INSERT INTO t2 VALUES (1,7,'f');
+EXPLAIN SELECT t1.i1
+FROM t1
+WHERE t1.i1 NOT IN
+( SELECT STRAIGHT_JOIN SUBQUERY_t1.pk
+FROM t1 AS SUBQUERY_t1
+JOIN t2 AS SUBQUERY_t2
+ON SUBQUERY_t2.i1 = SUBQUERY_t1.pk
+WHERE SUBQUERY_t1.i1 > 0
+OR SUBQUERY_t2.c1 = 'a'
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	index	NULL	col_int_key	5	NULL	2	Using where; Using index
+2	DEPENDENT SUBQUERY	SUBQUERY_t1	eq_ref	PRIMARY,col_int_key	PRIMARY	4	func	1	Using where; Full scan on NULL key
+2	DEPENDENT SUBQUERY	SUBQUERY_t2	ALL	col_int_key	NULL	NULL	NULL	1	Using where; Using join buffer (BNL, incremental buffers)
+SELECT t1.i1
+FROM t1
+WHERE t1.i1 NOT IN
+( SELECT STRAIGHT_JOIN SUBQUERY_t1.pk
+FROM t1 AS SUBQUERY_t1
+JOIN t2 AS SUBQUERY_t2
+ON SUBQUERY_t2.i1 = SUBQUERY_t1.pk
+WHERE SUBQUERY_t1.i1 > 0
+OR SUBQUERY_t2.c1 = 'a'
+);
+i1
+NULL
+133
+DROP TABLE t1,t2;
+#
+# Bug#11876420 "MISSING ROW IN RESULT WITH SUBQUERY + IN + XOR + 
+#               NULL VALUES AND ICP ENABLED"
+# 
+CREATE TABLE t1 (  
+i1 INTEGER,
+c1 VARCHAR(1),
+KEY col_varchar_key (c1)
+);
+INSERT INTO t1 VALUES (1,'j'), (0,'e'), (210,'f'), (8,'v'), (7,'x'),
+(5,'m'), (NULL,'c');
+CREATE TABLE t2 (  
+i1 INTEGER,
+c1 VARCHAR(1),
+KEY col_varchar_key (c1)
+);
+INSERT INTO t2 VALUES (8,NULL);
+CREATE TABLE t3 (  
+i1 INTEGER,
+c1 VARCHAR(1),
+KEY col_varchar_key (c1)
+) ENGINE=InnoDB;
+INSERT INTO t3 VALUES (NULL,'w'), (1,NULL), (2,'d');
+EXPLAIN SELECT i1
+FROM t3
+WHERE c1 IN
+( SELECT t1.c1
+FROM t2 JOIN t1
+ON t2.i1 >= t1.i1
+WHERE t1.c1 > t2.c1
+)
+XOR i1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	3	Using where
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT i1
+FROM t3
+WHERE c1 IN
+( SELECT t1.c1
+FROM t2 JOIN t1
+ON t2.i1 >= t1.i1
+WHERE t1.c1 > t2.c1
+)
+XOR i1;
+i1
+1
+2
+DROP TABLE t1, t2, t3;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2011-04-01 23:01:38 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2011-04-14 01:36:24 +0000
@@ -320,10 +320,6 @@ The following options may be given as th
  max_join_size records return an error
  --max-length-for-sort-data=# 
  Max number of bytes in sorted records
- --max-long-data-size=# 
- The maximum BLOB length to send to server from
- mysql_send_long_data API. Deprecated option; use
- max_allowed_packet instead.
  --max-prepared-stmt-count=# 
  Maximum number of prepared statements in the server
  --max-relay-log-size=# 
@@ -870,7 +866,6 @@ max-error-count 64
 max-heap-table-size 16777216
 max-join-size 18446744073709551615
 max-length-for-sort-data 1024
-max-long-data-size 1048576
 max-prepared-stmt-count 16382
 max-relay-log-size 0
 max-seeks-for-key 18446744073709551615

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	2011-04-01 23:01:38 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2011-04-14 01:36:24 +0000
@@ -319,10 +319,6 @@ The following options may be given as th
  max_join_size records return an error
  --max-length-for-sort-data=# 
  Max number of bytes in sorted records
- --max-long-data-size=# 
- The maximum BLOB length to send to server from
- mysql_send_long_data API. Deprecated option; use
- max_allowed_packet instead.
  --max-prepared-stmt-count=# 
  Maximum number of prepared statements in the server
  --max-relay-log-size=# 
@@ -873,7 +869,6 @@ max-error-count 64
 max-heap-table-size 16777216
 max-join-size 18446744073709551615
 max-length-for-sort-data 1024
-max-long-data-size 1048576
 max-prepared-stmt-count 16382
 max-relay-log-size 0
 max-seeks-for-key 18446744073709551615

=== modified file 'mysql-test/r/mysqlslap.result'
--- a/mysql-test/r/mysqlslap.result	2007-12-20 20:32:16 +0000
+++ b/mysql-test/r/mysqlslap.result	2011-04-08 07:04:54 +0000
@@ -225,3 +225,25 @@ DROP SCHEMA IF EXISTS `mysqlslap`;
 DROP PROCEDURE IF EXISTS p1;
 CREATE PROCEDURE p1() SELECT 1;
 DROP PROCEDURE p1;
+#
+# Bug #11765157 - 58090: mysqlslap drops schema specified in
+#                 create_schema if auto-generate-sql also set.
+#
+# 'bug58090' database should not be present.
+SHOW DATABASES;
+Database
+information_schema
+mtr
+mysql
+performance_schema
+test
+# 'bug58090' database should be present.
+SHOW DATABASES;
+Database
+information_schema
+bug58090
+mtr
+mysql
+performance_schema
+test
+DROP DATABASE bug58090;

=== modified file 'mysql-test/r/order_by_all.result'
--- a/mysql-test/r/order_by_all.result	2011-02-07 09:46:53 +0000
+++ b/mysql-test/r/order_by_all.result	2011-03-30 13:33:29 +0000
@@ -1430,6 +1430,7 @@ CALL mtr.add_suppression("Out of sort me
 select * from t1 order by b;
 ERROR HY001: Out of sort memory, consider increasing server sort buffer size
 drop table t1;
+call mtr.add_suppression("Out of sort memory; increase server sort buffer size");
 #
 # Bug #39844: Query Crash Mysql Server 5.0.67
 #

=== modified file 'mysql-test/r/order_by_icp_mrr.result'
--- a/mysql-test/r/order_by_icp_mrr.result	2011-04-01 14:04:52 +0000
+++ b/mysql-test/r/order_by_icp_mrr.result	2011-04-05 13:28:34 +0000
@@ -1430,6 +1430,7 @@ CALL mtr.add_suppression("Out of sort me
 select * from t1 order by b;
 ERROR HY001: Out of sort memory, consider increasing server sort buffer size
 drop table t1;
+call mtr.add_suppression("Out of sort memory; increase server sort buffer size");
 #
 # Bug #39844: Query Crash Mysql Server 5.0.67
 #

=== modified file 'mysql-test/r/order_by_none.result'
--- a/mysql-test/r/order_by_none.result	2011-04-01 14:04:52 +0000
+++ b/mysql-test/r/order_by_none.result	2011-04-05 13:28:34 +0000
@@ -1429,6 +1429,7 @@ CALL mtr.add_suppression("Out of sort me
 select * from t1 order by b;
 ERROR HY001: Out of sort memory, consider increasing server sort buffer size
 drop table t1;
+call mtr.add_suppression("Out of sort memory; increase server sort buffer size");
 #
 # Bug #39844: Query Crash Mysql Server 5.0.67
 #

=== modified file 'mysql-test/r/plugin_auth.result'
--- a/mysql-test/r/plugin_auth.result	2011-03-18 14:58:27 +0000
+++ b/mysql-test/r/plugin_auth.result	2011-04-07 09:55:09 +0000
@@ -403,4 +403,53 @@ ORDER BY COLUMN_NAME;
 IS_NULLABLE	COLUMN_NAME
 YES	authentication_string
 YES	plugin
+#
+# Bug #11936829: diff. between mysql.user (authentication_string) 
+#   in fresh and upgraded 5.5.11
+#
+SELECT IS_NULLABLE, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
+WHERE TABLE_SCHEMA= 'mysql' AND TABLE_NAME= 'user' AND
+COLUMN_NAME IN ('plugin', 'authentication_string')
+ORDER BY COLUMN_NAME;
+IS_NULLABLE	COLUMN_NAME
+YES	authentication_string
+YES	plugin
+ALTER TABLE mysql.user MODIFY plugin char(64) DEFAULT '' NOT NULL;
+ALTER TABLE mysql.user MODIFY authentication_string TEXT NOT NULL;
+Run mysql_upgrade on a 5.5.10 external authentication column layout
+mtr.global_suppressions                            OK
+mtr.test_suppressions                              OK
+mysql.columns_priv                                 OK
+mysql.db                                           OK
+mysql.event                                        OK
+mysql.func                                         OK
+mysql.general_log                                  OK
+mysql.help_category                                OK
+mysql.help_keyword                                 OK
+mysql.help_relation                                OK
+mysql.help_topic                                   OK
+mysql.host                                         OK
+mysql.ndb_binlog_index                             OK
+mysql.plugin                                       OK
+mysql.proc                                         OK
+mysql.procs_priv                                   OK
+mysql.proxies_priv                                 OK
+mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
+mysql.slow_log                                     OK
+mysql.tables_priv                                  OK
+mysql.time_zone                                    OK
+mysql.time_zone_leap_second                        OK
+mysql.time_zone_name                               OK
+mysql.time_zone_transition                         OK
+mysql.time_zone_transition_type                    OK
+mysql.user                                         OK
+SELECT IS_NULLABLE, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
+WHERE TABLE_SCHEMA= 'mysql' AND TABLE_NAME= 'user' AND
+COLUMN_NAME IN ('plugin', 'authentication_string')
+ORDER BY COLUMN_NAME;
+IS_NULLABLE	COLUMN_NAME
+YES	authentication_string
+YES	plugin
 End of 5.5 tests

=== modified file 'mysql-test/r/show_check.result'
--- a/mysql-test/r/show_check.result	2011-01-18 13:09:35 +0000
+++ b/mysql-test/r/show_check.result	2011-03-30 13:33:29 +0000
@@ -1338,6 +1338,7 @@ Name	Engine	Version	Row_format	Rows	Avg_
 DROP DATABASE `�
 show columns from `#mysql50#????????`;
 Got one of the listed errors
+call mtr.add_suppression("Can.t find file: '.\\\\test\\\\\\?{8}.frm'");
 DROP TABLE IF EXISTS t1;
 DROP PROCEDURE IF EXISTS p1;
 CREATE TABLE t1(c1 INT);

=== modified file 'mysql-test/r/sp-destruct.result'
--- a/mysql-test/r/sp-destruct.result	2010-12-16 18:18:20 +0000
+++ b/mysql-test/r/sp-destruct.result	2011-03-30 13:33:29 +0000
@@ -1,4 +1,5 @@
 call mtr.add_suppression("Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted");
+call mtr.add_suppression("Stored routine .test...bug14233_[123].: invalid value in column mysql.proc");
 use test;
 drop procedure if exists bug14233;
 drop function if exists bug14233;

=== modified file 'mysql-test/r/subquery_all.result'
--- a/mysql-test/r/subquery_all.result	2011-02-14 11:21:26 +0000
+++ b/mysql-test/r/subquery_all.result	2011-03-29 08:10:26 +0000
@@ -4923,7 +4923,7 @@ WHERE t3.name='xxx' AND t2.id=t3.id);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	4	Using where
 2	DEPENDENT SUBQUERY	t2	eq_ref	PRIMARY	PRIMARY	4	func	1	Using where; Using index; Full scan on NULL key
-2	DEPENDENT SUBQUERY	t3	eq_ref	PRIMARY	PRIMARY	4	func	1	Using index condition; Using where; Full scan on NULL key
+2	DEPENDENT SUBQUERY	t3	eq_ref	PRIMARY	PRIMARY	4	func	1	Using where; Full scan on NULL key
 SELECT * FROM t1
 WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3 
 WHERE t3.name='xxx' AND t2.id=t3.id);

=== modified file 'mysql-test/r/subquery_all_jcl6.result'
--- a/mysql-test/r/subquery_all_jcl6.result	2011-02-14 11:21:26 +0000
+++ b/mysql-test/r/subquery_all_jcl6.result	2011-03-29 08:10:26 +0000
@@ -4927,7 +4927,7 @@ WHERE t3.name='xxx' AND t2.id=t3.id);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	4	Using where
 2	DEPENDENT SUBQUERY	t2	eq_ref	PRIMARY	PRIMARY	4	func	1	Using where; Using index; Full scan on NULL key
-2	DEPENDENT SUBQUERY	t3	eq_ref	PRIMARY	PRIMARY	4	func	1	Using index condition; Using where; Full scan on NULL key; Using join buffer (BKA, incremental buffers)
+2	DEPENDENT SUBQUERY	t3	eq_ref	PRIMARY	PRIMARY	4	func	1	Using where; Full scan on NULL key; Using join buffer (BKA, incremental buffers)
 SELECT * FROM t1
 WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3 
 WHERE t3.name='xxx' AND t2.id=t3.id);

=== modified file 'mysql-test/r/subquery_mat.result'
--- a/mysql-test/r/subquery_mat.result	2011-02-14 11:21:26 +0000
+++ b/mysql-test/r/subquery_mat.result	2011-04-01 11:06:48 +0000
@@ -1124,4 +1124,32 @@ WHERE t1.f1 IN (SELECT t1.pk FROM t1 ORD
 f1	pk	pk
 DROP TABLE t1, t2;
 # End Bug#59833
+#
+# Bug#11852644 - CRASH IN ITEM_REF::SAVE_IN_FIELD ON SELECT DISTINCT
+#
+CREATE TABLE t1 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key (col_varchar_key)) 
+;
+INSERT INTO t1 VALUES
+('v','v'),('r','r');
+CREATE TABLE t2 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)) 
+;
+INSERT INTO t2 VALUES
+('r','r'),('c','c');
+CREATE VIEW v3 AS SELECT * FROM t2;
+SELECT DISTINCT alias2.col_varchar_key 
+FROM t1 AS alias1 JOIN v3 AS alias2 
+ON alias2.col_varchar_key = alias1.col_varchar_key
+HAVING col_varchar_key IN (SELECT col_varchar_nokey FROM t2)
+;
+col_varchar_key
+r
+DROP TABLE t1, t2;
+DROP VIEW v3;
+# End Bug#11852644
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_mat_all.result'
--- a/mysql-test/r/subquery_mat_all.result	2011-03-17 11:23:06 +0000
+++ b/mysql-test/r/subquery_mat_all.result	2011-04-01 11:06:48 +0000
@@ -1123,4 +1123,32 @@ WHERE t1.f1 IN (SELECT t1.pk FROM t1 ORD
 f1	pk	pk
 DROP TABLE t1, t2;
 # End Bug#59833
+#
+# Bug#11852644 - CRASH IN ITEM_REF::SAVE_IN_FIELD ON SELECT DISTINCT
+#
+CREATE TABLE t1 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key (col_varchar_key)) 
+;
+INSERT INTO t1 VALUES
+('v','v'),('r','r');
+CREATE TABLE t2 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)) 
+;
+INSERT INTO t2 VALUES
+('r','r'),('c','c');
+CREATE VIEW v3 AS SELECT * FROM t2;
+SELECT DISTINCT alias2.col_varchar_key 
+FROM t1 AS alias1 JOIN v3 AS alias2 
+ON alias2.col_varchar_key = alias1.col_varchar_key
+HAVING col_varchar_key IN (SELECT col_varchar_nokey FROM t2)
+;
+col_varchar_key
+r
+DROP TABLE t1, t2;
+DROP VIEW v3;
+# End Bug#11852644
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_mat_none.result'
--- a/mysql-test/r/subquery_mat_none.result	2011-02-14 11:21:26 +0000
+++ b/mysql-test/r/subquery_mat_none.result	2011-04-01 11:06:48 +0000
@@ -1122,4 +1122,32 @@ WHERE t1.f1 IN (SELECT t1.pk FROM t1 ORD
 f1	pk	pk
 DROP TABLE t1, t2;
 # End Bug#59833
+#
+# Bug#11852644 - CRASH IN ITEM_REF::SAVE_IN_FIELD ON SELECT DISTINCT
+#
+CREATE TABLE t1 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key (col_varchar_key)) 
+;
+INSERT INTO t1 VALUES
+('v','v'),('r','r');
+CREATE TABLE t2 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)) 
+;
+INSERT INTO t2 VALUES
+('r','r'),('c','c');
+CREATE VIEW v3 AS SELECT * FROM t2;
+SELECT DISTINCT alias2.col_varchar_key 
+FROM t1 AS alias1 JOIN v3 AS alias2 
+ON alias2.col_varchar_key = alias1.col_varchar_key
+HAVING col_varchar_key IN (SELECT col_varchar_nokey FROM t2)
+;
+col_varchar_key
+r
+DROP TABLE t1, t2;
+DROP VIEW v3;
+# End Bug#11852644
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_nomat_nosj_jcl6.result'
--- a/mysql-test/r/subquery_nomat_nosj_jcl6.result	2011-02-14 11:21:26 +0000
+++ b/mysql-test/r/subquery_nomat_nosj_jcl6.result	2011-03-29 08:10:26 +0000
@@ -4927,7 +4927,7 @@ WHERE t3.name='xxx' AND t2.id=t3.id);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	4	Using where
 2	DEPENDENT SUBQUERY	t2	eq_ref	PRIMARY	PRIMARY	4	func	1	Using where; Using index; Full scan on NULL key
-2	DEPENDENT SUBQUERY	t3	eq_ref	PRIMARY	PRIMARY	4	func	1	Using index condition; Using where; Full scan on NULL key; Using join buffer (BKA, incremental buffers)
+2	DEPENDENT SUBQUERY	t3	eq_ref	PRIMARY	PRIMARY	4	func	1	Using where; Full scan on NULL key; Using join buffer (BKA, incremental buffers)
 SELECT * FROM t1
 WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3 
 WHERE t3.name='xxx' AND t2.id=t3.id);

=== modified file 'mysql-test/r/variables-big.result'
--- a/mysql-test/r/variables-big.result	2010-11-15 15:17:38 +0000
+++ b/mysql-test/r/variables-big.result	2011-04-05 13:17:38 +0000
@@ -1,20 +1,20 @@
 SET SESSION transaction_prealloc_size=1024*1024*1024*1;
 SHOW PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
-<Id>	root	<Host>	test	Query	<Time>	NULL	SHOW PROCESSLIST
+<Id>	root	<Host>	test	Query	<Time>	init	SHOW PROCESSLIST
 SET SESSION transaction_prealloc_size=1024*1024*1024*2;
 SHOW PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
-<Id>	root	<Host>	test	Query	<Time>	NULL	SHOW PROCESSLIST
+<Id>	root	<Host>	test	Query	<Time>	init	SHOW PROCESSLIST
 SET SESSION transaction_prealloc_size=1024*1024*1024*3;
 SHOW PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
-<Id>	root	<Host>	test	Query	<Time>	NULL	SHOW PROCESSLIST
+<Id>	root	<Host>	test	Query	<Time>	init	SHOW PROCESSLIST
 SET SESSION transaction_prealloc_size=1024*1024*1024*4;
 SHOW PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
-<Id>	root	<Host>	test	Query	<Time>	NULL	SHOW PROCESSLIST
+<Id>	root	<Host>	test	Query	<Time>	init	SHOW PROCESSLIST
 SET SESSION transaction_prealloc_size=1024*1024*1024*5;
 SHOW PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
-<Id>	root	<Host>	test	Query	<Time>	NULL	SHOW PROCESSLIST
+<Id>	root	<Host>	test	Query	<Time>	init	SHOW PROCESSLIST

=== modified file 'mysql-test/r/variables.result'
--- a/mysql-test/r/variables.result	2011-03-28 11:10:42 +0000
+++ b/mysql-test/r/variables.result	2011-04-12 12:48:26 +0000
@@ -1532,9 +1532,6 @@ ERROR HY000: Cannot drop default keycach
 SET @@global.key_cache_block_size=0;
 Warnings:
 Warning	1292	Truncated incorrect key_cache_block_size value: '0'
-select @@max_long_data_size;
-@@max_long_data_size
-1048576
 #
 # Bug#11766424  59527: DECIMAL_BIN_SIZE: ASSERTION `SCALE >= 0 && PRECISION > 0 && SCALE <= PRE
 #

=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result	2011-03-08 19:14:42 +0000
+++ b/mysql-test/r/view.result	2011-04-08 08:15:19 +0000
@@ -4012,6 +4012,15 @@ DROP TABLE t1;
 #
 CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
 DROP VIEW v1;
+#
+# Bug 11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY
+#
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT s.* FROM t1 s, t1 b HAVING a;
+SELECT * FROM v1;
+a
+DROP VIEW v1;
+DROP TABLE t1;
 # -----------------------------------------------------------------
 # -- End of 5.1 tests.
 # -----------------------------------------------------------------

=== modified file 'mysql-test/r/xa.result'
--- a/mysql-test/r/xa.result	2011-03-25 15:13:41 +0000
+++ b/mysql-test/r/xa.result	2011-04-12 10:59:59 +0000
@@ -193,6 +193,8 @@ SAVEPOINT savep;
 ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the  PREPARED state
 SET @a=(SELECT * FROM t1);
 ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the  PREPARED state
+UPDATE t1 SET a=1 WHERE a=2;
+ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the  PREPARED state
 XA COMMIT 'a';
 SELECT * FROM t1;
 a

=== renamed file 'mysql-test/suite/bugs/r/rpl_bug23533.result' => 'mysql-test/suite/binlog/r/binlog_bug23533.result'
--- a/mysql-test/suite/bugs/r/rpl_bug23533.result	2008-02-28 21:50:15 +0000
+++ b/mysql-test/suite/binlog/r/binlog_bug23533.result	2011-04-13 20:18:08 +0000
@@ -1,23 +1,19 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-DROP TABLE IF EXISTS t1,t2;
 SET AUTOCOMMIT=0;
-SET GLOBAL max_binlog_cache_size=4096;
-SHOW VARIABLES LIKE 'max_binlog_cache_size';
-Variable_name	Value
-max_binlog_cache_size	4096
 CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b TEXT, PRIMARY KEY(a)) ENGINE=InnoDB;
 SELECT COUNT(*) FROM t1;
 COUNT(*)
 1000
+SHOW VARIABLES LIKE 'max_binlog_cache_size';
+Variable_name	Value
+max_binlog_cache_size	4294963200
+SET @saved_max_binlog_cache_size=@@max_binlog_cache_size;
+SET GLOBAL max_binlog_cache_size=4096;
 START TRANSACTION;
 CREATE TABLE t2 SELECT * FROM t1;
-ERROR HY000: Writing one row to the row-based binary log failed
+ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again
 COMMIT;
 SHOW TABLES LIKE 't%';
 Tables_in_test (t%)
 t1
+SET GLOBAL max_binlog_cache_size=@saved_max_binlog_cache_size;
+DROP TABLE t1;

=== renamed file 'mysql-test/suite/bugs/r/rpl_bug36391.result' => 'mysql-test/suite/binlog/r/binlog_bug36391.result'
--- a/mysql-test/suite/bugs/r/rpl_bug36391.result	2010-05-24 13:54:08 +0000
+++ b/mysql-test/suite/binlog/r/binlog_bug36391.result	2011-04-13 20:18:08 +0000
@@ -1,18 +1,10 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-drop table if exists t1;
-Warnings:
-Note	1051	Unknown table 't1'
-create table t1(id int);
-show tables;
+CREATE TABLE t1(id INT);
+SHOW TABLES;
 Tables_in_test
 t1
-show master status;
-File	Position	Binlog_Do_DB	Binlog_Ignore_DB
-master-bin.000001	#	<Binlog_Do_DB>	<Binlog_Ignore_DB>
-flush logs;
-drop table t1;
+FLUSH LOGS;
+DROP TABLE t1;
+SHOW TABLES;
+Tables_in_test
+t1
+DROP TABLE t1;

=== renamed file 'mysql-test/suite/bugs/t/rpl_bug23533.test' => 'mysql-test/suite/binlog/t/binlog_bug23533.test'
--- a/mysql-test/suite/bugs/t/rpl_bug23533.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/binlog/t/binlog_bug23533.test	2011-04-13 20:18:08 +0000
@@ -4,15 +4,13 @@
 #############################################################
 
 --source include/have_innodb.inc
+--source include/have_log_bin.inc
 --source include/have_binlog_format_row.inc
---source include/master-slave.inc
 
 SET AUTOCOMMIT=0;
-SET GLOBAL max_binlog_cache_size=4096;
-SHOW VARIABLES LIKE 'max_binlog_cache_size';
 
+# Create 1st table
 CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b TEXT, PRIMARY KEY(a)) ENGINE=InnoDB;
-
 --disable_query_log
 let $i= 1000;
 while ($i)
@@ -21,16 +19,20 @@ while ($i)
   dec $i;
 }
 --enable_query_log
-
 SELECT COUNT(*) FROM t1;
 
+# Set small value for max_binlog_cache_size
+SHOW VARIABLES LIKE 'max_binlog_cache_size';
+SET @saved_max_binlog_cache_size=@@max_binlog_cache_size;
+SET GLOBAL max_binlog_cache_size=4096;
+
 # Copied data from t1 into t2 large than max_binlog_cache_size
 START TRANSACTION;
---error 1534
+--error 1197
 CREATE TABLE t2 SELECT * FROM t1;
 COMMIT;
 SHOW TABLES LIKE 't%';
 
-
 # 5.1 End of Test
---source include/rpl_end.inc
+SET GLOBAL max_binlog_cache_size=@saved_max_binlog_cache_size;
+DROP TABLE t1;

=== renamed file 'mysql-test/suite/bugs/t/rpl_bug36391-master.opt' => 'mysql-test/suite/binlog/t/binlog_bug36391-master.opt'
=== renamed file 'mysql-test/suite/bugs/t/rpl_bug36391.test' => 'mysql-test/suite/binlog/t/binlog_bug36391.test'
--- a/mysql-test/suite/bugs/t/rpl_bug36391.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/binlog/t/binlog_bug36391.test	2011-04-13 20:18:08 +0000
@@ -13,17 +13,18 @@
 #
 # 
 
---source include/master-slave.inc
+--source include/have_log_bin.inc
+--source include/have_binlog_format_mixed.inc
 
-create table t1(id int);
+CREATE TABLE t1(id INT);
+let $binlog= query_get_value(SHOW MASTER STATUS, File, 1);
+let $binlog_path= `SELECT CONCAT(@@DATADIR, '$binlog')`;
+SHOW TABLES;
+FLUSH LOGS;
+DROP TABLE t1;
 
-show tables;
+--exec $MYSQL_BINLOG $binlog_path | $MYSQL test
+SHOW TABLES;
 
---source include/show_master_status.inc
-
-flush logs;
-
---exec $MYSQL_BINLOG $MYSQL_TEST_DIR/var/log/master-bin.000001 | $MYSQL test
-
-drop table t1;
---source include/rpl_end.inc
+# Clean up
+DROP TABLE t1;

=== removed directory 'mysql-test/suite/bugs'
=== removed file 'mysql-test/suite/bugs/combinations'
--- a/mysql-test/suite/bugs/combinations	2008-09-05 13:31:09 +0000
+++ b/mysql-test/suite/bugs/combinations	1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
-[row]
-binlog-format=row
-
-[stmt]
-binlog-format=statement
-
-[mix]
-binlog-format=mixed

=== removed directory 'mysql-test/suite/bugs/data'
=== removed file 'mysql-test/suite/bugs/data/rpl_bug12691.dat'
--- a/mysql-test/suite/bugs/data/rpl_bug12691.dat	2008-01-31 13:23:27 +0000
+++ b/mysql-test/suite/bugs/data/rpl_bug12691.dat	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-a
-b
-c

=== removed directory 'mysql-test/suite/bugs/r'
=== removed file 'mysql-test/suite/bugs/r/bug57108.result'
--- a/mysql-test/suite/bugs/r/bug57108.result	2010-11-04 10:00:59 +0000
+++ b/mysql-test/suite/bugs/r/bug57108.result	1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
-INSTALL PLUGIN example SONAME 'ha_example.so';
-SELECT @@global.connect_timeout AS connect_timeout, @@global.local_infile AS local_infile;
-connect_timeout	4711
-local_infile	1
-UNINSTALL PLUGIN example;

=== removed file 'mysql-test/suite/bugs/r/rpl_bug12691.result'
--- a/mysql-test/suite/bugs/r/rpl_bug12691.result	2010-05-24 13:54:08 +0000
+++ b/mysql-test/suite/bugs/r/rpl_bug12691.result	1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-
-**** On Master ****
-CREATE TABLE t1 (b CHAR(10));
-
-**** On Slave ****
-STOP SLAVE;
-
-**** On Master ****
-LOAD DATA INFILE FILENAME
-SELECT COUNT(*) FROM t1;
-COUNT(*)
-3
-show binlog events from <binlog_start>;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (b CHAR(10))
-master-bin.000001	#	Begin_load_query	#	#	;file_id=#;block_len=#
-master-bin.000001	#	Execute_load_query	#	#	use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/rpl_bug12691.dat' INTO TABLE `t1` FIELDS TERMINATED BY '|' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`b`) ;file_id=#
-
-**** On Slave ****
-SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
-SELECT COUNT(*) FROM t1;
-COUNT(*)
-0
-
-**** On Master ****
-DROP TABLE t1;

=== removed file 'mysql-test/suite/bugs/r/rpl_bug31582.result'
--- a/mysql-test/suite/bugs/r/rpl_bug31582.result	2007-12-05 19:49:50 +0000
+++ b/mysql-test/suite/bugs/r/rpl_bug31582.result	1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=MyISAM;
-INSERT INTO t1 VALUES ('a');
-UPDATE t1 SET a = 'MyISAM';
-SELECT * FROM t1 ORDER BY a;
-a
-MyISAM
-SELECT * FROM t1 ORDER BY a;
-a
-MyISAM
-DROP TABLE t1;

=== removed file 'mysql-test/suite/bugs/r/rpl_bug31583.result'
--- a/mysql-test/suite/bugs/r/rpl_bug31583.result	2008-02-18 14:48:17 +0000
+++ b/mysql-test/suite/bugs/r/rpl_bug31583.result	1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-CREATE TABLE t1 ( a INT, b INT DEFAULT -3 );
-INSERT INTO t1 VALUES (1, DEFAULT);
-UPDATE t1 SET a = 3;
-SELECT * FROM t1 ORDER BY a;
-a	b
-3	-3
-SELECT * FROM t1 ORDER BY a;
-a	b
-3	-3
-DROP TABLE t1;

=== removed file 'mysql-test/suite/bugs/r/rpl_bug33029.result'
--- a/mysql-test/suite/bugs/r/rpl_bug33029.result	2008-06-19 18:47:59 +0000
+++ b/mysql-test/suite/bugs/r/rpl_bug33029.result	1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-create table `t1` (`id` int not null auto_increment primary key);
-create trigger `trg` before insert on `t1` for each row begin end;
-set @@global.debug="+d,simulate_bug33029";
-stop slave;
-start slave;
-insert into `t1` values ();
-select * from t1;
-id
-1

=== removed file 'mysql-test/suite/bugs/r/rpl_bug38205.result'
--- a/mysql-test/suite/bugs/r/rpl_bug38205.result	2009-04-09 13:05:41 +0000
+++ b/mysql-test/suite/bugs/r/rpl_bug38205.result	1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-create table t1i(n int primary key) engine=innodb;
-create table t2m(n int primary key) engine=myisam;
-begin;
-insert into t1i values (1);
-insert into t1i values (2);
-insert into t1i values (3);
-commit;
-begin;
-insert into t1i values (5);
-begin;
-insert into t1i values (4);
-insert into t2m values (1);
-update t1i set n = 5 where n = 4;
-commit;
-zero
-0
-*** kill sql thread ***
-rollback;
-*** sql thread is *not* running: No ***
-*** the prove: the killed slave has not finished the current transaction ***
-three
-3
-one
-1
-zero
-0
-delete from t2m;
-start slave sql_thread;
-delete from t1i;
-delete from t2m;
-begin;
-insert into t1i values (5);
-begin;
-insert into t1i values (4);
-update t1i set n = 5 where n = 4;
-commit;
-zero
-0
-stop slave sql_thread;
-rollback;
-*** sql thread is *not* running: No ***
-*** the prove: the stopped slave has rolled back the current transaction ***
-zero
-0
-zero
-0
-one
-1
-start slave sql_thread;
-drop table t1i, t2m;

=== removed directory 'mysql-test/suite/bugs/t'
=== removed file 'mysql-test/suite/bugs/t/bug57108-master.opt'
--- a/mysql-test/suite/bugs/t/bug57108-master.opt	2010-11-04 10:00:59 +0000
+++ b/mysql-test/suite/bugs/t/bug57108-master.opt	1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
---defaults-file=std_data/bug57108.cnf
-$EXAMPLE_PLUGIN_OPT

=== removed file 'mysql-test/suite/bugs/t/bug57108.test'
--- a/mysql-test/suite/bugs/t/bug57108.test	2011-01-11 13:27:03 +0000
+++ b/mysql-test/suite/bugs/t/bug57108.test	1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
---source include/not_windows_embedded.inc
---source include/have_example_plugin.inc
-
-# Test that we can install a plugin despite the fact that we have
-# switched directory after starting the server and am using a relative
-# --defaults-file.
---replace_regex /\.dll/.so/
-eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';
-
---query_vertical SELECT @@global.connect_timeout AS connect_timeout, @@global.local_infile AS local_infile
-
-UNINSTALL PLUGIN example;

=== removed file 'mysql-test/suite/bugs/t/rpl_bug12691.test'
--- a/mysql-test/suite/bugs/t/rpl_bug12691.test	2010-12-19 17:15:12 +0000
+++ b/mysql-test/suite/bugs/t/rpl_bug12691.test	1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
-# Bug#12691: Exec_master_log_pos corrupted with SQL_SLAVE_SKIP_COUNTER
-
---source include/master-slave.inc
---source include/have_binlog_format_mixed_or_statement.inc
-
---echo
---echo **** On Master ****
-CREATE TABLE t1 (b CHAR(10));
---echo
---echo **** On Slave ****
---sync_slave_with_master
-STOP SLAVE;
---source include/wait_for_slave_to_stop.inc
-
---connection master
-
---echo
---echo **** On Master ****
---exec cp $MYSQL_TEST_DIR/suite/bugs/data/rpl_bug12691.dat $MYSQLTEST_VARDIR/tmp/
---echo LOAD DATA INFILE FILENAME
---disable_query_log
---eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/rpl_bug12691.dat' INTO TABLE t1 FIELDS TERMINATED BY '|'
---enable_query_log
---remove_file $MYSQLTEST_VARDIR/tmp/rpl_bug12691.dat
-
-SELECT COUNT(*) FROM t1;
-
-source include/show_binlog_events.inc;
-
---save_master_pos
-
---connection slave
---echo
---echo **** On Slave ****
-SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
---source include/wait_for_slave_to_start.inc
---sync_with_master
-
-SELECT COUNT(*) FROM t1;
-
-# Clean up
---connection master
---echo
---echo **** On Master ****
-DROP TABLE t1;
-
---source include/rpl_end.inc

=== removed file 'mysql-test/suite/bugs/t/rpl_bug31582.test'
--- a/mysql-test/suite/bugs/t/rpl_bug31582.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/bugs/t/rpl_bug31582.test	1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
-
-# BUG#31582: 5.1-telco-6.1 -> 5.1.22. Slave crashes when reading
-#            UPDATE for VARCHAR
-
-# This is a problem for any update statement replicating from an old
-# server to a new server. The bug consisted of a new slave trying to
-# read two column bitmaps, but there is only one available in the old
-# format.
-
-# This test case should be executed replicating from an old server to
-# a new server, so make sure you have one handy.
-
-source include/master-slave.inc;
-
-CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=MyISAM;
-INSERT INTO t1 VALUES ('a');
-UPDATE t1 SET a = 'MyISAM';
-SELECT * FROM t1 ORDER BY a;
-sync_slave_with_master;
-SELECT * FROM t1 ORDER BY a;
-
-connection master;
-DROP TABLE t1;
-
---source include/rpl_end.inc

=== removed file 'mysql-test/suite/bugs/t/rpl_bug31583.test'
--- a/mysql-test/suite/bugs/t/rpl_bug31583.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/bugs/t/rpl_bug31583.test	1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
-#
-# BUG#31583: 5.1-telco-6.1 -> 5.1.22. Slave returns Error in unknown event
-
-# This is a problem for any update statement replicating from an old
-# server to a new server. The bug consisted of a new slave trying to
-# read two column bitmaps, but there is only one available in the old
-# format.
-
-# This test case should be executed replicating from an old server to
-# a new server, so make sure you have one handy.
-
-source include/master-slave.inc;
-
-CREATE TABLE t1 ( a INT, b INT DEFAULT -3 );
-
-INSERT INTO t1 VALUES (1, DEFAULT);
-UPDATE t1 SET a = 3;
-SELECT * FROM t1 ORDER BY a;
-sync_slave_with_master;
-SELECT * FROM t1 ORDER BY a;
-
-connection master;
-DROP TABLE t1;
-
---source include/rpl_end.inc

=== removed file 'mysql-test/suite/bugs/t/rpl_bug33029.test'
--- a/mysql-test/suite/bugs/t/rpl_bug33029.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/bugs/t/rpl_bug33029.test	1970-01-01 00:00:00 +0000
@@ -1,26 +0,0 @@
-#
-# Bug #36443 Server crashes when executing insert when insert trigger on table
-#
-# Emulating the former bug#33029 situation to see that there is no crash anymore.
-# 
-
-
-source include/master-slave.inc;
-
-create table `t1` (`id` int not null auto_increment primary key);
-create trigger `trg` before insert on `t1` for each row begin end;
-
-sync_slave_with_master;
-set @@global.debug="+d,simulate_bug33029";
-
-stop slave;
-start slave;
-
-connection master;
-
-insert into `t1` values ();
-
-sync_slave_with_master;
-select * from t1;
-
---source include/rpl_end.inc

=== removed file 'mysql-test/suite/bugs/t/rpl_bug38205.test'
--- a/mysql-test/suite/bugs/t/rpl_bug38205.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/bugs/t/rpl_bug38205.test	1970-01-01 00:00:00 +0000
@@ -1,166 +0,0 @@
-#
-# Bug #38205 Row-based Replication (RBR) causes inconsistencies: HA_ERR_FOUND_DUPP_KEY
-# Bug#319  if while a non-transactional slave is replicating a transaction possible problem 
-#
-# Verifying the fact that STOP SLAVE in the middle of a group execution waits
-# for the end of the group before the slave sql thread will stop.
-# The patch refines STOP SLAVE to not interrupt a transaction or other type of 
-# the replication events group (the part I).
-# Killing the sql thread continues to provide a "hard" stop (the part II).
-#
-# Non-deterministic tests
-#
-
-source include/master-slave.inc;
-source include/have_innodb.inc;
-
-
-#
-# Part II, killed sql slave leaves instantly
-#
-
-# A. multi-statement transaction as the replication group
-
-connection master;
-
-create table t1i(n int primary key) engine=innodb;
-create table t2m(n int primary key) engine=myisam;
-
-sync_slave_with_master;
-
-connection master;
-
-begin;
-insert into t1i values (1);
-insert into t1i values (2);
-insert into t1i values (3);
-commit;
-
-sync_slave_with_master;
-
-#
-# todo: first challenge is to find out the SQL thread id
-# the following is not fully reliable
-#
-
-let $id=`SELECT id from information_schema.processlist where user like 'system user' and state like '%Has read all relay log%' or user like 'system user' and state like '%Reading event from the relay log%'`;
-connection slave;
-begin;
-insert into t1i values (5);
-
-connection master;
-let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
-begin;
-insert into t1i values (4);
-insert into t2m values (1); # non-ta update
-update t1i set n = 5 where n = 4; # to block at. can't be played with killed
-commit;
-let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
-
-connection slave;
-# slave sql thread must be locked out by the conn `slave' explicit lock
-let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
---disable_query_log
-eval select $pos0_master - $pos0_slave as zero;
---enable_query_log
-
-connection slave1;
-
-let $count= 1;
-let $table= t2m;
-source include/wait_until_rows_count.inc;
-#
-# todo: may fail as said above
-#
---echo *** kill sql thread ***
---disable_query_log
-eval kill connection $id;
---enable_query_log
-
-connection slave;
-rollback; # release the sql thread
-
-connection slave1;
-
-source include/wait_for_slave_sql_to_stop.inc;
-let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
---echo *** sql thread is *not* running: $sql_status ***
-let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
-
-connection slave;
---echo *** the prove: the killed slave has not finished the current transaction ***
-
---disable_query_log
-select count(*) as three from t1i;
-eval select $pos1_master > $pos1_slave as one;
-eval select $pos1_slave - $pos0_slave as zero;
---enable_query_log
-
-delete from t2m; # remove the row to be able to replay
-start slave sql_thread;
-
-#
-# Part I: B The homogenous transaction remains interuptable in between
-#
-
-connection master;
-delete from t1i;
-delete from t2m;
-
-sync_slave_with_master;
-begin;
-insert into t1i values (5);
-
-connection master;
-let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
-begin;
-insert into t1i values (4);
-update t1i set n = 5 where n = 4; # to block at. not to be played
-commit;
-let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
-
-
-connection slave1;
-# slave sql can't advance as must be locked by the conn `slave' trans
-let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
---disable_query_log
-eval select $pos0_master - $pos0_slave as zero;
---enable_query_log
-
-#
-# the replicated trans is blocked by the slave's local.
-# However, it's not easy to catch the exact moment when it happens.
-# The test issues sleep which makes the test either non-deterministic or
-# wasting too much time.
-#
---sleep 3
-
-send stop slave sql_thread;
-
-connection slave;
-rollback; # release the sql thread
-
-connection slave1;
-reap;
-source include/wait_for_slave_sql_to_stop.inc;
-let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
---echo *** sql thread is *not* running: $sql_status ***
-
-let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
-
---echo *** the prove: the stopped slave has rolled back the current transaction ***
-
---disable_query_log
-select count(*) as zero from t1i;
-eval select $pos0_master - $pos0_slave as zero;
-eval select $pos1_master > $pos0_slave as one;
---enable_query_log
-
-start slave sql_thread;
-
-# clean-up
-
-connection master;
-drop table t1i, t2m;
-
---source include/rpl_end.inc

=== renamed file 'mysql-test/suite/bugs/r/rpl_bug37426.result' => 'mysql-test/suite/rpl/r/rpl_bug37426.result'
--- a/mysql-test/suite/bugs/r/rpl_bug37426.result	2008-06-30 20:11:18 +0000
+++ b/mysql-test/suite/rpl/r/rpl_bug37426.result	2011-04-13 20:18:08 +0000
@@ -1,13 +1,6 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-CREATE TABLE char128_utf8 ( 
-i1 INT NOT NULL, 
-c CHAR(128) CHARACTER SET utf8 NOT NULL, 
-i2 INT NOT NULL);
+include/master-slave.inc
+[connection master]
+CREATE TABLE char128_utf8 (i1 INT NOT NULL, c CHAR(128) CHARACTER SET utf8 NOT NULL, i2 INT NOT NULL);
 INSERT INTO char128_utf8 VALUES ( 1, "123", 1 );
 SELECT * FROM char128_utf8;
 i1	c	i2
@@ -15,3 +8,5 @@ i1	c	i2
 SELECT * FROM char128_utf8;
 i1	c	i2
 1	123	1
+DROP TABLE char128_utf8;
+include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result'
--- a/mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result	2011-02-23 20:01:27 +0000
+++ b/mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result	2011-03-31 08:39:55 +0000
@@ -57,11 +57,6 @@ f1	f2	f3	f4	f5	f6	f7	f8	f9	hex(f10)	hex(
 27	27	27	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
 29	29	29	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
 30	30	30	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
-call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 2 type mismatch.* 1535");
-call mtr.add_suppression("Slave SQL.*Error .Can.t DROP .c7.; check that column.key exists. on query.* 1091");
-call mtr.add_suppression("Slave SQL.*Error .Unknown column .c7. in .t15.. on query.* 1054");
-call mtr.add_suppression("Slave SQL.*Error .Key column .c6. doesn.t exist in table. on query.* 1072");
-call mtr.add_suppression("Slave SQL.*Column 2 of table .test.t1.. cannot be converted from type.* Error_code: 1677");
 
 * Select count and 20 rows from Slave *
 

=== modified file 'mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result'
--- a/mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result	2011-02-23 20:01:27 +0000
+++ b/mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result	2011-03-31 08:39:55 +0000
@@ -57,11 +57,6 @@ f1	f2	f3	f4	f5	f6	f7	f8	f9	hex(f10)	hex(
 27	27	27	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
 29	29	29	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
 30	30	30	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
-call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 2 type mismatch.* 1535");
-call mtr.add_suppression("Slave SQL.*Error .Can.t DROP .c7.; check that column.key exists. on query.* 1091");
-call mtr.add_suppression("Slave SQL.*Error .Unknown column .c7. in .t15.. on query.* 1054");
-call mtr.add_suppression("Slave SQL.*Error .Key column .c6. doesn.t exist in table. on query.* 1072");
-call mtr.add_suppression("Slave SQL.*Column 2 of table .test.t1.. cannot be converted from type.* Error_code: 1677");
 
 * Select count and 20 rows from Slave *
 

=== modified file 'mysql-test/suite/rpl/r/rpl_migration_crash_safe.result'
--- a/mysql-test/suite/rpl/r/rpl_migration_crash_safe.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_migration_crash_safe.result	2011-03-23 23:28:49 +0000
@@ -5,5 +5,10 @@ CREATE TABLE test(id INTEGER NOT NULL PR
 INSERT INTO test VALUES (1), (2), (3);
 include/rpl_restart_server.inc [server_number=2 parameters: --relay-log-info-repository=TABLE --skip-slave-start]
 include/rpl_restart_server.inc [server_number=2 parameters: --relay-log-info-repository=FILE --skip-slave-start]
+SET @@GLOBAL.relay_log_info_repository= "TABLE";
+SET @@GLOBAL.relay_log_info_repository= "FILE";
+SET @@GLOBAL.relay_log_info_repository= "FILE";
 include/start_slave.inc
+SET @@GLOBAL.relay_log_info_repository= "TABLE";
+ERROR HY000: This operation cannot be performed with a running slave; run STOP SLAVE first
 DROP TABLE test;

=== modified file 'mysql-test/suite/rpl/r/rpl_rotate_logs.result'
--- a/mysql-test/suite/rpl/r/rpl_rotate_logs.result	2011-02-23 20:01:27 +0000
+++ b/mysql-test/suite/rpl/r/rpl_rotate_logs.result	2011-04-04 09:42:22 +0000
@@ -1,5 +1,6 @@
 CALL mtr.add_suppression("Failed to open the existing info file");
 CALL mtr.add_suppression("Error while reading from master info file");
+CALL mtr.add_suppression("Failed to create a new info file");
 start slave;
 Got one of the listed errors
 start slave;

=== renamed file 'mysql-test/suite/bugs/t/rpl_bug37426.test' => 'mysql-test/suite/rpl/t/rpl_bug37426.test'
--- a/mysql-test/suite/bugs/t/rpl_bug37426.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/t/rpl_bug37426.test	2011-04-13 20:18:08 +0000
@@ -7,15 +7,16 @@ source include/master-slave.inc;
 source include/have_binlog_format_row.inc;
 
 connection master;
-CREATE TABLE char128_utf8 ( 
-    i1 INT NOT NULL, 
-    c CHAR(128) CHARACTER SET utf8 NOT NULL, 
-    i2 INT NOT NULL);
-
+CREATE TABLE char128_utf8 (i1 INT NOT NULL, c CHAR(128) CHARACTER SET utf8 NOT NULL, i2 INT NOT NULL);
 INSERT INTO char128_utf8 VALUES ( 1, "123", 1 );
 
 SELECT * FROM char128_utf8;
 sync_slave_with_master;
 
 SELECT * FROM char128_utf8;
+
+# Clean up
+connection master;
+DROP TABLE char128_utf8;
+sync_slave_with_master;
 --source include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_migration_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_migration_crash_safe.test	2010-12-20 14:27:17 +0000
+++ b/mysql-test/suite/rpl/t/rpl_migration_crash_safe.test	2011-03-23 23:28:49 +0000
@@ -22,16 +22,33 @@
 #   if data is replicated correctly.
 #   1.3. Assertions AF1 and AF2 are verified.
 #
-# 2. Migration from FILE to TABLE
+# 2. Migration from FILE to TABLE by restarting the SERVER
 #   2.1. The slave is stopped and restarted with --relay-log-info-repository=TABLE
 #   2.2. Assertions AT1 and AT2 are verified.
 #
-# 3. Migration from TABLE to FILE with success
+# 3. Migration from TABLE to FILE by restarting the SERVER
 #   4.1. The slave is stopped and restarted with --relay-log-info-repository=FILE
 #   4.2. Assertions AF1 and AF2 are verified.
 #
-# 4. Check consistency
-#   4.1. The replication is started and the master is compared to the slave.
+# 4. Migration from FILE to TALBE by using SET
+#   4.1. SET @GLOBAL.relay_log_info_repository=TABLE is exectued.
+#   4.2. Assertions AT1 and AT2 are verified.
+#
+# 5. Migration from TABLE to FILE by using SET
+#   5.1. SET @GLOBAL.relay_log_info_repository=FILE is executed.
+#   5.2. Assertions AF1 and AF2 are verified.
+#
+# 6. Migration from FILE to FILE by using SET
+#   6.1. SET @GLOBAL.relay_log_info_repository=FILE is executed.
+#   6.2. Assertions AF1 and AF2 are verified.
+#
+# 7. Migration while slave is running by using SET
+#   7.1  Slave is started.
+#   7.2. SET @GLOBAL.relay_log_info_repository=FILE is executed and fails.
+#   7.3. Assertions AF1 and AF2 are verified.
+#
+# 8. Check consistency
+#   8.1. The replication is started and the master is compared to the slave.
 ########################################################################################
 ########################################################################################
 # 1. Preparation
@@ -62,7 +79,7 @@ CREATE TABLE test(id INTEGER NOT NULL PR
 INSERT INTO test VALUES (1), (2), (3);
 
 ########################################################################################
-# 2. Migration from FILE to TABLE
+# 2. Migration from FILE to TABLE by restarting the SERVER
 ########################################################################################
 --connection slave
 
@@ -74,15 +91,16 @@ let $exp_slave= 1;
 let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
 if ($got_slave != $exp_slave)
 {
-  --echo "The mysql.slave_relay_log_info has information and this is not expected."
+  --echo "The mysql.slave_relay_log_info has no information and this is not expected."
   --die
 }
 --error 1
 file_exists $MYSQLD_DATADIR/relay-log.info;
 
 ########################################################################################
-# 3. Migration from TABLE to FILE
+# 3. Migration from TABLE to FILE by restarting the SERVER
 ########################################################################################
+--connection slave
 
 --let $rpl_server_number= 2
 --let $rpl_server_parameters= --relay-log-info-repository=FILE --skip-slave-start
@@ -98,12 +116,67 @@ if ($got_slave != $exp_slave)
 file_exists $MYSQLD_DATADIR/relay-log.info;
 
 ########################################################################################
-# 4. Check consistency
+# 4. Migration FROM FILE TO TABLE by using SET
+########################################################################################
+--connection slave
+
+SET @@GLOBAL.relay_log_info_repository= "TABLE";
+
+let $exp_slave= 1;
+let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
+if ($got_slave != $exp_slave)
+{
+  --echo "The mysql.slave_relay_log_info has no information and this is not expected."
+  --die
+}
+--error 1
+file_exists $MYSQLD_DATADIR/relay-log.info;
+
+########################################################################################
+# 5. Migration FROM TABLE TO FILE by using SET
+########################################################################################
+--connection slave
+
+SET @@GLOBAL.relay_log_info_repository= "FILE";
+
+let $exp_slave= 0;
+let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
+if ($got_slave != $exp_slave)
+{
+  --echo "The mysql.slave_relay_log_info has information and this is not expected."
+  --die
+}
+file_exists $MYSQLD_DATADIR/relay-log.info;
+
+########################################################################################
+# 6. Migration FROM FILE TO FILE by using SET
+########################################################################################
+--connection slave
+
+SET @@GLOBAL.relay_log_info_repository= "FILE";
+
+let $exp_slave= 0;
+let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
+if ($got_slave != $exp_slave)
+{
+  --echo "The mysql.slave_relay_log_info has information and this is not expected."
+  --die
+}
+file_exists $MYSQLD_DATADIR/relay-log.info;
+
+########################################################################################
+# 7. Migration while slave is running by using SET
 ########################################################################################
 --connection slave
 
 --source include/start_slave.inc
 
+--error ER_SLAVE_MUST_STOP
+SET @@GLOBAL.relay_log_info_repository= "TABLE";
+
+########################################################################################
+# 8. Check consistency
+########################################################################################
 --connection master
 
 sync_slave_with_master;

=== modified file 'mysql-test/suite/rpl/t/rpl_rotate_logs.test'
--- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test	2011-02-23 20:01:27 +0000
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test	2011-04-04 09:42:22 +0000
@@ -30,6 +30,7 @@ connection slave;
 --disable_result_log
 CALL mtr.add_suppression("Failed to open the existing info file");
 CALL mtr.add_suppression("Error while reading from master info file");
+CALL mtr.add_suppression("Failed to create a new info file");
 --enable_result_log
 
 # START SLAVE will fail because it can't read the file (mode 000)

=== modified file 'mysql-test/suite/sys_vars/r/master_info_repository_basic.result'
--- a/mysql-test/suite/sys_vars/r/master_info_repository_basic.result	2010-07-06 22:01:07 +0000
+++ b/mysql-test/suite/sys_vars/r/master_info_repository_basic.result	2011-03-23 23:28:49 +0000
@@ -10,10 +10,9 @@ SELECT COUNT(@@SESSION.master_info_repos
 ERROR HY000: Variable 'master_info_repository' is a GLOBAL variable
 '#---------------------BS_STVARS_002_02----------------------#'
 SET @@GLOBAL.master_info_repository= "TABLE";
-ERROR HY000: Variable 'master_info_repository' is a read only variable
 SELECT @@GLOBAL.master_info_repository;
 @@GLOBAL.master_info_repository
-FILE
+TABLE
 '#---------------------BS_STVARS_002_03----------------------#'
 SELECT @@GLOBAL.master_info_repository = VARIABLE_VALUE
 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
@@ -42,3 +41,5 @@ SELECT COUNT(@@GLOBAL.master_info_reposi
 COUNT(@@GLOBAL.master_info_repository)
 1
 1 Expected
+'#---------------------BS_STVARS_002_06----------------------#'
+SET @@GLOBAL.master_info_repository= "FILE";

=== removed file 'mysql-test/suite/sys_vars/r/max_long_data_size_basic.result'
--- a/mysql-test/suite/sys_vars/r/max_long_data_size_basic.result	2011-03-15 12:57:36 +0000
+++ b/mysql-test/suite/sys_vars/r/max_long_data_size_basic.result	1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
-select @@global.max_long_data_size=20;
-@@global.max_long_data_size=20
-0
-select @@session.max_long_data_size;
-ERROR HY000: Variable 'max_long_data_size' is a GLOBAL variable
-SELECT @@global.max_long_data_size = VARIABLE_VALUE
-FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
-WHERE VARIABLE_NAME='max_long_data_size';
-@@global.max_long_data_size = VARIABLE_VALUE
-1
-set global max_long_data_size=1;
-ERROR HY000: Variable 'max_long_data_size' is a read only variable
-set session max_long_data_size=1;
-ERROR HY000: Variable 'max_long_data_size' is a read only variable

=== modified file 'mysql-test/suite/sys_vars/r/relay_log_info_repository_basic.result'
--- a/mysql-test/suite/sys_vars/r/relay_log_info_repository_basic.result	2010-07-06 22:01:07 +0000
+++ b/mysql-test/suite/sys_vars/r/relay_log_info_repository_basic.result	2011-03-23 23:28:49 +0000
@@ -10,10 +10,9 @@ SELECT COUNT(@@SESSION.relay_log_info_re
 ERROR HY000: Variable 'relay_log_info_repository' is a GLOBAL variable
 '#---------------------BS_STVARS_002_02----------------------#'
 SET @@GLOBAL.relay_log_info_repository= "TABLE";
-ERROR HY000: Variable 'relay_log_info_repository' is a read only variable
 SELECT @@GLOBAL.relay_log_info_repository;
 @@GLOBAL.relay_log_info_repository
-FILE
+TABLE
 '#---------------------BS_STVARS_002_03----------------------#'
 SELECT @@GLOBAL.relay_log_info_repository = VARIABLE_VALUE
 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
@@ -42,3 +41,5 @@ SELECT COUNT(@@GLOBAL.relay_log_info_rep
 COUNT(@@GLOBAL.relay_log_info_repository)
 1
 1 Expected
+'#---------------------BS_STVARS_002_06----------------------#'
+SET @@GLOBAL.relay_log_info_repository= "FILE";

=== modified file 'mysql-test/suite/sys_vars/t/master_info_repository_basic.test'
--- a/mysql-test/suite/sys_vars/t/master_info_repository_basic.test	2010-10-25 10:39:01 +0000
+++ b/mysql-test/suite/sys_vars/t/master_info_repository_basic.test	2011-03-23 23:28:49 +0000
@@ -37,7 +37,6 @@ SELECT COUNT(@@SESSION.master_info_repos
 ####################################################################
 #   Check if Value can set                                         #
 ####################################################################
---error ER_INCORRECT_GLOBAL_LOCAL_VAR
 SET @@GLOBAL.master_info_repository= "TABLE";
 
 SELECT @@GLOBAL.master_info_repository;
@@ -74,3 +73,10 @@ SELECT COUNT(@@local.master_info_reposit
 
 SELECT COUNT(@@GLOBAL.master_info_repository);
 --echo 1 Expected
+
+
+--echo '#---------------------BS_STVARS_002_06----------------------#'
+################################################################################
+#                                     Clean up                                 #
+################################################################################
+SET @@GLOBAL.master_info_repository= "FILE";

=== removed file 'mysql-test/suite/sys_vars/t/max_long_data_size_basic.test'
--- a/mysql-test/suite/sys_vars/t/max_long_data_size_basic.test	2011-03-15 12:57:36 +0000
+++ b/mysql-test/suite/sys_vars/t/max_long_data_size_basic.test	1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-select @@global.max_long_data_size=20;
---error ER_INCORRECT_GLOBAL_LOCAL_VAR
-select @@session.max_long_data_size;
-
-# Show that value of the variable matches the value in the GLOBAL I_S table
-SELECT @@global.max_long_data_size = VARIABLE_VALUE
-FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
-WHERE VARIABLE_NAME='max_long_data_size';
-
-#
-# show that it's read-only
-#
---error ER_INCORRECT_GLOBAL_LOCAL_VAR
-set global max_long_data_size=1;
---error ER_INCORRECT_GLOBAL_LOCAL_VAR
-set session max_long_data_size=1;
-

=== modified file 'mysql-test/suite/sys_vars/t/relay_log_info_repository_basic.test'
--- a/mysql-test/suite/sys_vars/t/relay_log_info_repository_basic.test	2010-10-25 10:39:01 +0000
+++ b/mysql-test/suite/sys_vars/t/relay_log_info_repository_basic.test	2011-03-23 23:28:49 +0000
@@ -37,7 +37,6 @@ SELECT COUNT(@@SESSION.relay_log_info_re
 ####################################################################
 #   Check if Value can set                                         #
 ####################################################################
---error ER_INCORRECT_GLOBAL_LOCAL_VAR
 SET @@GLOBAL.relay_log_info_repository= "TABLE";
 
 SELECT @@GLOBAL.relay_log_info_repository;
@@ -74,3 +73,10 @@ SELECT COUNT(@@local.relay_log_info_repo
 
 SELECT COUNT(@@GLOBAL.relay_log_info_repository);
 --echo 1 Expected
+
+
+--echo '#---------------------BS_STVARS_002_06----------------------#'
+################################################################################
+#                                     Clean up                                 #
+################################################################################
+SET @@GLOBAL.relay_log_info_repository= "FILE";

=== modified file 'mysql-test/t/alter_table.test'
--- a/mysql-test/t/alter_table.test	2011-02-21 11:30:08 +0000
+++ b/mysql-test/t/alter_table.test	2011-04-13 06:16:40 +0000
@@ -1159,3 +1159,20 @@ CREATE TABLE db1.t1 (bar TINYTEXT, KEY (
 ALTER TABLE db1.t1 ADD baz INT;
 
 DROP DATABASE db1;
+
+
+--echo #
+--echo # Bug#11938039 RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME
+--echo #              CLAUSE FAILS OR ABORTS SERVER.
+--echo #
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int);
+prepare stmt1 from 'alter table t1 alter column a set default 1, rename to t2';
+execute stmt1;
+rename table t2 to t1;
+--echo # The below statement should succeed and not emit error or abort server.
+execute stmt1;
+deallocate prepare stmt1;
+drop table t2;

=== modified file 'mysql-test/t/func_group.test'
--- a/mysql-test/t/func_group.test	2011-02-02 09:21:41 +0000
+++ b/mysql-test/t/func_group.test	2011-04-12 10:31:30 +0000
@@ -1118,6 +1118,28 @@ SELECT RELEASE_LOCK('aaaaaaaaaaaaaaaaa')
 
 --enable_result_log
 
+
+--echo #
+--echo # Bug #11766094 - 59132: MIN() AND MAX() REMOVE UNSIGNEDNESS 
+--echo #
+
+CREATE TABLE t1 (a BIGINT UNSIGNED);
+INSERT INTO t1 VALUES (18446668621106209655);
+SELECT MAX(LENGTH(a)), LENGTH(MAX(a)), MIN(a), MAX(a), CONCAT(MIN(a)), CONCAT(MAX(a)) FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #11766270  59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+--echo #
+
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+--enable_metadata
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+--disable_metadata
+DROP TABLE t1;
+
+
 --echo #
 --echo End of 5.1 tests
 

=== modified file 'mysql-test/t/innodb_mysql_lock.test'
--- a/mysql-test/t/innodb_mysql_lock.test	2010-08-06 11:29:37 +0000
+++ b/mysql-test/t/innodb_mysql_lock.test	2011-04-13 18:43:08 +0000
@@ -279,6 +279,38 @@ disconnect con2;
 disconnect con3;
 
 
+--echo #
+--echo # Bug#11815600 [ERROR] INNODB COULD NOT FIND INDEX PRIMARY
+--echo #              KEY NO 0 FOR TABLE IN ERROR LOG 
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--connect (con1,localhost,root)
+
+--echo # Connection default
+connection default;
+CREATE TABLE t1 (id INT PRIMARY KEY, value INT) ENGINE = InnoDB;
+INSERT INTO t1 VALUES (1, 12345);
+START TRANSACTION;
+SELECT * FROM t1;
+
+--echo # Connection con1
+--connection con1
+SET lock_wait_timeout=1;
+--error ER_LOCK_WAIT_TIMEOUT
+ALTER TABLE t1 ADD INDEX idx(value);
+
+--echo # Connection default
+--connection default
+SELECT * FROM t1;
+COMMIT;
+DROP TABLE t1;
+disconnect con1;
+
+
 # Check that all connections opened by test cases in this file are really
 # gone so execution of other tests won't be affected by their presence.
 --source include/wait_until_count_sessions.inc

=== modified file 'mysql-test/t/innodb_mysql_sync.test'
--- a/mysql-test/t/innodb_mysql_sync.test	2011-03-07 13:30:49 +0000
+++ b/mysql-test/t/innodb_mysql_sync.test	2011-04-13 18:43:08 +0000
@@ -152,129 +152,133 @@ disconnect con1;
 --echo #           that implement add_index
 --echo #
 
---disable_warnings
-DROP DATABASE IF EXISTS db1;
-DROP TABLE IF EXISTS t1;
---enable_warnings
-
-connect(con1,localhost,root);
-connect(con2,localhost,root);
-
---echo # Test 1: Secondary index, should not block reads (original test case).
-
---echo # Connection default
-connection default;
-CREATE DATABASE db1;
-CREATE TABLE db1.t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT) engine=innodb;
-INSERT INTO db1.t1(value) VALUES (1), (2);
-SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
---echo # Sending:
---send ALTER TABLE db1.t1 ADD INDEX(value)
-
---echo # Connection con1
-connection con1;
-SET DEBUG_SYNC= "now WAIT_FOR manage";
-# Neither of these two statements should be blocked
-USE db1;
-SELECT * FROM t1;
-SET DEBUG_SYNC= "now SIGNAL query";
-
---echo # Connection default
-connection default;
---echo # Reaping: ALTER TABLE db1.t1 ADD INDEX(value)
---reap
-DROP DATABASE db1;
-
---echo # Test 2: Primary index (implicit), should block reads.
-
-CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
-SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
---echo # Sending:
---send ALTER TABLE t1 ADD UNIQUE INDEX(a)
-
---echo # Connection con1
-connection con1;
-SET DEBUG_SYNC= "now WAIT_FOR manage";
-USE test;
---echo # Sending:
---send SELECT * FROM t1
-
---echo # Connection con2
-connection con2;
---echo # Waiting for SELECT to be blocked by the metadata lock on t1
-let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
-  WHERE state= 'Waiting for table metadata lock'
-  AND info='SELECT * FROM t1';
---source include/wait_condition.inc
-SET DEBUG_SYNC= "now SIGNAL query";
-
---echo # Connection default
-connection default;
---echo # Reaping: ALTER TABLE t1 ADD UNIQUE INDEX(a)
---reap
-
---echo # Connection con1
-connection con1;
---echo # Reaping: SELECT * FROM t1
---reap
-
---echo # Test 3: Primary index (explicit), should block reads.
-
---echo # Connection default
-connection default;
-ALTER TABLE t1 DROP INDEX a;
-SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
---echo # Sending:
---send ALTER TABLE t1 ADD PRIMARY KEY (a)
-
---echo # Connection con1
-connection con1;
-SET DEBUG_SYNC= "now WAIT_FOR manage";
---echo # Sending:
---send SELECT * FROM t1
-
---echo # Connection con2
-connection con2;
---echo # Waiting for SELECT to be blocked by the metadata lock on t1
-let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
-  WHERE state= 'Waiting for table metadata lock'
-  AND info='SELECT * FROM t1';
---source include/wait_condition.inc
-SET DEBUG_SYNC= "now SIGNAL query";
-
---echo # Connection default
-connection default;
---echo # Reaping: ALTER TABLE t1 ADD PRIMARY KEY (a)
---reap
-
---echo # Connection con1
-connection con1;
---echo # Reaping: SELECT * FROM t1
---reap
-
---echo # Test 4: Secondary unique index, should not block reads.
-
---echo # Connection default
-connection default;
-SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
---echo # Sending:
---send ALTER TABLE t1 ADD UNIQUE (b)
-
---echo # Connection con1
-connection con1;
-SET DEBUG_SYNC= "now WAIT_FOR manage";
-SELECT * FROM t1;
-SET DEBUG_SYNC= "now SIGNAL query";
-
---echo # Connection default
-connection default;
---echo # Reaping: ALTER TABLE t1 ADD UNIQUE (b)
---reap
+--echo #
+--echo # DISABLED due to Bug#11815600
+--echo #
 
-disconnect con1;
-disconnect con2;
-SET DEBUG_SYNC= "RESET";
-DROP TABLE t1;
+#--disable_warnings
+#DROP DATABASE IF EXISTS db1;
+#DROP TABLE IF EXISTS t1;
+#--enable_warnings
+#
+#connect(con1,localhost,root);
+#connect(con2,localhost,root);
+#
+#--echo # Test 1: Secondary index, should not block reads (original test case).
+#
+#--echo # Connection default
+#connection default;
+#CREATE DATABASE db1;
+#CREATE TABLE db1.t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT) engine=innodb;
+#INSERT INTO db1.t1(value) VALUES (1), (2);
+#SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
+#--echo # Sending:
+#--send ALTER TABLE db1.t1 ADD INDEX(value)
+#
+#--echo # Connection con1
+#connection con1;
+#SET DEBUG_SYNC= "now WAIT_FOR manage";
+# # Neither of these two statements should be blocked
+#USE db1;
+#SELECT * FROM t1;
+#SET DEBUG_SYNC= "now SIGNAL query";
+#
+#--echo # Connection default
+#connection default;
+#--echo # Reaping: ALTER TABLE db1.t1 ADD INDEX(value)
+#--reap
+#DROP DATABASE db1;
+#
+#--echo # Test 2: Primary index (implicit), should block reads.
+#
+#CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
+#SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
+#--echo # Sending:
+#--send ALTER TABLE t1 ADD UNIQUE INDEX(a)
+#
+#--echo # Connection con1
+#connection con1;
+#SET DEBUG_SYNC= "now WAIT_FOR manage";
+#USE test;
+#--echo # Sending:
+#--send SELECT * FROM t1
+#
+#--echo # Connection con2
+#connection con2;
+#--echo # Waiting for SELECT to be blocked by the metadata lock on t1
+#let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
+#  WHERE state= 'Waiting for table metadata lock'
+#  AND info='SELECT * FROM t1';
+#--source include/wait_condition.inc
+#SET DEBUG_SYNC= "now SIGNAL query";
+#
+#--echo # Connection default
+#connection default;
+#--echo # Reaping: ALTER TABLE t1 ADD UNIQUE INDEX(a)
+#--reap
+#
+#--echo # Connection con1
+#connection con1;
+#--echo # Reaping: SELECT * FROM t1
+#--reap
+#
+#--echo # Test 3: Primary index (explicit), should block reads.
+#
+#--echo # Connection default
+#connection default;
+#ALTER TABLE t1 DROP INDEX a;
+#SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
+#--echo # Sending:
+#--send ALTER TABLE t1 ADD PRIMARY KEY (a)
+#
+#--echo # Connection con1
+#connection con1;
+#SET DEBUG_SYNC= "now WAIT_FOR manage";
+#--echo # Sending:
+#--send SELECT * FROM t1
+#
+#--echo # Connection con2
+#connection con2;
+#--echo # Waiting for SELECT to be blocked by the metadata lock on t1
+#let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
+#  WHERE state= 'Waiting for table metadata lock'
+#  AND info='SELECT * FROM t1';
+#--source include/wait_condition.inc
+#SET DEBUG_SYNC= "now SIGNAL query";
+#
+#--echo # Connection default
+#connection default;
+#--echo # Reaping: ALTER TABLE t1 ADD PRIMARY KEY (a)
+#--reap
+#
+#--echo # Connection con1
+#connection con1;
+#--echo # Reaping: SELECT * FROM t1
+#--reap
+#
+#--echo # Test 4: Secondary unique index, should not block reads.
+#
+#--echo # Connection default
+#connection default;
+#SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
+#--echo # Sending:
+#--send ALTER TABLE t1 ADD UNIQUE (b)
+#
+#--echo # Connection con1
+#connection con1;
+#SET DEBUG_SYNC= "now WAIT_FOR manage";
+#SELECT * FROM t1;
+#SET DEBUG_SYNC= "now SIGNAL query";
+#
+#--echo # Connection default
+#connection default;
+#--echo # Reaping: ALTER TABLE t1 ADD UNIQUE (b)
+#--reap
+#
+#disconnect con1;
+#disconnect con2;
+#SET DEBUG_SYNC= "RESET";
+#DROP TABLE t1;
 
 
 # Check that all connections opened by test cases in this file are really

=== modified file 'mysql-test/t/lowercase_table2.test'
--- a/mysql-test/t/lowercase_table2.test	2010-06-28 09:23:50 +0000
+++ b/mysql-test/t/lowercase_table2.test	2011-04-06 15:11:43 +0000
@@ -151,6 +151,41 @@ where TABLE_SCHEMA ='mysqltest_LC2';
 use test;
 drop database mysqltest_LC2;
 
+
+--echo #
+--echo # Bug #11758687: 50924: object names not resolved correctly 
+--echo #   on lctn2 systems
+--echo #
+
+CREATE DATABASE BUP_XPFM_COMPAT_DB2;
+
+CREATE TABLE BUP_XPFM_COMPAT_DB2.TABLE2 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TABLE BUP_XPFM_COMPAT_DB2.table1 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TABLE bup_xpfm_compat_db2.table3 (c13 INT) DEFAULT CHARSET latin1;
+
+delimiter |;
+#
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.trigger1 AFTER INSERT
+  ON BUP_XPFM_COMPAT_DB2.table1 FOR EACH ROW
+  update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.TRIGGER2 AFTER INSERT
+  ON BUP_XPFM_COMPAT_DB2.TABLE2 FOR EACH ROW
+  update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.TrigGer3 AFTER INSERT
+  ON BUP_XPFM_COMPAT_DB2.TaBle3 FOR EACH ROW
+  update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+delimiter ;|
+
+SELECT trigger_schema, trigger_name, event_object_table FROM
+INFORMATION_SCHEMA.TRIGGERS
+  WHERE trigger_schema COLLATE utf8_bin = 'BUP_XPFM_COMPAT_DB2'
+  ORDER BY trigger_schema, trigger_name;
+
+DROP DATABASE BUP_XPFM_COMPAT_DB2;
+
 --echo # End of 5.1 tests
 
 

=== modified file 'mysql-test/t/mysqlslap.test'
--- a/mysql-test/t/mysqlslap.test	2010-03-23 19:43:49 +0000
+++ b/mysql-test/t/mysqlslap.test	2011-04-08 07:07:57 +0000
@@ -52,3 +52,18 @@ CREATE PROCEDURE p1() SELECT 1;
 --exec $MYSQL_SLAP --create-schema=test --delimiter=";" --query="CALL p1; SELECT 1;" --silent 2>&1 
 
 DROP PROCEDURE p1;
+
+
+--echo #
+--echo # Bug #11765157 - 58090: mysqlslap drops schema specified in
+--echo #                 create_schema if auto-generate-sql also set.
+--echo #
+
+--exec $MYSQL_SLAP --silent --create-schema=bug58090 --concurrency=5 --iterations=20 --auto-generate-sql
+--echo # 'bug58090' database should not be present.
+SHOW DATABASES;
+--exec $MYSQL_SLAP --silent --create-schema=bug58090 --no-drop --auto-generate-sql
+--echo # 'bug58090' database should be present.
+SHOW DATABASES;
+DROP DATABASE bug58090;
+

=== modified file 'mysql-test/t/plugin_auth.test'
--- a/mysql-test/t/plugin_auth.test	2011-03-18 14:58:27 +0000
+++ b/mysql-test/t/plugin_auth.test	2011-04-07 09:55:09 +0000
@@ -491,4 +491,26 @@ SELECT IS_NULLABLE, COLUMN_NAME FROM INF
   TABLE_SCHEMA='mysql'
 ORDER BY COLUMN_NAME;
 
+
+--echo #
+--echo # Bug #11936829: diff. between mysql.user (authentication_string) 
+--echo #   in fresh and upgraded 5.5.11
+--echo #
+
+SELECT IS_NULLABLE, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
+  WHERE TABLE_SCHEMA= 'mysql' AND TABLE_NAME= 'user' AND
+    COLUMN_NAME IN ('plugin', 'authentication_string')
+  ORDER BY COLUMN_NAME;
+ALTER TABLE mysql.user MODIFY plugin char(64) DEFAULT '' NOT NULL;
+ALTER TABLE mysql.user MODIFY authentication_string TEXT NOT NULL;
+
+--echo Run mysql_upgrade on a 5.5.10 external authentication column layout
+--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1
+
+SELECT IS_NULLABLE, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
+  WHERE TABLE_SCHEMA= 'mysql' AND TABLE_NAME= 'user' AND
+    COLUMN_NAME IN ('plugin', 'authentication_string')
+  ORDER BY COLUMN_NAME;
+
+
 --echo End of 5.5 tests

=== modified file 'mysql-test/t/show_check.test'
--- a/mysql-test/t/show_check.test	2011-03-07 15:17:39 +0000
+++ b/mysql-test/t/show_check.test	2011-03-30 13:33:29 +0000
@@ -1082,6 +1082,7 @@ DROP DATABASE `�
 #
 --error ER_NO_SUCH_TABLE,ER_FILE_NOT_FOUND
 show columns from `#mysql50#????????`;
+call mtr.add_suppression("Can.t find file: '.\\\\test\\\\\\?{8}.frm'");
 
 #
 # SHOW CREATE TRIGGER test.

=== modified file 'mysql-test/t/sp-destruct.test'
--- a/mysql-test/t/sp-destruct.test	2010-12-16 18:18:20 +0000
+++ b/mysql-test/t/sp-destruct.test	2011-03-30 13:33:29 +0000
@@ -14,6 +14,7 @@
 
 # Supress warnings written to the log file
 call mtr.add_suppression("Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted");
+call mtr.add_suppression("Stored routine .test...bug14233_[123].: invalid value in column mysql.proc");
 
 # Backup proc table
 let $MYSQLD_DATADIR= `select @@datadir`;

=== modified file 'mysql-test/t/variables.test'
--- a/mysql-test/t/variables.test	2011-03-28 11:10:42 +0000
+++ b/mysql-test/t/variables.test	2011-04-12 12:48:26 +0000
@@ -1268,11 +1268,6 @@ SET @@global.max_join_size=0;
 SET @@global.key_buffer_size=0;
 SET @@global.key_cache_block_size=0;
 
-#
-# Bug#56976: added new start-up parameter
-#
-select @@max_long_data_size;
-
 --echo #
 --echo # Bug#11766424  59527: DECIMAL_BIN_SIZE: ASSERTION `SCALE >= 0 && PRECISION > 0 && SCALE <= PRE
 --echo #

=== modified file 'mysql-test/t/view.test'
--- a/mysql-test/t/view.test	2011-03-08 19:14:42 +0000
+++ b/mysql-test/t/view.test	2011-04-08 08:15:19 +0000
@@ -3989,6 +3989,18 @@ DROP TABLE t1;
 CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
 DROP VIEW v1;
 
+--echo #
+--echo # Bug 11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY
+--echo #
+
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT s.* FROM t1 s, t1 b HAVING a;
+
+SELECT * FROM v1; 
+
+DROP VIEW v1;
+DROP TABLE t1;
+
 --echo # -----------------------------------------------------------------
 --echo # -- End of 5.1 tests.
 --echo # -----------------------------------------------------------------

=== modified file 'mysql-test/t/xa.test'
--- a/mysql-test/t/xa.test	2011-03-25 15:13:41 +0000
+++ b/mysql-test/t/xa.test	2011-04-12 10:59:59 +0000
@@ -318,6 +318,8 @@ INSERT INTO t1 VALUES (2); # used to cau
 SAVEPOINT savep;
 --error ER_XAER_RMFAIL
 SET @a=(SELECT * FROM t1); # used to cause InnoDB assert
+--error ER_XAER_RMFAIL
+UPDATE t1 SET a=1 WHERE a=2;
 
 XA COMMIT 'a';
 SELECT * FROM t1;

=== modified file 'mysys/charset.c'
--- a/mysys/charset.c	2011-03-09 20:54:55 +0000
+++ b/mysys/charset.c	2011-03-21 20:16:05 +0000
@@ -950,8 +950,11 @@ CHARSET_INFO *fs_character_set()
       As we're now interested in cp932 only,
       let's just detect it using strcmp().
     */
-    fs_cset_cache= !strcmp(buf, "cp932") ?
-                   &my_charset_cp932_japanese_ci : &my_charset_bin;
+    fs_cset_cache= 
+                #ifdef HAVE_CHARSET_cp932
+                        !strcmp(buf, "cp932") ? &my_charset_cp932_japanese_ci : 
+                #endif
+                        &my_charset_bin;
   }
   return fs_cset_cache;
 }

=== modified file 'mysys/my_init.c'
--- a/mysys/my_init.c	2011-03-17 11:23:31 +0000
+++ b/mysys/my_init.c	2011-04-13 19:16:45 +0000
@@ -467,10 +467,6 @@ PSI_mutex_key key_my_file_info_mutex;
 PSI_mutex_key key_LOCK_localtime_r;
 #endif /* !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) */
 
-#ifndef HAVE_GETHOSTBYNAME_R
-PSI_mutex_key key_LOCK_gethostbyname_r;
-#endif /* HAVE_GETHOSTBYNAME_R */
-
 PSI_mutex_key key_BITMAP_mutex, key_IO_CACHE_append_buffer_lock,
   key_IO_CACHE_SHARE_mutex, key_KEY_CACHE_cache_lock, key_LOCK_alarm,
   key_my_thread_var_mutex, key_THR_LOCK_charset, key_THR_LOCK_heap,
@@ -487,9 +483,6 @@ static PSI_mutex_info all_mysys_mutexes[
 #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
   { &key_LOCK_localtime_r, "LOCK_localtime_r", PSI_FLAG_GLOBAL},
 #endif /* !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) */
-#ifndef HAVE_GETHOSTBYNAME_R
-  { &key_LOCK_gethostbyname_r, "LOCK_gethostbyname_r", PSI_FLAG_GLOBAL},
-#endif /* HAVE_GETHOSTBYNAME_R */
   { &key_BITMAP_mutex, "BITMAP::mutex", 0},
   { &key_IO_CACHE_append_buffer_lock, "IO_CACHE::append_buffer_lock", 0},
   { &key_IO_CACHE_SHARE_mutex, "IO_CACHE::SHARE_mutex", 0},

=== modified file 'mysys/my_thr_init.c'
--- a/mysys/my_thr_init.c	2011-03-17 11:23:31 +0000
+++ b/mysys/my_thr_init.c	2011-04-13 19:16:45 +0000
@@ -34,9 +34,6 @@ uint 		my_thread_end_wait_time= 5;
 #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
 mysql_mutex_t LOCK_localtime_r;
 #endif
-#ifndef HAVE_GETHOSTBYNAME_R
-mysql_mutex_t LOCK_gethostbyname_r;
-#endif
 #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
 pthread_mutexattr_t my_fast_mutexattr;
 #endif
@@ -218,10 +215,6 @@ my_bool my_thread_global_init(void)
 #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
   mysql_mutex_init(key_LOCK_localtime_r, &LOCK_localtime_r, MY_MUTEX_INIT_SLOW);
 #endif
-#ifndef HAVE_GETHOSTBYNAME_R
-  mysql_mutex_init(key_LOCK_gethostbyname_r,
-                   &LOCK_gethostbyname_r, MY_MUTEX_INIT_SLOW);
-#endif
 
 #ifdef _MSC_VER
   install_sigabrt_handler();
@@ -284,9 +277,6 @@ void my_thread_global_end(void)
 #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
   mysql_mutex_destroy(&LOCK_localtime_r);
 #endif
-#ifndef HAVE_GETHOSTBYNAME_R
-  mysql_mutex_destroy(&LOCK_gethostbyname_r);
-#endif
 
   my_thread_global_init_done= 0;
 }

=== modified file 'mysys/mysys_priv.h'
--- a/mysys/mysys_priv.h	2011-03-17 11:23:31 +0000
+++ b/mysys/mysys_priv.h	2011-04-13 19:16:45 +0000
@@ -36,10 +36,6 @@ extern PSI_mutex_key key_my_file_info_mu
 extern PSI_mutex_key key_LOCK_localtime_r;
 #endif /* !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) */
 
-#ifndef HAVE_GETHOSTBYNAME_R
-extern PSI_mutex_key key_LOCK_gethostbyname_r;
-#endif /* HAVE_GETHOSTBYNAME_R */
-
 extern PSI_mutex_key key_BITMAP_mutex, key_IO_CACHE_append_buffer_lock,
   key_IO_CACHE_SHARE_mutex, key_KEY_CACHE_cache_lock, key_LOCK_alarm,
   key_my_thread_var_mutex, key_THR_LOCK_charset, key_THR_LOCK_heap,

=== modified file 'plugin/auth/auth_socket.c'
--- a/plugin/auth/auth_socket.c	2011-01-11 14:53:14 +0000
+++ b/plugin/auth/auth_socket.c	2011-04-05 12:25:19 +0000
@@ -17,7 +17,7 @@
 /**
   @file
 
-  socket_peercred authentication plugin.
+  auth_socket authentication plugin.
 
   Authentication is successful if the connection is done via a unix socket and
   the owner of the client process matches the user name that was used when

=== modified file 'scripts/mysql_install_db.pl.in'
--- a/scripts/mysql_install_db.pl.in	2010-10-25 10:39:01 +0000
+++ b/scripts/mysql_install_db.pl.in	2011-03-23 23:28:49 +0000
@@ -79,11 +79,6 @@ Usage: $0 [OPTIONS]
                        user.  You must be root to use this option.  By default
                        mysqld runs using your current login name and files and
                        directories that it creates will be owned by you.
-  --rpl-engine=engine  The storage engine used for the mysql.slave_master_info and
-                       mysql.slave_relay_log_info tables. By default, both tables are
-                       created using the MyISAM storage engine. However, any storage
-                       engine available to the server may be used. If a crash-safe
-                       slave is required, the storage engine must be transactional.
 
 All other options are passed to the mysqld program
 
@@ -122,7 +117,6 @@ sub parse_arguments
              "builddir=s",      # FIXME not documented
              "srcdir=s",
              "ldata|datadir=s",
-             "rpl-engine=s",
 
              # Note that the user will be passed to mysqld so that it runs
              # as 'user' (crucial e.g. if log-bin=/some_other_path/
@@ -459,29 +453,6 @@ if ( open(PIPE, "| $mysqld_install_cmd_l
   report_verbose($opt,"OK");
 
   # ----------------------------------------------------------------------
-  # Pipe ALTER TABLE mysql.slave_master_info|slave_relay_log_info to "mysqld --bootstrap"
-  # ----------------------------------------------------------------------
-
-  if ($opt->{'rpl-engine'})
-  {
-    report_verbose_wait($opt,"Setting engine for mysql.slave_master_info mysql.slave_relay_log_info tables...");
-    if ( open(PIPE, "| $mysqld_install_cmd_line") )
-    {
-      print PIPE "use mysql;\n";
-      print PIPE "ALTER TABLE mysql.slave_master_info ENGINE= " . $opt->{'rpl-engine'} . ";\n";
-      print PIPE "ALTER TABLE mysql.slave_relay_log_info ENGINE= " . $opt->{'$rpl-engine'} . ";\n";
-      close PIPE;
-
-      report_verbose($opt,"OK");
-    }
-    else
-    {
-      warning($opt,"CRASH-SAFE SLAVE IS NOT COMPLETELY CONFIGURED!",
-                   "The \"CRASH-SAFE SLAVE\" might not work properly.");
-    }
-  }
-
-  # ----------------------------------------------------------------------
   # Pipe fill_help_tables.sql to "mysqld --bootstrap"
   # ----------------------------------------------------------------------
 

=== modified file 'scripts/mysql_install_db.sh'
--- a/scripts/mysql_install_db.sh	2010-10-25 10:39:01 +0000
+++ b/scripts/mysql_install_db.sh	2011-03-23 23:28:49 +0000
@@ -63,11 +63,6 @@ Usage: $0 [OPTIONS]
                        user.  You must be root to use this option.  By default
                        mysqld runs using your current login name and files and
                        directories that it creates will be owned by you.
-  --rpl-engine=engine  The storage engine used for the mysql.slave_master_info and
-                       mysql.slave_relay_log_info tables. By default, both tables are
-                       created using the MyISAM storage engine. However, any storage
-                       engine available to the server may be used. If a crash-safe
-                       slave is required, the storage engine must be transactional.
 
 All other options are passed to the mysqld program
 
@@ -120,8 +115,6 @@ parse_arguments()
       --no-defaults|--defaults-file=*|--defaults-extra-file=*)
         defaults="$arg" ;;
 
-      --rpl-engine=*) rpl_engine=`parse_arg "$arg"` ;;
-
       --cross-bootstrap|--windows)
         # Used when building the MySQL system tables on a different host than
         # the target. The platform-independent files that are created in
@@ -434,19 +427,6 @@ else
   exit 1
 fi
 
-if test -n "$rpl_engine"
-then
-  s_echo "Setting engine for mysql.slave_master_info mysql.slave_relay_log_info tables..."
-  if { echo "use mysql;"; echo "ALTER TABLE mysql.slave_master_info ENGINE= $rpl_engine;"; echo "ALTER TABLE mysql.slave_relay_log_info ENGINE= $rpl_engine;"; } | $mysqld_install_cmd_line > /dev/null
-  then
-    s_echo "OK"
-  else
-    echo
-    echo "WARNING: CRASH-SAFE SLAVE IS NOT COMPLETELY CONFIGURED!"
-    echo "The \"CRASH-SAFE SLAVE\" might not work properly."
-  fi
-fi
-
 s_echo "Filling help tables..."
 if { echo "use mysql;"; cat $fill_help_tables; } | $mysqld_install_cmd_line > /dev/null
 then

=== modified file 'scripts/mysql_system_tables_fix.sql'
--- a/scripts/mysql_system_tables_fix.sql	2011-03-18 14:58:27 +0000
+++ b/scripts/mysql_system_tables_fix.sql	2011-04-07 09:55:09 +0000
@@ -644,6 +644,7 @@ drop procedure mysql.die;
 
 ALTER TABLE user ADD plugin char(64) DEFAULT '',  ADD authentication_string TEXT;
 ALTER TABLE user MODIFY plugin char(64) DEFAULT '';
+ALTER TABLE user MODIFY authentication_string TEXT;
 
 -- Need to pre-fill mysql.proxies_priv with access for root even when upgrading from
 -- older versions

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2011-03-14 17:55:26 +0000
+++ b/sql/binlog.cc	2011-04-04 08:47:25 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -5379,24 +5379,6 @@ THD::binlog_prepare_pending_rows_event(T
   DBUG_RETURN(pending);        /* This is the current pending event */
 }
 
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-/*
-  Instantiate the versions we need, we have -fno-implicit-template as
-  compiling option.
-*/
-template Rows_log_event*
-THD::binlog_prepare_pending_rows_event(TABLE*, uint32, size_t, bool,
-				       Write_rows_log_event*);
-
-template Rows_log_event*
-THD::binlog_prepare_pending_rows_event(TABLE*, uint32, size_t, bool,
-				       Delete_rows_log_event *);
-
-template Rows_log_event* 
-THD::binlog_prepare_pending_rows_event(TABLE*, uint32, size_t, bool,
-				       Update_rows_log_event *);
-#endif
-
 /* Declare in unnamed namespace. */
 CPP_UNNAMED_NS_START
 

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2011-03-22 11:44:40 +0000
+++ b/sql/field.cc	2011-04-12 10:31:30 +0000
@@ -40,15 +40,9 @@
 // Maximum allowed exponent value for converting string to decimal
 #define MAX_EXPONENT 1024
 
-/*****************************************************************************
-  Instansiate templates and static variables
-*****************************************************************************/
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class List<Create_field>;
-template class List_iterator<Create_field>;
-#endif
-
+/**
+  Static variables
+*/
 uchar Field_null::null[1]={1};
 const char field_separator=',';
 
@@ -5386,6 +5380,7 @@ double Field_year::val_real(void)
 longlong Field_year::val_int(void)
 {
   ASSERT_COLUMN_MARKED_FOR_READ;
+  DBUG_ASSERT(field_length == 2 || field_length == 4);
   int tmp= (int) ptr[0];
   if (field_length != 4)
     tmp%=100;					// Return last 2 char
@@ -5398,6 +5393,7 @@ longlong Field_year::val_int(void)
 String *Field_year::val_str(String *val_buffer,
 			    String *val_ptr __attribute__((unused)))
 {
+  DBUG_ASSERT(field_length < 5);
   val_buffer->alloc(5);
   val_buffer->length(field_length);
   char *to=(char*) val_buffer->ptr();

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2011-03-17 17:39:31 +0000
+++ b/sql/filesort.cc	2011-04-04 08:47:25 +0000
@@ -37,10 +37,6 @@
 #include "sql_select.h"
 #include "debug_sync.h"
 
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class Bounded_queue<uchar, uchar>;
-#endif
-
 	/* functions defined in this file */
 
 static void make_char_array(FILESORT_INFO *info, uint fields, uint length);

=== modified file 'sql/hostname.cc'
--- a/sql/hostname.cc	2010-07-23 20:59:42 +0000
+++ b/sql/hostname.cc	2011-04-08 10:32:40 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -366,41 +366,35 @@ bool ip_to_hostname(struct sockaddr_stor
   err_code= vio_getnameinfo(ip, hostname_buffer, NI_MAXHOST, NULL, 0,
                             NI_NAMEREQD);
 
-  if (err_code == EAI_NONAME)
+  if (err_code)
   {
-    /*
-      There is no reverse address mapping for the IP address. A host name
-      can not be resolved.
-    */
+    // NOTE: gai_strerror() returns a string ending by a dot.
 
-    DBUG_PRINT("error", ("IP address '%s' could not be resolved: "
-                         "no reverse address mapping.",
-                         (const char *) ip_key));
+    DBUG_PRINT("error", ("IP address '%s' could not be resolved: %s",
+                         (const char *) ip_key,
+                         (const char *) gai_strerror(err_code)));
 
-    sql_print_warning("IP address '%s' could not be resolved: "
-                      "no reverse address mapping.",
-                      (const char *) ip_key);
+    sql_print_warning("IP address '%s' could not be resolved: %s",
+                      (const char *) ip_key,
+                      (const char *) gai_strerror(err_code));
 
-    err_status= add_hostname(ip_key, NULL);
+    if (vio_is_no_name_error(err_code))
+    {
+      /*
+        The no-name error means that there is no reverse address mapping
+        for the IP address. A host name can not be resolved.
+
+        If it is not the no-name error, we should not cache the hostname
+        (or rather its absence), because the failure might be transient.
+      */
 
-    *hostname= NULL;
-    *connect_errors= 0; /* New IP added to the cache. */
+      add_hostname(ip_key, NULL);
 
-    DBUG_RETURN(err_status);
-  }
-  else if (err_code)
-  {
-    DBUG_PRINT("error", ("IP address '%s' could not be resolved: "
-                         "getnameinfo() returned %d.",
-                         (const char *) ip_key,
-                         (int) err_code));
-
-    sql_print_warning("IP address '%s' could not be resolved: "
-                      "getnameinfo() returned error (code: %d).",
-                      (const char *) ip_key,
-                      (int) err_code);
+      *hostname= NULL;
+      *connect_errors= 0; /* New IP added to the cache. */
+    }
 
-    DBUG_RETURN(TRUE);
+    DBUG_RETURN(FALSE);
   }
 
   DBUG_PRINT("info", ("IP '%s' resolved to '%s'.",

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2011-03-30 07:42:03 +0000
+++ b/sql/item.cc	2011-04-11 10:28:36 +0000
@@ -1765,7 +1765,8 @@ bool agg_item_collations(DTCollation &c,
   }
   
   /* If all arguments where numbers, reset to @@collation_connection */
-  if (c.derivation == DERIVATION_NUMERIC)
+  if (flags & MY_COLL_ALLOW_NUMERIC_CONV &&
+      c.derivation == DERIVATION_NUMERIC)
     c.set(Item::default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_NUMERIC);
 
   return FALSE;
@@ -2979,12 +2980,12 @@ bool Item_param::set_longdata(const char
     (here), and first have to concatenate all pieces together,
     write query to the binary log and only then perform conversion.
   */
-  if (str_value.length() + length > max_long_data_size)
+  if (str_value.length() + length > current_thd->variables.max_allowed_packet)
   {
     my_message(ER_UNKNOWN_ERROR,
                "Parameter of prepared statement which is set through "
                "mysql_send_long_data() is longer than "
-               "'max_long_data_size' bytes",
+               "'max_allowed_packet' bytes",
                MYF(0));
     DBUG_RETURN(true);
   }
@@ -6576,7 +6577,7 @@ void Item_ref::print(String *str, enum_q
     {
       THD *thd= current_thd;
       append_identifier(thd, str, (*ref)->real_item()->name,
-                        (*ref)->real_item()->name_length);
+                        strlen((*ref)->real_item()->name));
     }
     else
       (*ref)->print(str, query_type);
@@ -6742,7 +6743,19 @@ my_decimal *Item_ref::val_decimal(my_dec
 int Item_ref::save_in_field(Field *to, bool no_conversions)
 {
   int res;
-  DBUG_ASSERT(!result_field);
+  if (result_field)
+  {
+    if (result_field->is_null())
+    {
+      null_value= 1;
+      res= set_field_to_null_with_conversions(to, no_conversions);
+      return res;
+    }
+    to->set_notnull();
+    res= field_conv(to, result_field);
+    null_value= 0;
+    return res;
+  }
   res= (*ref)->save_in_field(to, no_conversions);
   null_value= (*ref)->null_value;
   return res;
@@ -7601,7 +7614,7 @@ String *Item_cache_int::val_str(String *
   DBUG_ASSERT(fixed == 1);
   if (!has_value())
     return NULL;
-  str->set(value, default_charset());
+  str->set_int(value, unsigned_flag, default_charset());
   return str;
 }
 
@@ -8501,14 +8514,3 @@ void view_error_processor(THD *thd, void
   ((TABLE_LIST *)data)->hide_view_error(thd);
 }
 
-/*****************************************************************************
-** Instantiate templates
-*****************************************************************************/
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class List<Item>;
-template class List_iterator<Item>;
-template class List_iterator_fast<Item>;
-template class List_iterator_fast<Item_field>;
-template class List<List_item>;
-#endif

=== modified file 'sql/item.h'
--- a/sql/item.h	2011-03-22 11:44:40 +0000
+++ b/sql/item.h	2011-04-08 13:41:38 +0000
@@ -49,6 +49,8 @@ char_to_byte_length_safe(uint32 char_len
                                  (i.e. constant).
   MY_COLL_ALLOW_CONV           - allow any kind of conversion
                                  (combination of the above two)
+  MY_COLL_ALLOW_NUMERIC_CONV   - if all items were numbers, convert to
+                                 @@character_set_connection
   MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
                                  (e.g. when aggregating for comparison)
   MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
@@ -58,6 +60,7 @@ char_to_byte_length_safe(uint32 char_len
 #define MY_COLL_ALLOW_SUPERSET_CONV   1
 #define MY_COLL_ALLOW_COERCIBLE_CONV  2
 #define MY_COLL_DISALLOW_NONE         4
+#define MY_COLL_ALLOW_NUMERIC_CONV    8
 
 #define MY_COLL_ALLOW_CONV (MY_COLL_ALLOW_SUPERSET_CONV | MY_COLL_ALLOW_COERCIBLE_CONV)
 #define MY_COLL_CMP_CONV   (MY_COLL_ALLOW_CONV | MY_COLL_DISALLOW_NONE)
@@ -549,6 +552,10 @@ public:
    */
   Item *next;
   uint32 max_length;                    /* Maximum length, in bytes */
+  /*
+    TODO: convert name and name_length fields into String to keep them in sync
+    (see bug #11829681/60295 etc).
+  */
   uint name_length;                     /* Length of name */
   int8 marker;
   uint8 decimals;
@@ -1609,7 +1616,8 @@ agg_item_charsets_for_string_result(DTCo
                                     int item_sep= 1)
 {
   uint flags= MY_COLL_ALLOW_SUPERSET_CONV |
-              MY_COLL_ALLOW_COERCIBLE_CONV;
+              MY_COLL_ALLOW_COERCIBLE_CONV |
+              MY_COLL_ALLOW_NUMERIC_CONV;
   return agg_item_charsets(c, name, items, nitems, flags, item_sep);
 }
 inline bool
@@ -1622,6 +1630,19 @@ agg_item_charsets_for_comparison(DTColla
               MY_COLL_DISALLOW_NONE;
   return agg_item_charsets(c, name, items, nitems, flags, item_sep);
 }
+inline bool
+agg_item_charsets_for_string_result_with_comparison(DTCollation &c,
+                                                    const char *name,
+                                                    Item **items, uint nitems,
+                                                    int item_sep= 1)
+{
+  uint flags= MY_COLL_ALLOW_SUPERSET_CONV |
+              MY_COLL_ALLOW_COERCIBLE_CONV |
+              MY_COLL_ALLOW_NUMERIC_CONV |
+              MY_COLL_DISALLOW_NONE;
+  return agg_item_charsets(c, name, items, nitems, flags, item_sep);
+}
+
 
 class Item_num: public Item_basic_constant
 {

=== modified file 'sql/item_buff.cc'
--- a/sql/item_buff.cc	2010-08-16 06:58:42 +0000
+++ b/sql/item_buff.cc	2011-04-04 08:47:25 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -175,13 +175,3 @@ bool Cached_item_decimal::cmp()
   }
   return FALSE;
 }
-
-
-/*****************************************************************************
-** Instansiate templates
-*****************************************************************************/
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class List<Cached_item>;
-template class List_iterator<Cached_item>;
-#endif

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2011-03-22 11:44:40 +0000
+++ b/sql/item_cmpfunc.cc	2011-04-12 10:31:30 +0000
@@ -4152,13 +4152,11 @@ void Item_func_in::fix_length_and_dec()
       uint j=0;
       for (uint i=1 ; i < arg_count ; i++)
       {
-	if (!args[i]->null_value)			// Skip NULL values
-        {
-          array->set(j,args[i]);
-	  j++;
-        }
-	else
-	  have_null= 1;
+        array->set(j,args[i]);
+        if (!args[i]->null_value)                      // Skip NULL values
+          j++;
+        else
+          have_null= 1;
       }
       if ((array->used_count= j))
 	array->sort();

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2011-03-28 13:38:03 +0000
+++ b/sql/item_func.cc	2011-04-08 13:41:38 +0000
@@ -2550,7 +2550,8 @@ void Item_func_min_max::fix_length_and_d
   }
   if (cmp_type == STRING_RESULT)
   {
-    agg_arg_charsets_for_comparison(collation, args, arg_count);
+    agg_arg_charsets_for_string_result_with_comparison(collation,
+                                                       args, arg_count);
     if (datetime_found)
     {
       thd= current_thd;

=== modified file 'sql/item_func.h'
--- a/sql/item_func.h	2011-03-22 11:44:40 +0000
+++ b/sql/item_func.h	2011-04-08 13:41:38 +0000
@@ -164,6 +164,11 @@ public:
   {
     return agg_item_charsets(c, func_name(), items, nitems, flags, item_sep);
   }
+  /*
+    Aggregate arguments for string result, e.g: CONCAT(a,b)
+    - convert to @@character_set_connection if all arguments are numbers
+    - allow DERIVATION_NONE
+  */
   bool agg_arg_charsets_for_string_result(DTCollation &c,
                                           Item **items, uint nitems,
                                           int item_sep= 1)
@@ -171,6 +176,11 @@ public:
     return agg_item_charsets_for_string_result(c, func_name(),
                                                items, nitems, item_sep);
   }
+  /*
+    Aggregate arguments for comparison, e.g: a=b, a LIKE b, a RLIKE b
+    - don't convert to @@character_set_connection if all arguments are numbers
+    - don't allow DERIVATION_NONE
+  */
   bool agg_arg_charsets_for_comparison(DTCollation &c,
                                        Item **items, uint nitems,
                                        int item_sep= 1)
@@ -178,6 +188,21 @@ public:
     return agg_item_charsets_for_comparison(c, func_name(),
                                             items, nitems, item_sep);
   }
+  /*
+    Aggregate arguments for string result, when some comparison
+    is involved internally, e.g: REPLACE(a,b,c)
+    - convert to @@character_set_connection if all arguments are numbers
+    - disallow DERIVATION_NONE
+  */
+  bool agg_arg_charsets_for_string_result_with_comparison(DTCollation &c,
+                                                          Item **items,
+                                                          uint nitems,
+                                                          int item_sep= 1)
+  {
+    return agg_item_charsets_for_string_result_with_comparison(c, func_name(),
+                                                               items, nitems,
+                                                               item_sep);
+  }
   bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
   Item *transform(Item_transformer transformer, uchar *arg);
   Item* compile(Item_analyzer analyzer, uchar **arg_p,

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2011-03-24 10:37:16 +0000
+++ b/sql/item_strfunc.cc	2011-04-08 13:41:38 +0000
@@ -1261,7 +1261,7 @@ void Item_func_replace::fix_length_and_d
     char_length+= max_substrs * (uint) diff;
   }
 
-  if (agg_arg_charsets_for_comparison(collation, args, 3))
+  if (agg_arg_charsets_for_string_result_with_comparison(collation, args, 3))
     return;
   fix_char_length_ulonglong(char_length);
 }
@@ -1551,7 +1551,7 @@ void Item_func_substr::fix_length_and_de
 
 void Item_func_substr_index::fix_length_and_dec()
 { 
-  if (agg_arg_charsets_for_comparison(collation, args, 2))
+  if (agg_arg_charsets_for_string_result_with_comparison(collation, args, 2))
     return;
   fix_char_length(args[0]->max_char_length());
 }
@@ -1890,7 +1890,8 @@ void Item_func_trim::fix_length_and_dec(
   {
     // Handle character set for args[1] and args[0].
     // Note that we pass args[1] as the first item, and args[0] as the second.
-    if (agg_arg_charsets_for_comparison(collation, &args[1], 2, -1))
+    if (agg_arg_charsets_for_string_result_with_comparison(collation,
+                                                           &args[1], 2, -1))
       return;
   }
   fix_char_length(args[0]->max_char_length());

=== modified file 'sql/item_sum.cc'
--- a/sql/item_sum.cc	2011-04-01 14:04:52 +0000
+++ b/sql/item_sum.cc	2011-04-12 10:31:30 +0000
@@ -1142,17 +1142,13 @@ Item_sum_hybrid::fix_fields(THD *thd, It
 
   switch (hybrid_type= item->result_type()) {
   case INT_RESULT:
-    max_length= 20;
-    break;
   case DECIMAL_RESULT:
+  case STRING_RESULT:
     max_length= item->max_length;
     break;
   case REAL_RESULT:
     max_length= float_length(decimals);
     break;
-  case STRING_RESULT:
-    max_length= item->max_length;
-    break;
   case ROW_RESULT:
   default:
     DBUG_ASSERT(0);

=== modified file 'sql/keycaches.cc'
--- a/sql/keycaches.cc	2010-07-08 21:42:23 +0000
+++ b/sql/keycaches.cc	2011-04-04 08:47:25 +0000
@@ -157,7 +157,3 @@ bool process_key_caches(process_key_cach
   return 0;
 }
 
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class I_List_iterator<NAMED_ILINK>;
-#endif
-

=== modified file 'sql/mdl.h'
--- a/sql/mdl.h	2011-01-27 15:31:18 +0000
+++ b/sql/mdl.h	2011-04-11 11:52:24 +0000
@@ -321,21 +321,6 @@ private:
 };
 
 
-
-/**
-  Hook class which via its methods specifies which members
-  of T should be used for participating in MDL lists.
-*/
-
-template <typename T, T* T::*next, T** T::*prev>
-struct I_P_List_adapter
-{
-  static inline T **next_ptr(T *el) { return &(el->*next); }
-
-  static inline T ***prev_ptr(T *el) { return &(el->*prev); }
-};
-
-
 /**
   A pending metadata lock request.
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-04-01 23:01:38 +0000
+++ b/sql/mysqld.cc	2011-04-14 01:36:24 +0000
@@ -245,11 +245,7 @@ inline void setup_fpu()
 
 #define MYSQL_KILL_SIGNAL SIGTERM
 
-#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
-#include <sys/types.h>
-#else
 #include <my_pthread.h>			// For thr_setconcurency()
-#endif
 
 #ifdef SOLARIS
 extern "C" int gethostname(char *name, int namelen);
@@ -324,7 +320,6 @@ static PSI_rwlock_key key_rwlock_openssl
 
 /* the default log output is log tables */
 static bool lower_case_table_names_used= 0;
-static bool max_long_data_size_used= false;
 static bool volatile select_thread_in_use, signal_thread_in_use;
 /* See Bug#56666 and Bug#56760 */;
 volatile bool ready_to_exit;
@@ -483,11 +478,6 @@ ulong specialflag=0;
 ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
 ulong binlog_stmt_cache_use= 0, binlog_stmt_cache_disk_use= 0;
 ulong max_connections, max_connect_errors;
-/*
-  Maximum length of parameter value which can be set through
-  mysql_send_long_data() call.
-*/
-ulong max_long_data_size;
 /**
   Limit of the total number of prepared statements in the server.
   Is necessary to protect the server against out-of-memory attacks.
@@ -7602,10 +7592,6 @@ mysqld_get_one_option(int optid,
     if (argument == NULL) /* no argument */
       log_error_file_ptr= const_cast<char*>("");
     break;
-  case OPT_MAX_LONG_DATA_SIZE:
-    max_long_data_size_used= true;
-    WARN_DEPRECATED(NULL, "--max_long_data_size", "'--max_allowed_packet'");
-    break;
   }
   return 0;
 }
@@ -7840,13 +7826,6 @@ static int get_options(int *argc_ptr, ch
 
   opt_readonly= read_only;
 
-  /*
-    If max_long_data_size is not specified explicitly use
-    value of max_allowed_packet.
-  */
-  if (!max_long_data_size_used)
-    max_long_data_size= global_system_variables.max_allowed_packet;
-
   return 0;
 }
 
@@ -8140,20 +8119,6 @@ void refresh_status(THD *thd)
   This section should go away soon
 *****************************************************************************/
 
-/*****************************************************************************
-  Instantiate templates
-*****************************************************************************/
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-/* Used templates */
-template class I_List<THD>;
-template class I_List_iterator<THD>;
-template class I_List<i_string>;
-template class I_List<i_string_pair>;
-template class I_List<Statement>;
-template class I_List_iterator<Statement>;
-#endif
-
 #ifdef HAVE_PSI_INTERFACE
 #ifdef HAVE_MMAP
 PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active, key_LOCK_pool;
@@ -8556,8 +8521,8 @@ PSI_socket_key key_socket_tcpip, key_soc
 
 static PSI_socket_info all_server_sockets[]=
 {
-  { &key_socket_tcpip, "server_tcpip_socket", 0},
-  { &key_socket_unix, "server_unix_socket", 0},
+  { &key_socket_tcpip, "server_tcpip_socket", PSI_FLAG_GLOBAL},
+  { &key_socket_unix, "server_unix_socket", PSI_FLAG_GLOBAL},
   { &key_socket_client_connection, "client_connection", 0}
 };
 

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2011-04-01 14:04:52 +0000
+++ b/sql/opt_range.cc	2011-04-07 14:24:47 +0000
@@ -1154,8 +1154,7 @@ SQL_SELECT::SQL_SELECT() :quick(0),cond(
 
 void SQL_SELECT::cleanup()
 {
-  delete quick;
-  quick= 0;
+  set_quick(NULL);
   if (free_cond)
   {
     free_cond=0;
@@ -2216,8 +2215,7 @@ int SQL_SELECT::test_quick_select(THD *t
 		      (ulong) keys_to_use.to_ulonglong(), (ulong) prev_tables,
 		      (ulong) const_tables));
   DBUG_PRINT("info", ("records: %lu", (ulong) head->file->stats.records));
-  delete quick;
-  quick=0;
+  set_quick(NULL);
   needed_reg.clear_all();
   quick_keys.clear_all();
   if (keys_to_use.is_clear_all())
@@ -2458,10 +2456,7 @@ int SQL_SELECT::test_quick_select(THD *t
     {
       records= best_trp->records;
       if (!(quick= best_trp->make_quick(&param, TRUE)) || quick->init())
-      {
-        delete quick;
-        quick= NULL;
-      }
+        set_quick(NULL);
     }
 
   free_mem:
@@ -11963,12 +11958,3 @@ void QUICK_GROUP_MIN_MAX_SELECT::dbug_du
 
 
 #endif /* !DBUG_OFF */
-
-/*****************************************************************************
-** Instantiate templates 
-*****************************************************************************/
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class List<QUICK_RANGE>;
-template class List_iterator<QUICK_RANGE>;
-#endif

=== modified file 'sql/rpl_info.cc'
--- a/sql/rpl_info.cc	2010-12-21 09:33:41 +0000
+++ b/sql/rpl_info.cc	2011-03-23 23:28:49 +0000
@@ -36,7 +36,7 @@ Rpl_info::Rpl_info(const char* type
 #endif
   info_thd(0), inited(0), abort_slave(0),
   slave_running(0), slave_run_id(0),
-  handler(0)
+  handler(0), rpl_info_type(INVALID_INFO_REPOSITORY)
 {
 #ifdef HAVE_PSI_INTERFACE
   mysql_mutex_init(*key_info_run_lock,
@@ -65,13 +65,7 @@ Rpl_info::~Rpl_info()
   mysql_cond_destroy(&start_cond);
   mysql_cond_destroy(&stop_cond);
 
-  if (handler)
-    delete handler;
+  delete handler;
 
   DBUG_VOID_RETURN;
 }
-
-void Rpl_info::set_rpl_info_handler(Rpl_info_handler * param_handler)
-{
-  handler= param_handler;
-}

=== modified file 'sql/rpl_info.h'
--- a/sql/rpl_info.h	2010-12-21 09:33:41 +0000
+++ b/sql/rpl_info.h	2011-03-23 23:28:49 +0000
@@ -21,9 +21,18 @@
 #include "rpl_info_handler.h"
 #include "rpl_reporting.h"
 
+enum enum_info_repository
+{
+  INVALID_INFO_REPOSITORY= -1,
+  INFO_REPOSITORY_FILE= 0,
+  INFO_REPOSITORY_TABLE= 1
+};
+
 class Rpl_info : public Slave_reporting_capability
 {
 public:
+  virtual ~Rpl_info();
+
   /*
     standard lock acquisition order to avoid deadlocks:
     run_lock, data_lock, relay_log.LOCK_log, relay_log.LOCK_index
@@ -53,16 +62,45 @@ public:
   int events_until_exit;
 #endif
 
-  Rpl_info(const char* type
-#ifdef HAVE_PSI_INTERFACE
-           ,PSI_mutex_key *param_key_info_run_lock,
-           PSI_mutex_key *param_key_info_data_lock,
-           PSI_mutex_key *param_key_info_data_cond,
-           PSI_mutex_key *param_key_info_start_cond,
-           PSI_mutex_key *param_key_info_stop_cond
-#endif
-          );
-  virtual ~Rpl_info();
+  /**
+    Defines the type of the repository that is used.
+
+    @param param_rpl_info_type Type of repository.
+  */
+  void set_rpl_info_type(uint param_rpl_info_type)
+  {
+    rpl_info_type= param_rpl_info_type;
+  }
+
+  /**
+    Gets the type of the repository that is used.
+
+    @return Type of repository.
+  */
+  uint get_rpl_info_type()
+  {
+    return(rpl_info_type);
+  }
+
+  /**
+    Sets the persistency component/handler.
+
+    @param[in] hanlder Pointer to the handler.
+  */ 
+  void set_rpl_info_handler(Rpl_info_handler * param_handler)
+  {
+    handler= param_handler;
+  }
+
+  /**
+    Gets the persistency component/handler.
+
+    @return the handler if there is one.
+  */ 
+  Rpl_info_handler *get_rpl_info_handler()
+  {
+    return (handler);
+  }
 
   int check_info()
   {
@@ -79,6 +117,11 @@ public:
     return (handler->is_transactional());
   }
 
+  bool update_is_transactional()
+  {
+    return (handler->update_is_transactional());
+  }
+
   char *get_description_info()
   {
     return (handler->get_description_info());
@@ -92,21 +135,26 @@ public:
     return(FALSE);
   }
 
-  /**
-    Sets the persistency component/handler.
-
-    @param[in] hanlder Pointer to the handler.
-  */ 
-  void set_rpl_info_handler(Rpl_info_handler * handler);
-
 protected:
   Rpl_info_handler *handler;
 
+  uint rpl_info_type;
+
+  Rpl_info(const char* type
+#ifdef HAVE_PSI_INTERFACE
+           ,PSI_mutex_key *param_key_info_run_lock,
+           PSI_mutex_key *param_key_info_data_lock,
+           PSI_mutex_key *param_key_info_data_cond,
+           PSI_mutex_key *param_key_info_start_cond,
+           PSI_mutex_key *param_key_info_stop_cond
+#endif
+          );
+
 private:
   virtual bool read_info(Rpl_info_handler *from)= 0;
   virtual bool write_info(Rpl_info_handler *to, bool force)= 0;
 
-  Rpl_info& operator=(const Rpl_info& info);
   Rpl_info(const Rpl_info& info);
+  Rpl_info& operator=(const Rpl_info& info);
 };
 #endif /* RPL_INFO_H */

=== modified file 'sql/rpl_info_factory.cc'
--- a/sql/rpl_info_factory.cc	2010-12-21 09:33:41 +0000
+++ b/sql/rpl_info_factory.cc	2011-04-05 15:51:15 +0000
@@ -18,13 +18,6 @@
 #include "rpl_slave.h"
 #include "rpl_info_factory.h"
 
-/*
-  We need to replace these definitions by an option that states the
-  engine one wants to use in the master info repository.
-*/
-#define master_info_engine NULL
-#define relay_log_info_engine NULL
-
 /**
   Creates both a Master info and a Relay log info repository whose types are
   defined as parameters.
@@ -42,7 +35,7 @@
 bool Rpl_info_factory::create(uint mi_option, Master_info **mi,
                               uint rli_option, Relay_log_info **rli)
 {
-  DBUG_ENTER("Rpl_info_factory::Rpl_info_factory");
+  DBUG_ENTER("Rpl_info_factory::create");
 
   if (!((*mi)= Rpl_info_factory::create_mi(mi_option)))
     DBUG_RETURN(TRUE);
@@ -80,12 +73,12 @@ bool Rpl_info_factory::create(uint mi_op
 Master_info *Rpl_info_factory::create_mi(uint mi_option)
 {
   Master_info* mi= NULL;
-  Rpl_info_file*  mi_file= NULL;
-  Rpl_info_table*  mi_table= NULL;
+  Rpl_info_handler*  handler_src= NULL;
+  Rpl_info_handler*  handler_dest= NULL;
   const char *msg= "Failed to allocate memory for the master info "
                    "structure";
 
-  DBUG_ENTER("Rpl_info_factory::Rpl_info_factory");
+  DBUG_ENTER("Rpl_info_factory::create_mi");
 
   if (!(mi= new Master_info(
 #ifdef HAVE_PSI_INTERFACE
@@ -98,36 +91,17 @@ Master_info *Rpl_info_factory::create_mi
                            )))
     goto err;
 
-  /*
-    Now we instantiate all info repos and later decide which one to take,
-    but not without first checking if there is already existing data for
-    a repo different from the one that is being requested.
-  */
-  if (!(mi_file= new Rpl_info_file(mi->get_number_info_mi_fields(),
-                                   master_info_file)))
-    goto err;
-
-  if (!(mi_table= new Rpl_info_table(mi->get_number_info_mi_fields() + 1,
-                                     MI_FIELD_ID, MI_SCHEMA, MI_TABLE)))
-    goto err;
-
-  DBUG_ASSERT(mi_option == MI_REPOSITORY_FILE ||
-              mi_option == MI_REPOSITORY_TABLE);
-
-  if (decide_repository(mi, &mi_table, &mi_file,
-                        mi_option == MI_REPOSITORY_TABLE, &msg))
+  if(init_mi_repositories(mi, mi_option, &handler_src, &handler_dest, &msg))
     goto err;
 
-  if ((mi_option == MI_REPOSITORY_TABLE) &&
-       change_engine(static_cast<Rpl_info_table *>(mi_table),
-                     master_info_engine, &msg))
+  if (decide_repository(mi, mi_option, &handler_src, &handler_dest, &msg))
     goto err;
 
   DBUG_RETURN(mi);
 
 err:
-  if (mi_file) delete mi_file;
-  if (mi_table) delete mi_table;
+  delete handler_src;
+  delete handler_dest;
   if (mi)
   {
     /*
@@ -135,13 +109,51 @@ err:
       any reference to it.  
     */
     mi->set_rpl_info_handler(NULL);
-    delete (mi);
+    mi->set_rpl_info_type(INVALID_INFO_REPOSITORY);
+    delete mi;
   }
-  sql_print_error("%s", msg);
+  sql_print_error("Error creating master info: %s.", msg);
   DBUG_RETURN(NULL);
 }
 
 /**
+  Allows to change the master info repository after startup.
+
+  @param[in]  mi        Pointer to Master_info.
+  @param[in]  mi_option Type of the repository, e.g. FILE TABLE.
+  @param[out] msg       Error message if something goes wrong.
+
+  @retval FALSE No error
+  @retval TRUE  Failure
+*/
+bool Rpl_info_factory::change_mi_repository(Master_info *mi,
+                                            const uint mi_option,
+                                            const char **msg)
+{
+  DBUG_ENTER("Rpl_info_factory::change_mi_repository");
+
+  Rpl_info_handler*  handler_src= mi->get_rpl_info_handler();
+  Rpl_info_handler*  handler_dest= NULL;
+
+  if (mi->get_rpl_info_type()  == mi_option)
+    DBUG_RETURN(FALSE);
+
+  if (init_mi_repositories(mi, mi_option, NULL, &handler_dest, msg))
+    goto err;
+
+  if (change_repository(mi, mi_option, &handler_src, &handler_dest, msg))
+    goto err;
+
+  DBUG_RETURN(FALSE);
+
+err:
+  delete handler_dest;
+
+  sql_print_error("Error changing the type of master info's repository: %s.", *msg);
+  DBUG_RETURN(TRUE);
+}
+
+/**
   Creates a Relay log info repository whose type is defined as a parameter.
   
   @param[in]  rli_option        Type of the Relay log info repository
@@ -160,8 +172,8 @@ err:
 Relay_log_info *Rpl_info_factory::create_rli(uint rli_option, bool is_slave_recovery)
 {
   Relay_log_info *rli= NULL;
-  Rpl_info_file* rli_file= NULL;
-  Rpl_info_table* rli_table= NULL;
+  Rpl_info_handler* handler_src= NULL;
+  Rpl_info_handler* handler_dest= NULL;
   const char *msg= "Failed to allocate memory for the relay log info "
                    "structure";
 
@@ -178,36 +190,17 @@ Relay_log_info *Rpl_info_factory::create
                                )))
     goto err;
 
-  /*
-    Now we instantiate all info repos and later decide which one to take,
-    but not without first checking if there is already existing data for
-    a repo different from the one that is being requested.
-  */
-  if (!(rli_file= new Rpl_info_file(rli->get_number_info_rli_fields(),
-                                    relay_log_info_file)))
-    goto err;
-
-  if (!(rli_table= new Rpl_info_table(rli->get_number_info_rli_fields() + 1,
-                                      RLI_FIELD_ID, RLI_SCHEMA, RLI_TABLE)))
-    goto err;
-
-  DBUG_ASSERT(rli_option == RLI_REPOSITORY_FILE ||
-              rli_option == RLI_REPOSITORY_TABLE);
-
-  if (decide_repository(rli, &rli_table, &rli_file,
-                        rli_option == RLI_REPOSITORY_TABLE, &msg))
+  if(init_rli_repositories(rli, rli_option, &handler_src, &handler_dest, &msg))
     goto err;
 
-  if ((rli_option == RLI_REPOSITORY_TABLE) &&
-      change_engine(static_cast<Rpl_info_table *>(rli_table),
-                    relay_log_info_engine, &msg))
+  if (decide_repository(rli, rli_option, &handler_src, &handler_dest, &msg))
     goto err;
 
   DBUG_RETURN(rli);
 
 err:
-  if (rli_file) delete rli_file;
-  if (rli_table) delete rli_table;
+  delete handler_src;
+  delete handler_dest;
   if (rli) 
   {
     /*
@@ -215,142 +208,345 @@ err:
       any reference to it.  
     */
     rli->set_rpl_info_handler(NULL);
-    delete (rli);
+    rli->set_rpl_info_type(INVALID_INFO_REPOSITORY);
+    delete rli;
   }
-  sql_print_error("%s", msg);
+  sql_print_error("Error creating relay log info: %s.", msg);
   DBUG_RETURN(NULL);
 }
 
 /**
-  Decides what repository will be used based on the following decision table:
+  Allows to change the relay log info repository after startup.
 
-  \code
-  |--------------+-----------------------+-----------------------|
-  | Exists \ Opt |         TABLE         |          FILE         |
-  |--------------+-----------------------+-----------------------|
-  | ~is_t,  is_f | Update T and delete F | Read F                |
-  |  is_t,  is_f | ERROR                 | ERROR                 |
-  | ~is_t, ~is_f | Fill in T             | Create and Fill in F  |
-  |  is_t, ~is_f | Read T                | Update F and delete T |
-  |--------------+-----------------------+-----------------------|
-  \endcode
+  @param[in]  mi        Pointer to Relay_log_info.
+  @param[in]  mi_option Type of the repository, e.g. FILE TABLE.
+  @param[out] msg       Error message if something goes wrong.
+
+  @retval FALSE No error
+  @retval TRUE  Failure
+*/
+bool Rpl_info_factory::change_rli_repository(Relay_log_info *rli,
+                                             const uint rli_option,
+                                             const char **msg)
+{
+  DBUG_ENTER("Rpl_info_factory::change_rli_repository");
 
-  <ul>
-    \li F     --> file
+  Rpl_info_handler*  handler_src= rli->get_rpl_info_handler();
+  Rpl_info_handler*  handler_dest= NULL;
 
-    \li T     --> table
+  if (rli->get_rpl_info_type()  == rli_option)
+    DBUG_RETURN(FALSE);
 
-    \li is_t  --> table with data
+  if (init_rli_repositories(rli, rli_option, NULL, &handler_dest, msg))
+    goto err;
 
-    \li is_f  --> file with data
+  if (change_repository(rli, rli_option, &handler_src, &handler_dest, msg))
+    goto err;
 
-    \li ~is_t --> no data in the table
+  DBUG_RETURN(FALSE);
 
-    \li ~is_f --> no file
-  </ul> 
+err:
+  delete handler_dest;
+  handler_dest= NULL;
 
-  @param[in] info     Either master info or relay log info.
-  @param[in] table    Table handler.
-  @param[in] file     File handler.
-  @param[in] is_table True if a table handler was requested.
-  @param[out] msg     Message specifying what went wrong, if there is any error.
+  sql_print_error("Error changing the type of relay log info's repository: %s.", *msg);
+  DBUG_RETURN(TRUE);
+}
+
+/**
+  Decides during startup what repository will be used based on the following
+  decision table:
+
+  \code
+  |--------------+-----------------------+-----------------------|
+  | Exists \ Opt |         SOURCE        |      DESTINATION      |
+  |--------------+-----------------------+-----------------------|
+  | ~is_s, ~is_d |            -          | Create/Update D       |
+  | ~is_s,  is_d |            -          | Continue with D       |
+  |  is_s, ~is_d | Copy S into D         | Create/Update D       |
+  |  is_s,  is_d | Error                 | Error                 |
+  |--------------+-----------------------+-----------------------|
+  \endcode
+
+  @param[in]  info         Either master info or relay log info.
+  @param[in]  option       Identifies the type of the repository that will
+                           be used, i.e., destination repository.
+  @param[out] handler_src  Source repository from where information is
+                           copied into the destination repository.
+  @param[out] handler_dest Destination repository to where informaiton is
+                           copied.
+  @param[out] msg          Error message if something goes wrong.
 
   @retval FALSE No error
   @retval TRUE  Failure
 */
-bool Rpl_info_factory::decide_repository(Rpl_info *info, Rpl_info_table **table,
-                                         Rpl_info_file **file, bool is_table,
+bool Rpl_info_factory::decide_repository(Rpl_info *info,
+                                         uint option,
+                                         Rpl_info_handler **handler_src,
+                                         Rpl_info_handler **handler_dest,
                                          const char **msg)
 {
 
   DBUG_ENTER("Rpl_info_factory::decide_repository");
  
   bool error= TRUE;
-  bool is_t= !((*table)->check_info());
-  bool is_f= !((*file)->check_info());
+  /*
+    check_info() returns FALSE if the repository exists. If a FILE, 
+    for example, this means that FALSE is returned if a file exists.
+    If a TABLE, for example, this means that FALSE is returned if
+    the table exists and is populated. Otherwise, TRUE is returned.
+
+    The check_info() behavior is odd and we are going to fix this
+    in the future.
+
+    So,
 
-  if (is_t && is_f)
+      . is_src  == TRUE, means that the source repository exists.
+      . is_dest == TRUE, means that the destination repository
+        exists.
+
+    /Alfranio
+  */
+  bool is_src= !((*handler_src)->check_info());
+  bool is_dest= !((*handler_dest)->check_info());
+
+  DBUG_ASSERT((*handler_dest) != NULL && (*handler_dest) != NULL);
+  if (is_src && is_dest)
   {
     *msg= "Multiple replication metadata repository instances "
           "found with data in them. Unable to decide which is "
-          "the correct one to choose.";
+          "the correct one to choose";
     DBUG_RETURN(error);
   }
 
-  if (is_table)
+  if (!is_dest && is_src)
   {
-    if (!is_t && is_f)
+    if ((*handler_src)->init_info() || (*handler_dest)->init_info())
     {
-      if ((*table)->init_info() || (*file)->init_info())
-      {
-        *msg= "Error transfering information from a file to a table.";
-        goto err;
-      }
-      /*
-        Transfer the information from the file to the table and delete the
-        file, i.e. Update the table (T) and delete the file (F).
-      */
-      if (info->copy_info(*file, *table) || (*file)->remove_info())
-      {
-        *msg= "Error transfering information from a file to a table.";
-        goto err;
-      }
+      *msg= "Error transfering information";
+      goto err;
+    }
+    /*
+      Transfer the information from source to destination and delete the
+      source. Note this is not fault-tolerant and a crash before removing
+      source may cause the next restart to fail as is_src and is_dest may
+      be true. Moreover, any failure in removing the source may lead to
+      the same.
+
+      /Alfranio
+    */
+    if (info->copy_info(*handler_src, *handler_dest))
+    {
+      *msg= "Error transfering information";
+      goto err;
+    }
+    (*handler_src)->end_info();
+    if ((*handler_src)->remove_info())
+    {
+      *msg= "Error removing old repository";
+      goto err;
     }
-    delete (*file);
-    info->set_rpl_info_handler(*table);
-    error= FALSE;
-    *file= NULL;
   }
-  else
+
+  delete (*handler_src);
+  *handler_src= NULL;
+  info->set_rpl_info_handler(*handler_dest);
+  info->set_rpl_info_type(option);
+  error= FALSE;
+
+err:
+  DBUG_RETURN(error); 
+}
+
+/**
+  Changes the type of the repository after startup based on the following
+  decision table:
+
+  \code
+  |--------------+-----------------------+-----------------------|
+  | Exists \ Opt |         SOURCE        |      DESTINATION      |
+  |--------------+-----------------------+-----------------------|
+  | ~is_s, ~is_d |            -          | Create/Update D       |
+  | ~is_s,  is_d |            -          | Continue with D       |
+  |  is_s, ~is_d | Copy S into D         | Create/Update D       |
+  |  is_s,  is_d | Copy S into D         | Continue with D       |
+  |--------------+-----------------------+-----------------------|
+  \endcode
+
+  @param[in]  info         Either master info or relay log info.
+  @param[in]  option       Identifies the type of the repository that will
+                           be used, i.e., destination repository.
+  @param[out] handler_src  Source repository from where information is
+                           copied into the destination repository.
+  @param[out] handler_dest Destination repository to where informaiton is
+                           copied.
+  @param[out] msg          Error message if something goes wrong.
+
+  @retval FALSE No error
+  @retval TRUE  Failure
+*/
+bool Rpl_info_factory::change_repository(Rpl_info *info,
+                                         uint option,
+                                         Rpl_info_handler **handler_src,
+                                         Rpl_info_handler **handler_dest,
+                                         const char **msg)
+{
+  bool error= TRUE;
+
+  DBUG_ENTER("Rpl_info_factory::change_repository");
+
+  DBUG_ASSERT((*handler_dest) != NULL && (*handler_dest) != NULL);
+  if (!(*handler_src)->check_info())
   {
-    if (is_t && !is_f)
+    if ((*handler_dest)->init_info())
     {
-      if ((*table)->init_info() || (*file)->init_info())
-      {
-        *msg= "Error transfering information from a file to a table.";
+      *msg= "Error initializing new repository";
+      goto err;
+    }
+
+    /*
+      Transfer the information from source to destination and delete the
+      source. Note this is not fault-tolerant and a crash before removing
+      source may cause the next restart to fail as is_src and is_dest may
+      be true. Moreover, any failure in removing the source may lead to
+      the same.
+
+      /Alfranio
+    */
+    if (info->copy_info(*handler_src, *handler_dest))
+    {
+      *msg= "Error transfering information";
+      goto err;
+    }
+  }
+  (*handler_src)->end_info();
+  if ((*handler_src)->remove_info())
+  {
+    *msg= "Error removing old repository";
+    goto err;
+  }
+
+  info->set_rpl_info_handler(NULL);
+  delete (*handler_src);
+  *handler_src= NULL;
+  info->set_rpl_info_handler(*handler_dest);
+  info->set_rpl_info_type(option);
+  error= FALSE;
+
+err:
+  DBUG_RETURN(error);
+}
+
+/**
+  Creates repositories that will be associated to the master info.
+
+  @param[in] mi            Pointer to the class Master info.
+  @param[in] rli_option    Identifies the type of the repository that will
+                           be used, i.e., destination repository.
+  @param[out] handler_src  Source repository from where information is
+                           copied into the destination repository.
+  @param[out] handler_dest Destination repository to where informaiton is
+                           copied.
+  @param[out] msg          Error message if something goes wrong.
+
+  @retval FALSE No error
+  @retval TRUE  Failure
+*/
+bool Rpl_info_factory::init_mi_repositories(Master_info *mi,
+                                            uint mi_option,
+                                            Rpl_info_handler **handler_src,
+                                            Rpl_info_handler **handler_dest,
+                                            const char **msg)
+{
+  bool error= TRUE;
+  *msg= "Failed to allocate memory for master info repositories";
+
+  DBUG_ENTER("Rpl_info_factory::init_mi_repositories");
+
+  DBUG_ASSERT(handler_dest != NULL);
+  switch (mi_option)
+  {
+    case INFO_REPOSITORY_FILE:
+      if (!(*handler_dest= new Rpl_info_file(mi->get_number_info_mi_fields(),
+                                             master_info_file)))
         goto err;
-      }
-      /*
-        Transfer the information from the table to the file and delete 
-        entries in the table, i.e. Update the file (F) and delete the
-        table (T).
-      */
-      if (info->copy_info(*table, *file) || (*table)->remove_info())
-      {
-        *msg= "Error transfering information from a table to a file.";
+      if (handler_src &&
+          !(*handler_src= new Rpl_info_table(mi->get_number_info_mi_fields() + 1,
+                                             MI_FIELD_ID, MYSQL_SCHEMA_NAME.str, MI_INFO_NAME.str)))
         goto err;
-      } 
-    }
-    delete (*table);
-    info->set_rpl_info_handler(*file);
-    error= FALSE;
-    *table= NULL;
+    break;
+
+    case INFO_REPOSITORY_TABLE:
+      if (!(*handler_dest= new Rpl_info_table(mi->get_number_info_mi_fields() + 1,
+                                              MI_FIELD_ID, MYSQL_SCHEMA_NAME.str, MI_INFO_NAME.str)))
+        goto err;
+      if (handler_src &&
+          !(*handler_src= new Rpl_info_file(mi->get_number_info_mi_fields(),
+                                            master_info_file)))
+        goto err;
+    break;
+    default:
+      DBUG_ASSERT(0);
   }
+  error= FALSE;
 
 err:
-  DBUG_RETURN(error); 
+  DBUG_RETURN(error);
 }
 
 /**
-  Changes the engine in use by a handler.
-  
-  @param[in]  handler Reference to a handler.
-  @param[in]  engine  Type of the engine, e.g. Innodb, MyIsam.
-  @param[out] msg     Message specifying what went wrong, if there is any error.
+  Creates repositories that will be associated to the relay log info.
+
+  @param[in] rli           Pointer to the class Relay_log_info.
+  @param[in] rli_option    Identifies the type of the repository that will
+                           be used, i.e., destination repository.
+  @param[out] handler_src  Source repository from where information is
+                           copied into the destination repository.
+  @param[out] handler_dest Destination repository to where informaiton is
+                           copied.
+  @param[out] msg          Error message if something goes wrong.
 
   @retval FALSE No error
   @retval TRUE  Failure
 */
-bool Rpl_info_factory::change_engine(Rpl_info_table *table, const char *engine,
-                                     const char **msg)
+bool Rpl_info_factory::init_rli_repositories(Relay_log_info *rli,
+                                             uint rli_option,
+                                             Rpl_info_handler **handler_src,
+                                             Rpl_info_handler **handler_dest,
+                                             const char **msg)
 {
-  DBUG_ENTER("Rpl_info_factory::decide_engine");
+  bool error= TRUE;
+  *msg= "Failed to allocate memory for relay log info repositories";
+
+  DBUG_ENTER("Rpl_info_factory::init_rli_repositories");
 
-  if (engine && table->change_engine(engine))
+  DBUG_ASSERT(handler_dest != NULL);
+  switch (rli_option)
   {
-    *msg= "Error changing the engine for a respository.";
-    DBUG_RETURN(TRUE);
+    case INFO_REPOSITORY_FILE:
+      if (!(*handler_dest= new Rpl_info_file(rli->get_number_info_rli_fields(),
+                                             relay_log_info_file)))
+        goto err;
+      if (handler_src &&
+          !(*handler_src= new Rpl_info_table(rli->get_number_info_rli_fields() + 1,
+                                             RLI_FIELD_ID, MYSQL_SCHEMA_NAME.str, RLI_INFO_NAME.str)))
+        goto err;
+    break;
+
+    case INFO_REPOSITORY_TABLE:
+      if (!(*handler_dest= new Rpl_info_table(rli->get_number_info_rli_fields() + 1,
+                                              RLI_FIELD_ID, MYSQL_SCHEMA_NAME.str, RLI_INFO_NAME.str)))
+        goto err;
+      if (handler_src &&
+          !(*handler_src= new Rpl_info_file(rli->get_number_info_rli_fields(),
+                                            relay_log_info_file)))
+        goto err;
+    break;
+    default:
+      DBUG_ASSERT(0);
   }
+  error= FALSE;
 
-  DBUG_RETURN(FALSE);
+err:
+  DBUG_RETURN(error);
 }

=== modified file 'sql/rpl_info_factory.h'
--- a/sql/rpl_info_factory.h	2010-10-25 10:39:01 +0000
+++ b/sql/rpl_info_factory.h	2011-03-23 23:28:49 +0000
@@ -16,6 +16,7 @@
 #ifndef RPL_INFO_FACTORY_H
 #define RPL_INFO_FACTORY_H
 
+#include "table.h"
 #include "rpl_info.h"
 #include "rpl_mi.h"
 #include "rpl_rli.h"
@@ -23,42 +24,43 @@
 #include "rpl_info_table.h"
 #include "rpl_info_handler.h"
 
-enum enum_mi_repository
-{
-  MI_REPOSITORY_FILE= 0,
-  MI_REPOSITORY_TABLE= 1
-};
 extern ulong opt_mi_repository_id;
-
-enum enum_rli_repository
-{
-  RLI_REPOSITORY_FILE= 0,
-  RLI_REPOSITORY_TABLE= 1
-};
 extern ulong opt_rli_repository_id;
 
 #define MI_FIELD_ID 0
-
-#define MI_SCHEMA "mysql"
-#define MI_TABLE  "slave_master_info"
-
 #define RLI_FIELD_ID 0
 
-#define RLI_SCHEMA "mysql"
-#define RLI_TABLE  "slave_relay_log_info"
-
 class Rpl_info_factory
 {
-  public:
-
+public:
   static bool create(uint mi_option, Master_info **mi,
                      uint rli_option, Relay_log_info **rli);
   static Master_info *create_mi(uint rli_option);
+  static bool change_mi_repository(Master_info *mi, uint mi_option,
+                                   const char **msg);
   static Relay_log_info *create_rli(uint rli_option, bool is_slave_recovery);
-  static bool decide_repository(Rpl_info *info, Rpl_info_table **table,
-                                Rpl_info_file **file, bool is_table,
+  static bool change_rli_repository(Relay_log_info *mi, uint mi_option,
+                                    const char **msg);
+private:
+  static bool decide_repository(Rpl_info *info,
+                                uint option,
+                                Rpl_info_handler **handler_src,
+                                Rpl_info_handler **handler_dest,
+                                const char **msg);
+  static bool change_repository(Rpl_info *info,
+                                uint option,
+                                Rpl_info_handler **handler_src,
+                                Rpl_info_handler **handler_dest,
                                 const char **msg);
-  static bool change_engine(Rpl_info_table *table, const char *engine,
-                            const char **msg);
+  static bool init_mi_repositories(Master_info *mi,
+                                   uint mi_option,
+                                   Rpl_info_handler **handler_src,
+                                   Rpl_info_handler **handler_dest,
+                                   const char **msg);
+  static bool init_rli_repositories(Relay_log_info *rli,
+                                    uint rli_option,
+                                    Rpl_info_handler **handler_src,
+                                    Rpl_info_handler **handler_dest,
+                                    const char **msg);
 };
 #endif

=== modified file 'sql/rpl_info_file.cc'
--- a/sql/rpl_info_file.cc	2010-10-29 09:07:21 +0000
+++ b/sql/rpl_info_file.cc	2011-04-05 16:46:24 +0000
@@ -122,7 +122,26 @@ int Rpl_info_file::do_prepare_info_for_w
 
 int Rpl_info_file::do_check_info()
 {
-  return (access(info_fname,F_OK));
+  /*
+    This function checks if the file exists and in other modules
+    further actions are taken based on this. If the file exists
+    but users do not have the appropriated rights to access it,
+    other modules will assume that the file does not exist and
+    will take the appropriate actions and most likely will fail
+    safely after trying to create it. 
+
+    This is behavior is not a problem. However, in other modules,
+    it is not possible to print out what is the root of the
+    failure as a detailed error code is not returned. For that
+    reason, we print out such information in here.
+  */
+  if (my_access(info_fname, F_OK | R_OK | W_OK))
+    sql_print_information("Info file %s cannot be accessed (errno %d)."
+                          " Most likely this is a new slave or you are "
+                          " changing the repository type.", info_fname,
+                          errno);
+  
+  return my_access(info_fname, F_OK);
 }
 
 int Rpl_info_file::do_flush_info(const bool force)
@@ -294,6 +313,11 @@ bool Rpl_info_file::do_is_transactional(
 {
   return FALSE;
 }
+
+bool Rpl_info_file::do_update_is_transactional()
+{
+  return FALSE;
+}
 
 int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
                           const char *default_val)

=== modified file 'sql/rpl_info_file.h'
--- a/sql/rpl_info_file.h	2010-10-25 10:39:01 +0000
+++ b/sql/rpl_info_file.h	2011-03-23 23:28:49 +0000
@@ -20,13 +20,16 @@
 #include <sql_priv.h>
 #include "rpl_info_handler.h"
 
+class Rpl_info_factory;
+
 /**
   Defines a file hander.
 */
 class Rpl_info_file : public Rpl_info_handler
 {
+  friend class Rpl_info_factory;
+
 public:
-  Rpl_info_file(int const nparam, const char* param_info_fname);
   virtual ~Rpl_info_file() { };
 
 private:
@@ -66,8 +69,11 @@ private:
                    const Server_ids *default_value);
   char* do_get_description_info();
   bool do_is_transactional();
+  bool do_update_is_transactional();
 
-  Rpl_info_file& operator=(const Rpl_info_file& info);
+  Rpl_info_file(int const nparam, const char* param_info_fname);
   Rpl_info_file(const Rpl_info_file& info);
+
+  Rpl_info_file& operator=(const Rpl_info_file& info);
 };
 #endif /* RPL_INFO_FILE_H */

=== modified file 'sql/rpl_info_handler.cc'
--- a/sql/rpl_info_handler.cc	2010-10-25 10:39:01 +0000
+++ b/sql/rpl_info_handler.cc	2011-03-23 23:28:49 +0000
@@ -35,10 +35,7 @@ Rpl_info_handler::Rpl_info_handler(const
 
 Rpl_info_handler::~Rpl_info_handler()
 {
-  if (field_values)
-  {
-    delete field_values;
-  }
+  delete field_values;
 }
 
 void Rpl_info_handler::set_sync_period(uint period)

=== modified file 'sql/rpl_info_handler.h'
--- a/sql/rpl_info_handler.h	2011-02-04 11:55:17 +0000
+++ b/sql/rpl_info_handler.h	2011-03-23 23:28:49 +0000
@@ -23,9 +23,6 @@
 class Rpl_info_handler
 {
 public:
-  Rpl_info_handler(const int nparam);
-  virtual ~Rpl_info_handler();
-
   /**
     After creating an object and assembling components, this method is
     used to initialize internal structures. Everything that does not
@@ -260,6 +257,21 @@ public:
   */
   bool is_transactional() { return do_is_transactional(); }
 
+  /**
+    Updates the value returned by the member function is_transactional()
+    because it may be expensive to compute it whenever is_transactional()
+    is called.
+
+    In the current implementation, the type of the repository can only be
+    changed when replication, i.e. slave, is stopped. For that reason,
+    this member function, i.e. update_is__transactional(), must be called
+    when slave is starting.
+
+    @retval FALSE No error
+    @retval TRUE Failure
+  */
+  bool update_is_transactional() { return do_update_is_transactional(); }
+
   /*                                                                                                                                    
     Pre-store information before writing it to the repository and if
     necessary after reading it from the repository. The decision is
@@ -267,6 +279,8 @@ public:
   */
   Rpl_info_values *field_values;
 
+  virtual ~Rpl_info_handler();
+
 protected:
   /* Number of fields to be stored in the repository. */
   int ninfo;
@@ -289,6 +303,8 @@ protected:
   */
   uint sync_period;
 
+  Rpl_info_handler(const int nparam);
+
 private:
   virtual int do_init_info()= 0;
   virtual int do_check_info()= 0;
@@ -315,8 +331,10 @@ private:
                            const Server_ids *default_value)= 0;
   virtual char* do_get_description_info()= 0;
   virtual bool do_is_transactional()= 0;
+  virtual bool do_update_is_transactional()= 0;
 
-  Rpl_info_handler& operator=(const Rpl_info_handler& handler);
   Rpl_info_handler(const Rpl_info_handler& handler);
+
+  Rpl_info_handler& operator=(const Rpl_info_handler& handler);
 };
 #endif /* RPL_INFO_HANDLER_H */

=== modified file 'sql/rpl_info_table.cc'
--- a/sql/rpl_info_table.cc	2010-12-03 00:15:40 +0000
+++ b/sql/rpl_info_table.cc	2011-04-04 10:06:13 +0000
@@ -15,12 +15,12 @@
 
 #include "rpl_info_table.h"
 #include "rpl_utility.h"
-#include "sql_parse.h"
 
 Rpl_info_table::Rpl_info_table(uint nparam, uint param_field_idx,
                                const char* param_schema,
                                const char *param_table)
-:Rpl_info_handler(nparam), field_idx(param_field_idx)
+:Rpl_info_handler(nparam), field_idx(param_field_idx),
+ is_transactional(FALSE)
 {
   str_schema.str= str_table.str= NULL;
   str_schema.length= str_table.length= 0;
@@ -52,17 +52,13 @@ Rpl_info_table::Rpl_info_table(uint npar
 
 Rpl_info_table::~Rpl_info_table()
 {
-  if (access)
-    delete access;
+  delete access;
   
-  if (description)
-    my_free(description);
+  my_free(description);
 
-  if (str_table.str)
-    my_free(str_table.str);
+  my_free(str_table.str);
 
-  if (str_schema.str)
-    my_free(str_schema.str);
+  my_free(str_schema.str);
 }
 
 int Rpl_info_table::do_init_info()
@@ -285,7 +281,12 @@ int Rpl_info_table::do_check_info()
   if (access->open_table(thd, str_schema, str_table,
                          get_number_info(), TL_READ,
                          &table, &backup))
+  {
+    sql_print_warning("Info table is not ready to be used. Table "
+                      "'%s.%s' cannot be opened.", str_schema.str,
+                      str_table.str);
     goto end;
+  }
 
   /*
     Points the cursor at the row to be deleted where the the master_id
@@ -447,47 +448,35 @@ char* Rpl_info_table::do_get_description
 
 bool Rpl_info_table::do_is_transactional()
 {
-  ulong saved_mode;
-  TABLE *table= NULL;
-  Open_tables_backup backup;
-  bool is_trans= FALSE;
-
-  DBUG_ENTER("Rpl_info_table::do_is_transactional");
-
-  THD *thd= access->create_thd();
-
-  saved_mode= thd->variables.sql_mode;
-
-  /*
-    Opens and locks the rpl_info table before accessing it.
-  */
-  if (!access->open_table(thd, str_schema, str_table,
-                          get_number_info(), TL_READ,
-                          &table, &backup))
-    is_trans= table->file->has_transactions();
-
-  access->close_table(thd, table, &backup, 0);
-  thd->variables.sql_mode= saved_mode;
-  access->drop_thd(thd);
-  DBUG_RETURN(is_trans);
+  return is_transactional;
 }
 
-bool Rpl_info_table::change_engine(const char *engine)
+bool Rpl_info_table::do_update_is_transactional()
 {
   bool error= TRUE;
   ulong saved_mode;
-
-  DBUG_ENTER("Rpl_info_table::do_check_info");
+  TABLE *table= NULL;
+  Open_tables_backup backup;
+ 
+  DBUG_ENTER("Rpl_info_table::do_update_is_transactional");
 
   THD *thd= access->create_thd();
-
   saved_mode= thd->variables.sql_mode;
   tmp_disable_binlog(thd);
 
-  /* TODO: Change the engine using internal functions */
-
+  /*
+    Opens and locks the rpl_info table before accessing it.
+  */
+  if (access->open_table(thd, str_schema, str_table,
+                         get_number_info(), TL_READ,
+                         &table, &backup))
+    goto end;
+ 
+  is_transactional= table->file->has_transactions();
   error= FALSE;
 
+end:
+  access->close_table(thd, table, &backup, 0);
   reenable_binlog(thd);
   thd->variables.sql_mode= saved_mode;
   access->drop_thd(thd);

=== modified file 'sql/rpl_info_table.h'
--- a/sql/rpl_info_table.h	2010-10-25 10:39:01 +0000
+++ b/sql/rpl_info_table.h	2011-03-23 23:28:49 +0000
@@ -19,22 +19,15 @@
 #include "rpl_info_handler.h"
 #include "rpl_info_table_access.h"
 
+class Rpl_info_factory;
+
 class Rpl_info_table : public Rpl_info_handler
 {
+  friend class Rpl_info_factory;
+
 public:
-  Rpl_info_table(uint nparam, uint param_field_id, const char* param_schema,
-                 const char *param_table);
   virtual ~Rpl_info_table();
-  /*
-    This enables to change the engine in use by internally executing
-    an ALTER TABLE ENGINE= engine.
-
-    @param[in]  engine  Type of the engine, e.g. Innodb, MyIsam.
 
-    @retval FALSE No error
-    @retval TRUE  Failure
-  */
-  bool change_engine(const char* engine);
 private:
   /*
     This property identifies the name of the schema where a
@@ -65,6 +58,12 @@ private:
   */
   Rpl_info_table_access *access;
 
+  /*
+    Identifies if a table is transactional or non-transactional.
+    This is used to provide a crash-safe behaviour.
+  */
+  bool is_transactional;
+
   int do_init_info();
   int do_check_info();
   void do_end_info();
@@ -90,9 +89,12 @@ private:
                    const Server_ids *default_value);
   char* do_get_description_info();
   bool do_is_transactional();
+  bool do_update_is_transactional();
 
-  Rpl_info_table& operator=(const Rpl_info_table& info);
+  Rpl_info_table(uint nparam, uint param_field_id, const char* param_schema,
+                 const char *param_table);
   Rpl_info_table(const Rpl_info_table& info);
-};
 
+  Rpl_info_table& operator=(const Rpl_info_table& info);
+};
 #endif /* RPL_INFO_TABLE_H */

=== modified file 'sql/rpl_info_table_access.cc'
--- a/sql/rpl_info_table_access.cc	2010-10-27 11:20:32 +0000
+++ b/sql/rpl_info_table_access.cc	2011-03-23 23:28:49 +0000
@@ -288,6 +288,8 @@ THD *Rpl_info_table_access::create_thd()
     thd= new THD;
     thd->thread_stack= (char*) &thd;
     thd->store_globals();
+    thd->security_ctx->skip_grants();
+    thd->system_thread= SYSTEM_THREAD_INFO_REPOSITORY;
   }
   else
     thd= current_thd;

=== modified file 'sql/rpl_info_values.cc'
--- a/sql/rpl_info_values.cc	2010-10-27 09:04:21 +0000
+++ b/sql/rpl_info_values.cc	2011-03-23 23:28:49 +0000
@@ -39,8 +39,5 @@ bool Rpl_info_values::init()
 
 Rpl_info_values::~Rpl_info_values()
 {
-  for (int pos= 0; pos < ninfo; pos++)
-    value[pos].~String();
-
   delete [] value;
 }

=== modified file 'sql/rpl_mi.cc'
--- a/sql/rpl_mi.cc	2010-12-21 09:33:41 +0000
+++ b/sql/rpl_mi.cc	2011-04-04 09:42:22 +0000
@@ -263,12 +263,10 @@ int Master_info::init_info()
   if (necessary_to_configure)
   {
     init_master_log_pos();
-    goto end;
   }
   else if (read_info(handler))
     goto err;
 
-end:
   if (flush_info(TRUE))
     goto err;
 
@@ -276,7 +274,7 @@ end:
   DBUG_RETURN(0);
 
 err:
-  sql_print_error("Error reading master configuration");
+  sql_print_error("Error reading master configuration.");
   DBUG_RETURN(1);
 }
 

=== modified file 'sql/rpl_mi.h'
--- a/sql/rpl_mi.h	2010-12-21 09:33:41 +0000
+++ b/sql/rpl_mi.h	2011-03-23 23:28:49 +0000
@@ -27,6 +27,7 @@
 #include "my_sys.h"
 
 typedef struct st_mysql MYSQL;
+class Rpl_info_factory;
 
 /*****************************************************************************
   Replication IO Thread
@@ -62,18 +63,9 @@ typedef struct st_mysql MYSQL;
 
 class Master_info : public Rpl_info
 {
- public:
-  Master_info(
-#ifdef HAVE_PSI_INTERFACE
-              PSI_mutex_key *param_key_info_run_lock,
-              PSI_mutex_key *param_key_info_data_lock,
-              PSI_mutex_key *param_key_info_data_cond,
-              PSI_mutex_key *param_key_info_start_cond,
-              PSI_mutex_key *param_key_info_stop_cond
-#endif
-             );
-  virtual ~Master_info();
+  friend class Rpl_info_factory;
 
+public:
   /* the variables below are needed because we can change masters on the fly */
   char host[HOSTNAME_LENGTH+1];
   char user[USERNAME_LENGTH+1];
@@ -120,6 +112,8 @@ class Master_info : public Rpl_info
 
   bool shall_ignore_server_id(ulong s_id);
 
+  virtual ~Master_info();
+
 protected:
   char master_log_name[FN_REFLEN];
   my_off_t master_log_pos;
@@ -146,8 +140,18 @@ private:
   bool read_info(Rpl_info_handler *from);
   bool write_info(Rpl_info_handler *to, bool force);
 
-  Master_info& operator=(const Master_info& info);
+  Master_info(
+#ifdef HAVE_PSI_INTERFACE
+              PSI_mutex_key *param_key_info_run_lock,
+              PSI_mutex_key *param_key_info_data_lock,
+              PSI_mutex_key *param_key_info_data_cond,
+              PSI_mutex_key *param_key_info_start_cond,
+              PSI_mutex_key *param_key_info_stop_cond
+#endif
+             );
   Master_info(const Master_info& info);
+
+  Master_info& operator=(const Master_info& info);
 };
 int change_master_server_id_cmp(ulong *id1, ulong *id2);
 

=== modified file 'sql/rpl_reporting.cc'
--- a/sql/rpl_reporting.cc	2011-03-28 13:19:08 +0000
+++ b/sql/rpl_reporting.cc	2011-04-06 13:33:37 +0000
@@ -149,10 +149,11 @@ Slave_reporting_capability::report(logle
   va_end(args);
 
   /* If the msg string ends with '.', do not add a ',' it would be ugly */
-  report_function("Slave %s: %s%s Error_code: %d",
-                  m_thread_name, pbuff,
-                  (pbuff[0] && *(strend(pbuff)-1) == '.') ? "" : ",",
-                  err_code);
+  if (report_function)
+    report_function("Slave %s: %s%s Error_code: %d",
+                    m_thread_name, pbuff,
+                    (pbuff[0] && *(strend(pbuff)-1) == '.') ? "" : ",",
+                    err_code);
 #endif  
 }
 

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2011-03-10 10:08:09 +0000
+++ b/sql/rpl_rli.cc	2011-04-04 09:42:22 +0000
@@ -114,7 +114,7 @@ static inline int add_relay_log(Relay_lo
   if (!mysql_file_stat(key_file_relaylog,
                        linfo->log_file_name, &s, MYF(0)))
   {
-    sql_print_error("log %s listed in the index, but failed to stat",
+    sql_print_error("log %s listed in the index, but failed to stat.",
                     linfo->log_file_name);
     DBUG_RETURN(1);
   }
@@ -133,7 +133,7 @@ int Relay_log_info::count_relay_log_spac
   log_space_total= 0;
   if (relay_log.find_log_pos(&flinfo, NullS, 1))
   {
-    sql_print_error("Could not find first log while counting relay log space");
+    sql_print_error("Could not find first log while counting relay log space.");
     DBUG_RETURN(1);
   }
   do
@@ -1102,7 +1102,7 @@ int Relay_log_info::init_info()
   if (fn_format(pattern, PREFIX_SQL_LOAD, pattern, "",
                 MY_SAFE_PATH | MY_RETURN_REAL_PATH) == NullS)
   {
-    sql_print_error("Unable to use slave's temporary directory %s",
+    sql_print_error("Unable to use slave's temporary directory '%s'.",
                     slave_load_tmpdir);
     DBUG_RETURN(1);
   }
@@ -1130,7 +1130,7 @@ int Relay_log_info::init_info()
         opt_relay_logname[strlen(opt_relay_logname) - 1] == FN_LIBCHAR)
     {
       sql_print_error("Path '%s' is a directory name, please specify \
-a file name for --relay-log option", opt_relay_logname);
+a file name for --relay-log option.", opt_relay_logname);
       DBUG_RETURN(1);
     }
 
@@ -1141,7 +1141,7 @@ a file name for --relay-log option", opt
         == FN_LIBCHAR)
     {
       sql_print_error("Path '%s' is a directory name, please specify \
-a file name for --relay-log-index option", opt_relaylog_index_name);
+a file name for --relay-log-index option.", opt_relaylog_index_name);
       DBUG_RETURN(1);
     }
 
@@ -1179,7 +1179,7 @@ a file name for --relay-log-index option
                        (max_relay_log_size ? max_relay_log_size :
                         max_binlog_size), 1, TRUE))
     {
-      sql_print_error("Failed in open_log() called from Relay_log_info::init_info()");
+      sql_print_error("Failed in open_log() called from Relay_log_info::init_info().");
       DBUG_RETURN(1);
     }
   }
@@ -1230,7 +1230,7 @@ a file name for --relay-log-index option
                            &msg, 0))
     {
       char llbuf[22];
-      sql_print_error("Failed to open the relay log '%s' (relay_log_pos %s)",
+      sql_print_error("Failed to open the relay log '%s' (relay_log_pos %s).",
                       group_relay_log_name,
                       llstr(group_relay_log_pos, llbuf));
       error= 1;
@@ -1268,7 +1268,7 @@ a file name for --relay-log-index option
   DBUG_RETURN(error);
 
 err:
-  sql_print_error("%s", msg);
+  sql_print_error("%s.", msg);
   relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
   DBUG_RETURN(error);
 }
@@ -1391,7 +1391,7 @@ int Relay_log_info::flush_info(bool forc
   DBUG_RETURN(0);
 
 err:
-  sql_print_error("Error writing relay log configuration");
+  sql_print_error("Error writing relay log configuration.");
   DBUG_RETURN(1);
 }
 

=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h	2010-12-21 09:33:41 +0000
+++ b/sql/rpl_rli.h	2011-03-23 23:28:49 +0000
@@ -28,6 +28,7 @@
 
 struct RPL_TABLE_LIST;
 class Master_info;
+class Rpl_info_factory;
 extern uint sql_slave_skip_counter;
 
 /*******************************************************************************
@@ -104,6 +105,8 @@ tables along with the --relay-log-recove
 *******************************************************************************/
 class Relay_log_info : public Rpl_info
 {
+  friend class Rpl_info_factory;
+
 public:
   /**
      Flags for the state of the replication.
@@ -328,17 +331,6 @@ public:
   char slave_patternload_file[FN_REFLEN]; 
   size_t slave_patternload_file_size;  
 
-  Relay_log_info(bool is_slave_recovery
-#ifdef HAVE_PSI_INTERFACE
-                 ,PSI_mutex_key *param_key_info_run_lock,
-                 PSI_mutex_key *param_key_info_data_lock,
-                 PSI_mutex_key *param_key_info_data_cond,
-                 PSI_mutex_key *param_key_info_start_cond,
-                 PSI_mutex_key *param_key_info_stop_cond
-#endif
-                );
-  virtual ~Relay_log_info();
-
   /**
     Invalidates cached until_log_name and group_relay_log_name comparison
     result. Should be called after any update of group_realy_log_name if
@@ -585,8 +577,9 @@ public:
   void set_sql_delay(time_t _sql_delay) { sql_delay= _sql_delay; }
   time_t get_sql_delay_end() { return sql_delay_end; }
 
-private:
+  virtual ~Relay_log_info();
 
+private:
   /**
     Delay slave SQL thread by this amount, compared to master (in
     seconds). This is set with CHANGE MASTER TO MASTER_DELAY=X.
@@ -610,6 +603,7 @@ private:
   */
   time_t sql_delay_end;
 
+  uint32 m_flags;
   /*
     Before the MASTER_DELAY parameter was added (WL#344), relay_log.info
     had 4 lines. Now it has 5 lines.
@@ -619,10 +613,18 @@ private:
   bool read_info(Rpl_info_handler *from);
   bool write_info(Rpl_info_handler *to, bool force);
 
-  Relay_log_info& operator=(const Relay_log_info& info);
+  Relay_log_info(bool is_slave_recovery
+#ifdef HAVE_PSI_INTERFACE
+                 ,PSI_mutex_key *param_key_info_run_lock,
+                 PSI_mutex_key *param_key_info_data_lock,
+                 PSI_mutex_key *param_key_info_data_cond,
+                 PSI_mutex_key *param_key_info_start_cond,
+                 PSI_mutex_key *param_key_info_stop_cond
+#endif
+                );
   Relay_log_info(const Relay_log_info& info);
 
-  uint32 m_flags;
+  Relay_log_info& operator=(const Relay_log_info& info);
 };
 
 bool mysql_show_relaylog_events(THD* thd);

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2011-03-29 14:56:01 +0000
+++ b/sql/rpl_slave.cc	2011-04-04 10:06:13 +0000
@@ -141,8 +141,6 @@ failed read"
 };
 
 
-typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE;
-
 static int process_io_rotate(Master_info* mi, Rotate_log_event* rev);
 static int process_io_create_file(Master_info* mi, Create_file_log_event* cev);
 static bool wait_for_relay_log_space(Relay_log_info* rli);
@@ -3534,7 +3532,7 @@ pthread_handler_t handle_slave_sql(void
 
   Relay_log_info* rli = ((Master_info*)arg)->rli;
   const char *errmsg;
-
+ 
   // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
   my_thread_init();
   DBUG_ENTER("handle_slave_sql");
@@ -3596,6 +3594,20 @@ pthread_handler_t handle_slave_sql(void
   */
   rli->clear_error();
 
+  if (rli->update_is_transactional())
+  {
+    mysql_cond_broadcast(&rli->start_cond);
+    mysql_mutex_unlock(&rli->run_lock);
+    rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, 
+                "Error checking if the relay log repository is transactional.");
+    goto err;
+  }
+
+  if (!rli->is_transactional())
+    rli->report(WARNING_LEVEL, 0,
+    "If a crash happens this configuration does not guarantee that the relay "
+    "log info will be consistent");
+
   mysql_mutex_unlock(&rli->run_lock);
   mysql_cond_broadcast(&rli->start_cond);
 
@@ -5486,11 +5498,6 @@ bool rpl_master_erroneous_autoinc(THD *t
   return FALSE;
 }
 
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class I_List_iterator<i_string>;
-template class I_List_iterator<i_string_pair>;
-#endif
-
 /**
   a copy of active_mi->rli->slave_skip_counter, for showing in SHOW VARIABLES,
   INFORMATION_SCHEMA.GLOBAL_VARIABLES and @@sql_slave_skip_counter without

=== modified file 'sql/rpl_slave.h'
--- a/sql/rpl_slave.h	2011-03-28 13:19:08 +0000
+++ b/sql/rpl_slave.h	2011-04-04 10:06:13 +0000
@@ -16,6 +16,8 @@
 #ifndef RPL_SLAVE_H
 #define RPL_SLAVE_H
 
+typedef enum {SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE;
+
 /**
   MASTER_DELAY can be at most (1 << 31) - 1.
 */

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2011-03-25 14:35:13 +0000
+++ b/sql/share/errmsg-utf8.txt	2011-04-04 10:06:13 +0000
@@ -6495,3 +6495,6 @@ ER_TABLE_NEEDS_REBUILD
 
 WARN_OPTION_BELOW_LIMIT
   eng "The value of '%s' should be no less than the value of '%s'"
+
+ER_CHANGE_RPL_INFO_REPOSITORY_FAILURE
+  eng "Failure while changing the type of replication repository: %s."

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2011-03-23 22:51:19 +0000
+++ b/sql/sql_acl.cc	2011-04-04 08:47:25 +0000
@@ -7191,17 +7191,6 @@ bool sp_grant_privileges(THD *thd, const
 }
 
 
-/*****************************************************************************
-  Instantiate used templates
-*****************************************************************************/
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class List_iterator<LEX_COLUMN>;
-template class List_iterator<LEX_USER>;
-template class List<LEX_COLUMN>;
-template class List<LEX_USER>;
-#endif
-
 /**
   Validate if a user can proxy as another user
 

=== modified file 'sql/sql_base.h'
--- a/sql/sql_base.h	2011-03-07 09:23:36 +0000
+++ b/sql/sql_base.h	2011-04-12 11:40:17 +0000
@@ -149,16 +149,12 @@ bool open_new_frm(THD *thd, TABLE_SHARE
                   uint ha_open_flags, TABLE *outparam, TABLE_LIST *table_desc,
                   MEM_ROOT *mem_root);
 
-TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
-			    const char *table_name, bool link_in_list);
 bool get_key_map_from_key_list(key_map *map, TABLE *table,
                                List<String> *index_list);
 TABLE *open_table_uncached(THD *thd, const char *path, const char *db,
 			   const char *table_name,
                            bool add_to_temporary_tables_list);
 TABLE *find_locked_table(TABLE *list, const char *db, const char *table_name);
-TABLE *find_write_locked_table(TABLE *list, const char *db,
-                               const char *table_name);
 thr_lock_type read_lock_type_for_table(THD *thd,
                                        Query_tables_list *prelocking_ctx,
                                        TABLE_LIST *table_list);
@@ -256,7 +252,6 @@ TABLE *open_n_lock_single_table(THD *thd
                                 Prelocking_strategy *prelocking_strategy);
 bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags);
 bool lock_tables(THD *thd, TABLE_LIST *tables, uint counter, uint flags);
-int decide_logging_format(THD *thd, TABLE_LIST *tables);
 void free_io_cache(TABLE *entry);
 void intern_close_table(TABLE *entry);
 bool close_thread_table(THD *thd, TABLE **table_ptr);

=== modified file 'sql/sql_binlog.cc'
--- a/sql/sql_binlog.cc	2010-12-02 13:44:21 +0000
+++ b/sql/sql_binlog.cc	2011-03-23 23:28:49 +0000
@@ -158,7 +158,7 @@ void mysql_client_binlog_statement(THD*
   Relay_log_info *rli= thd->rli_fake;
   if (!rli)
   {
-    if ((rli= Rpl_info_factory::create_rli(RLI_REPOSITORY_FILE, FALSE)))
+    if ((rli= Rpl_info_factory::create_rli(INFO_REPOSITORY_FILE, FALSE)))
     {
       thd->rli_fake= rli;
       rli->info_thd= thd;

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-03-24 08:00:03 +0000
+++ b/sql/sql_class.cc	2011-04-04 08:47:25 +0000
@@ -67,23 +67,6 @@ char empty_c_string[1]= {0};    /* used
 
 const char * const THD::DEFAULT_WHERE= "field list";
 
-
-/*****************************************************************************
-** Instansiate templates
-*****************************************************************************/
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-/* Used templates */
-template class List<Key>;
-template class List_iterator<Key>;
-template class List<Key_part_spec>;
-template class List_iterator<Key_part_spec>;
-template class List<Alter_drop>;
-template class List_iterator<Alter_drop>;
-template class List<Alter_column>;
-template class List_iterator<Alter_column>;
-#endif
-
 /****************************************************************************
 ** User variables
 ****************************************************************************/

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-03-24 08:00:03 +0000
+++ b/sql/sql_class.h	2011-04-04 10:06:13 +0000
@@ -1193,7 +1193,8 @@ enum enum_thread_type
   SYSTEM_THREAD_SLAVE_SQL= 4,
   SYSTEM_THREAD_NDBCLUSTER_BINLOG= 8,
   SYSTEM_THREAD_EVENT_SCHEDULER= 16,
-  SYSTEM_THREAD_EVENT_WORKER= 32
+  SYSTEM_THREAD_EVENT_WORKER= 32,
+  SYSTEM_THREAD_INFO_REPOSITORY= 64
 };
 
 inline char const *
@@ -1209,6 +1210,7 @@ show_system_thread(enum_thread_type thre
     RETURN_NAME_AS_STRING(SYSTEM_THREAD_NDBCLUSTER_BINLOG);
     RETURN_NAME_AS_STRING(SYSTEM_THREAD_EVENT_SCHEDULER);
     RETURN_NAME_AS_STRING(SYSTEM_THREAD_EVENT_WORKER);
+    RETURN_NAME_AS_STRING(SYSTEM_THREAD_INFO_REPOSITORY);
   default:
     sprintf(buf, "<UNKNOWN SYSTEM THREAD: %d>", thread);
     return buf;

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2011-02-15 17:14:15 +0000
+++ b/sql/sql_insert.cc	2011-04-04 08:47:25 +0000
@@ -4138,17 +4138,3 @@ void select_create::abort_result_set()
   }
   DBUG_VOID_RETURN;
 }
-
-
-/*****************************************************************************
-  Instansiate templates
-*****************************************************************************/
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class List_iterator_fast<List_item>;
-#ifndef EMBEDDED_LIBRARY
-template class I_List<Delayed_insert>;
-template class I_List_iterator<Delayed_insert>;
-template class I_List<delayed_row>;
-#endif /* EMBEDDED_LIBRARY */
-#endif /* HAVE_EXPLICIT_TEMPLATE_INSTANTIATION */

=== modified file 'sql/sql_join_cache.cc'
--- a/sql/sql_join_cache.cc	2011-03-22 11:44:40 +0000
+++ b/sql/sql_join_cache.cc	2011-04-07 14:24:47 +0000
@@ -1777,12 +1777,9 @@ enum_nested_loop_state JOIN_CACHE_BNL::j
   if (skip_last)     
     put_record();     
  
-  if (join_tab->use_quick == 2 && join_tab->select->quick)
-  { 
+  if (join_tab->use_quick == QS_DYNAMIC_RANGE && join_tab->select->quick)
     /* A dynamic range access was used last. Clean up after it */
-    delete join_tab->select->quick;
-    join_tab->select->quick= 0;
-  }
+    join_tab->select->set_quick(NULL);
 
   for (tab= join->join_tab; tab != join_tab ; tab++)
   {

=== modified file 'sql/sql_plist.h'
--- a/sql/sql_plist.h	2010-07-02 18:15:21 +0000
+++ b/sql/sql_plist.h	2011-04-13 11:31:44 +0000
@@ -95,6 +95,7 @@ public:
     *last= a;
     *B::prev_ptr(a)= last;
     I::set_last(B::next_ptr(a));
+    C::inc();
   }
   inline void insert_after(T *pos, T *a)
   {
@@ -112,6 +113,7 @@ public:
       }
       else
         I::set_last(B::next_ptr(a));
+      C::inc();
     }
   }
   inline void remove(T *a)
@@ -187,6 +189,20 @@ public:
 };
 
 
+/**
+  Hook class which via its methods specifies which members
+  of T should be used for participating in a intrusive list.
+*/
+
+template <typename T, T* T::*next, T** T::*prev>
+struct I_P_List_adapter
+{
+  static inline T **next_ptr(T *el) { return &(el->*next); }
+
+  static inline T ***prev_ptr(T *el) { return &(el->*prev); }
+};
+
+
 /**
   Element counting policy class for I_P_List to be used in
   cases when no element counting should be done.

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-04-01 14:04:52 +0000
+++ b/sql/sql_select.cc	2011-04-07 14:24:47 +0000
@@ -11253,10 +11253,7 @@ make_join_readinfo(JOIN *join, ulonglong
     case JT_REF_OR_NULL:
     case JT_REF:
       if (tab->select)
-      {
-	delete tab->select->quick;
-	tab->select->quick=0;
-      }
+        tab->select->set_quick(NULL);
       delete tab->quick;
       tab->quick=0;
       /* fall through */
@@ -12015,13 +12012,6 @@ public:
   COND_CMP(Item *a,Item_func *b) :and_level(a),cmp_func(b) {}
 };
 
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class I_List<COND_CMP>;
-template class I_List_iterator<COND_CMP>;
-template class List<Item_func_match>;
-template class List_iterator<Item_func_match>;
-#endif
-
 
 /**
   Find the multiple equality predicate containing a field.
@@ -18428,8 +18418,7 @@ int read_first_record_seq(JOIN_TAB *tab)
 static int
 test_if_quick_select(JOIN_TAB *tab)
 {
-  delete tab->select->quick;
-  tab->select->quick=0;
+  tab->select->set_quick(NULL);
   return tab->select->test_quick_select(tab->join->thd, 
                                         tab->keys,
                                         0,          // empty table map
@@ -20348,10 +20337,8 @@ skipped_filesort:
 use_filesort:
   // Restore original save_quick
   if (select && select->quick != save_quick)
-  {
-    delete select->quick;
-    select->quick= save_quick;
-  }
+    select->set_quick(save_quick);
+
   if (orig_select_cond_saved)
     tab->set_cond(orig_select_cond, __LINE__);
   DBUG_RETURN(0);

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-03-28 08:10:39 +0000
+++ b/sql/sql_show.cc	2011-04-06 15:21:05 +0000
@@ -1751,10 +1751,6 @@ public:
   CSET_STRING query_string;
 };
 
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class I_List<thread_info>;
-#endif
-
 static const char *thread_state_info(THD *tmp)
 {
 #ifndef EMBEDDED_LIBRARY
@@ -3561,6 +3557,12 @@ int get_all_tables(THD *thd, TABLE_LIST
   it.rewind(); /* To get access to new elements in basis list */
   while ((db_name= it++))
   {
+    LEX_STRING orig_db_name;
+
+    /* db_name can be changed in make_table_list() func */
+    if (!thd->make_lex_string(&orig_db_name, db_name->str,
+                              db_name->length, FALSE))
+      goto err;
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
     if (!(check_access(thd, SELECT_ACL, db_name->str,
                        &thd->col_access, NULL, 0, 1) ||
@@ -3625,17 +3627,13 @@ int get_all_tables(THD *thd, TABLE_LIST
             }
 
             int res;
-            LEX_STRING tmp_lex_string, orig_db_name;
+            LEX_STRING tmp_lex_string;
             /*
               Set the parent lex of 'sel' because it is needed by
               sel.init_query() which is called inside make_table_list.
             */
             thd->no_warnings_for_error= 1;
             sel.parent_lex= lex;
-            /* db_name can be changed in make_table_list() func */
-            if (!thd->make_lex_string(&orig_db_name, db_name->str,
-                                      db_name->length, FALSE))
-              goto err;
             if (make_table_list(thd, &sel, db_name, table_name))
               goto err;
             TABLE_LIST *show_table_list= sel.table_list.first;
@@ -7522,11 +7520,6 @@ ST_SCHEMA_TABLE schema_tables[]=
 };
 
 
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class List_iterator_fast<char>;
-template class List<char>;
-#endif
-
 int initialize_schema_table(st_plugin_int *plugin)
 {
   ST_SCHEMA_TABLE *schema_table;

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-03-30 11:43:32 +0000
+++ b/sql/sql_table.cc	2011-04-13 07:13:13 +0000
@@ -6861,15 +6861,15 @@ bool mysql_alter_table(THD *thd,char *ne
       NO need to tamper with MERGE tables. The real open is done later.
     */
     Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN);
-    TABLE *t_table;
+    TABLE_LIST temp_table_list;
+    TABLE_LIST *t_table_list;
     if (new_name != table_name || new_db != db)
     {
-      table_list->alias= new_name;
-      table_list->table_name= new_name;
-      table_list->table_name_length= strlen(new_name);
-      table_list->db= new_db;
-      table_list->db_length= strlen(new_db);
-      table_list->mdl_request.ticket= target_mdl_request.ticket;
+      temp_table_list.init_one_table(new_db, strlen(new_db),
+                                     new_name, strlen(new_name),
+                                     new_name, TL_READ_NO_INSERT);
+      temp_table_list.mdl_request.ticket= target_mdl_request.ticket;
+      t_table_list= &temp_table_list;
     }
     else
     {
@@ -6879,20 +6879,21 @@ bool mysql_alter_table(THD *thd,char *ne
         to request the lock.
       */
       table_list->mdl_request.ticket= mdl_ticket;
+      t_table_list= table_list;
     }
-    if (open_table(thd, table_list, thd->mem_root, &ot_ctx))
+    if (open_table(thd, t_table_list, thd->mem_root, &ot_ctx))
     {
       goto err_with_mdl;
     }
-    t_table= table_list->table;
 
     /* Tell the handler that a new frm file is in place. */
-    error= t_table->file->ha_create_handler_files(path, NULL, CHF_INDEX_FLAG,
-                                               create_info);
+    error= t_table_list->table->file->ha_create_handler_files(path, NULL,
+                                                              CHF_INDEX_FLAG,
+                                                              create_info);
 
-    DBUG_ASSERT(thd->open_tables == t_table);
+    DBUG_ASSERT(thd->open_tables == t_table_list->table);
     close_thread_table(thd, &thd->open_tables);
-    table_list->table= 0;
+    t_table_list->table= NULL;
 
     if (error)
       goto err_with_mdl;

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2011-04-01 14:04:52 +0000
+++ b/sql/sql_update.cc	2011-04-07 14:24:47 +0000
@@ -577,11 +577,10 @@ int mysql_update(THD *thd,
       /* Change select to use tempfile */
       if (select)
       {
-	delete select->quick;
-	if (select->free_cond)
-	  delete select->cond;
-	select->quick=0;
-	select->cond=0;
+        select->set_quick(NULL);
+        if (select->free_cond)
+          delete select->cond;
+        select->cond= NULL;
       }
       else
       {

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2011-03-28 20:15:26 +0000
+++ b/sql/sys_vars.cc	2011-04-14 01:36:24 +0000
@@ -36,6 +36,8 @@
 #include <thr_alarm.h>
 #include "rpl_slave.h"
 #include "rpl_mi.h"
+#include "rpl_rli.h"
+#include "rpl_slave.h"
 #include "rpl_info_factory.h"
 #include "transaction.h"
 #include "mysqld.h"
@@ -506,6 +508,73 @@ static Sys_var_mybool Sys_binlog_direct(
        CMD_LINE(OPT_ARG), DEFAULT(FALSE),
        NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(binlog_direct_check));
 
+static bool repository_check(sys_var *self, THD *thd, set_var *var, SLAVE_THD_TYPE thread_mask)
+{
+  bool ret= FALSE;
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+  if (!(thd->security_ctx->master_access & SUPER_ACL))
+  {
+    my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
+    return TRUE;
+  }
+#endif
+#ifdef HAVE_REPLICATION
+  int running= 0;
+  const char *msg= NULL;
+  mysql_mutex_lock(&LOCK_active_mi);
+  if (active_mi)
+  {
+    lock_slave_threads(active_mi);
+    init_thread_mask(&running, active_mi, FALSE);
+    if(!running)
+    {
+      switch (thread_mask)
+      {
+        case SLAVE_THD_IO:
+        if (Rpl_info_factory::change_mi_repository(active_mi,
+                                                   var->save_result.ulonglong_value,
+                                                   &msg))
+        {
+          ret= TRUE;
+          my_error(ER_CHANGE_RPL_INFO_REPOSITORY_FAILURE, MYF(0), msg);
+        }
+        break;
+        case SLAVE_THD_SQL:
+          if (Rpl_info_factory::change_rli_repository(active_mi->rli,
+                                                      var->save_result.ulonglong_value,
+                                                      &msg))
+          {
+            ret= TRUE;
+            my_error(ER_CHANGE_RPL_INFO_REPOSITORY_FAILURE, MYF(0), msg);
+          }
+        break;
+        default:
+          assert(0);
+        break;
+      }
+    }
+    else
+    {
+      ret= TRUE;
+      my_error(ER_SLAVE_MUST_STOP, MYF(0));
+    }
+    unlock_slave_threads(active_mi);
+  }
+  mysql_mutex_unlock(&LOCK_active_mi);
+#endif
+  return ret;
+}
+
+static bool relay_log_info_repository_check(sys_var *self, THD *thd, set_var *var)
+{
+  return repository_check(self, thd, var, SLAVE_THD_SQL);
+}
+
+static bool master_info_repository_check(sys_var *self, THD *thd, set_var *var)
+{
+  return repository_check(self, thd, var, SLAVE_THD_IO);
+}
+
 static const char *repository_names[]=
 {
   "FILE", "TABLE", 0
@@ -515,15 +584,19 @@ ulong opt_mi_repository_id;
 static Sys_var_enum Sys_mi_repository(
        "master_info_repository",
        "Defines the type of the repository for the master information."
-       , READ_ONLY GLOBAL_VAR(opt_mi_repository_id), CMD_LINE(REQUIRED_ARG),
-       repository_names, DEFAULT(0));
+       ,GLOBAL_VAR(opt_mi_repository_id), CMD_LINE(REQUIRED_ARG),
+       repository_names, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG,
+       ON_CHECK(master_info_repository_check),
+       ON_UPDATE(0));
 
 ulong opt_rli_repository_id;
 static Sys_var_enum Sys_rli_repository(
        "relay_log_info_repository",
        "Defines the type of the repository for the relay log information."
-       , READ_ONLY GLOBAL_VAR(opt_rli_repository_id), CMD_LINE(REQUIRED_ARG),
-       repository_names, DEFAULT(0));
+       ,GLOBAL_VAR(opt_rli_repository_id), CMD_LINE(REQUIRED_ARG),
+       repository_names, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG,
+       ON_CHECK(relay_log_info_repository_check),
+       ON_UPDATE(0));
 
 static Sys_var_mybool Sys_binlog_rows_query(
        "binlog_rows_query_log_events",
@@ -1363,16 +1436,6 @@ static Sys_var_ulong Sys_max_length_for_
        SESSION_VAR(max_length_for_sort_data), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(4, 8192*1024L), DEFAULT(1024), BLOCK_SIZE(1));
 
-static Sys_var_ulong Sys_max_long_data_size(
-       "max_long_data_size",
-       "The maximum BLOB length to send to server from "
-       "mysql_send_long_data API. Deprecated option; "
-       "use max_allowed_packet instead.",
-       READ_ONLY GLOBAL_VAR(max_long_data_size),
-       CMD_LINE(REQUIRED_ARG, OPT_MAX_LONG_DATA_SIZE),
-       VALID_RANGE(1024, UINT_MAX32), DEFAULT(1024*1024),
-       BLOCK_SIZE(1));
-
 static PolyLock_mutex PLock_prepared_stmt_count(&LOCK_prepared_stmt_count);
 static Sys_var_ulong Sys_max_prepared_stmt_count(
        "max_prepared_stmt_count",

=== modified file 'sql/sys_vars.h'
--- a/sql/sys_vars.h	2011-03-09 20:54:55 +0000
+++ b/sql/sys_vars.h	2011-04-04 08:47:25 +0000
@@ -1725,16 +1725,3 @@ public:
   virtual bool global_update(THD *thd, set_var *var);
 };
 
-/****************************************************************************
-  Used templates
-****************************************************************************/
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class List<set_var_base>;
-template class List_iterator_fast<set_var_base>;
-template class Sys_var_unsigned<uint, GET_UINT, SHOW_INT>;
-template class Sys_var_unsigned<ulong, GET_ULONG, SHOW_LONG>;
-template class Sys_var_unsigned<ha_rows, GET_HA_ROWS, SHOW_HA_ROWS>;
-template class Sys_var_unsigned<ulonglong, GET_ULL, SHOW_LONGLONG>;
-#endif
-

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2011-03-28 08:10:39 +0000
+++ b/sql/table.cc	2011-04-04 08:47:25 +0000
@@ -5488,13 +5488,3 @@ bool is_simple_order(ORDER *order)
   }
   return TRUE;
 }
-
-
-/*****************************************************************************
-** Instansiate templates
-*****************************************************************************/
-
-#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
-template class List<String>;
-template class List_iterator<String>;
-#endif

=== modified file 'sql/table.h'
--- a/sql/table.h	2011-04-01 14:04:52 +0000
+++ b/sql/table.h	2011-04-04 10:06:13 +0000
@@ -2203,6 +2203,10 @@ extern LEX_STRING SLOW_LOG_NAME;
 extern LEX_STRING INFORMATION_SCHEMA_NAME;
 extern LEX_STRING MYSQL_SCHEMA_NAME;
 
+/* replication's tables */
+extern LEX_STRING RLI_INFO_NAME;
+extern LEX_STRING MI_INFO_NAME;
+
 inline bool is_infoschema_db(const char *name, size_t len)
 {
   return (INFORMATION_SCHEMA_NAME.length == len &&

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2011-03-30 07:34:34 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2011-04-13 18:43:08 +0000
@@ -2826,10 +2826,8 @@ innobase_alter_table_flags(
 	uint	flags)
 {
 	return(HA_INPLACE_ADD_INDEX_NO_READ_WRITE
-		| HA_INPLACE_ADD_INDEX_NO_WRITE
 		| HA_INPLACE_DROP_INDEX_NO_READ_WRITE
 		| HA_INPLACE_ADD_UNIQUE_INDEX_NO_READ_WRITE
-		| HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE
 		| HA_INPLACE_DROP_UNIQUE_INDEX_NO_READ_WRITE
 		| HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE);
 }

=== modified file 'storage/innobase/handler/handler0alter.cc'
--- a/storage/innobase/handler/handler0alter.cc	2011-02-14 10:26:00 +0000
+++ b/storage/innobase/handler/handler0alter.cc	2011-03-30 12:20:45 +0000
@@ -638,7 +638,7 @@ innobase_add_index_cleanup(
 {
 	mem_heap_free(heap);
 
-	trx_general_rollback_for_mysql(trx, NULL);
+	trx_rollback_to_savepoint(trx, NULL);
 
 	ut_a(trx != prebuilt->trx);
 

=== modified file 'storage/innobase/include/sync0arr.h'
--- a/storage/innobase/include/sync0arr.h	2010-07-16 21:00:50 +0000
+++ b/storage/innobase/include/sync0arr.h	2011-03-30 12:02:53 +0000
@@ -115,8 +115,11 @@ Prints warnings of long semaphore waits
 @return	TRUE if fatal semaphore wait threshold was exceeded */
 UNIV_INTERN
 ibool
-sync_array_print_long_waits(void);
-/*=============================*/
+sync_array_print_long_waits(
+/*========================*/
+	os_thread_id_t*	waiter,	/*!< out: longest waiting thread */
+	const void**	sema)	/*!< out: longest-waited-for semaphore */
+	__attribute__((nonnull));
 /********************************************************************//**
 Validates the integrity of the wait array. Checks
 that the number of reserved cells equals the count variable. */

=== modified file 'storage/innobase/include/trx0roll.h'
--- a/storage/innobase/include/trx0roll.h	2011-01-24 10:28:28 +0000
+++ b/storage/innobase/include/trx0roll.h	2011-03-30 12:20:45 +0000
@@ -159,12 +159,12 @@ trx_rollback_last_sql_stat_for_mysql(
 /*=================================*/
 	trx_t*	trx);	/*!< in/out: transaction */
 /*******************************************************************//**
-Rollback a transaction used in MySQL.
+Rollback a transaction to a given savepoint or do a complete rollback.
 @return	error code or DB_SUCCESS */
 UNIV_INTERN
 int
-trx_general_rollback_for_mysql(
-/*===========================*/
+trx_rollback_to_savepoint(
+/*======================*/
 	trx_t*		trx,	/*!< in: transaction handle */
 	trx_savept_t*	savept);/*!< in: pointer to savepoint undo number, if
 				partial rollback requested, or NULL for

=== modified file 'storage/innobase/row/row0merge.c'
--- a/storage/innobase/row/row0merge.c	2011-03-18 15:48:14 +0000
+++ b/storage/innobase/row/row0merge.c	2011-03-30 12:20:45 +0000
@@ -2461,7 +2461,7 @@ row_merge_rename_tables(
 	if (err != DB_SUCCESS) {
 err_exit:
 		trx->error_state = DB_SUCCESS;
-		trx_general_rollback_for_mysql(trx, NULL);
+		trx_rollback_to_savepoint(trx, NULL);
 		trx->error_state = DB_SUCCESS;
 	}
 

=== modified file 'storage/innobase/row/row0mysql.c'
--- a/storage/innobase/row/row0mysql.c	2011-03-18 15:48:14 +0000
+++ b/storage/innobase/row/row0mysql.c	2011-03-30 12:20:45 +0000
@@ -579,7 +579,7 @@ handle_new_error:
 	switch (err) {
 	case DB_LOCK_WAIT_TIMEOUT:
 		if (row_rollback_on_timeout) {
-			trx_general_rollback_for_mysql(trx, NULL);
+			trx_rollback_to_savepoint(trx, NULL);
 			break;
 		}
 		/* fall through */
@@ -596,7 +596,7 @@ handle_new_error:
 			/* Roll back the latest, possibly incomplete
 			insertion or update */
 
-			trx_general_rollback_for_mysql(trx, savept);
+			trx_rollback_to_savepoint(trx, savept);
 		}
 		/* MySQL will roll back the latest SQL statement */
 		break;
@@ -618,7 +618,7 @@ handle_new_error:
 		/* Roll back the whole transaction; this resolution was added
 		to version 3.23.43 */
 
-		trx_general_rollback_for_mysql(trx, NULL);
+		trx_rollback_to_savepoint(trx, NULL);
 		break;
 
 	case DB_MUST_GET_MORE_FILE_SPACE:
@@ -1941,7 +1941,7 @@ err_exit:
 		break;
 	case DB_OUT_OF_FILE_SPACE:
 		trx->error_state = DB_SUCCESS;
-		trx_general_rollback_for_mysql(trx, NULL);
+		trx_rollback_to_savepoint(trx, NULL);
 
 		ut_print_timestamp(stderr);
 		fputs("  InnoDB: Warning: cannot create table ",
@@ -1971,7 +1971,7 @@ err_exit:
 		table already exists */
 
 		trx->error_state = DB_SUCCESS;
-		trx_general_rollback_for_mysql(trx, NULL);
+		trx_rollback_to_savepoint(trx, NULL);
 		dict_mem_table_free(table);
 		break;
 	}
@@ -2095,7 +2095,7 @@ error_handling:
 
 		trx->error_state = DB_SUCCESS;
 
-		trx_general_rollback_for_mysql(trx, NULL);
+		trx_rollback_to_savepoint(trx, NULL);
 
 		row_drop_table_for_mysql(table_name, trx, FALSE);
 
@@ -2164,7 +2164,7 @@ row_table_add_foreign_constraints(
 
 		trx->error_state = DB_SUCCESS;
 
-		trx_general_rollback_for_mysql(trx, NULL);
+		trx_rollback_to_savepoint(trx, NULL);
 
 		row_drop_table_for_mysql(name, trx, FALSE);
 
@@ -2533,7 +2533,7 @@ row_discard_tablespace_for_mysql(
 
 	if (err != DB_SUCCESS) {
 		trx->error_state = DB_SUCCESS;
-		trx_general_rollback_for_mysql(trx, NULL);
+		trx_rollback_to_savepoint(trx, NULL);
 		trx->error_state = DB_SUCCESS;
 	} else {
 		dict_table_change_id_in_cache(table, new_id);
@@ -2542,7 +2542,7 @@ row_discard_tablespace_for_mysql(
 
 		if (!success) {
 			trx->error_state = DB_SUCCESS;
-			trx_general_rollback_for_mysql(trx, NULL);
+			trx_rollback_to_savepoint(trx, NULL);
 			trx->error_state = DB_SUCCESS;
 
 			err = DB_ERROR;
@@ -3028,7 +3028,7 @@ next_rec:
 
 	if (err != DB_SUCCESS) {
 		trx->error_state = DB_SUCCESS;
-		trx_general_rollback_for_mysql(trx, NULL);
+		trx_rollback_to_savepoint(trx, NULL);
 		trx->error_state = DB_SUCCESS;
 		ut_print_timestamp(stderr);
 		fputs("  InnoDB: Unable to assign a new identifier to table ",
@@ -3494,7 +3494,7 @@ check_next_foreign:
 		fprintf(stderr, ".\n");
 
 		trx->error_state = DB_SUCCESS;
-		trx_general_rollback_for_mysql(trx, NULL);
+		trx_rollback_to_savepoint(trx, NULL);
 		trx->error_state = DB_SUCCESS;
 	}
 
@@ -4085,7 +4085,7 @@ end:
 			      "InnoDB: succeed.\n", stderr);
 		}
 		trx->error_state = DB_SUCCESS;
-		trx_general_rollback_for_mysql(trx, NULL);
+		trx_rollback_to_savepoint(trx, NULL);
 		trx->error_state = DB_SUCCESS;
 	} else {
 		/* The following call will also rename the .ibd data file if
@@ -4094,7 +4094,7 @@ end:
 		if (!dict_table_rename_in_cache(table, new_name,
 						!new_is_tmp)) {
 			trx->error_state = DB_SUCCESS;
-			trx_general_rollback_for_mysql(trx, NULL);
+			trx_rollback_to_savepoint(trx, NULL);
 			trx->error_state = DB_SUCCESS;
 			goto funct_exit;
 		}
@@ -4134,7 +4134,7 @@ end:
 			ut_a(dict_table_rename_in_cache(table,
 							old_name, FALSE));
 			trx->error_state = DB_SUCCESS;
-			trx_general_rollback_for_mysql(trx, NULL);
+			trx_rollback_to_savepoint(trx, NULL);
 			trx->error_state = DB_SUCCESS;
 		}
 	}

=== modified file 'storage/innobase/srv/srv0srv.c'
--- a/storage/innobase/srv/srv0srv.c	2011-03-24 12:24:08 +0000
+++ b/storage/innobase/srv/srv0srv.c	2011-03-30 12:02:53 +0000
@@ -1867,6 +1867,12 @@ srv_error_monitor_thread(
 	lsn_t		old_lsn;
 	lsn_t		new_lsn;
 	ib_int64_t	sig_count;
+	/* longest waiting thread for a semaphore */
+	os_thread_id_t	waiter		= os_thread_get_curr_id();
+	os_thread_id_t	old_waiter	= waiter;
+	/* the semaphore that is being waited for */
+	const void*	sema		= NULL;
+	const void*	old_sema	= NULL;
 
 	old_lsn = srv_start_lsn;
 
@@ -1919,7 +1925,8 @@ loop:
 
 	sync_arr_wake_threads_if_sema_free();
 
-	if (sync_array_print_long_waits()) {
+	if (sync_array_print_long_waits(&waiter, &sema)
+	    && sema == old_sema && os_thread_eq(waiter, old_waiter)) {
 		fatal_cnt++;
 		if (fatal_cnt > 10) {
 
@@ -1934,6 +1941,8 @@ loop:
 		}
 	} else {
 		fatal_cnt = 0;
+		old_waiter = waiter;
+		old_sema = sema;
 	}
 
 	/* Flush stderr so that a database user gets the output

=== modified file 'storage/innobase/sync/sync0arr.c'
--- a/storage/innobase/sync/sync0arr.c	2011-02-25 09:27:27 +0000
+++ b/storage/innobase/sync/sync0arr.c	2011-03-30 12:02:53 +0000
@@ -915,8 +915,10 @@ Prints warnings of long semaphore waits
 @return	TRUE if fatal semaphore wait threshold was exceeded */
 UNIV_INTERN
 ibool
-sync_array_print_long_waits(void)
-/*=============================*/
+sync_array_print_long_waits(
+/*========================*/
+	os_thread_id_t*	waiter,	/*!< out: longest waiting thread */
+	const void**	sema)	/*!< out: longest-waited-for semaphore */
 {
 	sync_cell_t*	cell;
 	ibool		old_val;
@@ -924,6 +926,7 @@ sync_array_print_long_waits(void)
 	ulint		i;
 	ulint		fatal_timeout = srv_fatal_semaphore_wait_threshold;
 	ibool		fatal = FALSE;
+	double		longest_diff = 0;
 
 #ifdef UNIV_DEBUG_VALGRIND
 	/* Increase the timeouts if running under valgrind because it executes
@@ -939,22 +942,36 @@ sync_array_print_long_waits(void)
 
 	for (i = 0; i < sync_primary_wait_array->n_cells; i++) {
 
+		double	diff;
+		void*	wait_object;
+
 		cell = sync_array_get_nth_cell(sync_primary_wait_array, i);
 
-		if (cell->wait_object != NULL && cell->waiting
-		    && difftime(time(NULL), cell->reservation_time)
-		    > SYNC_ARRAY_TIMEOUT) {
+		wait_object = cell->wait_object;
+
+		if (wait_object == NULL || !cell->waiting) {
+
+			continue;
+		}
+
+		diff = difftime(time(NULL), cell->reservation_time);
+
+		if (diff > SYNC_ARRAY_TIMEOUT) {
 			fputs("InnoDB: Warning: a long semaphore wait:\n",
 			      stderr);
 			sync_array_cell_print(stderr, cell);
 			noticed = TRUE;
 		}
 
-		if (cell->wait_object != NULL && cell->waiting
-		    && difftime(time(NULL), cell->reservation_time)
-		    > fatal_timeout) {
+		if (diff > fatal_timeout) {
 			fatal = TRUE;
 		}
+
+		if (diff > longest_diff) {
+			longest_diff = diff;
+			*sema = wait_object;
+			*waiter = cell->thread;
+		}
 	}
 
 	if (noticed) {

=== modified file 'storage/innobase/trx/trx0roll.c'
--- a/storage/innobase/trx/trx0roll.c	2011-02-17 14:06:09 +0000
+++ b/storage/innobase/trx/trx0roll.c	2011-03-30 12:20:45 +0000
@@ -72,8 +72,8 @@ trx_rollback_finish(
 Rollback a transaction used in MySQL. */
 static
 void
-trx_general_rollback_for_mysql_low(
-/*===============================*/
+trx_rollback_to_savepoint_low(
+/*==========================*/
 	trx_t*		trx,	/*!< in: transaction handle */
 	trx_savept_t*	savept)	/*!< in: pointer to savepoint undo number, if
 				partial rollback requested, or NULL for
@@ -122,12 +122,12 @@ trx_general_rollback_for_mysql_low(
 }
 
 /*******************************************************************//**
-Rollback a transaction used in MySQL.
+Rollback a transaction to a given savepoint or do a complete rollback.
 @return	error code or DB_SUCCESS */
 UNIV_INTERN
 int
-trx_general_rollback_for_mysql(
-/*===========================*/
+trx_rollback_to_savepoint(
+/*======================*/
 	trx_t*		trx,	/*!< in: transaction handle */
 	trx_savept_t*	savept)	/*!< in: pointer to savepoint undo number, if
 				partial rollback requested, or NULL for
@@ -142,7 +142,7 @@ trx_general_rollback_for_mysql(
 
 	trx_start_if_not_started_xa(trx);
 
-	trx_general_rollback_for_mysql_low(trx, savept);
+	trx_rollback_to_savepoint_low(trx, savept);
 
 	/* Tell Innobase server that there might be work for
 	utility threads: */
@@ -185,7 +185,7 @@ trx_rollback_for_mysql(
 		object, and we set a dummy session that we use for all MySQL
 		transactions. */
 
-		trx_general_rollback_for_mysql_low(trx, NULL);
+		trx_rollback_to_savepoint_low(trx, NULL);
 
 		trx->op_info = "";
 
@@ -227,7 +227,7 @@ trx_rollback_last_sql_stat_for_mysql(
 
 		trx->op_info = "rollback of SQL statement";
 
-		err = trx_general_rollback_for_mysql(
+		err = trx_rollback_to_savepoint(
 			trx, &trx->last_sql_stat_start);
 
 		/* The following call should not be needed,
@@ -316,10 +316,10 @@ the row, these locks are naturally relea
 were set after this savepoint are deleted.
 @return if no savepoint of the name found then DB_NO_SAVEPOINT,
 otherwise DB_SUCCESS */
-UNIV_INTERN
+static
 ulint
-trx_rollback_to_savepoint_low(
-/*==========================*/
+trx_rollback_to_savepoint_for_mysql_low(
+/*====================================*/
 	trx_t*			trx,	/*!< in/out: transaction */
 	trx_named_savept_t*	savep,	/*!< in/out: savepoint */
 	ib_int64_t*		mysql_binlog_cache_pos)
@@ -344,7 +344,7 @@ trx_rollback_to_savepoint_low(
 
 	trx->op_info = "rollback to a savepoint";
 
-	err = trx_general_rollback_for_mysql(trx, &savep->savept);
+	err = trx_rollback_to_savepoint(trx, &savep->savept);
 
 	/* Store the current undo_no of the transaction so that
 	we know where to roll back if we have to roll back the
@@ -401,8 +401,8 @@ trx_rollback_to_savepoint_for_mysql(
 		fputs(" though it is not started\n", stderr);
 		return(DB_ERROR);
 	case TRX_STATE_ACTIVE:
-		return(trx_rollback_to_savepoint_low(trx, savep,
-						     mysql_binlog_cache_pos));
+		return(trx_rollback_to_savepoint_for_mysql_low(
+				trx, savep, mysql_binlog_cache_pos));
 	case TRX_STATE_PREPARED:
 	case TRX_STATE_COMMITTED_IN_MEMORY:
 		/* The savepoint rollback is only allowed on an ACTIVE

=== modified file 'storage/perfschema/ha_perfschema.h'
--- a/storage/perfschema/ha_perfschema.h	2011-03-22 11:44:40 +0000
+++ b/storage/perfschema/ha_perfschema.h	2011-04-04 14:34:42 +0000
@@ -28,12 +28,18 @@
 */
 struct PFS_engine_table_share;
 class PFS_engine_table;
+/** Name of the performance schema engine. */
 extern const char *pfs_engine_name;
 
 /** A handler for a PERFORMANCE_SCHEMA table. */
 class ha_perfschema : public handler
 {
 public:
+  /**
+    Create a new performance schema table handle on a table.
+    @param hton storage engine handler singleton
+    @param share table share
+  */
   ha_perfschema(handlerton *hton, TABLE_SHARE *share);
 
   ~ha_perfschema();
@@ -97,26 +103,72 @@ public:
   double scan_time(void)
   { return 1.0; }
 
+  /**
+    Open a performance schema table.
+    @param name the table to open
+    @param mode unused
+    @param test_if_locked unused
+    @return 0 on success
+  */
   int open(const char *name, int mode, uint test_if_locked);
 
+  /**
+    Close a table handle.
+    @sa open.
+  */
   int close(void);
 
+  /**
+    Write a row.
+    @param buf the row to write
+    @return 0 on success
+  */
   int write_row(uchar *buf);
 
   void use_hidden_primary_key();
 
+  /**
+    Update a row.
+    @param old_data the row old values
+    @param new_data the row new values
+    @return 0 on success
+  */
   int update_row(const uchar *old_data, uchar *new_data);
 
+  /**
+    Delete a row.
+    @param buf the row to delete
+    @return 0 on success
+  */
   int delete_row(const uchar *buf);
 
   int rnd_init(bool scan);
 
+  /**
+    Scan end.
+    @sa rnd_init.
+  */
   int rnd_end(void);
 
+  /**
+    Iterator, fetch the next row.
+    @param[out] buf the row fetched.
+    @return 0 on success
+  */
   int rnd_next(uchar *buf);
 
+  /**
+    Iterator, fetch the row at a given position.
+    @param[out] buf the row fetched.
+    @param pos the row position
+    @return 0 on success
+  */
   int rnd_pos(uchar *buf, uchar *pos);
 
+  /**
+    Read the row current position.
+    @param record the current row
+  */
   void position(const uchar *record);
 
   int info(uint);

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2011-04-03 00:15:15 +0000
+++ b/storage/perfschema/pfs.cc	2011-04-14 01:21:41 +0000
@@ -871,15 +871,15 @@ static inline int mysql_mutex_lock(...)
    |
    | [1]
    |
-   |-> pfs_socket(F)                            =====>> [B], [C], [D], [E]
-   |    |
-   |    | [2]
-   |    |
-   |    |-> pfs_socket_class(F.class)           =====>> [C], [D]
-   |
-   |-> pfs_thread(T).event_name(F)            =====>> [A]
+   |-> pfs_socket(F)                            =====>> [A], [B], [C], [D], [E]
+        |
+        | [2]
+        |
+        |-> pfs_socket_class(F.class)           =====>> [C], [D]
+        |   
+        |-> pfs_thread(T).event_name(F)         =====>> [A]
         |
-       ...
+        ...
 @endverbatim
 
   Implemented as:
@@ -2810,7 +2810,7 @@ get_thread_socket_locker_v1(PSI_socket_l
 
   if (flag_thread_instrumentation)
   {
-    PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+    PFS_thread *pfs_thread= pfs_socket->m_thread_owner;
 
     if (unlikely(pfs_thread == NULL))
       return NULL;
@@ -2835,9 +2835,10 @@ get_thread_socket_locker_v1(PSI_socket_l
       state->m_wait= wait;
       flags|= STATE_FLAG_EVENT;
 
-#ifdef HAVE_NESTED_EVENTS
-      wait->m_nesting_event_id= (wait - 1)->m_event_id;
-#endif
+      PFS_events_waits *parent_event= wait - 1;
+      wait->m_event_type= EVENT_TYPE_WAIT;
+      wait->m_nesting_event_id= parent_event->m_event_id;
+      wait->m_nesting_event_id= parent_event->m_event_type;
       wait->m_thread=      pfs_thread;
       wait->m_class=       klass;
       wait->m_timer_start= 0;
@@ -2856,7 +2857,6 @@ get_thread_socket_locker_v1(PSI_socket_l
     if (klass->m_timed)
     {
       flags= STATE_FLAG_TIMED;
-      state->m_thread= NULL;
     }
     else
     {
@@ -2880,8 +2880,7 @@ get_thread_socket_locker_v1(PSI_socket_l
       case PSI_SOCKET_CLOSE:
         {
         PFS_socket *pfs_socket= reinterpret_cast<PFS_socket *>(socket);
-        /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
-        pfs_socket->m_wait_stat.aggregate_counted();
+        pfs_socket->m_socket_stat.m_io_stat.m_misc.aggregate_counted();
         return NULL;
         }
         break;
@@ -4597,7 +4596,7 @@ static void end_socket_wait_v1(PSI_socke
   DBUG_ASSERT(state != NULL);
   ulonglong timer_end= 0;
   ulonglong wait_time= 0;
-  bool socket_destroyed= false;
+  bool socket_closed= false;
 
   PFS_socket *socket= reinterpret_cast<PFS_socket *>(state->m_socket);
   DBUG_ASSERT(socket != NULL);
@@ -4634,8 +4633,7 @@ static void end_socket_wait_v1(PSI_socke
   case PSI_SOCKET_CLOSE:
     byte_stat= &socket->m_socket_stat.m_io_stat.m_misc;
     /* This socket will no longer be used by the server */
-    destroy_socket(socket);
-    socket_destroyed= true;
+    socket_closed= true;
     break;
 
   default:
@@ -4667,11 +4665,8 @@ static void end_socket_wait_v1(PSI_socke
     event_name_array= thread->m_instr_class_waits_stats;
     uint index= socket->m_class->m_event_name_index;
 
-    /*
-       To reduce overhead per operation, aggregate the accumulated socket stats
-       after the socket has been destroyed.
-    */
-    if (socket_destroyed)
+    /* Reduce overhead by aggregating after the socket has been closed. */
+    if (socket_closed)
     {
       /* Combine stats for all operations */
       PFS_single_stat stat;
@@ -4709,6 +4704,10 @@ static void end_socket_wait_v1(PSI_socke
       thread->m_events_waits_count--;
     }
   }
+
+  /* This socket will no longer be used */
+  if (socket_closed)
+    destroy_socket(socket);
 }
 
 static void set_socket_state_v1(PSI_socket *socket, PSI_socket_state state)

=== modified file 'storage/perfschema/pfs.h'
--- a/storage/perfschema/pfs.h	2010-07-16 01:28:30 +0000
+++ b/storage/perfschema/pfs.h	2011-04-04 14:34:42 +0000
@@ -27,8 +27,14 @@
 #include <my_pthread.h>
 #include <mysql/psi/psi.h>
 
+/**
+  Entry point to the performance schema implementation.
+  This singleton is used to discover the performance schema services.
+*/
 extern struct PSI_bootstrap PFS_bootstrap;
+/** Performance schema Thread Local Storage key.  */
 extern pthread_key(PFS_thread*, THR_PFS);
+/** True when @c THR_PFS is initialized. */
 extern bool THR_PFS_initialized;
 
 #endif

=== modified file 'storage/perfschema/pfs_atomic.h'
--- a/storage/perfschema/pfs_atomic.h	2010-07-16 01:28:30 +0000
+++ b/storage/perfschema/pfs_atomic.h	2011-04-04 14:34:42 +0000
@@ -27,7 +27,9 @@
 class PFS_atomic
 {
 public:
+  /** Initialise the PFS_atomic component. */
   static void init();
+  /** Cleanup the PFS_atomic component. */
   static void cleanup();
 
   /** Atomic load. */
@@ -112,6 +114,10 @@ public:
 private:
   static my_atomic_rwlock_t m_rwlock_array[256];
 
+  /**
+    Helper used only with non native atomic implementations.
+    @sa MY_ATOMIC_MODE_RWLOCKS
+  */
   static inline my_atomic_rwlock_t *get_rwlock(volatile void *ptr)
   {
     /*
@@ -123,21 +129,37 @@ private:
     return result;
   }
 
+  /**
+    Helper used only with non native atomic implementations.
+    @sa MY_ATOMIC_MODE_RWLOCKS
+  */
   static inline void rdlock(volatile void *ptr)
   {
     my_atomic_rwlock_rdlock(get_rwlock(ptr));
   }
 
+  /**
+    Helper used only with non native atomic implementations.
+    @sa MY_ATOMIC_MODE_RWLOCKS
+  */
   static inline void wrlock(volatile void *ptr)
   {
     my_atomic_rwlock_wrlock(get_rwlock(ptr));
   }
 
+  /**
+    Helper used only with non native atomic implementations.
+    @sa MY_ATOMIC_MODE_RWLOCKS
+  */
   static inline void rdunlock(volatile void *ptr)
   {
     my_atomic_rwlock_rdunlock(get_rwlock(ptr));
   }
 
+  /**
+    Helper used only with non native atomic implementations.
+    @sa MY_ATOMIC_MODE_RWLOCKS
+  */
   static inline void wrunlock(volatile void *ptr)
   {
     my_atomic_rwlock_wrunlock(get_rwlock(ptr));

=== modified file 'storage/perfschema/pfs_column_types.h'
--- a/storage/perfschema/pfs_column_types.h	2011-03-28 20:15:26 +0000
+++ b/storage/perfschema/pfs_column_types.h	2011-04-14 01:36:24 +0000
@@ -68,8 +68,11 @@ enum enum_timer_name
   TIMER_NAME_TICK= 5
 };
 
+/** Integer, first value of @sa enum_timer_name. */
 #define FIRST_TIMER_NAME (static_cast<int> (TIMER_NAME_CYCLE))
+/** Integer, last value of @sa enum_timer_name. */
 #define LAST_TIMER_NAME (static_cast<int> (TIMER_NAME_TICK))
+/** Integer, number of values of @sa enum_timer_name. */
 #define COUNT_TIMER_NAME (LAST_TIMER_NAME - FIRST_TIMER_NAME + 1)
 
 /**
@@ -165,18 +168,26 @@ enum enum_operation_type
   /* Idle operation */
   OPERATION_TYPE_IDLE= 55
 };
-
+/** Integer, first value of @sa enum_operation_type. */
 #define FIRST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_LOCK))
+/** Integer, last value of @sa enum_operation_type. */
 #define LAST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_IDLE))
+/** Integer, number of values of @sa enum_operation_type. */
 #define COUNT_OPERATION_TYPE (LAST_OPERATION_TYPE - FIRST_OPERATION_TYPE + 1)
 
+/**
+  Enum values for the various OBJECT_TYPE columns.
+*/
 enum enum_object_type
 {
   OBJECT_TYPE_TABLE= 1,
   OBJECT_TYPE_TEMPORARY_TABLE= 2
 };
+/** Integer, first value of @sa enum_object_type. */
 #define FIRST_OBJECT_TYPE (static_cast<int> (OBJECT_TYPE_TABLE))
+/** Integer, last value of @sa enum_object_type. */
 #define LAST_OBJECT_TYPE (static_cast<int> (OBJECT_TYPE_TEMPORARY_TABLE))
+/** Integer, number of values of @sa enum_object_type. */
 #define COUNT_OBJECT_TYPE (LAST_OBJECT_TYPE - FIRST_OBJECT_TYPE + 1)
 
 /**
@@ -193,8 +204,11 @@ enum enum_event_type
   EVENT_TYPE_WAIT= 3
 };
 
+/** Integer, first value of @sa enum_event_type. */
 #define FIRST_EVENT_TYPE (static_cast<int> (EVENT_TYPE_STATEMENT))
+/** Integer, last value of @sa enum_event_type. */
 #define LAST_EVENT_TYPE (static_cast<int> (EVENT_TYPE_WAIT))
+/** Integer, number of values of @sa enum_event_type. */
 #define COUNT_EVENT_TYPE (LAST_EVENT_TYPE - FIRST_EVENT_TYPE + 1)
 
 #endif

=== modified file 'storage/perfschema/pfs_column_values.h'
--- a/storage/perfschema/pfs_column_values.h	2011-03-28 20:15:26 +0000
+++ b/storage/perfschema/pfs_column_values.h	2011-04-14 01:36:24 +0000
@@ -24,14 +24,22 @@
   performance schema tables (declarations).
 */
 
+/** String, "PERFORMANCE_SCHEMA". */
 extern LEX_STRING PERFORMANCE_SCHEMA_str;
 
+/** String prefix for all mutex instruments. */
 extern LEX_STRING mutex_instrument_prefix;
+/** String prefix for all rwlock instruments. */
 extern LEX_STRING rwlock_instrument_prefix;
+/** String prefix for all cond instruments. */
 extern LEX_STRING cond_instrument_prefix;
+/** String prefix for all thread instruments. */
 extern LEX_STRING thread_instrument_prefix;
+/** String prefix for all file instruments. */
 extern LEX_STRING file_instrument_prefix;
+/** String prefix for all stage instruments. */
 extern LEX_STRING stage_instrument_prefix;
+/** String prefix for all statement instruments. */
 extern LEX_STRING statement_instrument_prefix;
 extern LEX_STRING socket_instrument_prefix;
 

=== modified file 'storage/perfschema/pfs_con_slice.h'
--- a/storage/perfschema/pfs_con_slice.h	2011-02-14 14:23:55 +0000
+++ b/storage/perfschema/pfs_con_slice.h	2011-04-04 14:34:42 +0000
@@ -33,12 +33,32 @@ struct PFS_statement_stat;
   @{
 */
 
+/**
+  A connection slice, an arbitrary grouping of several connections.
+  This structure holds statistics for grouping of connections.
+*/
 struct PFS_connection_slice
 {
+  /**
+    Allocate memory for waits statistics.
+    @param sizing the number of wait classes.
+    @return wait statistics for this slice.
+  */
   static PFS_single_stat *alloc_waits_slice(uint sizing);
+  /**
+    Allocate memory for stages statistics.
+    @param sizing the number of stage classes.
+    @return stage statistics for this slice.
+  */
   static PFS_stage_stat *alloc_stages_slice(uint sizing);
+  /**
+    Allocate memory for statement statistics.
+    @param sizing the number of statement classes.
+    @return statement statistics for this slice.
+  */
   static PFS_statement_stat *alloc_statements_slice(uint sizing);
 
+  /** Reset all statistics. */
   inline void reset_stats()
   {
     reset_waits_stats();
@@ -46,8 +66,11 @@ struct PFS_connection_slice
     reset_statements_stats();
   }
 
+  /** Reset all wait statistics. */
   void reset_waits_stats();
+  /** Reset all stages statistics. */
   void reset_stages_stats();
+  /** Reset all statements statistics. */
   void reset_statements_stats();
 
   /**

=== modified file 'storage/perfschema/pfs_defaults.h'
--- a/storage/perfschema/pfs_defaults.h	2010-07-02 16:15:37 +0000
+++ b/storage/perfschema/pfs_defaults.h	2011-04-04 14:34:42 +0000
@@ -21,6 +21,12 @@
   Default setup (declarations).
 */
 
+/**
+  Configure the performance schema setup tables with default content.
+  The tables populated are:
+  - SETUP_ACTORS
+  - SETUP_OBJECTS
+*/
 void install_default_setup(PSI_bootstrap *boot);
 
 #endif

=== modified file 'storage/perfschema/pfs_engine_table.h'
--- a/storage/perfschema/pfs_engine_table.h	2011-02-04 11:55:17 +0000
+++ b/storage/perfschema/pfs_engine_table.h	2011-04-04 14:34:42 +0000
@@ -46,6 +46,13 @@ public:
   int update_row(TABLE *table, const unsigned char *old_buf,
                  unsigned char *new_buf, Field **fields);
 
+  /**
+    Delete a row from this table.
+    @param table Table handle
+    @param buf the row buffer to delete
+    @param fields Table fields
+    @return 0 on success
+  */
   int delete_row(TABLE *table, const unsigned char *buf, Field **fields);
 
   /** Fetch the next row in this cursor. */
@@ -58,21 +65,71 @@ public:
 
   void get_position(void *ref);
   void set_position(const void *ref);
+  /** Reset the cursor position to the beginning of the table. */
   virtual void reset_position(void)= 0;
 
   /** Destructor. */
   virtual ~PFS_engine_table()
   {}
 
+  /**
+    Helper, assign a value to a ulong field.
+    @param f the field to set
+    @param value the value to assign
+  */
   static void set_field_ulong(Field *f, ulong value);
+  /**
+    Helper, assign a value to a ulonglong field.
+    @param f the field to set
+    @param value the value to assign
+  */
   static void set_field_ulonglong(Field *f, ulonglong value);
+  /**
+    Helper, assign a value to a char utf8 field.
+    @param f the field to set
+    @param str the string to assign
+    @param len the length of the string to assign
+  */
   static void set_field_char_utf8(Field *f, const char *str, uint len);
+  /**
+    Helper, assign a value to a varchar utf8 field.
+    @param f the field to set
+    @param str the string to assign
+    @param len the length of the string to assign
+  */
   static void set_field_varchar_utf8(Field *f, const char *str, uint len);
+  /**
+    Helper, assign a value to a longtext utf8 field.
+    @param f the field to set
+    @param str the string to assign
+    @param len the length of the string to assign
+  */
   static void set_field_longtext_utf8(Field *f, const char *str, uint len);
+  /**
+    Helper, assign a value to an enum field.
+    @param f the field to set
+    @param value the value to assign
+  */
   static void set_field_enum(Field *f, ulonglong value);
-
+  /**
+    Helper, read a value from an enum field.
+    @param f the field to read
+    @return the field value
+  */
   static ulonglong get_field_enum(Field *f);
+  /**
+    Helper, read a value from a char utf8 field.
+    @param f the field to read
+    @param[out] val the field value
+    @return the field value
+  */
   static String *get_field_char_utf8(Field *f, String *val);
+  /**
+    Helper, read a value from a varchar utf8 field.
+    @param f the field to read
+    @param[out] val the field value
+    @return the field value
+  */
   static String *get_field_varchar_utf8(Field *f, String *val);
 
 protected:
@@ -274,16 +331,29 @@ struct PFS_simple_index
   /** Current row index. */
   uint m_index;
 
+  /**
+    Constructor.
+    @param index the index initial value.
+  */
   PFS_simple_index(uint index)
     : m_index(index)
   {}
 
+  /**
+    Set this index at a given position.
+    @param other a position
+  */
   void set_at(const struct PFS_simple_index *other)
   { m_index= other->m_index; }
 
+  /**
+    Set this index after a given position.
+    @param other a position
+  */
   void set_after(const struct PFS_simple_index *other)
   { m_index= other->m_index + 1; }
 
+  /** Set this index to the next record. */
   void next(void)
   { m_index++; }
 };
@@ -296,16 +366,29 @@ struct PFS_double_index
   /** Current index within index_1. */
   uint m_index_2;
 
+  /**
+    Constructor.
+    @param index_1 the first index initial value.
+    @param index_2 the second index initial value.
+  */
   PFS_double_index(uint index_1, uint index_2)
     : m_index_1(index_1), m_index_2(index_2)
   {}
 
+  /**
+    Set this index at a given position.
+    @param other a position
+  */
   void set_at(const struct PFS_double_index *other)
   {
     m_index_1= other->m_index_1;
     m_index_2= other->m_index_2;
   }
 
+  /**
+    Set this index after a given position.
+    @param other a position
+  */
   void set_after(const struct PFS_double_index *other)
   {
     m_index_1= other->m_index_1;
@@ -323,10 +406,20 @@ struct PFS_triple_index
   /** Current index within index_2. */
   uint m_index_3;
 
+  /**
+    Constructor.
+    @param index_1 the first index initial value.
+    @param index_2 the second index initial value.
+    @param index_3 the third index initial value.
+  */
   PFS_triple_index(uint index_1, uint index_2, uint index_3)
     : m_index_1(index_1), m_index_2(index_2), m_index_3(index_3)
   {}
 
+  /**
+    Set this index at a given position.
+    @param other a position
+  */
   void set_at(const struct PFS_triple_index *other)
   {
     m_index_1= other->m_index_1;
@@ -334,6 +427,10 @@ struct PFS_triple_index
     m_index_3= other->m_index_3;
   }
 
+  /**
+    Set this index after a given position.
+    @param other a position
+  */
   void set_after(const struct PFS_triple_index *other)
   {
     m_index_1= other->m_index_1;

=== modified file 'storage/perfschema/pfs_events_statements.h'
--- a/storage/perfschema/pfs_events_statements.h	2011-02-14 14:23:55 +0000
+++ b/storage/perfschema/pfs_events_statements.h	2011-04-04 14:34:42 +0000
@@ -41,32 +41,51 @@ struct PFS_events_statements : public PF
   /** Length of @ m_info. */
   uint m_sqltext_length;
 
-  /* Lock */
+  /** Locked time. */
   ulonglong m_lock_time;
 
-  /* Diagnostics area */
+  /** Diagnostics area, message text. */
   char m_message_text[MYSQL_ERRMSG_SIZE+1];
+  /** Diagnostics area, error number. */
   uint m_sql_errno;
+  /** Diagnostics area, SQLSTATE. */
   char m_sqlstate[SQLSTATE_LENGTH];
+  /** Diagnostics area, error count. */
   uint m_error_count;
+  /** Diagnostics area, warning count. */
   uint m_warning_count;
+  /** Diagnostics area, rows affected. */
   ulonglong m_rows_affected;
 
-  /* Optimizer */
+  /** Optimizer metric, number of rows sent. */
   ulonglong m_rows_sent;
+  /** Optimizer metric, number of rows examined. */
   ulonglong m_rows_examined;
+  /** Optimizer metric, number of temporary tables created on disk. */
   ulonglong m_created_tmp_disk_tables;
+  /** Optimizer metric, number of temporary tables created. */
   ulonglong m_created_tmp_tables;
+  /** Optimizer metric, number of full join. */
   ulonglong m_select_full_join;
+  /** Optimizer metric, number of full range join. */
   ulonglong m_select_full_range_join;
+  /** Optimizer metric, number of select range. */
   ulonglong m_select_range;
+  /** Optimizer metric, number of select range checks. */
   ulonglong m_select_range_check;
+  /** Optimizer metric, number of select scans. */
   ulonglong m_select_scan;
+  /** Optimizer metric, number of sort merge passes. */
   ulonglong m_sort_merge_passes;
+  /** Optimizer metric, number of sort ranges. */
   ulonglong m_sort_range;
+  /** Optimizer metric, number of sort rows. */
   ulonglong m_sort_rows;
+  /** Optimizer metric, number of sort scans. */
   ulonglong m_sort_scan;
+  /** Optimizer metric, number of 'no index used'. */
   ulonglong m_no_index_used;
+  /** Optimizer metric, number of 'no good index used'. */
   ulonglong m_no_good_index_used;
 };
 

=== modified file 'storage/perfschema/pfs_global.h'
--- a/storage/perfschema/pfs_global.h	2011-03-18 22:24:30 +0000
+++ b/storage/perfschema/pfs_global.h	2011-04-14 01:36:24 +0000
@@ -21,20 +21,38 @@
   Miscellaneous global dependencies (declarations).
 */
 
+/** True when the performance schema is initialized. */
 extern bool pfs_initialized;
+/** Total memory allocated by the performance schema, in bytes. */
 extern ulonglong pfs_allocated_memory;
 
 void *pfs_malloc(size_t size, myf flags);
+
+/**
+  Helper, to allocate an array of structures.
+  @param n number of elements in the array.
+  @param T type of an element.
+  @param f flags to use when allocating memory
+*/
 #define PFS_MALLOC_ARRAY(n, T, f) \
   reinterpret_cast<T*> (pfs_malloc((n) * sizeof(T), (f)))
+
+/** Free memory allocated with @sa pfs_malloc. */
 void pfs_free(void *ptr);
 
+
 uint pfs_get_socket_address(char *host,
                             uint host_len,
                             uint *port,
                             const struct sockaddr *src_addr,
                             socklen_t src_len);
 
+/**
+  Compute a random index value in an interval.
+  @param ptr seed address
+  @param max_size maximun size of the interval
+  @return a random value in [0, max_size-1]
+*/
 inline uint randomized_index(const void *ptr, uint max_size)
 {
   static uint seed1= 0;

=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc	2011-04-03 00:15:15 +0000
+++ b/storage/perfschema/pfs_instr.cc	2011-04-14 01:21:41 +0000
@@ -1401,7 +1401,6 @@ PFS_socket* create_socket(PFS_socket_cla
           pfs->m_identity= pfs;
           pfs->m_class= klass;
           pfs->m_idle= false;
-          pfs->m_wait_stat.reset();
           pfs->m_socket_stat.reset();
           pfs->m_lock.dirty_to_allocated();
           if (klass->is_singleton())
@@ -1486,7 +1485,7 @@ static void reset_socket_waits_by_instan
   PFS_socket *pfs_last= socket_array + socket_max;
 
   for ( ; pfs < pfs_last; pfs++)
-    pfs->m_wait_stat.reset();
+    pfs->m_socket_stat.reset();
 }
 
 /** Reset the wait statistics per object instance. */

=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h	2011-04-01 22:04:26 +0000
+++ b/storage/perfschema/pfs_instr.h	2011-04-14 01:36:24 +0000
@@ -223,8 +223,6 @@ struct PFS_socket : public PFS_instr
   bool m_idle;
   /** Socket class. */
   PFS_socket_class *m_class;
-  /** Instrument wait statistics. */
-  PFS_single_stat m_wait_stat;
   /** Socket usage statistics. */
   PFS_socket_stat m_socket_stat;
 };
@@ -257,6 +255,7 @@ extern uint statement_stack_max;
 */
 #define PFS_MAX_ALLOC_RETRY 1000
 
+/** The maximun number of passes in @sa PFS_scan. */
 #define PFS_MAX_SCAN_PASS 2
 
 /**
@@ -270,24 +269,42 @@ extern uint statement_stack_max;
 struct PFS_scan
 {
 public:
+  /**
+    Initialize a new scan.
+    @param random a random index to start from
+    @param max_size the max size of the interval to scan
+  */
   void init(uint random, uint max_size);
 
+  /**
+    Predicate, has a next pass.
+    @return true if there is a next pass to perform.
+  */
   bool has_pass() const
   { return (m_pass < m_pass_max); }
 
+  /**
+    Iterator, proceed to the next pass.
+  */
   void next_pass()
   { m_pass++; }
-
+  
+  /** First index for this pass. */
   uint first() const
   { return m_first[m_pass]; }
 
+  /** Last index for this pass. */
   uint last() const
   { return m_last[m_pass]; }
 
 private:
+  /** Current pass. */
   uint m_pass;
+  /** Maximum number of passes. */
   uint m_pass_max;
+  /** First element for each pass. */
   uint m_first[PFS_MAX_SCAN_PASS];
+  /** Last element for each pass. */
   uint m_last[PFS_MAX_SCAN_PASS];
 };
 

=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc	2011-04-01 22:04:26 +0000
+++ b/storage/perfschema/pfs_instr_class.cc	2011-04-14 01:21:41 +0000
@@ -577,7 +577,6 @@ static void init_instr_class(PFS_instr_c
   klass->m_flags= flags;
   klass->m_enabled= true;
   klass->m_timed= true;
-  klass->m_deferred= false;
   klass->m_type= class_type;
 }
 
@@ -1029,7 +1028,6 @@ PFS_socket_key register_socket_class(con
     entry->m_index= index;
     entry->m_event_name_index= socket_class_start + index;
     entry->m_singleton= NULL;
-    entry->m_deferred= true;
     PFS_atomic::add_u32(&socket_class_allocated_count, 1);
     return (index + 1);
   }

=== modified file 'storage/perfschema/pfs_instr_class.h'
--- a/storage/perfschema/pfs_instr_class.h	2011-04-01 22:04:26 +0000
+++ b/storage/perfschema/pfs_instr_class.h	2011-04-14 01:21:41 +0000
@@ -103,8 +103,6 @@ struct PFS_instr_class
   bool m_enabled;
   /** True if this instrument is timed. */
   bool m_timed;
-  /** True if this instrument requires deferred aggregation */
-  bool m_deferred;
   /**
     Instrument name index.
     Self index in:
@@ -118,6 +116,19 @@ struct PFS_instr_class
   {
     return m_flags & PSI_FLAG_GLOBAL;
   }
+
+  bool is_deferred() const
+  {
+    switch(m_type)
+    {
+      case PFS_CLASS_SOCKET:
+        return true;
+        break;
+      default:
+        return false;
+        break;
+    };
+  }
 };
 
 struct PFS_mutex;

=== modified file 'storage/perfschema/pfs_server.h'
--- a/storage/perfschema/pfs_server.h	2011-03-28 23:37:10 +0000
+++ b/storage/perfschema/pfs_server.h	2011-04-14 01:36:24 +0000
@@ -97,56 +97,144 @@
   #define PFS_STATEMENTS_STACK_SIZE 10
 #endif
 
-
 /** Performance schema global sizing parameters. */
 struct PFS_global_param
 {
+  /** True if the performance schema is enabled. */
   bool m_enabled;
+  /**
+    Maximum number of instrumented mutex classes.
+    @sa mutex_class_lost.
+  */
   ulong m_mutex_class_sizing;
+  /**
+    Maximum number of instrumented rwlock classes.
+    @sa rwlock_class_lost.
+  */
   ulong m_rwlock_class_sizing;
+  /**
+    Maximum number of instrumented cond classes.
+    @sa cond_class_lost.
+  */
   ulong m_cond_class_sizing;
+  /**
+    Maximum number of instrumented thread classes.
+    @sa thread_class_lost.
+  */
   ulong m_thread_class_sizing;
   /**
     Maximum number of instrumented table share.
     @sa table_share_lost.
   */
   ulong m_table_share_sizing;
+  /**
+    Maximum number of instrumented file classes.
+    @sa file_class_lost.
+  */
   ulong m_file_class_sizing;
+  /**
+    Maximum number of instrumented mutex instances.
+    @sa mutex_lost.
+  */
   ulong m_mutex_sizing;
+  /**
+    Maximum number of instrumented rwlock instances.
+    @sa rwlock_lost.
+  */
   ulong m_rwlock_sizing;
+  /**
+    Maximum number of instrumented cond instances.
+    @sa cond_lost.
+  */
   ulong m_cond_sizing;
+  /**
+    Maximum number of instrumented thread instances.
+    @sa thread_lost.
+  */
   ulong m_thread_sizing;
   /**
     Maximum number of instrumented table handles.
     @sa table_lost.
   */
   ulong m_table_sizing;
+  /**
+    Maximum number of instrumented file instances.
+    @sa file_lost.
+  */
   ulong m_file_sizing;
+  /**
+    Maximum number of instrumented file handles.
+    @sa file_handle_lost.
+  */
   ulong m_file_handle_sizing;
+  /**
+    Maxium number of instrumented socket instances
+    @sa socket_lost  
+  */
   ulong m_socket_sizing;
+  /**
+    Maximum number of instrumented socket classes.
+    @sa socket_class_lost.
+  */
   ulong m_socket_class_sizing;
+  /** Maximum number of rows per thread in table EVENTS_WAITS_HISTORY. */
   ulong m_events_waits_history_sizing;
+  /** Maximum number of rows in table EVENTS_WAITS_HISTORY_LONG. */
   ulong m_events_waits_history_long_sizing;
+  /** Maximum number of rows in table SETUP_ACTORS. */
   ulong m_setup_actor_sizing;
-  /** Maximum number of setup object records. */
+  /** Maximum number of rows in table SETUP_OBJECTS. */
   ulong m_setup_object_sizing;
+  /**
+    Maximum number of instrumented stage classes.
+    @sa stage_class_lost.
+  */
   ulong m_stage_class_sizing;
+  /** Maximum number of rows per thread in table EVENTS_STAGES_HISTORY. */
   ulong m_events_stages_history_sizing;
+  /** Maximum number of rows in table EVENTS_STAGES_HISTORY_LONG. */
   ulong m_events_stages_history_long_sizing;
+  /**
+    Maximum number of instrumented statement classes.
+    @sa statement_class_lost.
+  */
   ulong m_statement_class_sizing;
+  /** Maximum number of rows per thread in table EVENTS_STATEMENT_HISTORY. */
   ulong m_events_statements_history_sizing;
+  /** Maximum number of rows in table EVENTS_STATEMENTS_HISTORY_LONG. */
   ulong m_events_statements_history_long_sizing;
 };
 
+/**
+  Performance schema sizing values for the server.
+  This global variable is set when parsing server startup options.
+*/
 extern PFS_global_param pfs_param;
 
+/**
+  Initialize the performance schema.
+  @param param Size parameters to use.
+  @return A boostrap handle, or NULL.
+*/
 struct PSI_bootstrap*
 initialize_performance_schema(const PFS_global_param *param);
 
+/**
+  Initialize the performance schema ACL.
+  ACL is strictly enforced when the server is running in normal mode,
+  to enforce that only legal operations are allowed.
+  When running in boostrap mode, ACL restrictions are relaxed,
+  to allow the boostrap scripts to DROP / CREATE performance schema tables.
+  @sa ACL_internal_schema_registry
+  @param bootstrap True if the server is starting in bootstrap mode.
+*/
 void initialize_performance_schema_acl(bool bootstrap);
 
 void check_performance_schema();
 
+/**
+  Shutdown the performance schema.
+*/
 void shutdown_performance_schema();
 
 #endif

=== modified file 'storage/perfschema/pfs_setup_actor.cc'
--- a/storage/perfschema/pfs_setup_actor.cc	2010-07-02 16:15:37 +0000
+++ b/storage/perfschema/pfs_setup_actor.cc	2011-04-04 14:34:42 +0000
@@ -32,11 +32,19 @@
   @{
 */
 
+/** Size of the setup_actor instances array. @sa setup_actor_array */
 ulong setup_actor_max;
 
+/**
+  Setup_actor instances array.
+  @sa setup_actor_max
+*/
+
 PFS_setup_actor *setup_actor_array= NULL;
 
+/** Hash table for setup_actor records. */
 static LF_HASH setup_actor_hash;
+/** True if @c setup_actor_hash is initialized. */
 static bool setup_actor_hash_inited= false;
 
 /**

=== modified file 'storage/perfschema/pfs_stat.h'
--- a/storage/perfschema/pfs_stat.h	2011-04-03 00:15:15 +0000
+++ b/storage/perfschema/pfs_stat.h	2011-04-14 01:21:41 +0000
@@ -87,6 +87,60 @@ struct PFS_single_stat
   }
 };
 
+/** Single statistic. */
+struct PFS_single_stat_test
+{
+  /** Count of values. */
+  ulonglong m_count;
+  /** Sum of values. */
+  ulonglong m_sum;
+  /** Minimum value. */
+  ulonglong m_min;
+  /** Maximum value. */
+  ulonglong m_max;
+
+  PFS_single_stat_test()
+  {
+    m_count= 0;
+    m_sum= 0;
+    m_min= ULONGLONG_MAX;
+    m_max= 0;
+  }
+
+  inline void reset(void)
+  {
+    m_count= 0;
+    m_sum= 0;
+    m_min= ULONGLONG_MAX;
+    m_max= 0;
+  }
+
+  inline void aggregate(const PFS_single_stat *stat)
+  {
+    m_count+= stat->m_count;
+    m_sum+= stat->m_sum;
+    if (unlikely(m_min > stat->m_min))
+      m_min= stat->m_min;
+    if (unlikely(m_max < stat->m_max))
+      m_max= stat->m_max;
+  }
+
+  inline void aggregate_counted(ulonglong count)
+  {
+    m_count+= count;
+  }
+
+  inline void aggregate_value(ulonglong value)
+  {
+    m_count++;
+    m_sum+= value;
+    if (unlikely(m_min > value))
+      m_min= value;
+    if (unlikely(m_max < value))
+      m_max= value;
+  }
+};
+
 /** Combined statistic. */
 struct PFS_byte_stat : public PFS_single_stat
 {
@@ -117,6 +171,12 @@ struct PFS_byte_stat : public PFS_single
   }
 
   /* Aggregate event count and byte count */
+  inline void aggregate_counted()
+  {
+    PFS_single_stat::aggregate_counted();
+  }
+
+  /* Aggregate event count and byte count */
   inline void aggregate_counted(ulonglong bytes)
   {
     PFS_single_stat::aggregate_counted();

=== modified file 'storage/perfschema/pfs_timer.h'
--- a/storage/perfschema/pfs_timer.h	2011-03-28 20:15:26 +0000
+++ b/storage/perfschema/pfs_timer.h	2011-04-14 01:36:24 +0000
@@ -23,6 +23,7 @@
 #include <my_rdtsc.h>
 #include "pfs_column_types.h"
 
+/** Conversion factor, from micro seconds to pico seconds. */
 #define MICROSEC_TO_PICOSEC 1000000
 
 /**
@@ -33,42 +34,107 @@
 */
 struct time_normalizer
 {
+  /**
+    Get a time normalizer for a given timer.
+    @param timer_name the timer name
+    @return the normalizer for the timer
+  */
   static time_normalizer* get(enum_timer_name timer_name);
 
+  /** Timer value at server statup. */
   ulonglong m_v0;
+  /** Conversion factor from timer values to pico seconds. */
   ulonglong m_factor;
 
+  /**
+    Convert a wait from timer units to pico seconds.
+    @param wait a wait, expressed in timer units
+    @return the wait, expressed in pico seconds
+  */
   inline ulonglong wait_to_pico(ulonglong wait)
   {
     return wait * m_factor;
   }
 
+  /**
+    Convert a time from timer units to pico seconds.
+    @param t a time, expressed in timer units
+    @return the time, expressed in pico seconds
+  */
   inline ulonglong time_to_pico(ulonglong t)
   {
     return (t == 0 ? 0 : (t - m_v0) * m_factor);
   }
 
+  /**
+    Convert start / end times from timer units to pico seconds.
+    @param start start time, expressed in timer units
+    @param end end time, expressed in timer units
+    @param[out] pico_start start time, expressed in pico seconds
+    @param[out] pico_end end time, expressed in pico seconds
+    @param[out] pico_wait wait time, expressed in pico seconds
+  */
   void to_pico(ulonglong start, ulonglong end,
                ulonglong *pico_start, ulonglong *pico_end, ulonglong *pico_wait);
 };
 
+/**
+  Idle timer.
+  The timer used to measure all idle events.
+*/
 extern enum_timer_name idle_timer;
+/**
+  Wait timer.
+  The timer used to measure all wait events.
+*/
 extern enum_timer_name wait_timer;
+/**
+  Stage timer.
+  The timer used to measure all stage events.
+*/
 extern enum_timer_name stage_timer;
+/**
+  Statement timer.
+  The timer used to measure all statement events.
+*/
 extern enum_timer_name statement_timer;
+/**
+  Timer information data.
+  Characteristics about each suported timer.
+*/
 extern MY_TIMER_INFO pfs_timer_info;
 
+/** Initialize the timer component. */
 void init_timers();
 
 extern "C"
 {
+  /** A timer function. */
   typedef ulonglong (*timer_fct_t)(void);
 }
 
+/**
+  Get a timer value, in pico seconds.
+  @param timer_name the timer to use
+  @return timer value, in pico seconds
+*/
 ulonglong get_timer_pico_value(enum_timer_name timer_name);
+/**
+  Get a timer value, in timer units.
+  @param timer_name the timer to use
+  @return timer value, in timer units
+*/
 ulonglong get_timer_raw_value(enum_timer_name timer_name);
+/**
+  Get a timer value and function, in timer units.
+  This function is useful when code needs to call the same timer several times.
+  The returned timer function can be invoked directly, which avoids having to
+  resolve the timer by name for each call.
+  @param timer_name the timer to use
+  @param[out] fct the timer function
+  @return timer value, in timer units
+*/
 ulonglong get_timer_raw_value_and_function(enum_timer_name timer_name, timer_fct_t *fct);
 
-
 #endif
 

=== modified file 'storage/perfschema/pfs_visitor.cc'
--- a/storage/perfschema/pfs_visitor.cc	2011-04-03 00:15:15 +0000
+++ b/storage/perfschema/pfs_visitor.cc	2011-04-14 01:21:41 +0000
@@ -189,61 +189,92 @@ void PFS_instance_iterator::visit_socket
 
   visitor->visit_socket_class(klass);
 
-  PFS_socket *pfs= socket_array;
-  PFS_socket *pfs_last= pfs + socket_max;
-  for ( ; pfs < pfs_last; pfs++)
+  if (klass->is_singleton())
   {
-    if ((pfs->m_class == klass) && pfs->m_lock.is_populated())
+    PFS_socket *pfs= sanitize_socket(klass->m_singleton);
+    if (likely(pfs != NULL))
     {
-      visitor->visit_socket(pfs);
+      if (likely(pfs->m_lock.is_populated()))
+      {
+        visitor->visit_socket(pfs);
+      }
+    }
+  }
+  else
+  {
+    PFS_socket *pfs= socket_array;
+    PFS_socket *pfs_last= pfs + socket_max;
+    for ( ; pfs < pfs_last; pfs++)
+    {
+      if ((pfs->m_class == klass) && pfs->m_lock.is_populated())
+      {
+        visitor->visit_socket(pfs);
+      }
     }
   }
 }
 
-/**
-    Socket instance iterator visting sockets owned by PFS_thread.
-    The socket class is not visited.
-*/
+/** Socket instance iterator visting sockets owned by PFS_thread. */
 
 void PFS_instance_iterator::visit_socket_instances(PFS_socket_class *klass,
                                                    PFS_instance_visitor *visitor,
-                                                   PFS_thread *thread)
+                                                   PFS_thread *thread,
+                                                   bool visit_class)
 {
   DBUG_ASSERT(visitor != NULL);
   DBUG_ASSERT(thread != NULL);
 
-  /* Get current socket stats from each socket instance owned by this thread */
-  PFS_socket *pfs= socket_array;
-  PFS_socket *pfs_last= pfs + socket_max;
-  ulong thread_id= thread->m_thread_internal_id;
+  if (visit_class)
+    visitor->visit_socket_class(klass);
 
-  for ( ; pfs < pfs_last; pfs++)
+  if (klass->is_singleton())
   {
-    if (pfs->m_class == klass && pfs->m_lock.is_populated()
-         && pfs->m_thread_owner != NULL)
+    PFS_socket *pfs= sanitize_socket(klass->m_singleton);
+    if (likely(pfs != NULL))
     {
-      if (pfs->m_thread_owner->m_thread_internal_id == thread_id)
-        visitor->visit_socket(pfs);
+      if (likely(pfs->m_lock.is_populated())
+          && pfs->m_thread_owner != NULL)
+      {
+        if (pfs->m_thread_owner == thread)
+          visitor->visit_socket(pfs);
+      }
     }
   }
-}
+  else
+  {
+    /* Get current socket stats from each socket instance owned by this thread */
+    PFS_socket *pfs= socket_array;
+    PFS_socket *pfs_last= pfs + socket_max;
 
+    for ( ; pfs < pfs_last; pfs++)
+    {
+      if (pfs->m_class == klass && pfs->m_lock.is_populated()
+           && pfs->m_thread_owner != NULL)
+      {
+        if (pfs->m_thread_owner == thread)
+          visitor->visit_socket(pfs);
+      }
+    }
+  }
+}
 
 /** Generic instance iterator with PFS_thread as matching criteria */
 
-void PFS_instance_iterator::visit_instances(PFS_instr_class *instr_class,
+void PFS_instance_iterator::visit_instances(PFS_instr_class *klass,
                                             PFS_instance_visitor *visitor,
-                                            PFS_thread *thread)
+                                            PFS_thread *thread,
+                                            bool visit_class)
 {
   DBUG_ASSERT(visitor != NULL);
-  DBUG_ASSERT(instr_class != NULL);
+  DBUG_ASSERT(klass != NULL);
 
-  switch (instr_class->m_type)
+  switch (klass->m_type)
   {
   case PFS_CLASS_SOCKET:
     {
-      PFS_socket_class *klass= reinterpret_cast<PFS_socket_class *>(instr_class);
-      PFS_instance_iterator::visit_socket_instances(klass, visitor, thread);
+    PFS_socket_class *socket_class= reinterpret_cast<PFS_socket_class*>(klass);
+    PFS_instance_iterator::visit_socket_instances(socket_class, visitor,
+                                                  thread, visit_class);
     }
     break;
   default:
@@ -425,7 +456,7 @@ void PFS_instance_wait_visitor::visit_so
   m_stat.aggregate(&global_instr_class_waits_array[index]);
 
   /* If deferred, then pull wait stats directly from the socket class. */
-  if (pfs->m_deferred)
+  if (pfs->is_deferred())
     pfs->m_socket_stat.m_io_stat.sum_waits(&m_stat);
 }
 
@@ -603,8 +634,6 @@ void PFS_table_lock_stat_visitor::visit_
   m_stat.aggregate(& pfs->m_table_stat.m_lock_stat);
 }
 
-/** Socket IO stat visitor */
-
 PFS_instance_socket_io_stat_visitor::PFS_instance_socket_io_stat_visitor()
 {}
 

=== modified file 'storage/perfschema/pfs_visitor.h'
--- a/storage/perfschema/pfs_visitor.h	2011-04-01 22:04:26 +0000
+++ b/storage/perfschema/pfs_visitor.h	2011-04-14 01:21:41 +0000
@@ -161,19 +161,24 @@ public:
     Visit a socket class and related instances.
     @param klass the klass to visit.
     @param visitor the visitor to call
+    @param thread the owning thread to match
+    @param visit_class if true then visit the socket class
   */
   static void visit_socket_instances(PFS_socket_class *klass,
                                      PFS_instance_visitor *visitor,
-                                     PFS_thread *thread);
+                                     PFS_thread *thread,
+                                     bool visit_class= true);
   /**
     Visit an instrument class and related instances.
     @param klass the klass to visit.
     @param visitor the visitor to call
     @param thread comparison criteria
+    @param visit_class if true then visit the class
   */
   static void visit_instances(PFS_instr_class *klass,
                               PFS_instance_visitor *visitor,
-                              PFS_thread *thread);
+                              PFS_thread *thread,
+                              bool visit_class= true);
 };
 
 /**

=== modified file 'storage/perfschema/table_ews_by_thread_by_event_name.cc'
--- a/storage/perfschema/table_ews_by_thread_by_event_name.cc	2011-04-01 22:04:26 +0000
+++ b/storage/perfschema/table_ews_by_thread_by_event_name.cc	2011-04-14 01:21:41 +0000
@@ -238,18 +238,17 @@ void table_ews_by_thread_by_event_name
   PFS_connection_iterator::visit_thread(thread, &visitor);
 
   /*
-     If the aggregation for this class is deferred, then we must pull the stats
-     from the class itself and from the instances associated with this thread.
+     If the aggregation for this class is deferred, then we must pull the
+     current wait stats from the instances associated with this thread.
   */  
-  if (klass->m_deferred)
+  if (klass->is_deferred())
   {
-    PFS_instance_socket_io_stat_visitor inst_visitor;
-    PFS_instance_iterator::visit_instances(klass, &inst_visitor, thread);
-    /* Sum separate per-operation stats into one */
-    PFS_byte_stat stat;
-    inst_visitor.m_socket_io_stat.sum(&stat);
+    /* Visit instances owned by this thread. Do not visit the class. */
+    PFS_instance_wait_visitor inst_visitor;
+    PFS_instance_iterator::visit_instances(klass, &inst_visitor,
+                                           thread, false);
     /* Combine the deferred stats and global stats */
-    visitor.m_stat.aggregate(&stat);
+    visitor.m_stat.aggregate(&inst_visitor.m_stat);
   }
 
   if (! thread->m_lock.end_optimistic_lock(&lock))

=== modified file 'unittest/gunit/CMakeLists.txt'
--- a/unittest/gunit/CMakeLists.txt	2011-02-17 14:39:47 +0000
+++ b/unittest/gunit/CMakeLists.txt	2011-04-13 11:31:44 +0000
@@ -25,10 +25,6 @@ ELSE()
 ENDIF() 
 
 IF(CMAKE_COMPILER_IS_GNUCXX)
-  # Remove -fno-implicit-templates, gunit sources cannot be compiled with it.
-  STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS
-    ${CMAKE_CXX_FLAGS})
-
   # MySQL is often compiled/linked with gcc rather than g++
   # (to avoid dependencies on libstdc++.so)
   # This does not work for googletest binaries.
@@ -216,6 +212,7 @@ SET(TESTS
   my_decimal
   my_regex
   sql_list
+  sql_plist
   thread_utils
   )
 

=== added file 'unittest/gunit/sql_plist-t.cc'
--- a/unittest/gunit/sql_plist-t.cc	1970-01-01 00:00:00 +0000
+++ b/unittest/gunit/sql_plist-t.cc	2011-04-13 11:31:44 +0000
@@ -0,0 +1,147 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
+
+// First include (the generated) my_config.h, to get correct platform defines,
+// then gtest.h (before any other MySQL headers), to avoid min() macros etc ...
+#include "my_config.h"
+#include <gtest/gtest.h>
+
+#include "sql_plist.h"
+
+namespace {
+
+// A simple helper function to determine array size.
+template <class T, int size>
+int array_size(const T (&)[size])
+{
+  return size;
+}
+
+// A simple helper function to insert values into a List.
+template <class T, int size, class L>
+void insert_values(T (&array)[size], L *list)
+{
+  uint ix, elements= list->elements();
+  for (ix= 0; ix < size; ++ix)
+    list->push_back(&array[ix]);
+  EXPECT_EQ(ix + elements, list->elements());
+}
+
+/*
+  The fixture for testing the MySQL List and List_iterator classes.
+  A fresh instance of this class will be created for each of the
+  TEST_F functions below.
+*/
+class IPListTest : public ::testing::Test
+{
+protected:
+  IPListTest()
+    : m_int_list(), m_int_list_iter(m_int_list)
+  {
+  }
+
+public:
+  template<typename V>
+  struct I_P_ListTestValue
+  {
+    V value;
+    I_P_ListTestValue(V val) : value(val) {}
+    bool operator == (const I_P_ListTestValue<V> &obj) const
+    { return value == obj.value; }
+    struct I_P_ListTestValue<V> *next;
+    struct I_P_ListTestValue<V> **prev;
+  };
+
+protected:
+  template<typename V>
+  struct I_P_ListCountedPushBack
+  {
+    typedef I_P_ListTestValue<V> Value;
+    typedef I_P_List<Value,
+                     I_P_List_adapter<Value, &Value::next, &Value::prev>,
+                     I_P_List_counter,
+                     I_P_List_fast_push_back<Value>
+                    > Type;
+  };
+
+  I_P_ListCountedPushBack<int>::Type m_int_list;
+  I_P_ListCountedPushBack<int>::Type::Iterator m_int_list_iter;
+
+private:
+  // Declares (but does not define) copy constructor and assignment operator.
+  GTEST_DISALLOW_COPY_AND_ASSIGN_(IPListTest);
+};
+
+
+// Allow construction of test messages via the << operator.
+template<typename T>
+std::ostream &operator<< (std::ostream &s,
+                          const IPListTest::I_P_ListTestValue<T> &v)
+{
+  return s << v.value;
+}
+
+
+// Tests that we can construct and destruct lists.
+TEST_F(IPListTest, ConstructAndDestruct)
+{
+  EXPECT_TRUE(m_int_list.is_empty());
+  I_P_ListCountedPushBack<int>::Type *p_int_list;
+  p_int_list= new I_P_ListCountedPushBack<int>::Type;
+  EXPECT_TRUE(p_int_list->is_empty());
+  delete p_int_list;
+}
+
+
+// Tests basic operations push and remove.
+TEST_F(IPListTest, BasicOperations)
+{
+  I_P_ListTestValue<int> v1(1), v2(2), v3(3);
+  m_int_list.push_front(&v1);
+  m_int_list.insert_after(&v1, &v2);
+  m_int_list.push_back(&v3);
+  EXPECT_FALSE(m_int_list.is_empty());
+  EXPECT_EQ(3U, m_int_list.elements());
+
+  EXPECT_EQ(&v1, m_int_list.front());
+  m_int_list.remove(&v1);
+  EXPECT_EQ(&v2, m_int_list.front());
+  m_int_list.remove(&v2);
+  EXPECT_EQ(&v3, m_int_list.front());
+  m_int_list.remove(&v3);
+  EXPECT_TRUE(m_int_list.is_empty()) << "The list should be empty now!";
+}
+
+
+// Tests that we can iterate over values.
+TEST_F(IPListTest, Iterate)
+{
+  I_P_ListTestValue<int> values[]= {3, 2, 1};
+  insert_values(values, &m_int_list);
+  m_int_list_iter.init(m_int_list);
+  for (int ix= 0; ix < array_size(values); ++ix)
+  {
+    EXPECT_EQ(values[ix], *m_int_list_iter++);
+  }
+  m_int_list_iter.init(m_int_list);
+  I_P_ListTestValue<int> *value;
+  int value_number= 0;
+  while ((value= m_int_list_iter++))
+  {
+    EXPECT_EQ(values[value_number++], value->value);
+  }
+}
+
+}  // namespace

=== modified file 'vio/viosocket.c'
--- a/vio/viosocket.c	2011-03-28 23:37:10 +0000
+++ b/vio/viosocket.c	2011-04-14 01:36:24 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -1092,6 +1092,34 @@ ssize_t vio_pending(Vio *vio)
 }
 
 
+/**
+  Checks if the error code, returned by vio_getnameinfo(), means it was the
+  "No-name" error.
+
+  Windows-specific note: getnameinfo() returns WSANO_DATA instead of
+  EAI_NODATA or EAI_NONAME when no reverse mapping is available at the host
+  (i.e. Windows can't get hostname by IP-address). This error should be
+  treated as EAI_NONAME.
+
+  @return if the error code is actually EAI_NONAME.
+  @retval true if the error code is EAI_NONAME.
+  @retval false otherwise.
+*/
+
+my_bool vio_is_no_name_error(int err_code)
+{
+#ifdef _WIN32
+
+  return err_code == WSANO_DATA || err_code == EAI_NONAME;
+
+#else
+
+  return err_code == EAI_NONAME;
+
+#endif
+}
+
+
 /**
   This is a wrapper for the system getnameinfo(), because different OS
   differ in the getnameinfo() implementation:

Attachment: [text/bzr-bundle] bzr/cpowers@tma-1-20110414013624-3wqxicqyit34j18u.bundle
Thread
bzr push into mysql-trunk branch (chris.powers:3278 to 3280) WL#4896Christopher Powers14 Apr