List:Commits« Previous MessageNext Message »
From:Bjorn Munch Date:October 21 2010 1:05pm
Subject:bzr push into mysql-trunk-mtr branch (bjorn.munch:2976 to 2978)
View as plain text  
 2978 Bjorn Munch	2010-10-21 [merge]
      upmerge follow-up to 55582

    modified:
      mysql-test/extra/binlog_tests/implicit.test
      mysql-test/extra/rpl_tests/create_recursive_construct.inc
      mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test
      mysql-test/extra/rpl_tests/rpl_loaddata.test
      mysql-test/include/check_concurrent_insert.inc
      mysql-test/include/check_no_concurrent_insert.inc
      mysql-test/include/get_relay_log_pos.inc
      mysql-test/include/kill_query.inc
      mysql-test/include/kill_query_and_diff_master_slave.inc
      mysql-test/include/setup_fake_relay_log.inc
      mysql-test/include/show_events.inc
      mysql-test/include/show_rpl_debug_info.inc
      mysql-test/include/wait_for_slave_io_error.inc
      mysql-test/include/wait_for_slave_param.inc
      mysql-test/include/wait_for_slave_sql_error.inc
      mysql-test/include/wait_for_status_var.inc
      mysql-test/suite/binlog/t/binlog_unsafe.test
      mysql-test/suite/rpl/t/rpl_killed_ddl.test
      mysql-test/t/server_uuid_embedded.test
 2977 Bjorn Munch	2010-10-21 [merge]
      merge from trunk

    added:
      mysql-test/include/ctype_filesort2.inc
      mysql-test/suite/perfschema/r/checksum.result
      mysql-test/suite/perfschema/t/checksum.test
    modified:
      client/mysqldump.c
      client/mysqltest.cc
      cmake/cmake_parse_arguments.cmake
      cmake/dtrace.cmake
      cmake/install_macros.cmake
      cmake/libutils.cmake
      cmake/mysql_add_executable.cmake
      cmake/plugin.cmake
      dbug/dbug.c
      include/m_ctype.h
      include/mysql/service_my_snprintf.h
      libmysqld/Makefile.am
      libmysqld/lib_sql.cc
      mysql-test/CMakeLists.txt
      mysql-test/collections/default.experimental
      mysql-test/extra/binlog_tests/binlog_insert_delayed.test
      mysql-test/extra/rpl_tests/create_recursive_construct.inc
      mysql-test/include/default_mysqld.cnf
      mysql-test/r/ctype_utf16.result
      mysql-test/r/ctype_utf32.result
      mysql-test/r/ctype_utf8mb4.result
      mysql-test/r/func_time.result
      mysql-test/r/parser.result
      mysql-test/r/select.result
      mysql-test/r/strict.result
      mysql-test/r/type_datetime.result
      mysql-test/r/type_newdecimal.result
      mysql-test/suite/binlog/r/binlog_row_binlog.result
      mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result
      mysql-test/suite/binlog/r/binlog_stm_binlog.result
      mysql-test/suite/binlog/r/binlog_unsafe.result
      mysql-test/suite/binlog/t/binlog_unsafe.test
      mysql-test/suite/perfschema/include/upgrade_check.inc
      mysql-test/suite/perfschema/r/server_init.result
      mysql-test/suite/perfschema/r/start_server_no_cond_class.result
      mysql-test/suite/perfschema/r/start_server_no_cond_inst.result
      mysql-test/suite/perfschema/r/start_server_no_file_class.result
      mysql-test/suite/perfschema/r/start_server_no_file_inst.result
      mysql-test/suite/perfschema/r/start_server_no_mutex_class.result
      mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result
      mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result
      mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result
      mysql-test/suite/perfschema/r/start_server_no_table_hdl.result
      mysql-test/suite/perfschema/r/start_server_no_table_inst.result
      mysql-test/suite/perfschema/r/start_server_no_thread_class.result
      mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
      mysql-test/suite/perfschema/r/start_server_off.result
      mysql-test/suite/perfschema/r/start_server_on.result
      mysql-test/suite/perfschema/t/server_init.test
      mysql-test/suite/rpl/t/disabled.def
      mysql-test/t/ctype_utf16.test
      mysql-test/t/ctype_utf32.test
      mysql-test/t/ctype_utf8mb4.test
      mysql-test/t/disabled.def
      mysql-test/t/log_tables_debug.test
      mysql-test/t/strict.test
      mysql-test/t/type_datetime.test
      mysql-test/t/type_newdecimal.test
      mysql-test/valgrind.supp
      mysys/my_gethwaddr.c
      mysys/my_getopt.c
      mysys/my_sync.c
      packaging/WiX/mysql_server.wxs.in
      sql/binlog.cc
      sql/binlog.h
      sql/derror.cc
      sql/field.cc
      sql/item_timefunc.cc
      sql/item_timefunc.h
      sql/mysqld.cc
      sql/rpl_master.cc
      sql/set_var.cc
      sql/set_var.h
      sql/sql_insert.cc
      sql/sql_lex.h
      sql/sql_plugin.cc
      sql/sql_yacc.yy
      sql/sys_vars.h
      storage/perfschema/pfs_engine_table.cc
      storage/perfschema/table_events_waits.cc
      storage/perfschema/table_events_waits.h
      strings/ctype-ucs2.c
      strings/ctype-utf8.c
      strings/my_vsnprintf.c
      unittest/mysys/my_vsnprintf-t.c
 2976 Bjorn Munch	2010-10-20 [merge]
      upmerge 52019

    modified:
      client/mysqltest.cc
=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2010-07-24 13:47:42 +0000
+++ b/client/mysqldump.c	2010-08-30 12:11:53 +0000
@@ -50,7 +50,6 @@
 #include "mysql.h"
 #include "mysql_version.h"
 #include "mysqld_error.h"
-#include "../sql/ha_ndbcluster_tables.h"
 
 /* Exit codes */
 

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2010-10-20 10:20:10 +0000
+++ b/client/mysqltest.cc	2010-10-21 12:36:16 +0000
@@ -250,11 +250,14 @@ struct st_connection
   my_bool pending;
 
 #ifdef EMBEDDED_LIBRARY
+  pthread_t tid;
   const char *cur_query;
   int cur_query_len;
-  pthread_mutex_t mutex;
-  pthread_cond_t cond;
-  pthread_t tid;
+  int command, result;
+  pthread_mutex_t query_mutex;
+  pthread_cond_t query_cond;
+  pthread_mutex_t result_mutex;
+  pthread_cond_t result_cond;
   int query_done;
   my_bool has_thread;
 #endif /*EMBEDDED_LIBRARY*/
@@ -710,71 +713,146 @@ void handle_no_error(struct st_command*)
 
 #ifdef EMBEDDED_LIBRARY
 
+#define EMB_SEND_QUERY 1
+#define EMB_READ_QUERY_RESULT 2
+#define EMB_END_CONNECTION 3
+
 /* attributes of the query thread */
 pthread_attr_t cn_thd_attrib;
 
+
 /*
-  send_one_query executes query in separate thread, which is
-  necessary in embedded library to run 'send' in proper way.
-  This implementation doesn't handle errors returned
-  by mysql_send_query. It's technically possible, though
-  I don't see where it is needed.
+  This procedure represents the connection and actually
+  runs queries when in the EMBEDDED-SERVER mode.
+  The run_query_normal() just sends request for running
+  mysql_send_query and mysql_read_query_result() here.
 */
-pthread_handler_t send_one_query(void *arg)
+
+pthread_handler_t connection_thread(void *arg)
 {
   struct st_connection *cn= (struct st_connection*)arg;
 
   mysql_thread_init();
-  (void) mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len);
+  while (cn->command != EMB_END_CONNECTION)
+  {
+    if (!cn->command)
+    {
+      pthread_mutex_lock(&cn->query_mutex);
+      while (!cn->command)
+        pthread_cond_wait(&cn->query_cond, &cn->query_mutex);
+      pthread_mutex_unlock(&cn->query_mutex);
+    }
+    switch (cn->command)
+    {
+      case EMB_END_CONNECTION:
+        goto end_thread;
+      case EMB_SEND_QUERY:
+        cn->result= mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len);
+        break;
+      case EMB_READ_QUERY_RESULT:
+        cn->result= mysql_read_query_result(&cn->mysql);
+        break;
+      default:
+        DBUG_ASSERT(0);
+    }
+    cn->command= 0;
+    pthread_mutex_lock(&cn->result_mutex);
+    cn->query_done= 1;
+    pthread_cond_signal(&cn->result_cond);
+    pthread_mutex_unlock(&cn->result_mutex);
+  }
 
-  mysql_thread_end();
-  pthread_mutex_lock(&cn->mutex);
+end_thread:
   cn->query_done= 1;
-  pthread_cond_signal(&cn->cond);
-  pthread_mutex_unlock(&cn->mutex);
+  mysql_thread_end();
   pthread_exit(0);
   return 0;
 }
 
-static int do_send_query(struct st_connection *cn, const char *q, int q_len,
-                         int flags)
+static void wait_query_thread_done(struct st_connection *con)
 {
-  if (flags & QUERY_REAP_FLAG)
-    return mysql_send_query(&cn->mysql, q, q_len);
+  DBUG_ASSERT(con->has_thread);
+  if (!con->query_done)
+  {
+    pthread_mutex_lock(&con->result_mutex);
+    while (!con->query_done)
+      pthread_cond_wait(&con->result_cond, &con->result_mutex);
+    pthread_mutex_unlock(&con->result_mutex);
+  }
+}
 
-  if (pthread_mutex_init(&cn->mutex, NULL) ||
-      pthread_cond_init(&cn->cond, NULL))
-    die("Error in the thread library");
 
-  cn->cur_query= q;
-  cn->cur_query_len= q_len;
+static void signal_connection_thd(struct st_connection *cn, int command)
+{
+  DBUG_ASSERT(cn->has_thread);
   cn->query_done= 0;
-  if (pthread_create(&cn->tid, &cn_thd_attrib, send_one_query, (void*)cn))
-    die("Cannot start new thread for query");
+  cn->command= command;
+  pthread_mutex_lock(&cn->query_mutex);
+  pthread_cond_signal(&cn->query_cond);
+  pthread_mutex_unlock(&cn->query_mutex);
+}
+
 
-  cn->has_thread= TRUE;
+/*
+  Sometimes we try to execute queries when the connection is closed.
+  It's done to make sure it was closed completely.
+  So that if our connection is closed (cn->has_thread == 0), we just return
+  the mysql_send_query() result which is an error in this case.
+*/
+
+static int do_send_query(struct st_connection *cn, const char *q, int q_len)
+{
+  if (!cn->has_thread)
+    return mysql_send_query(&cn->mysql, q, q_len);
+  cn->cur_query= q;
+  cn->cur_query_len= q_len;
+  signal_connection_thd(cn, EMB_SEND_QUERY);
   return 0;
 }
 
-static void wait_query_thread_end(struct st_connection *con)
+static int do_read_query_result(struct st_connection *cn)
 {
-  if (!con->query_done)
-  {
-    pthread_mutex_lock(&con->mutex);
-    while (!con->query_done)
-      pthread_cond_wait(&con->cond, &con->mutex);
-    pthread_mutex_unlock(&con->mutex);
-  }
-  if (con->has_thread)
-  {
-    pthread_join(con->tid, NULL);
-    con->has_thread= FALSE;
-  }
+  DBUG_ASSERT(cn->has_thread);
+  wait_query_thread_done(cn);
+  signal_connection_thd(cn, EMB_READ_QUERY_RESULT);
+  wait_query_thread_done(cn);
+
+  return cn->result;
+}
+
+
+static void emb_close_connection(struct st_connection *cn)
+{
+  if (!cn->has_thread)
+    return;
+  wait_query_thread_done(cn);
+  signal_connection_thd(cn, EMB_END_CONNECTION);
+  pthread_join(cn->tid, NULL);
+  cn->has_thread= FALSE;
+  pthread_mutex_destroy(&cn->query_mutex);
+  pthread_cond_destroy(&cn->query_cond);
+  pthread_mutex_destroy(&cn->result_mutex);
+  pthread_cond_destroy(&cn->result_cond);
+}
+
+
+static void init_connection_thd(struct st_connection *cn)
+{
+  cn->query_done= 1;
+  cn->command= 0;
+  if (pthread_mutex_init(&cn->query_mutex, NULL) ||
+      pthread_cond_init(&cn->query_cond, NULL) ||
+      pthread_mutex_init(&cn->result_mutex, NULL) ||
+      pthread_cond_init(&cn->result_cond, NULL) ||
+      pthread_create(&cn->tid, &cn_thd_attrib, connection_thread, (void*)cn))
+    die("Error in the thread library");
+  cn->has_thread=TRUE;
 }
 
 #else /*EMBEDDED_LIBRARY*/
 
-#define do_send_query(cn,q,q_len,flags) mysql_send_query(&cn->mysql, q, q_len)
+#define do_send_query(cn,q,q_len) mysql_send_query(&cn->mysql, q, q_len)
+#define do_read_query_result(cn) mysql_read_query_result(&cn->mysql)
 
 #endif /*EMBEDDED_LIBRARY*/
 
@@ -1117,6 +1195,9 @@ void close_connections()
   DBUG_ENTER("close_connections");
   for (--next_con; next_con >= connections; --next_con)
   {
+#ifdef EMBEDDED_LIBRARY
+    emb_close_connection(next_con);
+#endif
     if (next_con->stmt)
       mysql_stmt_close(next_con->stmt);
     next_con->stmt= 0;
@@ -4921,7 +5002,7 @@ void do_close_connection(struct st_comma
     we need to check if the query's thread was finished and probably wait
     (embedded-server specific)
   */
-  wait_query_thread_end(con);
+  emb_close_connection(con);
 #endif /*EMBEDDED_LIBRARY*/
   if (con->stmt)
     mysql_stmt_close(con->stmt);
@@ -5288,9 +5369,9 @@ void do_connect(struct st_command *comma
   }
 
 #ifdef EMBEDDED_LIBRARY
-  con_slot->query_done= 1;
-  con_slot->has_thread= FALSE;
-#endif
+  init_connection_thd(con_slot);
+#endif /*EMBEDDED_LIBRARY*/
+
   if (!mysql_init(&con_slot->mysql))
     die("Failed on mysql_init()");
 
@@ -6849,21 +6930,13 @@ void run_query_normal(struct st_connecti
     /*
       Send the query
     */
-    if (do_send_query(cn, query, query_len, flags))
+    if (do_send_query(cn, query, query_len))
     {
       handle_error(command, mysql_errno(mysql), mysql_error(mysql),
 		   mysql_sqlstate(mysql), ds);
       goto end;
     }
   }
-#ifdef EMBEDDED_LIBRARY
-  /*
-    Here we handle 'reap' command, so we need to check if the
-    query's thread was finished and probably wait
-  */
-  else if (flags & QUERY_REAP_FLAG)
-    wait_query_thread_end(cn);
-#endif /*EMBEDDED_LIBRARY*/
   if (!(flags & QUERY_REAP_FLAG))
   {
     cn->pending= TRUE;
@@ -6876,7 +6949,7 @@ void run_query_normal(struct st_connecti
       When  on first result set, call mysql_read_query_result to retrieve
       answer to the query sent earlier
     */
-    if ((counter==0) && mysql_read_query_result(mysql))
+    if ((counter==0) && do_read_query_result(cn))
     {
       handle_error(command, mysql_errno(mysql), mysql_error(mysql),
 		   mysql_sqlstate(mysql), ds);
@@ -8056,6 +8129,9 @@ int main(int argc, char **argv)
     ps_protocol_enabled= 1;
 
   st_connection *con= connections;
+#ifdef EMBEDDED_LIBRARY
+  init_connection_thd(con);
+#endif /*EMBEDDED_LIBRARY*/
   if (!( mysql_init(&con->mysql)))
     die("Failed in mysql_init()");
   if (opt_connect_timeout)

=== modified file 'cmake/cmake_parse_arguments.cmake'
--- a/cmake/cmake_parse_arguments.cmake	2009-12-12 01:03:05 +0000
+++ b/cmake/cmake_parse_arguments.cmake	2010-09-29 09:42:35 +0000
@@ -15,7 +15,7 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 # Handy macro to parse macro arguments
-MACRO(CMAKE_PARSE_ARGUMENTS prefix arg_names option_names)
+MACRO(MYSQL_PARSE_ARGUMENTS prefix arg_names option_names)
   SET(DEFAULT_ARGS)
   FOREACH(arg_name ${arg_names})    
     SET(${prefix}_${arg_name})

=== modified file 'cmake/dtrace.cmake'
--- a/cmake/dtrace.cmake	2010-02-25 16:31:31 +0000
+++ b/cmake/dtrace.cmake	2010-09-06 12:45:12 +0000
@@ -13,13 +13,30 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
 
+IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_COMPILER_IS_GNUCXX
+  AND CMAKE_SIZEOF_VOID_P EQUAL 4)
+  IF(NOT DEFINED BUGGY_GCC_NO_DTRACE_MODULES)
+    EXECUTE_PROCESS(
+      COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}  --version
+      OUTPUT_VARIABLE out)
+    IF(out MATCHES "3.4.6")
+     # This gcc causes crashes in dlopen() for dtraced shared libs,
+     # while standard shipped with Solaris10 3.4.3 is ok
+     SET(BUGGY_GCC_NO_DTRACE_MODULES 1 CACHE INTERNAL "")
+    ELSE()
+     SET(BUGGY_GCC_NO_DTRACE_MODULES 0 CACHE INTERNAL "")
+    ENDIF()
+  ENDIF()
+ENDIF()
+
 # Check if OS supports DTrace
 MACRO(CHECK_DTRACE)
  FIND_PROGRAM(DTRACE dtrace)
  MARK_AS_ADVANCED(DTRACE)
 
  # On FreeBSD, dtrace does not handle userland tracing yet
- IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD"
+     AND NOT BUGGY_GCC_NO_DTRACE_MODULES)
    SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace")
  ENDIF()
  SET(HAVE_DTRACE ${ENABLE_DTRACE})
@@ -72,22 +89,6 @@ IF(ENABLE_DTRACE)
   ) 
 ENDIF()
 
-IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_COMPILER_IS_GNUCXX
-  AND CMAKE_SIZEOF_VOID_P EQUAL 4)
-  IF(NOT DEFINED BUGGY_GCC_NO_DTRACE_MODULES)
-    EXECUTE_PROCESS(
-      COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}  --version
-      OUTPUT_VARIABLE out)
-    IF(out MATCHES "3.4.6")
-     # This gcc causes crashes in dlopen() for dtraced shared libs,
-     # while standard shipped with Solaris10 3.4.3 is ok
-     SET(BUGGY_GCC_NO_DTRACE_MODULES 1 CACHE INTERNAL "")
-    ELSE()
-     SET(BUGGY_GCC_NO_DTRACE_MODULES 0 CACHE INTERNAL "")
-    ENDIF()
-  ENDIF()
-ENDIF()
-
 FUNCTION(DTRACE_INSTRUMENT target)
   IF(BUGGY_GCC_NO_DTRACE_MODULES)
     GET_TARGET_PROPERTY(target_type ${target} TYPE)

=== modified file 'cmake/install_macros.cmake'
--- a/cmake/install_macros.cmake	2010-06-30 21:08:12 +0000
+++ b/cmake/install_macros.cmake	2010-09-29 10:03:11 +0000
@@ -83,7 +83,7 @@ FUNCTION(INSTALL_MANPAGE file)
 ENDFUNCTION()
 
 FUNCTION(INSTALL_SCRIPT)
- CMAKE_PARSE_ARGUMENTS(ARG
+ MYSQL_PARSE_ARGUMENTS(ARG
   "DESTINATION;COMPONENT"
   ""
   ${ARGN}
@@ -205,7 +205,7 @@ ENDMACRO()
 #
 
 FUNCTION(MYSQL_INSTALL_TARGETS)
-  CMAKE_PARSE_ARGUMENTS(ARG
+  MYSQL_PARSE_ARGUMENTS(ARG
     "DESTINATION;COMPONENT"
   ""
   ${ARGN}
@@ -247,7 +247,7 @@ SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/d
 
 
 FUNCTION(INSTALL_DEBUG_TARGET target)
- CMAKE_PARSE_ARGUMENTS(ARG
+ MYSQL_PARSE_ARGUMENTS(ARG
   "DESTINATION;RENAME;PDB_DESTINATION;COMPONENT"
   ""
   ${ARGN}

=== modified file 'cmake/libutils.cmake'
--- a/cmake/libutils.cmake	2010-06-21 13:20:18 +0000
+++ b/cmake/libutils.cmake	2010-09-29 10:03:11 +0000
@@ -213,7 +213,7 @@ ENDMACRO()
 #  [OUTPUT_NAME output_name]
 #)
 MACRO(MERGE_LIBRARIES)
-  CMAKE_PARSE_ARGUMENTS(ARG
+  MYSQL_PARSE_ARGUMENTS(ARG
     "EXPORTS;OUTPUT_NAME;COMPONENT"
     "STATIC;SHARED;MODULE;NOINSTALL"
     ${ARGN}

=== modified file 'cmake/mysql_add_executable.cmake'
--- a/cmake/mysql_add_executable.cmake	2010-06-21 13:20:18 +0000
+++ b/cmake/mysql_add_executable.cmake	2010-09-29 10:03:11 +0000
@@ -28,7 +28,7 @@ INCLUDE(cmake_parse_arguments)
 
 FUNCTION (MYSQL_ADD_EXECUTABLE)
   # Pass-through arguments for ADD_EXECUTABLE
-  CMAKE_PARSE_ARGUMENTS(ARG
+  MYSQL_PARSE_ARGUMENTS(ARG
    "WIN32;MACOSX_BUNDLE;EXCLUDE_FROM_ALL;DESTINATION;COMPONENT"
    ""
    ${ARGN}

=== modified file 'cmake/plugin.cmake'
--- a/cmake/plugin.cmake	2010-08-05 16:45:21 +0000
+++ b/cmake/plugin.cmake	2010-09-29 10:03:11 +0000
@@ -28,7 +28,7 @@ INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_
 # [DEPENDENCIES target1...targetN]
 
 MACRO(MYSQL_ADD_PLUGIN)
-  CMAKE_PARSE_ARGUMENTS(ARG
+  MYSQL_PARSE_ARGUMENTS(ARG
     "LINK_LIBRARIES;DEPENDENCIES;MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME"
     "STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;RECOMPILE_FOR_EMBEDDED"
     ${ARGN}

=== modified file 'dbug/dbug.c'
--- a/dbug/dbug.c	2010-07-15 11:41:37 +0000
+++ b/dbug/dbug.c	2010-09-15 11:51:29 +0000
@@ -1335,15 +1335,11 @@ void _db_doprnt_(const char *format,...)
  * This function is intended as a
  * vfprintf clone with consistent, platform independent output for 
  * problematic formats like %p, %zd and %lld.
- * However: full functionality for my_vsnprintf has not been backported yet,
- * so code using "%g" or "%f" will have undefined behaviour.
  */
 static void DbugVfprintf(FILE *stream, const char* format, va_list args)
 {
   char cvtbuf[1024];
-  size_t len;
-  /* Do not use my_vsnprintf, it does not support "%g". */
-  len = vsnprintf(cvtbuf, sizeof(cvtbuf), format, args);
+  (void) my_vsnprintf(cvtbuf, sizeof(cvtbuf), format, args);
   (void) fprintf(stream, "%s\n", cvtbuf);
 }
 

=== modified file 'include/m_ctype.h'
--- a/include/m_ctype.h	2010-09-13 10:04:11 +0000
+++ b/include/m_ctype.h	2010-09-28 15:29:26 +0000
@@ -628,6 +628,11 @@ size_t my_strnxfrm_unicode(CHARSET_INFO
                            uchar *dst, size_t dstlen, uint nweights,
                            const uchar *src, size_t srclen, uint flags);
 
+size_t my_strnxfrm_unicode_full_bin(CHARSET_INFO *,
+                                    uchar *dst, size_t dstlen, uint nweights,
+                                    const uchar *src, size_t srclen, uint flags);
+size_t  my_strnxfrmlen_unicode_full_bin(CHARSET_INFO *, size_t); 
+
 int my_wildcmp_unicode(CHARSET_INFO *cs,
                        const char *str, const char *str_end,
                        const char *wildstr, const char *wildend,

=== modified file 'include/mysql/service_my_snprintf.h'
--- a/include/mysql/service_my_snprintf.h	2010-07-20 19:34:20 +0000
+++ b/include/mysql/service_my_snprintf.h	2010-09-15 11:33:22 +0000
@@ -53,7 +53,7 @@
   <length modifier> can be 'l', 'll', or 'z'.
 
   Supported formats are 's' (null pointer is accepted, printed as
-  "(null)"), 'b' (extension, see below), 'c', 'd', 'u', 'x', 'o',
+  "(null)"), 'b' (extension, see below), 'c', 'd', 'i', 'u', 'x', 'o',
   'X', 'p' (works as 0x%x).
 
   Standard syntax for positional arguments $n is supported.

=== modified file 'libmysqld/Makefile.am'
--- a/libmysqld/Makefile.am	2010-08-20 08:48:59 +0000
+++ b/libmysqld/Makefile.am	2010-09-01 12:50:57 +0000
@@ -1,21 +1,17 @@
 # Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
 # 
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; version 2
-# of the License.
+# 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 library is distributed in the hope that it will be useful,
+# 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
-# Library General Public License for more details.
+# 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 Library General Public
-# License along with this library; if not, write to the Free
-# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-# MA 02111-1307, USA
-#
-# This file is public domain and comes with NO WARRANTY of any kind
+# 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
 
 MYSQLDATAdir =		$(localstatedir)
 MYSQLSHAREdir =		$(pkgdatadir)

=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc	2010-07-19 16:09:51 +0000
+++ b/libmysqld/lib_sql.cc	2010-09-08 07:09:13 +0000
@@ -481,6 +481,10 @@ int init_embedded_server(int argc, char
   char *fake_argv[] = { (char *)"", 0 };
   const char *fake_groups[] = { "server", "embedded", 0 };
   my_bool acl_error;
+
+  if (my_thread_init())
+    return 1;
+
   if (argc)
   {
     argcp= &argc;

=== modified file 'mysql-test/CMakeLists.txt'
--- a/mysql-test/CMakeLists.txt	2010-08-23 17:01:12 +0000
+++ b/mysql-test/CMakeLists.txt	2010-09-02 22:29:56 +0000
@@ -13,6 +13,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
+IF(INSTALL_MYSQLTESTDIR)
 INSTALL(
   DIRECTORY .
   DESTINATION ${INSTALL_MYSQLTESTDIR}
@@ -28,6 +29,7 @@ INSTALL(
   PATTERN "*.am" EXCLUDE
   PATTERN "*.in" EXCLUDE
 )
+ENDIF()
 
 
 
@@ -48,9 +50,11 @@ IF(UNIX)
      ./mysql-test-run.pl mysql-test-run
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
   ) 
-  INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mtr 
-    ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run 
-    DESTINATION ${INSTALL_MYSQLTESTDIR})
+  IF(INSTALL_MYSQLTESTDIR)
+    INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mtr 
+      ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run 
+      DESTINATION ${INSTALL_MYSQLTESTDIR})
+  ENDIF()
 ENDIF()
 
 IF(CMAKE_GENERATOR MATCHES "Visual Studio")

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2010-09-06 08:36:48 +0000
+++ b/mysql-test/collections/default.experimental	2010-09-28 15:29:26 +0000
@@ -93,6 +93,5 @@ parts.partition_mgm_lc1_ndb
 parts.partition_mgm_lc2_ndb              # joro : NDB tests marked as experimental as agreed with bochklin
 parts.partition_syntax_ndb               # joro : NDB tests marked as experimental as agreed with bochklin
 parts.partition_value_ndb                # joro : NDB tests marked as experimental as agreed with bochklin
-main.mysqlhotcopy_myisam                 # horst: due to bug#54129
-main.mysqlhotcopy_archive                # horst: due to bug#54129
+
 rpl_bhs.*                                # skozlov : WL#5139 - rpl_bhs suite generated "on-the-fly" at testing moment from rpl suite

=== modified file 'mysql-test/extra/binlog_tests/binlog_insert_delayed.test'
--- a/mysql-test/extra/binlog_tests/binlog_insert_delayed.test	2008-07-23 16:56:39 +0000
+++ b/mysql-test/extra/binlog_tests/binlog_insert_delayed.test	2010-08-30 06:03:28 +0000
@@ -52,13 +52,19 @@ inc $count;
 FLUSH TABLES;
 source include/show_binlog_events.inc;
 
-insert delayed into t1 values (null),(null),(null),(null);
+RESET MASTER;
+insert /* before delayed */ delayed /* after delayed */ into t1 values (null),(null),(null),(null);
 inc $count; inc $count; inc $count; inc $count;
 --source include/wait_until_rows_count.inc
 
-insert delayed into t1 values (null),(null),(400),(null);
+insert  /*! delayed */ into t1 values (null),(null),(400),(null);
 inc $count; inc $count; inc $count; inc $count;
 --source include/wait_until_rows_count.inc
 
+if (`SELECT @@SESSION.BINLOG_FORMAT = 'STATEMENT'`) {
+  FLUSH TABLES;
+  source include/show_binlog_events.inc;
+}
+
 select * from t1;
 drop table t1;

=== modified file 'mysql-test/extra/binlog_tests/implicit.test'
--- a/mysql-test/extra/binlog_tests/implicit.test	2009-09-23 11:20:48 +0000
+++ b/mysql-test/extra/binlog_tests/implicit.test	2010-10-21 07:37:10 +0000
@@ -6,7 +6,7 @@ INSERT INTO t1 VALUES (1);
 source include/show_binlog_events.inc;
 eval $statement;
 source include/show_binlog_events.inc;
-if (`select '$cleanup' != ''`) {
+if ($cleanup) {
   eval $cleanup;
 }
 
@@ -22,7 +22,7 @@ INSERT INTO t1 VALUES (3);
 source include/show_binlog_events.inc;
 COMMIT;
 source include/show_binlog_events.inc;
-if (`select '$cleanup' != ''`) {
+if ($cleanup) {
   eval $cleanup;
 }
 

=== modified file 'mysql-test/extra/rpl_tests/create_recursive_construct.inc'
--- a/mysql-test/extra/rpl_tests/create_recursive_construct.inc	2010-08-10 11:58:46 +0000
+++ b/mysql-test/extra/rpl_tests/create_recursive_construct.inc	2010-10-21 12:36:16 +0000
@@ -285,10 +285,10 @@ if (`SELECT $CRC_ARG_type = 7`) {
 }
 
 ######## execute! ########
-if (`SELECT '$CRC_RET_stmt_sidef' != ''`) {
+if ($CRC_RET_stmt_sidef) {
   --echo
   --echo Invoking $CRC_RET_desc.
-  if (`SELECT '$CRC_create' != ''`) {
+  if ($CRC_create) {
     --eval $CRC_create
   }
 
@@ -338,10 +338,21 @@ if (`SELECT '$CRC_RET_stmt_sidef' != ''`
     SHOW BINLOG EVENTS;
     --die Warnings printed
   }
-  # The first event is format_description, the second is
-  # Query_event('BEGIN'), and the third should be our Table_map.
   --let $event_type= query_get_value(SHOW BINLOG EVENTS, Event_type, 3)
-  if (`SELECT '$event_type' != 'Table_map'`) {
+  # The first event is format_description, the second is
+  # Query_event('BEGIN'), and the third should be our Query
+  # for 'INSERT DELAYED' unsafe_type 3, which is safe after
+  # the fix of bug#54579.
+  if (`SELECT $unsafe_type = 3 AND '$event_type' != 'Query'`) {
+    --enable_query_log
+    --echo ******** Failure! Event number 3 was a '$event_type', not a 'Query'. ********
+    SHOW BINLOG EVENTS;
+    --die Wrong events in binlog.
+  }
+  # The first event is format_description, the second is
+  # Query_event('BEGIN'), and the third should be our Table_map
+  # for unsafe statement.
+  if (`SELECT $unsafe_type != 3 AND '$event_type' != 'Table_map'`) {
     --enable_query_log
     --echo ******** Failure! Event number 3 was a '$event_type', not a 'Table_map'. ********
     SHOW WARNINGS;
@@ -355,7 +366,7 @@ if (`SELECT '$CRC_RET_stmt_sidef' != ''`
 
 # Invoke created object, discarding the return value. This should not
 # give any warning.
-if (`SELECT '$CRC_RET_sel_retval' != ''`) {
+if ($CRC_RET_sel_retval) {
   --echo * Invoke statement so that return value is dicarded: expect no warning.
   --disable_result_log
   --eval $CRC_RET_sel_retval

=== modified file 'mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test'
--- a/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test	2010-07-12 11:55:16 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test	2010-10-21 12:36:16 +0000
@@ -34,7 +34,7 @@
 #
 
 connection slave;
-if (`SELECT $debug_sync_action = ''`)
+if (!$debug_sync_action)
 {
     --die Cannot continue. Please set value for debug_sync_action.
 }

=== modified file 'mysql-test/extra/rpl_tests/rpl_loaddata.test'
--- a/mysql-test/extra/rpl_tests/rpl_loaddata.test	2010-08-04 08:10:38 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test	2010-10-21 12:36:16 +0000
@@ -25,7 +25,7 @@ CALL mtr.add_suppression("Unsafe stateme
 # MTR is not case-sensitive.
 let $lower_stmt_head= load data;
 let $UPPER_STMT_HEAD= LOAD DATA;
-if (`SELECT '$lock_option' <> ''`)
+if ($lock_option)
 {
   #if $lock_option is null, an extra blank is added into the statement,
   #this will change the result of rpl_loaddata test case. so $lock_option

=== modified file 'mysql-test/include/check_concurrent_insert.inc'
--- a/mysql-test/include/check_concurrent_insert.inc	2010-06-17 13:31:51 +0000
+++ b/mysql-test/include/check_concurrent_insert.inc	2010-10-21 07:37:10 +0000
@@ -23,7 +23,7 @@
 # Reset DEBUG_SYNC facility for safety.
 set debug_sync= "RESET";
 
-if (`SELECT '$restore_table' <> ''`)
+if ($restore_table)
 {
 --eval create temporary table t_backup select * from $restore_table;
 }
@@ -82,7 +82,7 @@ connection default;
 
 --eval delete from $table where i = 0;
 
-if (`SELECT '$restore_table' <> ''`)
+if ($restore_table)
 {
 --eval truncate table $restore_table;
 --eval insert into $restore_table select * from t_backup;

=== modified file 'mysql-test/include/check_no_concurrent_insert.inc'
--- a/mysql-test/include/check_no_concurrent_insert.inc	2010-08-06 11:29:37 +0000
+++ b/mysql-test/include/check_no_concurrent_insert.inc	2010-10-21 07:37:10 +0000
@@ -23,7 +23,7 @@
 # Reset DEBUG_SYNC facility for safety.
 set debug_sync= "RESET";
 
-if (`SELECT '$restore_table' <> ''`)
+if ($restore_table)
 {
 --eval create temporary table t_backup select * from $restore_table;
 }
@@ -68,7 +68,7 @@ if (!$success)
 
 --eval delete from $table where i = 0;
 
-if (`SELECT '$restore_table' <> ''`)
+if ($restore_table)
 {
 --eval truncate table $restore_table;
 --eval insert into $restore_table select * from t_backup;

=== added file 'mysql-test/include/ctype_filesort2.inc'
--- a/mysql-test/include/ctype_filesort2.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/ctype_filesort2.inc	2010-09-28 15:29:26 +0000
@@ -0,0 +1,18 @@
+#
+# Testing filesort for full Unicode character sets
+# with supplementary characters.
+#
+
+--echo #
+--echo # Bug#55980 Character sets: supplementary character _bin ordering is wrong
+--echo #
+CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84);
+INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080);
+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
+ALTER TABLE t1 ADD KEY(a);
+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
+--echo # Additional test for bug#37244 Character sets: short utf8_bin weight_string value
+SELECT HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a;
+DROP TABLE IF EXISTS t1;

=== modified file 'mysql-test/include/default_mysqld.cnf'
--- a/mysql-test/include/default_mysqld.cnf	2010-03-01 00:06:27 +0000
+++ b/mysql-test/include/default_mysqld.cnf	2010-09-09 16:00:27 +0000
@@ -43,5 +43,11 @@ log-bin=mysqld-bin
 
 # Run tests with the performance schema instrumentation
 loose-enable-performance-schema
+# Run tests with a small number of instrumented objects
+# to limit memory consumption with MTR
+loose-performance-schema-max-mutex-instances=10000
+loose-performance-schema-max-rwlock-instances=10000
+loose-performance-schema-max-table-instances=500
+loose-performance-schema-max-table-handles=1000
 
 binlog-direct-non-transactional-updates

=== modified file 'mysql-test/include/get_relay_log_pos.inc'
--- a/mysql-test/include/get_relay_log_pos.inc	2010-05-26 14:34:25 +0000
+++ b/mysql-test/include/get_relay_log_pos.inc	2010-10-21 07:37:10 +0000
@@ -10,12 +10,12 @@
 #   # at this point, get_relay_log_pos.inc sets $relay_log_pos. echo position
 #   # in $relay_log_file: $relay_log_pos. 
 
-if (`SELECT '$relay_log_file' = ''`)
+if (!$relay_log_file)
 {
   --die 'variable $relay_log_file is null'
 }
 
-if (`SELECT '$master_log_pos' = ''`)
+if (!$master_log_pos)
 {
   --die 'variable $master_log_pos is null'
 }

=== modified file 'mysql-test/include/kill_query.inc'
--- a/mysql-test/include/kill_query.inc	2009-12-10 03:44:19 +0000
+++ b/mysql-test/include/kill_query.inc	2010-10-20 14:15:32 +0000
@@ -44,7 +44,7 @@ connection master;
 # kill the query that is waiting
 eval kill query $connection_id;
 
-if (`SELECT '$debug_lock' != ''`)
+if ($debug_lock)
 {
   # release the lock to allow binlog continue
   eval SELECT RELEASE_LOCK($debug_lock);
@@ -57,7 +57,7 @@ reap;
 
 connection master;
 
-if (`SELECT '$debug_lock' != ''`)
+if ($debug_lock)
 {
   # get lock again to make the next query wait
   eval SELECT GET_LOCK($debug_lock, 10);

=== modified file 'mysql-test/include/kill_query_and_diff_master_slave.inc'
--- a/mysql-test/include/kill_query_and_diff_master_slave.inc	2009-03-27 05:19:50 +0000
+++ b/mysql-test/include/kill_query_and_diff_master_slave.inc	2010-10-20 14:15:32 +0000
@@ -25,7 +25,7 @@ source include/kill_query.inc;
 connection master;
 disable_query_log;
 disable_result_log;
-if (`SELECT '$debug_lock' != ''`)
+if ($debug_lock)
 {
   eval SELECT RELEASE_LOCK($debug_lock);
 }
@@ -36,8 +36,8 @@ source include/diff_master_slave.inc;
 
 # Acquire the debug lock again if used
 connection master;
-disable_query_log; disable_result_log; if (`SELECT '$debug_lock' !=
-''`) { eval SELECT GET_LOCK($debug_lock, 10); } enable_result_log;
-enable_query_log;
+disable_query_log; disable_result_log;
+if ($debug_lock) { eval SELECT GET_LOCK($debug_lock, 10); }
+enable_result_log; enable_query_log;
 
 connection $connection_name;

=== modified file 'mysql-test/include/setup_fake_relay_log.inc'
--- a/mysql-test/include/setup_fake_relay_log.inc	2010-09-20 08:24:39 +0000
+++ b/mysql-test/include/setup_fake_relay_log.inc	2010-10-21 12:36:16 +0000
@@ -56,7 +56,7 @@ if (`SELECT "$_sql_running" = "Yes" OR "
 # Read server variables.
 let $MYSQLD_DATADIR= `SELECT @@datadir`;
 let $_fake_filename= query_get_value(SHOW VARIABLES LIKE 'relay_log', Value, 1);
-if (`SELECT '$_fake_filename' = ''`) {
+if (!$_fake_filename) {
   --echo Badly written test case: relay_log variable is empty. Please use the
   --echo server option --relay-log=FILE.
 }

=== modified file 'mysql-test/include/show_events.inc'
--- a/mysql-test/include/show_events.inc	2010-05-26 14:34:25 +0000
+++ b/mysql-test/include/show_events.inc	2010-10-21 07:37:10 +0000
@@ -18,14 +18,14 @@ if ($is_relay_log)
   --let $_statement=show relaylog events
 }
 
-if (`SELECT '$binlog_file' <> ''`)
+if ($binlog_file)
 {
   --let $_statement= $_statement in '$binlog_file'
 }
 
 --let $_statement= $_statement from $binlog_start
 
-if (`SELECT '$binlog_limit' <> ''`)
+if ($binlog_limit)
 {
   --let $_statement= $_statement limit $binlog_limit
 }

=== modified file 'mysql-test/include/show_rpl_debug_info.inc'
--- a/mysql-test/include/show_rpl_debug_info.inc	2010-05-24 13:54:08 +0000
+++ b/mysql-test/include/show_rpl_debug_info.inc	2010-10-20 14:15:32 +0000
@@ -48,13 +48,13 @@ let $binlog_name= query_get_value("SHOW
 eval SHOW BINLOG EVENTS IN '$binlog_name';
 
 let $_master_con= $master_connection;
-if (`SELECT '$_master_con' = ''`)
+if (!$_master_con)
 {
   if (`SELECT '$_con' = 'slave'`)
   {
     let $_master_con= master;
   }
-  if (`SELECT '$_master_con' = ''`)
+  if (!$_master_con)
   {
     --echo Unable to determine master connection. No debug info printed for master.
     --echo Please fix the test case by setting $master_connection before sourcing
@@ -62,7 +62,7 @@ if (`SELECT '$_master_con' = ''`)
   }
 }
 
-if (`SELECT '$_master_con' != ''`)
+if ($_master_con)
 {
 
   let $master_binlog_name_io= query_get_value("SHOW SLAVE STATUS", Master_Log_File, 1);

=== modified file 'mysql-test/include/wait_for_slave_io_error.inc'
--- a/mysql-test/include/wait_for_slave_io_error.inc	2010-07-12 11:55:16 +0000
+++ b/mysql-test/include/wait_for_slave_io_error.inc	2010-10-21 12:36:16 +0000
@@ -31,7 +31,7 @@
 # $master_connection
 #   See wait_for_slave_param.inc for description.
 
-if (`SELECT '$slave_io_errno' = ''`) {
+if (!$slave_io_errno) {
   --die !!!ERROR IN TEST: you must set \$slave_io_errno before sourcing wait_for_slave_io_error.inc
 }
 

=== modified file 'mysql-test/include/wait_for_slave_param.inc'
--- a/mysql-test/include/wait_for_slave_param.inc	2010-05-26 14:34:25 +0000
+++ b/mysql-test/include/wait_for_slave_param.inc	2010-10-21 07:37:10 +0000
@@ -53,7 +53,7 @@ if (!$_slave_timeout_counter)
 let $slave_tcnt= $_slave_timeout_counter;
 
 let $_slave_param_comparison= $slave_param_comparison;
-if (`SELECT '$_slave_param_comparison' = ''`)
+if (!$_slave_param_comparison)
 {
   let $_slave_param_comparison= =;
 }
@@ -73,7 +73,7 @@ while (`SELECT NOT('$_show_slave_status_
 if (!$_slave_timeout_counter)
 {
   --echo **** ERROR: timeout after $slave_tcnt deci-seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
-  if (`SELECT '$slave_error_message' != ''`)
+  if ($slave_error_message)
   {
     --echo Message: $slave_error_message
   }

=== modified file 'mysql-test/include/wait_for_slave_sql_error.inc'
--- a/mysql-test/include/wait_for_slave_sql_error.inc	2010-06-18 11:10:53 +0000
+++ b/mysql-test/include/wait_for_slave_sql_error.inc	2010-10-21 12:36:16 +0000
@@ -31,7 +31,7 @@
 # $master_connection
 #   See wait_for_slave_param.inc for description.
 
-if (`SELECT '$slave_sql_errno' = ''`) {
+if (!$slave_sql_errno) {
   --die !!!ERROR IN TEST: you must set \$slave_sql_errno before sourcing wait_for_slave_sql_error.inc
 }
 

=== modified file 'mysql-test/include/wait_for_status_var.inc'
--- a/mysql-test/include/wait_for_status_var.inc	2010-05-24 13:54:08 +0000
+++ b/mysql-test/include/wait_for_status_var.inc	2010-10-20 14:15:32 +0000
@@ -45,7 +45,7 @@ if (!$_status_timeout_counter)
 }
 
 let $_status_var_comparsion= $status_var_comparsion;
-if (`SELECT '$_status_var_comparsion' = ''`)
+if (!$_status_var_comparsion)
 {
   let $_status_var_comparsion= =;
 }

=== modified file 'mysql-test/r/ctype_utf16.result'
--- a/mysql-test/r/ctype_utf16.result	2010-09-13 10:04:11 +0000
+++ b/mysql-test/r/ctype_utf16.result	2010-09-28 15:29:26 +0000
@@ -611,6 +611,38 @@ utf16_bin	00610009
 utf16_bin	0061
 utf16_bin	00610020
 drop table t1;
+#
+# Bug#55980 Character sets: supplementary character _bin ordering is wrong
+#
+CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` varchar(1) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84);
+INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080);
+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
+HEX(a)	HEX(CONVERT(a USING utf8mb4))
+0385	CE85
+D800DF84	F0908E84
+DBC0DC00	F4808080
+FF9D	EFBE9D
+ALTER TABLE t1 ADD KEY(a);
+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
+HEX(a)	HEX(CONVERT(a USING utf8mb4))
+0385	CE85
+D800DF84	F0908E84
+DBC0DC00	F4808080
+FF9D	EFBE9D
+# Additional test for bug#37244 Character sets: short utf8_bin weight_string value
+SELECT HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a;
+HEX(a)	HEX(WEIGHT_STRING(a))
+0385	000385
+D800DF84	010384
+DBC0DC00	100000
+FF9D	20FF9D
+DROP TABLE IF EXISTS t1;
 select @@collation_connection;
 @@collation_connection
 utf16_bin
@@ -1275,178 +1307,178 @@ select @@collation_connection;
 utf16_bin
 select hex(weight_string('a'));
 hex(weight_string('a'))
-0061
+000061
 select hex(weight_string('A'));
 hex(weight_string('A'))
-0041
+000041
 select hex(weight_string('abc'));
 hex(weight_string('abc'))
-006100620063
+000061000062000063
 select hex(weight_string('abc' as char(2)));
 hex(weight_string('abc' as char(2)))
-00610062
+000061000062
 select hex(weight_string('abc' as char(3)));
 hex(weight_string('abc' as char(3)))
-006100620063
+000061000062000063
 select hex(weight_string('abc' as char(5)));
 hex(weight_string('abc' as char(5)))
-00610062006300200020
+000061000062000063000020000020
 select hex(weight_string('abc', 1, 2, 0xC0));
 hex(weight_string('abc', 1, 2, 0xC0))
 00
 select hex(weight_string('abc', 2, 2, 0xC0));
 hex(weight_string('abc', 2, 2, 0xC0))
-0061
+0000
 select hex(weight_string('abc', 3, 2, 0xC0));
 hex(weight_string('abc', 3, 2, 0xC0))
-006100
+000061
 select hex(weight_string('abc', 4, 2, 0xC0));
 hex(weight_string('abc', 4, 2, 0xC0))
-00610062
+00006100
 select hex(weight_string('abc', 5, 2, 0xC0));
 hex(weight_string('abc', 5, 2, 0xC0))
-0061006200
+0000610000
 select hex(weight_string('abc',25, 2, 0xC0));
 hex(weight_string('abc',25, 2, 0xC0))
-00610062002000200020002000200020002000200020002000
+00006100006200002000002000002000002000002000002000
 select hex(weight_string('abc', 1, 3, 0xC0));
 hex(weight_string('abc', 1, 3, 0xC0))
 00
 select hex(weight_string('abc', 2, 3, 0xC0));
 hex(weight_string('abc', 2, 3, 0xC0))
-0061
+0000
 select hex(weight_string('abc', 3, 3, 0xC0));
 hex(weight_string('abc', 3, 3, 0xC0))
-006100
+000061
 select hex(weight_string('abc', 4, 3, 0xC0));
 hex(weight_string('abc', 4, 3, 0xC0))
-00610062
+00006100
 select hex(weight_string('abc', 5, 3, 0xC0));
 hex(weight_string('abc', 5, 3, 0xC0))
-0061006200
+0000610000
 select hex(weight_string('abc',25, 3, 0xC0));
 hex(weight_string('abc',25, 3, 0xC0))
-00610062006300200020002000200020002000200020002000
+00006100006200006300002000002000002000002000002000
 select hex(weight_string('abc', 1, 4, 0xC0));
 hex(weight_string('abc', 1, 4, 0xC0))
 00
 select hex(weight_string('abc', 2, 4, 0xC0));
 hex(weight_string('abc', 2, 4, 0xC0))
-0061
+0000
 select hex(weight_string('abc', 3, 4, 0xC0));
 hex(weight_string('abc', 3, 4, 0xC0))
-006100
+000061
 select hex(weight_string('abc', 4, 4, 0xC0));
 hex(weight_string('abc', 4, 4, 0xC0))
-00610062
+00006100
 select hex(weight_string('abc', 5, 4, 0xC0));
 hex(weight_string('abc', 5, 4, 0xC0))
-0061006200
+0000610000
 select hex(weight_string('abc',25, 4, 0xC0));
 hex(weight_string('abc',25, 4, 0xC0))
-00610062006300200020002000200020002000200020002000
+00006100006200006300002000002000002000002000002000
 select @@collation_connection;
 @@collation_connection
 utf16_bin
 select hex(weight_string(cast(_latin1 0x80 as char)));
 hex(weight_string(cast(_latin1 0x80 as char)))
-20AC
+0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char)));
 hex(weight_string(cast(_latin1 0x808080 as char)))
-20AC20AC20AC
+0020AC0020AC0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
 hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
-20AC20AC
+0020AC0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
 hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
-20AC20AC20AC
+0020AC0020AC0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
 hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
-20AC20AC20AC00200020
+0020AC0020AC0020AC000020000020
 select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
-20
+00
 select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
-20AC
+0020
 select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
-20AC20
+0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
-20AC20AC
+0020AC00
 select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
-20AC20AC00
+0020AC0020
 select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
-20AC20AC002000200020002000200020002000200020002000
+0020AC0020AC00002000002000002000002000002000002000
 select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
-20
+00
 select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
-20AC
+0020
 select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
-20AC20
+0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
-20AC20AC
+0020AC00
 select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
-20AC20AC20
+0020AC0020
 select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
-20AC20AC20AC00200020002000200020002000200020002000
+0020AC0020AC0020AC00002000002000002000002000002000
 select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
-20
+00
 select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
-20AC
+0020
 select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
-20AC20
+0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
-20AC20AC
+0020AC00
 select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
-20AC20AC20
+0020AC0020
 select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
-20AC20AC20AC00200020002000200020002000200020002000
+0020AC0020AC0020AC00002000002000002000002000002000
 select @@collation_connection;
 @@collation_connection
 utf16_bin
 select hex(weight_string('a' LEVEL 1));
 hex(weight_string('a' LEVEL 1))
-0061
+000061
 select hex(weight_string('A' LEVEL 1));
 hex(weight_string('A' LEVEL 1))
-0041
+000041
 select hex(weight_string('abc' LEVEL 1));
 hex(weight_string('abc' LEVEL 1))
-006100620063
+000061000062000063
 select hex(weight_string('abc' as char(2) LEVEL 1));
 hex(weight_string('abc' as char(2) LEVEL 1))
-00610062
+000061000062
 select hex(weight_string('abc' as char(3) LEVEL 1));
 hex(weight_string('abc' as char(3) LEVEL 1))
-006100620063
+000061000062000063
 select hex(weight_string('abc' as char(5) LEVEL 1));
 hex(weight_string('abc' as char(5) LEVEL 1))
-00610062006300200020
+000061000062000063000020000020
 select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
 hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
-20002000630062006100
+200000200000630000620000610000
 select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
 hex(weight_string('abc' as char(5) LEVEL 1 DESC))
-FF9EFF9DFF9CFFDFFFDF
+FFFF9EFFFF9DFFFF9CFFFFDFFFFFDF
 select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
 hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
-DFFFDFFF9CFF9DFF9EFF
+DFFFFFDFFFFF9CFFFF9DFFFF9EFFFF
 #
 # End of 5.6 tests
 #

=== modified file 'mysql-test/r/ctype_utf32.result'
--- a/mysql-test/r/ctype_utf32.result	2010-09-13 10:36:27 +0000
+++ b/mysql-test/r/ctype_utf32.result	2010-09-28 15:29:26 +0000
@@ -610,6 +610,38 @@ utf32_bin	0000006100000009
 utf32_bin	00000061
 utf32_bin	0000006100000020
 drop table t1;
+#
+# Bug#55980 Character sets: supplementary character _bin ordering is wrong
+#
+CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` varchar(1) CHARACTER SET utf32 COLLATE utf32_bin NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84);
+INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080);
+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
+HEX(a)	HEX(CONVERT(a USING utf8mb4))
+00000385	CE85
+0000FF9D	EFBE9D
+00010384	F0908E84
+00100000	F4808080
+ALTER TABLE t1 ADD KEY(a);
+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
+HEX(a)	HEX(CONVERT(a USING utf8mb4))
+00000385	CE85
+0000FF9D	EFBE9D
+00010384	F0908E84
+00100000	F4808080
+# Additional test for bug#37244 Character sets: short utf8_bin weight_string value
+SELECT HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a;
+HEX(a)	HEX(WEIGHT_STRING(a))
+00000385	000385
+0000FF9D	00FF9D
+00010384	010384
+00100000	100000
+DROP TABLE IF EXISTS t1;
 select @@collation_connection;
 @@collation_connection
 utf32_bin
@@ -1325,178 +1357,178 @@ select @@collation_connection;
 utf32_bin
 select hex(weight_string('a'));
 hex(weight_string('a'))
-0061
+000061
 select hex(weight_string('A'));
 hex(weight_string('A'))
-0041
+000041
 select hex(weight_string('abc'));
 hex(weight_string('abc'))
-006100620063
+000061000062000063
 select hex(weight_string('abc' as char(2)));
 hex(weight_string('abc' as char(2)))
-00610062
+000061000062
 select hex(weight_string('abc' as char(3)));
 hex(weight_string('abc' as char(3)))
-006100620063
+000061000062000063
 select hex(weight_string('abc' as char(5)));
 hex(weight_string('abc' as char(5)))
-00610062006300200020
+000061000062000063000020000020
 select hex(weight_string('abc', 1, 2, 0xC0));
 hex(weight_string('abc', 1, 2, 0xC0))
 00
 select hex(weight_string('abc', 2, 2, 0xC0));
 hex(weight_string('abc', 2, 2, 0xC0))
-0061
+0000
 select hex(weight_string('abc', 3, 2, 0xC0));
 hex(weight_string('abc', 3, 2, 0xC0))
-006100
+000061
 select hex(weight_string('abc', 4, 2, 0xC0));
 hex(weight_string('abc', 4, 2, 0xC0))
-00610062
+00006100
 select hex(weight_string('abc', 5, 2, 0xC0));
 hex(weight_string('abc', 5, 2, 0xC0))
-0061006200
+0000610000
 select hex(weight_string('abc',25, 2, 0xC0));
 hex(weight_string('abc',25, 2, 0xC0))
-00610062002000200020002000200020002000200020002000
+00006100006200002000002000002000002000002000002000
 select hex(weight_string('abc', 1, 3, 0xC0));
 hex(weight_string('abc', 1, 3, 0xC0))
 00
 select hex(weight_string('abc', 2, 3, 0xC0));
 hex(weight_string('abc', 2, 3, 0xC0))
-0061
+0000
 select hex(weight_string('abc', 3, 3, 0xC0));
 hex(weight_string('abc', 3, 3, 0xC0))
-006100
+000061
 select hex(weight_string('abc', 4, 3, 0xC0));
 hex(weight_string('abc', 4, 3, 0xC0))
-00610062
+00006100
 select hex(weight_string('abc', 5, 3, 0xC0));
 hex(weight_string('abc', 5, 3, 0xC0))
-0061006200
+0000610000
 select hex(weight_string('abc',25, 3, 0xC0));
 hex(weight_string('abc',25, 3, 0xC0))
-00610062006300200020002000200020002000200020002000
+00006100006200006300002000002000002000002000002000
 select hex(weight_string('abc', 1, 4, 0xC0));
 hex(weight_string('abc', 1, 4, 0xC0))
 00
 select hex(weight_string('abc', 2, 4, 0xC0));
 hex(weight_string('abc', 2, 4, 0xC0))
-0061
+0000
 select hex(weight_string('abc', 3, 4, 0xC0));
 hex(weight_string('abc', 3, 4, 0xC0))
-006100
+000061
 select hex(weight_string('abc', 4, 4, 0xC0));
 hex(weight_string('abc', 4, 4, 0xC0))
-00610062
+00006100
 select hex(weight_string('abc', 5, 4, 0xC0));
 hex(weight_string('abc', 5, 4, 0xC0))
-0061006200
+0000610000
 select hex(weight_string('abc',25, 4, 0xC0));
 hex(weight_string('abc',25, 4, 0xC0))
-00610062006300200020002000200020002000200020002000
+00006100006200006300002000002000002000002000002000
 select @@collation_connection;
 @@collation_connection
 utf32_bin
 select hex(weight_string(cast(_latin1 0x80 as char)));
 hex(weight_string(cast(_latin1 0x80 as char)))
-20AC
+0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char)));
 hex(weight_string(cast(_latin1 0x808080 as char)))
-20AC20AC20AC
+0020AC0020AC0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
 hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
-20AC20AC
+0020AC0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
 hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
-20AC20AC20AC
+0020AC0020AC0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
 hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
-20AC20AC20AC00200020
+0020AC0020AC0020AC000020000020
 select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
-20
+00
 select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
-20AC
+0020
 select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
-20AC20
+0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
-20AC20AC
+0020AC00
 select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
-20AC20AC00
+0020AC0020
 select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
-20AC20AC002000200020002000200020002000200020002000
+0020AC0020AC00002000002000002000002000002000002000
 select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
-20
+00
 select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
-20AC
+0020
 select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
-20AC20
+0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
-20AC20AC
+0020AC00
 select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
-20AC20AC20
+0020AC0020
 select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
-20AC20AC20AC00200020002000200020002000200020002000
+0020AC0020AC0020AC00002000002000002000002000002000
 select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
-20
+00
 select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
-20AC
+0020
 select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
-20AC20
+0020AC
 select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
-20AC20AC
+0020AC00
 select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
-20AC20AC20
+0020AC0020
 select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
 hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
-20AC20AC20AC00200020002000200020002000200020002000
+0020AC0020AC0020AC00002000002000002000002000002000
 select @@collation_connection;
 @@collation_connection
 utf32_bin
 select hex(weight_string('a' LEVEL 1));
 hex(weight_string('a' LEVEL 1))
-0061
+000061
 select hex(weight_string('A' LEVEL 1));
 hex(weight_string('A' LEVEL 1))
-0041
+000041
 select hex(weight_string('abc' LEVEL 1));
 hex(weight_string('abc' LEVEL 1))
-006100620063
+000061000062000063
 select hex(weight_string('abc' as char(2) LEVEL 1));
 hex(weight_string('abc' as char(2) LEVEL 1))
-00610062
+000061000062
 select hex(weight_string('abc' as char(3) LEVEL 1));
 hex(weight_string('abc' as char(3) LEVEL 1))
-006100620063
+000061000062000063
 select hex(weight_string('abc' as char(5) LEVEL 1));
 hex(weight_string('abc' as char(5) LEVEL 1))
-00610062006300200020
+000061000062000063000020000020
 select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
 hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
-20002000630062006100
+200000200000630000620000610000
 select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
 hex(weight_string('abc' as char(5) LEVEL 1 DESC))
-FF9EFF9DFF9CFFDFFFDF
+FFFF9EFFFF9DFFFF9CFFFFDFFFFFDF
 select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
 hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
-DFFFDFFF9CFF9DFF9EFF
+DFFFFFDFFFFF9CFFFF9DFFFF9EFFFF
 #
 # End of 5.6 tests
 #

=== modified file 'mysql-test/r/ctype_utf8mb4.result'
--- a/mysql-test/r/ctype_utf8mb4.result	2010-09-13 10:04:11 +0000
+++ b/mysql-test/r/ctype_utf8mb4.result	2010-09-28 15:29:26 +0000
@@ -1043,6 +1043,38 @@ utf8mb4_bin	6109
 utf8mb4_bin	61
 utf8mb4_bin	6120
 drop table t1;
+#
+# Bug#55980 Character sets: supplementary character _bin ordering is wrong
+#
+CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84);
+INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080);
+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
+HEX(a)	HEX(CONVERT(a USING utf8mb4))
+CE85	CE85
+EFBE9D	EFBE9D
+F0908E84	F0908E84
+F4808080	F4808080
+ALTER TABLE t1 ADD KEY(a);
+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
+HEX(a)	HEX(CONVERT(a USING utf8mb4))
+CE85	CE85
+EFBE9D	EFBE9D
+F0908E84	F0908E84
+F4808080	F4808080
+# Additional test for bug#37244 Character sets: short utf8_bin weight_string value
+SELECT HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a;
+HEX(a)	HEX(WEIGHT_STRING(a))
+CE85	000385
+EFBE9D	00FF9D
+F0908E84	010384
+F4808080	100000
+DROP TABLE IF EXISTS t1;
 select @@collation_connection;
 @@collation_connection
 utf8mb4_bin

=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	2010-08-16 07:11:57 +0000
+++ b/mysql-test/r/func_time.result	2010-09-09 12:02:02 +0000
@@ -1200,6 +1200,8 @@ set time_zone= @@global.time_zone;
 select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
 str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE
 NULL
+Warnings:
+Warning	1411	Incorrect datetime value: '10:00 PM' for function str_to_date
 create table t1 (field DATE);
 insert into t1 values ('2006-11-06');
 select * from t1 where field < '2006-11-06 04:08:36.0';

=== modified file 'mysql-test/r/parser.result'
--- a/mysql-test/r/parser.result	2010-06-17 16:58:30 +0000
+++ b/mysql-test/r/parser.result	2010-09-09 13:04:25 +0000
@@ -556,9 +556,13 @@ DROP TABLE IF EXISTS t1;
 SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
 STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE
 NULL
+Warnings:
+Warning	1411	Incorrect datetime value: '10:00 PM' for function str_to_date
 SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE;
 STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE
 NULL
+Warnings:
+Warning	1411	Incorrect datetime value: '10:00 PM' for function str_to_date
 SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
 "1997-12-31 23:59:59" + INTERVAL 1 SECOND
 1998-01-01 00:00:00

=== modified file 'mysql-test/r/select.result'
--- a/mysql-test/r/select.result	2010-09-09 15:00:33 +0000
+++ b/mysql-test/r/select.result	2010-09-28 15:29:26 +0000
@@ -4171,9 +4171,10 @@ str_to_date('2007-10-00','%Y-%m-%d') bet
 set SQL_MODE=TRADITIONAL;
 select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
 str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
-0
+NULL
 Warnings:
 Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34'
+Warning	1411	Incorrect datetime value: '2007-10-00 12:34' for function str_to_date
 select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
 str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
 0
@@ -4181,17 +4182,16 @@ Warnings:
 Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34'
 select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
 str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'
-0
+NULL
 Warnings:
-Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34:00'
+Warning	1411	Incorrect datetime value: '2007-10-00 12:34' for function str_to_date
 select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
                                                 and '2007/10/20';
 str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
                                                 and '2007/10/20'
-0
+NULL
 Warnings:
-Warning	1292	Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1
-Warning	1292	Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1
+Warning	1411	Incorrect datetime value: '2007-10-00' for function str_to_date
 set SQL_MODE=DEFAULT;
 select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
 str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'

=== modified file 'mysql-test/r/strict.result'
--- a/mysql-test/r/strict.result	2010-07-30 15:28:36 +0000
+++ b/mysql-test/r/strict.result	2010-09-07 06:45:00 +0000
@@ -206,12 +206,11 @@ INSERT INTO t1 (col1) VALUES (STR_TO_DAT
 INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
 INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
-Warnings:
-Note	1265	Data truncated for column 'col1' at row 1
+ERROR HY000: Incorrect datetime value: '31.10.0000 15.30' for function str_to_date
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect date value: '2004-00-31 15:30:00' for column 'col1' at row 1
+ERROR HY000: Incorrect datetime value: '31.0.2004 15.30' for function str_to_date
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect date value: '2004-10-00 15:30:00' for column 'col1' at row 1
+ERROR HY000: Incorrect datetime value: '0.10.2004 15.30' for function str_to_date
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
 ERROR 22007: Incorrect date value: '2004-09-31 15:30:00' for column 'col1' at row 1
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
@@ -221,12 +220,13 @@ ERROR 22007: Incorrect date value: '2003
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
 ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_date
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
-ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
+ERROR HY000: Incorrect datetime value: '00.00.0000' for function str_to_date
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
+ERROR HY000: Incorrect datetime value: '31.10.0000 15.30' for function str_to_date
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect datetime value: '2004-00-31 15:30:00' for column 'col2' at row 1
+ERROR HY000: Incorrect datetime value: '31.0.2004 15.30' for function str_to_date
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1
+ERROR HY000: Incorrect datetime value: '0.10.2004 15.30' for function str_to_date
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
 ERROR 22007: Incorrect datetime value: '2004-09-31 15:30:00' for column 'col2' at row 1
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
@@ -236,13 +236,13 @@ ERROR 22007: Incorrect datetime value: '
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
 ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_date
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
-ERROR 22007: Incorrect datetime value: '0000-00-00' for column 'col2' at row 1
+ERROR HY000: Incorrect datetime value: '00.00.0000' for function str_to_date
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1
+ERROR HY000: Incorrect datetime value: '31.10.0000 15.30' for function str_to_date
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect datetime value: '2004-00-31 15:30:00' for column 'col3' at row 1
+ERROR HY000: Incorrect datetime value: '31.0.2004 15.30' for function str_to_date
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1
+ERROR HY000: Incorrect datetime value: '0.10.2004 15.30' for function str_to_date
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
 ERROR 22007: Incorrect datetime value: '2004-09-31 15:30:00' for column 'col3' at row 1
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
@@ -252,7 +252,7 @@ ERROR 22007: Incorrect datetime value: '
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
 ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_date
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
-ERROR 22007: Incorrect datetime value: '0000-00-00' for column 'col3' at row 1
+ERROR HY000: Incorrect datetime value: '00.00.0000' for function str_to_date
 drop table t1;
 CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
 INSERT INTO t1 (col1) VALUES (CAST('2004-10-15' AS DATE));
@@ -1108,6 +1108,9 @@ Warnings:
 Warning	1411	Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
 Warning	1411	Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
 Warning	1411	Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
+Warning	1411	Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
+Warning	1411	Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
+Warning	1411	Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
 drop table t1;
 create table t1 (col1 char(3), col2 integer);
 insert into t1 (col1) values (cast(1000 as char(3)));

=== modified file 'mysql-test/r/type_datetime.result'
--- a/mysql-test/r/type_datetime.result	2010-05-05 09:28:37 +0000
+++ b/mysql-test/r/type_datetime.result	2010-09-07 06:45:00 +0000
@@ -655,5 +655,30 @@ Note	1003	select `test`.`t1`.`Id` AS `Id
 DROP TABLE t1;
 SET NAMES latin1;
 #
+# Bug#56271: Wrong comparison result with STR_TO_DATE function
+#
+CREATE TABLE t1 (
+`year` int(4) NOT NULL,
+`month` int(2) NOT NULL
+);
+INSERT INTO t1 VALUES (2010,3),(2010,4),(2009,8),(2008,9);
+SELECT *
+FROM t1
+WHERE STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') >=
+STR_TO_DATE('1/1/2010', '%m/%d/%Y');
+year	month
+2010	3
+2010	4
+create table t2(f1 datetime primary key);
+insert into t2 select STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') from t1;
+select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y');
+f1
+2010-04-01 00:00:00
+t2 should be const
+explain select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y');
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	const	PRIMARY	PRIMARY	8	const	1	Using index
+DROP TABLE t1,t2;
+#
 # End of 5.5 tests
 #

=== modified file 'mysql-test/r/type_newdecimal.result'
--- a/mysql-test/r/type_newdecimal.result	2010-04-11 06:52:42 +0000
+++ b/mysql-test/r/type_newdecimal.result	2010-09-23 12:38:24 +0000
@@ -1908,4 +1908,16 @@ group by PAY.id + 1;
 mult	v_net_with_discount	v_total
 1.0000	27.18	27.180000
 DROP TABLE currencies, payments, sub_tasks;
+#
+# BUG#52171: distinct aggregates on unsigned decimal fields trigger assertions
+#
+CREATE TABLE t1 (a DECIMAL(4,4) UNSIGNED);
+INSERT INTO t1 VALUES (0);
+SELECT AVG(DISTINCT a) FROM t1;
+AVG(DISTINCT a)
+0.00000000
+SELECT SUM(DISTINCT a) FROM t1;
+SUM(DISTINCT a)
+0.0000
+DROP TABLE t1;
 End of 5.1 tests

=== modified file 'mysql-test/suite/binlog/r/binlog_row_binlog.result'
--- a/mysql-test/suite/binlog/r/binlog_row_binlog.result	2010-08-20 03:37:42 +0000
+++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result	2010-08-30 06:11:20 +0000
@@ -1267,8 +1267,9 @@ master-bin.000001	#	Table_map	#	#	table_
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	use `test`; FLUSH TABLES
-insert delayed into t1 values (null),(null),(null),(null);
-insert delayed into t1 values (null),(null),(400),(null);
+RESET MASTER;
+insert /* before delayed */ delayed /* after delayed */ into t1 values (null),(null),(null),(null);
+insert  /*! delayed */ into t1 values (null),(null),(400),(null);
 select * from t1;
 a
 207

=== modified file 'mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result'
--- a/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result	2010-04-28 12:47:49 +0000
+++ b/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result	2010-08-30 06:03:28 +0000
@@ -20,12 +20,21 @@ master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; insert delayed into t1 values (300)
 master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	use `test`; FLUSH TABLES
-insert delayed into t1 values (null),(null),(null),(null);
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
-insert delayed into t1 values (null),(null),(400),(null);
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
+RESET MASTER;
+insert /* before delayed */ delayed /* after delayed */ into t1 values (null),(null),(null),(null);
+insert  /*! delayed */ into t1 values (null),(null),(400),(null);
+FLUSH TABLES;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Intvar	#	#	INSERT_ID=301
+master-bin.000001	#	Query	#	#	use `test`; insert /* before delayed */  /* after delayed */ into t1 values (null),(null),(null),(null)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Intvar	#	#	INSERT_ID=305
+master-bin.000001	#	Query	#	#	use `test`; insert  /*!  */ into t1 values (null),(null),(400),(null)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `test`; FLUSH TABLES
 select * from t1;
 a
 207

=== modified file 'mysql-test/suite/binlog/r/binlog_stm_binlog.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result	2010-08-20 03:37:42 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result	2010-08-30 06:11:20 +0000
@@ -758,8 +758,9 @@ master-bin.000001	#	Table_map	#	#	table_
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	use `test`; FLUSH TABLES
-insert delayed into t1 values (null),(null),(null),(null);
-insert delayed into t1 values (null),(null),(400),(null);
+RESET MASTER;
+insert /* before delayed */ delayed /* after delayed */ into t1 values (null),(null),(null),(null);
+insert  /*! delayed */ into t1 values (null),(null),(400),(null);
 select * from t1;
 a
 207

=== modified file 'mysql-test/suite/binlog/r/binlog_unsafe.result'
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result	2010-08-10 11:58:46 +0000
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result	2010-08-30 06:11:20 +0000
@@ -862,65 +862,51 @@ Note	1592	Unsafe statement written to th
 * Invoke statement so that return value is dicarded: expect no warning.
 SELECT * FROM data_table LIMIT 1;
 
-==== Testing INSERT DELAYED unsafeness ====
+==== Testing INSERT DELAYED safeness after BUG#54579 is fixed ====
 
 Invoking function func_sidef_1 invoking unsafe INSERT DELAYED statement.
 CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO t0 VALUES (1), (2); RETURN 0; END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 INSERT INTO t1 SELECT func_sidef_1();
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 
 Invoking function func_sidef_2 invoking function func_sidef_1 invoking unsafe INSERT DELAYED statement.
 CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); RETURN 0; END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 INSERT INTO t2 SELECT func_sidef_2();
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP FUNCTION func_sidef_2;
 
 Invoking procedure proc_2 invoking function func_sidef_1 invoking unsafe INSERT DELAYED statement.
 CREATE PROCEDURE proc_2() BEGIN INSERT INTO t1 SELECT func_sidef_1(); INSERT INTO ta2 VALUES (47); END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 CALL proc_2();
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PROCEDURE proc_2;
 
 Invoking trigger trig_2 invoking function func_sidef_1 invoking unsafe INSERT DELAYED statement.
 CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 INSERT INTO trigger_table_2 VALUES (1);
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP TRIGGER trig_2;
 
 Invoking view view_sidef_2 invoking function func_sidef_1 invoking unsafe INSERT DELAYED statement.
 CREATE VIEW view_sidef_2 AS SELECT func_sidef_1();
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 INSERT INTO t2 SELECT * FROM view_sidef_2;
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP VIEW view_sidef_2;
 
 Invoking prepared statement prep_2 invoking function func_sidef_1 invoking unsafe INSERT DELAYED statement.
 PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()";
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 EXECUTE prep_2;
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PREPARE prep_2;
@@ -928,49 +914,39 @@ DROP FUNCTION func_sidef_1;
 
 Invoking procedure proc_1 invoking unsafe INSERT DELAYED statement.
 CREATE PROCEDURE proc_1() BEGIN INSERT DELAYED INTO t0 VALUES (1), (2); INSERT INTO ta1 VALUES (47); END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 CALL proc_1();
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 
 Invoking function func_sidef_2 invoking procedure proc_1 invoking unsafe INSERT DELAYED statement.
 CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 INSERT INTO t2 SELECT func_sidef_2();
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP FUNCTION func_sidef_2;
 
 Invoking procedure proc_2 invoking procedure proc_1 invoking unsafe INSERT DELAYED statement.
 CREATE PROCEDURE proc_2() BEGIN CALL proc_1(); INSERT INTO ta2 VALUES (47); END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 CALL proc_2();
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PROCEDURE proc_2;
 
 Invoking trigger trig_2 invoking procedure proc_1 invoking unsafe INSERT DELAYED statement.
 CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 INSERT INTO trigger_table_2 VALUES (1);
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP TRIGGER trig_2;
 
 Invoking prepared statement prep_2 invoking procedure proc_1 invoking unsafe INSERT DELAYED statement.
 PREPARE prep_2 FROM "CALL proc_1()";
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 EXECUTE prep_2;
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PREPARE prep_2;
@@ -978,49 +954,39 @@ DROP PROCEDURE proc_1;
 
 Invoking trigger trig_1 invoking unsafe INSERT DELAYED statement.
 CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO t0 VALUES (1), (2); END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 INSERT INTO trigger_table_1 VALUES (1);
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 
 Invoking function func_sidef_2 invoking trigger trig_1 invoking unsafe INSERT DELAYED statement.
 CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); RETURN 0; END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 INSERT INTO t2 SELECT func_sidef_2();
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP FUNCTION func_sidef_2;
 
 Invoking procedure proc_2 invoking trigger trig_1 invoking unsafe INSERT DELAYED statement.
 CREATE PROCEDURE proc_2() BEGIN INSERT INTO trigger_table_1 VALUES (1); INSERT INTO ta2 VALUES (47); END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 CALL proc_2();
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PROCEDURE proc_2;
 
 Invoking trigger trig_2 invoking trigger trig_1 invoking unsafe INSERT DELAYED statement.
 CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END;
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 INSERT INTO trigger_table_2 VALUES (1);
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP TRIGGER trig_2;
 
 Invoking prepared statement prep_2 invoking trigger trig_1 invoking unsafe INSERT DELAYED statement.
 PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)";
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 EXECUTE prep_2;
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PREPARE prep_2;
@@ -1028,19 +994,15 @@ DROP TRIGGER trig_1;
 
 Invoking prepared statement prep_1 invoking unsafe INSERT DELAYED statement.
 PREPARE prep_1 FROM "INSERT DELAYED INTO t0 VALUES (1), (2)";
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 EXECUTE prep_1;
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 DROP PREPARE prep_1;
 
 Invoking unsafe INSERT DELAYED statement.
-* binlog_format = STATEMENT: expect 1 warnings.
+* binlog_format = STATEMENT: expect 0 warnings.
 INSERT DELAYED INTO t0 VALUES (1), (2);
-Warnings:
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 * SQL_LOG_BIN = 0: expect nothing logged and no warning.
 * binlog_format = MIXED: expect row events in binlog and no warning.
 
@@ -1798,11 +1760,10 @@ SELECT COUNT(*) FROM mysql.general_log;
 
 Invoking function func_sidef_1 invoking statement that is unsafe in many ways.
 CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; RETURN 0; END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 INSERT INTO t1 SELECT func_sidef_1();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1813,11 +1774,10 @@ Note	1592	Unsafe statement written to th
 
 Invoking function func_sidef_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways.
 CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); RETURN 0; END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 INSERT INTO t2 SELECT func_sidef_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1829,11 +1789,10 @@ DROP FUNCTION func_sidef_2;
 
 Invoking procedure proc_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways.
 CREATE PROCEDURE proc_2() BEGIN INSERT INTO t1 SELECT func_sidef_1(); INSERT INTO ta2 VALUES (47); END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 CALL proc_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1845,11 +1804,10 @@ DROP PROCEDURE proc_2;
 
 Invoking trigger trig_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways.
 CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 INSERT INTO trigger_table_2 VALUES (1);
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1863,17 +1821,15 @@ Invoking view view_sidef_2 invoking func
 CREATE VIEW view_sidef_2 AS SELECT func_sidef_1();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 INSERT INTO t2 SELECT * FROM view_sidef_2;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1885,11 +1841,10 @@ DROP VIEW view_sidef_2;
 
 Invoking prepared statement prep_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways.
 PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()";
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 EXECUTE prep_2;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1902,11 +1857,10 @@ DROP FUNCTION func_sidef_1;
 
 Invoking procedure proc_1 invoking statement that is unsafe in many ways.
 CREATE PROCEDURE proc_1() BEGIN INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; INSERT INTO ta1 VALUES (47); END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 CALL proc_1();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1917,11 +1871,10 @@ Note	1592	Unsafe statement written to th
 
 Invoking function func_sidef_2 invoking procedure proc_1 invoking statement that is unsafe in many ways.
 CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 INSERT INTO t2 SELECT func_sidef_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1933,11 +1886,10 @@ DROP FUNCTION func_sidef_2;
 
 Invoking procedure proc_2 invoking procedure proc_1 invoking statement that is unsafe in many ways.
 CREATE PROCEDURE proc_2() BEGIN CALL proc_1(); INSERT INTO ta2 VALUES (47); END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 CALL proc_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1949,11 +1901,10 @@ DROP PROCEDURE proc_2;
 
 Invoking trigger trig_2 invoking procedure proc_1 invoking statement that is unsafe in many ways.
 CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 INSERT INTO trigger_table_2 VALUES (1);
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1965,11 +1916,10 @@ DROP TRIGGER trig_2;
 
 Invoking prepared statement prep_2 invoking procedure proc_1 invoking statement that is unsafe in many ways.
 PREPARE prep_2 FROM "CALL proc_1()";
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 EXECUTE prep_2;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1982,11 +1932,10 @@ DROP PROCEDURE proc_1;
 
 Invoking trigger trig_1 invoking statement that is unsafe in many ways.
 CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 INSERT INTO trigger_table_1 VALUES (1);
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -1997,11 +1946,10 @@ Note	1592	Unsafe statement written to th
 
 Invoking function func_sidef_2 invoking trigger trig_1 invoking statement that is unsafe in many ways.
 CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); RETURN 0; END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 INSERT INTO t2 SELECT func_sidef_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -2013,11 +1961,10 @@ DROP FUNCTION func_sidef_2;
 
 Invoking procedure proc_2 invoking trigger trig_1 invoking statement that is unsafe in many ways.
 CREATE PROCEDURE proc_2() BEGIN INSERT INTO trigger_table_1 VALUES (1); INSERT INTO ta2 VALUES (47); END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 CALL proc_2();
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -2029,11 +1976,10 @@ DROP PROCEDURE proc_2;
 
 Invoking trigger trig_2 invoking trigger trig_1 invoking statement that is unsafe in many ways.
 CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END;
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 INSERT INTO trigger_table_2 VALUES (1);
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -2045,11 +1991,10 @@ DROP TRIGGER trig_2;
 
 Invoking prepared statement prep_2 invoking trigger trig_1 invoking statement that is unsafe in many ways.
 PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)";
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 EXECUTE prep_2;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -2062,11 +2007,10 @@ DROP TRIGGER trig_1;
 
 Invoking prepared statement prep_1 invoking statement that is unsafe in many ways.
 PREPARE prep_1 FROM "INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1";
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 EXECUTE prep_1;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -2077,11 +2021,10 @@ Note	1592	Unsafe statement written to th
 DROP PREPARE prep_1;
 
 Invoking statement that is unsafe in many ways.
-* binlog_format = STATEMENT: expect 7 warnings.
+* binlog_format = STATEMENT: expect 6 warnings.
 INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.
-Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses INSERT DELAYED. This is unsafe because the times when rows are inserted cannot be predicted.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses the general log, slow query log, or performance_schema table(s). This is unsafe because system tables may differ on slaves.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave.
@@ -2554,8 +2497,7 @@ func_limit()
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; INSERT DELAYED INTO t1 VALUES (1), (2)
 master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)

=== modified file 'mysql-test/suite/binlog/t/binlog_unsafe.test'
--- a/mysql-test/suite/binlog/t/binlog_unsafe.test	2010-08-10 11:58:46 +0000
+++ b/mysql-test/suite/binlog/t/binlog_unsafe.test	2010-10-21 12:36:16 +0000
@@ -179,13 +179,13 @@ while (`SELECT $unsafe_type < 9`) {
   }
 
   if (`SELECT $unsafe_type = 3`) {
-    --echo ==== Testing INSERT DELAYED unsafeness ====
+    --echo ==== Testing INSERT DELAYED safeness after BUG#54579 is fixed ====
     --let $desc_0= unsafe INSERT DELAYED statement
     --let $stmt_sidef_0= INSERT DELAYED INTO t0 VALUES (1), (2)
     --let $value_0=
     --let $sel_sidef_0=
     --let $sel_retval_0=
-    --let $CRC_ARG_expected_number_of_warnings= 1
+    --let $CRC_ARG_expected_number_of_warnings= 0
   }
 
   if (`SELECT $unsafe_type = 4`) {
@@ -227,7 +227,7 @@ while (`SELECT $unsafe_type < 9`) {
     --let $value_0=
     --let $sel_sidef_0=
     --let $sel_retval_0=
-    --let $CRC_ARG_expected_number_of_warnings= 7
+    --let $CRC_ARG_expected_number_of_warnings= 6
   }
 
   if (`SELECT $unsafe_type = 8`) {
@@ -321,7 +321,7 @@ while (`SELECT $unsafe_type < 9`) {
             --source extra/rpl_tests/create_recursive_construct.inc
 
             # Drop created object.
-            if (`SELECT '$drop_3' != ''`) {
+            if ($drop_3) {
               --eval $drop_3
             }
             --inc $call_type_3
@@ -330,7 +330,7 @@ while (`SELECT $unsafe_type < 9`) {
         } # if (!is_toplevel_2)
 
         # Drop created object.
-        if (`SELECT '$drop_2' != ''`) {
+        if ($drop_2) {
           --eval $drop_2
         }
         --inc $call_type_2
@@ -338,7 +338,7 @@ while (`SELECT $unsafe_type < 9`) {
     } # if (!is_toplevel_1)
 
     # Drop created object.
-    if (`SELECT '$drop_1' != ''`) {
+    if ($drop_1) {
       --eval $drop_1
     }
     --inc $call_type_1

=== modified file 'mysql-test/suite/perfschema/include/upgrade_check.inc'
--- a/mysql-test/suite/perfschema/include/upgrade_check.inc	2010-07-20 19:15:29 +0000
+++ b/mysql-test/suite/perfschema/include/upgrade_check.inc	2010-09-13 23:19:39 +0000
@@ -18,7 +18,7 @@
 #
 
 --error 1
---exec $MYSQL_UPGRADE --skip-verbose > $out_file 2> $err_file
+--exec $MYSQL_UPGRADE --skip-verbose --force > $out_file 2> $err_file
 
 # Verify that mysql_upgrade complained about the performance_schema
 --cat_file $err_file

=== added file 'mysql-test/suite/perfschema/r/checksum.result'
--- a/mysql-test/suite/perfschema/r/checksum.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/checksum.result	2010-09-15 18:20:48 +0000
@@ -0,0 +1,34 @@
+checksum table performance_schema.COND_INSTANCES;
+checksum table performance_schema.EVENTS_WAITS_CURRENT;
+checksum table performance_schema.EVENTS_WAITS_HISTORY;
+checksum table performance_schema.EVENTS_WAITS_HISTORY_LONG;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_INSTANCE;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME;
+checksum table performance_schema.FILE_INSTANCES;
+checksum table performance_schema.FILE_SUMMARY_BY_EVENT_NAME;
+checksum table performance_schema.FILE_SUMMARY_BY_INSTANCE;
+checksum table performance_schema.MUTEX_INSTANCES;
+checksum table performance_schema.PERFORMANCE_TIMERS;
+checksum table performance_schema.RWLOCK_INSTANCES;
+checksum table performance_schema.SETUP_CONSUMERS;
+checksum table performance_schema.SETUP_INSTRUMENTS;
+checksum table performance_schema.SETUP_TIMERS;
+checksum table performance_schema.THREADS;
+checksum table performance_schema.COND_INSTANCES extended;
+checksum table performance_schema.EVENTS_WAITS_CURRENT extended;
+checksum table performance_schema.EVENTS_WAITS_HISTORY extended;
+checksum table performance_schema.EVENTS_WAITS_HISTORY_LONG extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_INSTANCE extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME extended;
+checksum table performance_schema.FILE_INSTANCES extended;
+checksum table performance_schema.FILE_SUMMARY_BY_EVENT_NAME extended;
+checksum table performance_schema.FILE_SUMMARY_BY_INSTANCE extended;
+checksum table performance_schema.MUTEX_INSTANCES extended;
+checksum table performance_schema.PERFORMANCE_TIMERS extended;
+checksum table performance_schema.RWLOCK_INSTANCES extended;
+checksum table performance_schema.SETUP_CONSUMERS extended;
+checksum table performance_schema.SETUP_INSTRUMENTS extended;
+checksum table performance_schema.SETUP_TIMERS extended;
+checksum table performance_schema.THREADS extended;

=== modified file 'mysql-test/suite/perfschema/r/server_init.result'
--- a/mysql-test/suite/perfschema/r/server_init.result	2010-08-20 08:48:59 +0000
+++ b/mysql-test/suite/perfschema/r/server_init.result	2010-09-17 16:43:02 +0000
@@ -112,18 +112,10 @@ where name like "wait/synch/mutex/sql/LO
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/LOG_INFO::lock";
-count(name)
-1
-select count(name) from MUTEX_INSTANCES
 where name like "wait/synch/mutex/sql/Query_cache::structure_guard_mutex";
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state";
-count(name)
-1
-select count(name) from MUTEX_INSTANCES
 where name like "wait/synch/mutex/sql/LOCK_event_metadata";
 count(name)
 1
@@ -140,15 +132,15 @@ where name like "wait/synch/mutex/sql/Cv
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/LOCK_xid_cache";
+where name like "wait/synch/mutex/sql/LOCK_audit_mask";
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/LOCK_plugin";
+where name like "wait/synch/mutex/sql/LOCK_xid_cache";
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/LOCK_gdl";
+where name like "wait/synch/mutex/sql/LOCK_plugin";
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
@@ -204,10 +196,6 @@ where name like "wait/synch/cond/sql/Que
 count(name)
 1
 select count(name) from COND_INSTANCES
-where name like "wait/synch/cond/sql/Event_scheduler::COND_state";
-count(name)
-1
-select count(name) from COND_INSTANCES
 where name like "wait/synch/cond/sql/COND_queue_state";
 count(name)
 1

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result	2010-09-09 16:00:27 +0000
@@ -45,11 +45,11 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result	2010-09-09 16:00:27 +0000
@@ -45,11 +45,11 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_class.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_class.result	2010-09-09 16:00:27 +0000
@@ -45,11 +45,11 @@ performance_schema_max_file_classes	0
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result	2010-09-09 16:00:27 +0000
@@ -45,11 +45,11 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	0
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result	2010-09-09 16:00:27 +0000
@@ -45,11 +45,11 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	0
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result	2010-09-09 16:00:27 +0000
@@ -47,9 +47,9 @@ performance_schema_max_file_instances	10
 performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	0
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result	2010-09-09 16:00:27 +0000
@@ -45,11 +45,11 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	0
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result	2010-09-09 16:00:27 +0000
@@ -45,11 +45,11 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	0
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_hdl.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result	2010-09-09 16:00:27 +0000
@@ -45,18 +45,18 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
+performance_schema_max_rwlock_instances	10000
 performance_schema_max_table_handles	0
-performance_schema_max_table_instances	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_table_instances";
 Variable_name	Value
-performance_schema_max_table_instances	1000
+performance_schema_max_table_instances	500
 show variables like "performance_schema_max_table_handles";
 Variable_name	Value
 performance_schema_max_table_handles	0
@@ -71,7 +71,7 @@ a
 drop table test.instrument_me;
 show variables like "performance_schema_max_table_instances";
 Variable_name	Value
-performance_schema_max_table_instances	1000
+performance_schema_max_table_instances	500
 select variable_value > 0 from information_schema.global_status
 where variable_name like 'PERFORMANCE_SCHEMA_TABLE_HANDLES_LOST';
 variable_value > 0

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result	2010-09-09 16:00:27 +0000
@@ -45,10 +45,10 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	0
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
@@ -59,7 +59,7 @@ Variable_name	Value
 performance_schema_max_table_instances	0
 show variables like "performance_schema_max_table_handles";
 Variable_name	Value
-performance_schema_max_table_handles	10000
+performance_schema_max_table_handles	1000
 drop table if exists test.instrument_me;
 create table test.instrument_me(a int);
 insert into test.instrument_me values (1), (2), (3);

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result	2010-09-09 16:00:27 +0000
@@ -45,11 +45,11 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	0
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result	2010-09-09 16:00:27 +0000
@@ -45,11 +45,11 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	0
 show engine PERFORMANCE_SCHEMA status;

=== modified file 'mysql-test/suite/perfschema/r/start_server_off.result'
--- a/mysql-test/suite/perfschema/r/start_server_off.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_off.result	2010-09-09 16:00:27 +0000
@@ -45,11 +45,11 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;

=== modified file 'mysql-test/suite/perfschema/r/start_server_on.result'
--- a/mysql-test/suite/perfschema/r/start_server_on.result	2010-08-27 21:51:59 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_on.result	2010-09-09 16:00:27 +0000
@@ -45,11 +45,11 @@ performance_schema_max_file_classes	50
 performance_schema_max_file_handles	32768
 performance_schema_max_file_instances	10000
 performance_schema_max_mutex_classes	200
-performance_schema_max_mutex_instances	1000000
+performance_schema_max_mutex_instances	10000
 performance_schema_max_rwlock_classes	30
-performance_schema_max_rwlock_instances	1000000
-performance_schema_max_table_handles	10000
-performance_schema_max_table_instances	1000
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 show engine PERFORMANCE_SCHEMA status;

=== added file 'mysql-test/suite/perfschema/t/checksum.test'
--- a/mysql-test/suite/perfschema/t/checksum.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/checksum.test	2010-09-15 18:20:48 +0000
@@ -0,0 +1,64 @@
+# Copyright (c) 2010, 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,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#
+# The checksum value itself is random (data is volatile),
+# just testing that this does not crash
+#
+--disable_result_log
+
+checksum table performance_schema.COND_INSTANCES;
+checksum table performance_schema.EVENTS_WAITS_CURRENT;
+checksum table performance_schema.EVENTS_WAITS_HISTORY;
+checksum table performance_schema.EVENTS_WAITS_HISTORY_LONG;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_INSTANCE;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME;
+checksum table performance_schema.FILE_INSTANCES;
+checksum table performance_schema.FILE_SUMMARY_BY_EVENT_NAME;
+checksum table performance_schema.FILE_SUMMARY_BY_INSTANCE;
+checksum table performance_schema.MUTEX_INSTANCES;
+checksum table performance_schema.PERFORMANCE_TIMERS;
+checksum table performance_schema.RWLOCK_INSTANCES;
+checksum table performance_schema.SETUP_CONSUMERS;
+checksum table performance_schema.SETUP_INSTRUMENTS;
+checksum table performance_schema.SETUP_TIMERS;
+checksum table performance_schema.THREADS;
+
+checksum table performance_schema.COND_INSTANCES extended;
+checksum table performance_schema.EVENTS_WAITS_CURRENT extended;
+checksum table performance_schema.EVENTS_WAITS_HISTORY extended;
+checksum table performance_schema.EVENTS_WAITS_HISTORY_LONG extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_INSTANCE extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME extended;
+checksum table performance_schema.FILE_INSTANCES extended;
+checksum table performance_schema.FILE_SUMMARY_BY_EVENT_NAME extended;
+checksum table performance_schema.FILE_SUMMARY_BY_INSTANCE extended;
+checksum table performance_schema.MUTEX_INSTANCES extended;
+checksum table performance_schema.PERFORMANCE_TIMERS extended;
+checksum table performance_schema.RWLOCK_INSTANCES extended;
+checksum table performance_schema.SETUP_CONSUMERS extended;
+checksum table performance_schema.SETUP_INSTRUMENTS extended;
+checksum table performance_schema.SETUP_TIMERS extended;
+checksum table performance_schema.THREADS extended;
+
+--enable_result_log
+

=== modified file 'mysql-test/suite/perfschema/t/server_init.test'
--- a/mysql-test/suite/perfschema/t/server_init.test	2010-08-20 08:48:59 +0000
+++ b/mysql-test/suite/perfschema/t/server_init.test	2010-09-17 16:43:02 +0000
@@ -43,10 +43,6 @@ select count(name) from MUTEX_INSTANCES
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/mysys/THR_LOCK_myisam";
 
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/mysys/THR_LOCK_myisam_log";
-
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/mysys/THR_LOCK_heap";
 
@@ -83,11 +79,6 @@ select count(name) from MUTEX_INSTANCES
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_delayed_insert";
 
-# Named LOCK_uuid_short in 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/LOCK_uuid_short";
-
-# Named LOCK_uuid_generator in 5.5, LOCK_uuid_short in 6.0
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_uuid_generator";
 
@@ -127,14 +118,16 @@ select count(name) from MUTEX_INSTANCES
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_server_started";
 
-select count(name) from MUTEX_INSTANCES
- where name like "wait/synch/mutex/sql/LOG_INFO::lock";
+# LOG_INFO object are created on demand, and are not global.
+# select count(name) from MUTEX_INSTANCES
+#  where name like "wait/synch/mutex/sql/LOG_INFO::lock";
 
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/Query_cache::structure_guard_mutex";
 
-select count(name) from MUTEX_INSTANCES
- where name like "wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state";
+# The event scheduler may be disabled
+# select count(name) from MUTEX_INSTANCES
+#  where name like "wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state";
 
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_event_metadata";
@@ -145,16 +138,11 @@ select count(name) from MUTEX_INSTANCES
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_user_locks";
 
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/LOCK_mdl";
-
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/Cversion_lock";
 
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/LOCK_audit_mask";
+select count(name) from MUTEX_INSTANCES
+ where name like "wait/synch/mutex/sql/LOCK_audit_mask";
 
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_xid_cache";
@@ -162,28 +150,13 @@ select count(name) from MUTEX_INSTANCES
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_plugin";
 
-select count(name) from MUTEX_INSTANCES
- where name like "wait/synch/mutex/sql/LOCK_gdl";
+# Not a global variable, may be destroyed already.
+# select count(name) from MUTEX_INSTANCES
+#  where name like "wait/synch/mutex/sql/LOCK_gdl";
 
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/tz_LOCK";
 
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/slave_start";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/BML_class::THR_LOCK_BML";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/BML_class::THR_LOCK_BML_active";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/BML_class::THR_LOCK_BML_get";
-
 # Verify that these global rwlocks have been properly initilized in sql
 
 select count(name) from RWLOCK_INSTANCES
@@ -224,25 +197,10 @@ select count(name) from COND_INSTANCES
 select count(name) from COND_INSTANCES
  where name like "wait/synch/cond/sql/Query_cache::COND_cache_status_changed";
 
-select count(name) from COND_INSTANCES
- where name like "wait/synch/cond/sql/Event_scheduler::COND_state";
+# The event scheduler may be disabled
+# select count(name) from COND_INSTANCES
+#  where name like "wait/synch/cond/sql/Event_scheduler::COND_state";
 
 select count(name) from COND_INSTANCES
  where name like "wait/synch/cond/sql/COND_queue_state";
 
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from COND_INSTANCES
-#  where name like "wait/synch/cond/sql/COND_mdl";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from COND_INSTANCES
-#  where name like "wait/synch/cond/sql/BML_class::COND_BML";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from COND_INSTANCES
-#  where name like "wait/synch/cond/sql/BML_class::COND_BML_registered";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from COND_INSTANCES
-#  where name like "wait/synch/cond/sql/BML_class::COND_BML_release";
-

=== modified file 'mysql-test/suite/rpl/t/disabled.def'
--- a/mysql-test/suite/rpl/t/disabled.def	2010-08-13 10:10:01 +0000
+++ b/mysql-test/suite/rpl/t/disabled.def	2010-09-06 12:52:04 +0000
@@ -10,6 +10,5 @@
 #
 ##############################################################################
 
-rpl_plugin_load           : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
 rpl_row_create_table      : Bug#51574 2010-02-27 andrei failed different way than earlier with bug#45576
 rpl_spec_variables        : BUG#47661 2009-10-27 jasonh rpl_spec_variables fails on PB2 hpux

=== modified file 'mysql-test/suite/rpl/t/rpl_killed_ddl.test'
--- a/mysql-test/suite/rpl/t/rpl_killed_ddl.test	2010-02-06 10:28:06 +0000
+++ b/mysql-test/suite/rpl/t/rpl_killed_ddl.test	2010-10-21 07:37:10 +0000
@@ -119,7 +119,7 @@ echo [on master];
 
 # This will block the execution of a statement at the DBUG_SYNC_POINT
 # with given lock name
-if (`SELECT '$debug_lock' != ''`)
+if ($debug_lock)
 {
   disable_query_log;
   disable_result_log;

=== modified file 'mysql-test/t/ctype_utf16.test'
--- a/mysql-test/t/ctype_utf16.test	2010-09-13 10:04:11 +0000
+++ b/mysql-test/t/ctype_utf16.test	2010-09-28 15:29:26 +0000
@@ -327,6 +327,7 @@ SET collation_connection='utf16_general_
 SET NAMES latin1;
 SET collation_connection='utf16_bin';
 -- source include/ctype_filesort.inc
+-- source include/ctype_filesort2.inc
 -- source include/ctype_like_escape.inc
 
 #

=== modified file 'mysql-test/t/ctype_utf32.test'
--- a/mysql-test/t/ctype_utf32.test	2010-09-13 10:36:27 +0000
+++ b/mysql-test/t/ctype_utf32.test	2010-09-28 15:29:26 +0000
@@ -328,6 +328,7 @@ SET collation_connection='utf32_general_
 SET NAMES latin1;
 SET collation_connection='utf32_bin';
 -- source include/ctype_filesort.inc
+-- source include/ctype_filesort2.inc
 -- source include/ctype_like_escape.inc
 
 #

=== modified file 'mysql-test/t/ctype_utf8mb4.test'
--- a/mysql-test/t/ctype_utf8mb4.test	2010-09-13 10:04:11 +0000
+++ b/mysql-test/t/ctype_utf8mb4.test	2010-09-28 15:29:26 +0000
@@ -733,6 +733,7 @@ SET collation_connection='utf8mb4_genera
 -- source include/ctype_german.inc
 SET collation_connection='utf8mb4_bin';
 -- source include/ctype_filesort.inc
+-- source include/ctype_filesort2.inc
 -- source include/ctype_like_escape.inc
 
 #

=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def	2010-08-30 08:38:30 +0000
+++ b/mysql-test/t/disabled.def	2010-09-06 12:52:04 +0000
@@ -11,10 +11,9 @@
 ##############################################################################
 kill                     : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild.
 lowercase_table3         : Bug#54845 2010-06-30 alik main.lowercase_table3 on Mac OSX
+mysqlhotcopy_myisam      : Bug#54129 2010-08-31 alik mysqlhotcopy* fails
+mysqlhotcopy_archive     : Bug#54129 2010-08-31 alik mysqlhotcopy* fails
 partition_innodb_plugin  : Bug#53307 2010-04-30 VasilDimov valgrind warnings
-plugin                   : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
-plugin_load              : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
-plugin_not_embedded      : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
 query_cache_28249        : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
 sp_sync                  : Bug#48157 2010-02-06 5.5-m3 demands a differnt solution
 ctype_utf8mb4_ndb	: Bug#55799, Bug#51907, disabled by Konstantin 2010-08-06

=== modified file 'mysql-test/t/log_tables_debug.test'
--- a/mysql-test/t/log_tables_debug.test	2009-06-15 23:27:27 +0000
+++ b/mysql-test/t/log_tables_debug.test	2010-09-27 10:18:10 +0000
@@ -7,6 +7,7 @@
 # changed (see explanation in log_state.test)
 let $fixed_bug38124 = 0;
 
+--source include/not_embedded.inc
 --source include/have_debug.inc
 
 # Several subtests modify global variables. Save the initial values only here,

=== modified file 'mysql-test/t/server_uuid_embedded.test'
--- a/mysql-test/t/server_uuid_embedded.test	2010-07-14 15:04:32 +0000
+++ b/mysql-test/t/server_uuid_embedded.test	2010-10-21 12:36:16 +0000
@@ -25,7 +25,7 @@ SET GLOBAL SERVER_UUID= UUID();
 --echo # SERVER_UUID is not null
 --echo -----------------------------------------------------------------------------
 --let $server_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
-if (`SELECT '$server_uuid' = ''`)
+if (!$server_uuid)
 {
   --echo server's UUID is null
 }

=== modified file 'mysql-test/t/strict.test'
--- a/mysql-test/t/strict.test	2010-03-18 10:38:29 +0000
+++ b/mysql-test/t/strict.test	2010-09-07 06:45:00 +0000
@@ -192,11 +192,11 @@ INSERT INTO t1 (col3) VALUES (STR_TO_DAT
 #       All test cases expected to fail should return 
 #       SQLSTATE 22007 <invalid date value>
 
+--error 1411
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
-
---error 1292
+--error 1411
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
 --error 1292
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
@@ -206,18 +206,18 @@ INSERT INTO t1 (col1) VALUES(STR_TO_DATE
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
 --error 1411
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
 
 ## Test INSERT with STR_TO_DATE into DATETIME
 #       All test cases expected to fail should return 
 #       SQLSTATE 22007 <invalid datetime value>
 
+--error 1411
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
-
---error 1292
+--error 1411
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
 --error 1292
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
@@ -227,18 +227,18 @@ INSERT INTO t1 (col2) VALUES(STR_TO_DATE
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
 --error 1411
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
 
 ## Test INSERT with STR_TO_DATE into TIMESTAMP
 #       All test cases expected to fail should return 
 #       SQLSTATE 22007 <invalid datetime value>
 
---error 1292
+--error 1411
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
 --error 1292
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
@@ -248,7 +248,7 @@ INSERT INTO t1 (col3) VALUES(STR_TO_DATE
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
 --error 1411
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
 INSERT INTO t1 (col3) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
 
 drop table t1;

=== modified file 'mysql-test/t/type_datetime.test'
--- a/mysql-test/t/type_datetime.test	2010-05-05 09:28:37 +0000
+++ b/mysql-test/t/type_datetime.test	2010-09-07 06:45:00 +0000
@@ -462,5 +462,28 @@ DROP TABLE t1;
 SET NAMES latin1;
 
 --echo #
+--echo # Bug#56271: Wrong comparison result with STR_TO_DATE function
+--echo #
+CREATE TABLE t1 (
+  `year` int(4) NOT NULL,
+  `month` int(2) NOT NULL
+);
+
+INSERT INTO t1 VALUES (2010,3),(2010,4),(2009,8),(2008,9);
+
+SELECT *
+FROM t1
+WHERE STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') >=
+STR_TO_DATE('1/1/2010', '%m/%d/%Y');
+
+create table t2(f1 datetime primary key);
+insert into t2 select STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') from t1;
+select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y');
+--echo t2 should be const
+explain select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y');
+
+DROP TABLE t1,t2;
+
+--echo #
 --echo # End of 5.5 tests
 --echo #

=== modified file 'mysql-test/t/type_newdecimal.test'
--- a/mysql-test/t/type_newdecimal.test	2010-04-11 06:52:42 +0000
+++ b/mysql-test/t/type_newdecimal.test	2010-09-23 12:38:24 +0000
@@ -1509,5 +1509,14 @@ group by PAY.id + 1;
 
 DROP TABLE currencies, payments, sub_tasks;
 
+--echo #
+--echo # BUG#52171: distinct aggregates on unsigned decimal fields trigger assertions
+--echo #
+
+CREATE TABLE t1 (a DECIMAL(4,4) UNSIGNED);
+INSERT INTO t1 VALUES (0);
+SELECT AVG(DISTINCT a) FROM t1;
+SELECT SUM(DISTINCT a) FROM t1;
+DROP TABLE t1;
 
 --echo End of 5.1 tests

=== modified file 'mysql-test/valgrind.supp'
--- a/mysql-test/valgrind.supp	2010-06-07 09:14:56 +0000
+++ b/mysql-test/valgrind.supp	2010-09-28 00:32:57 +0000
@@ -745,3 +745,38 @@
    Memcheck:Addr1
    fun:buf_buddy_relocate
 }
+
+#
+# See related Bug#56666
+# Race condition between the server main thread and the kill server thread.
+#
+# Because of this race condition, the call to shutdown_performance_schema()
+# was commented in sql/mysqld.cc, causing the reported leaks.
+#
+
+{
+   missing shutdown_performance_schema 1
+   Memcheck:Leak
+   fun:malloc
+   fun:_Z10pfs_mallocmi
+}
+
+{
+   missing shutdown_performance_schema 2
+   Memcheck:Leak
+   fun:malloc
+   fun:my_malloc
+   fun:_lf_alloc_new
+   fun:lf_hash_insert
+}
+
+{
+   missing shutdown_performance_schema 3
+   Memcheck:Leak
+   fun:malloc
+   fun:my_malloc
+   fun:initialize_bucket
+   fun:lf_hash_search
+   fun:_Z19find_or_create_fileP10PFS_threadP14PFS_file_classPKcj
+}
+

=== modified file 'mysys/my_gethwaddr.c'
--- a/mysys/my_gethwaddr.c	2010-07-15 13:47:50 +0000
+++ b/mysys/my_gethwaddr.c	2010-09-09 12:51:50 +0000
@@ -64,7 +64,7 @@ my_bool my_gethwaddr(uchar *to)
     if (ifm->ifm_type == RTM_IFINFO)
     {
       sdl = (struct sockaddr_dl *)(ifm + 1);
-      addr=LLADDR(sdl);
+      addr=(uchar *)LLADDR(sdl);
       res=memcpy_and_test(to, addr, ETHER_ADDR_LEN);
     }
   }

=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2010-09-27 11:37:21 +0000
+++ b/mysys/my_getopt.c	2010-09-28 15:29:26 +0000
@@ -187,6 +187,7 @@ int handle_options(int *argc, char ***ar
   {
     char **first= pos;
     char *cur_arg= *pos;
+    opt_found= 0;
     if (!is_cmdline_arg && (cur_arg == args_separator))
     {
       is_cmdline_arg= 1;

=== modified file 'mysys/my_sync.c'
--- a/mysys/my_sync.c	2009-12-11 09:39:38 +0000
+++ b/mysys/my_sync.c	2010-09-09 13:55:37 +0000
@@ -100,9 +100,9 @@ static const char cur_dir_name[]= {FN_CU
   RETURN
     0 if ok, !=0 if error
 */
+#ifdef NEED_EXPLICIT_SYNC_DIR
 int my_sync_dir(const char *dir_name, myf my_flags)
 {
-#ifdef NEED_EXPLICIT_SYNC_DIR
   File dir_fd;
   int res= 0;
   const char *correct_dir_name;
@@ -124,10 +124,14 @@ int my_sync_dir(const char *dir_name, my
   else
     res= 1;
   DBUG_RETURN(res);
-#else
+}
+#else /* NEED_EXPLICIT_SYNC_DIR */
+int my_sync_dir(const char *dir_name __attribute__((unused)),
+		myf my_flags __attribute__((unused)))
+{
   return 0;
-#endif
 }
+#endif /* NEED_EXPLICIT_SYNC_DIR */
 
 
 /*
@@ -141,15 +145,18 @@ int my_sync_dir(const char *dir_name, my
   RETURN
     0 if ok, !=0 if error
 */
+#ifdef NEED_EXPLICIT_SYNC_DIR
 int my_sync_dir_by_file(const char *file_name, myf my_flags)
 {
-#ifdef NEED_EXPLICIT_SYNC_DIR
   char dir_name[FN_REFLEN];
   size_t dir_name_length;
   dirname_part(dir_name, file_name, &dir_name_length);
   return my_sync_dir(dir_name, my_flags);
-#else
+}
+#else /* NEED_EXPLICIT_SYNC_DIR */
+int my_sync_dir_by_file(const char *file_name __attribute__((unused)),
+			myf my_flags __attribute__((unused)))
+{
   return 0;
-#endif
 }
-
+#endif /* NEED_EXPLICIT_SYNC_DIR */

=== modified file 'packaging/WiX/mysql_server.wxs.in'
--- a/packaging/WiX/mysql_server.wxs.in	2010-07-24 16:18:39 +0000
+++ b/packaging/WiX/mysql_server.wxs.in	2010-09-21 09:13:38 +0000
@@ -21,7 +21,9 @@
     <Media Id='1' Cabinet='product.cab' EmbedCab='yes' />
 
     <!-- Upgrade -->
+    
     <Upgrade Id="49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3">
+      <?if '@PATCH@' != '0'?>
       <UpgradeVersion 
         Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.0"
         IncludeMinimum="yes"
@@ -29,6 +31,7 @@
         Property="OLDERVERSIONBEINGUPGRADED"
         MigrateFeatures="yes"
         />
+      <?endif?>
       <UpgradeVersion 
         Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@"
         OnlyDetect="yes"

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2010-09-27 11:37:21 +0000
+++ b/sql/binlog.cc	2010-09-28 15:17:07 +0000
@@ -3543,11 +3543,8 @@ int MYSQL_BIN_LOG::wait_for_update_bin_l
                                            const struct timespec *timeout)
 {
   int ret= 0;
-  const char* old_msg = thd->proc_info;
   DBUG_ENTER("wait_for_update_bin_log");
-  old_msg= thd->enter_cond(&update_cond, &LOCK_log,
-                           "Master has sent all binlog to slave; "
-                           "waiting for binlog to be updated");
+
   if (!timeout)
     mysql_cond_wait(&update_cond, &LOCK_log);
   else

=== modified file 'sql/binlog.h'
--- a/sql/binlog.h	2010-08-26 14:29:22 +0000
+++ b/sql/binlog.h	2010-09-17 12:31:54 +0000
@@ -228,6 +228,7 @@ public:
   inline char* get_log_fname() { return log_file_name; }
   inline char* get_name() { return name; }
   inline mysql_mutex_t* get_log_lock() { return &LOCK_log; }
+  inline mysql_cond_t* get_log_cond() { return &update_cond; }
   inline IO_CACHE* get_log_file() { return &log_file; }
 
   inline void lock_index() { mysql_mutex_lock(&LOCK_index);}

=== modified file 'sql/derror.cc'
--- a/sql/derror.cc	2010-07-08 21:42:23 +0000
+++ b/sql/derror.cc	2010-09-08 07:09:13 +0000
@@ -35,6 +35,8 @@ static void init_myfunc_errs(void);
 C_MODE_START
 static const char **get_server_errmsgs()
 {
+  if (!current_thd)
+    return DEFAULT_ERRMSGS;
   return CURRENT_THD_ERRMSGS;
 }
 C_MODE_END

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2010-09-13 09:58:11 +0000
+++ b/sql/field.cc	2010-09-28 15:29:26 +0000
@@ -9151,7 +9151,7 @@ void Create_field::init_for_tmp_table(en
   case MYSQL_TYPE_NEWDECIMAL:
   case MYSQL_TYPE_FLOAT:
   case MYSQL_TYPE_DOUBLE:
-    pack_flag= FIELDFLAG_DECIMAL | FIELDFLAG_NUMBER |
+    pack_flag= FIELDFLAG_NUMBER |
       (decimals_arg & FIELDFLAG_MAX_DEC) << FIELDFLAG_DEC_SHIFT;
     break;
 
@@ -9200,12 +9200,13 @@ void Create_field::init_for_tmp_table(en
     (maybe_null ? FIELDFLAG_MAYBE_NULL : 0) |
     (is_unsigned ? 0 : FIELDFLAG_DECIMAL);
 
-  DBUG_PRINT("debug", ("pack_flag: %s%s%s%s%s, pack_type: %d",
+  DBUG_PRINT("debug", ("pack_flag: %s%s%s%s%s%s, pack_type: %d",
                        FLAGSTR(pack_flag, FIELDFLAG_BINARY),
                        FLAGSTR(pack_flag, FIELDFLAG_NUMBER),
                        FLAGSTR(pack_flag, FIELDFLAG_INTERVAL),
                        FLAGSTR(pack_flag, FIELDFLAG_GEOM),
                        FLAGSTR(pack_flag, FIELDFLAG_BLOB),
+                       FLAGSTR(pack_flag, FIELDFLAG_DECIMAL),
                        f_packtype(pack_flag)));
   DBUG_VOID_RETURN;
 }

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2010-07-16 21:00:50 +0000
+++ b/sql/item_timefunc.cc	2010-09-09 13:04:25 +0000
@@ -3368,6 +3368,8 @@ void Item_func_str_to_date::fix_length_a
   cached_field_type= MYSQL_TYPE_DATETIME;
   max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
   cached_timestamp_type= MYSQL_TIMESTAMP_NONE;
+  sql_mode= (current_thd->variables.sql_mode &
+             (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE));
   if ((const_item= args[1]->const_item()))
   {
     char format_buff[64];
@@ -3433,6 +3435,14 @@ bool Item_func_str_to_date::get_date(MYS
   return 0;
 
 null_date:
+  if (fuzzy_date & TIME_NO_ZERO_DATE)
+  {
+    char buff[128];
+    strmake(buff, val->ptr(), min(val->length(), sizeof(buff)-1));
+    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
+                        "datetime", buff, "str_to_date");
+  }
   return (null_value=1);
 }
 
@@ -3442,7 +3452,7 @@ String *Item_func_str_to_date::val_str(S
   DBUG_ASSERT(fixed == 1);
   MYSQL_TIME ltime;
 
-  if (Item_func_str_to_date::get_date(&ltime, TIME_FUZZY_DATE))
+  if (Item_func_str_to_date::get_date(&ltime, TIME_FUZZY_DATE | sql_mode))
     return 0;
 
   if (!make_datetime((const_item ? cached_format_type :
@@ -3453,6 +3463,29 @@ String *Item_func_str_to_date::val_str(S
 }
 
 
+longlong Item_func_str_to_date::val_int()
+{
+  DBUG_ASSERT(fixed == 1);
+  MYSQL_TIME ltime;
+
+  if (Item_func_str_to_date::get_date(&ltime, TIME_FUZZY_DATE | sql_mode))
+    return 0;
+
+  if (const_item)
+  {
+    switch (cached_field_type) {
+    case MYSQL_TYPE_DATE:
+      return TIME_to_ulonglong_date(&ltime);
+    case MYSQL_TYPE_TIME:
+      return TIME_to_ulonglong_time(&ltime);
+    default:
+      return TIME_to_ulonglong_datetime(&ltime);
+    }
+  }
+  return TIME_to_ulonglong_datetime(&ltime);
+}
+
+
 bool Item_func_last_day::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
 {
   if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) ||

=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h	2010-08-18 07:20:58 +0000
+++ b/sql/item_timefunc.h	2010-09-09 13:04:25 +0000
@@ -1039,6 +1039,7 @@ class Item_func_str_to_date :public Item
   date_time_format_types cached_format_type;
   timestamp_type cached_timestamp_type;
   bool const_item;
+  ulonglong sql_mode;
 public:
   Item_func_str_to_date(Item *a, Item *b)
     :Item_str_func(a, b), const_item(false)
@@ -1052,6 +1053,8 @@ public:
   {
     return tmp_table_field_from_field_type(table, 1);
   }
+  longlong val_int();
+  bool result_as_longlong() { return TRUE; }
 };
 
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-09-01 13:05:01 +0000
+++ b/sql/mysqld.cc	2010-09-14 21:51:35 +0000
@@ -1395,6 +1395,12 @@ static void mysqld_exit(int exit_code)
   mysql_audit_finalize();
   clean_up_mutexes();
   clean_up_error_log_mutex();
+#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
+  /*
+    Bug#56666 needs to be fixed before calling:
+    shutdown_performance_schema();
+  */
+#endif
   my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
   exit(exit_code); /* purecov: inspected */
 }
@@ -1486,6 +1492,7 @@ void clean_up(bool print_message)
   cleanup_errmsgs();
   MYSQL_CALLBACK(thread_scheduler, end, ());
   finish_client_errs();
+  (void) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); // finish server errs
   DBUG_PRINT("quit", ("Error messages freed"));
   /* Tell main we are ready */
   logger.cleanup_end();
@@ -2728,6 +2735,11 @@ pthread_handler_t signal_hand(void *arg
       if (!abort_loop)
       {
 	abort_loop=1;				// mark abort for threads
+#ifdef HAVE_PSI_INTERFACE
+        /* Delete the instrumentation for the signal thread */
+        if (likely(PSI_server != NULL))
+          PSI_server->delete_current_thread();
+#endif
 #ifdef USE_ONE_SIGNAL_HAND
 	pthread_t tmp;
         if (mysql_thread_create(0, /* Not instrumented */
@@ -4748,6 +4760,15 @@ int mysqld_main(int argc, char **argv)
 #endif
 #endif /* __WIN__ */
 
+#ifdef HAVE_PSI_INTERFACE
+  /*
+    Disable the main thread instrumentation,
+    to avoid recording events during the shutdown.
+  */
+  if (PSI_server)
+    PSI_server->delete_current_thread();
+#endif
+
   /* Wait until cleanup is done */
   mysql_mutex_lock(&LOCK_thread_count);
   while (!ready_to_exit)
@@ -4765,18 +4786,6 @@ int mysqld_main(int argc, char **argv)
   }
 #endif
   clean_up(1);
-#ifdef HAVE_PSI_INTERFACE
-  /*
-    Disable the instrumentation, to avoid recording events
-    during the shutdown.
-  */
-  if (PSI_server)
-  {
-    PSI_server->delete_current_thread();
-    PSI_server= NULL;
-  }
-  shutdown_performance_schema();
-#endif
   mysqld_exit(0);
 }
 

=== modified file 'sql/rpl_master.cc'
--- a/sql/rpl_master.cc	2010-07-29 11:30:51 +0000
+++ b/sql/rpl_master.cc	2010-09-17 12:31:54 +0000
@@ -511,6 +511,7 @@ void mysql_binlog_send(THD* thd, char* l
   const char *errmsg = "Unknown error";
   NET* net = &thd->net;
   mysql_mutex_t *log_lock;
+  mysql_cond_t *log_cond;
   bool binlog_can_be_corrupted= FALSE;
 #ifndef DBUG_OFF
   int left_events = max_binlog_dump_events;
@@ -654,7 +655,8 @@ impossible position";
     mysql_bin_log, and it's already inited, and it will be destroyed
     only at shutdown).
   */
-  log_lock = mysql_bin_log.get_log_lock();
+  log_lock= mysql_bin_log.get_log_lock();
+  log_cond= mysql_bin_log.get_log_cond();
   if (pos > BIN_LOG_HEADER_SIZE)
   {
     /* reset transmit packet for the event read from binary log
@@ -889,6 +891,7 @@ impossible position";
 #ifndef DBUG_OFF
           ulong hb_info_counter= 0;
 #endif
+          const char* old_msg= thd->proc_info;
           signal_cnt= mysql_bin_log.signal_cnt;
           do 
           {
@@ -897,6 +900,9 @@ impossible position";
               DBUG_ASSERT(heartbeat_ts && heartbeat_period != 0);
               set_timespec_nsec(*heartbeat_ts, heartbeat_period);
             }
+            thd->enter_cond(log_cond, log_lock,
+                            "Master has sent all binlog to slave; "
+                            "waiting for binlog to be updated");
             ret= mysql_bin_log.wait_for_update_bin_log(thd, heartbeat_ts);
             DBUG_ASSERT(ret == 0 || (heartbeat_period != 0 && coord != NULL));
             if (ret == ETIMEDOUT || ret == ETIME)
@@ -912,12 +918,15 @@ impossible position";
 #endif
               /* reset transmit packet for the heartbeat event */
               if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg))
+              {
+                thd->exit_cond(old_msg);
                 goto err;
+              }
               if (send_heartbeat_event(net, packet, coord))
               {
                 errmsg = "Failed on my_net_write()";
                 my_errno= ER_UNKNOWN_ERROR;
-                mysql_mutex_unlock(log_lock);
+                thd->exit_cond(old_msg);
                 goto err;
               }
             }
@@ -926,7 +935,7 @@ impossible position";
               DBUG_PRINT("wait",("binary log received update or a broadcast signal caught"));
             }
           } while (signal_cnt == mysql_bin_log.signal_cnt && !thd->killed);
-          mysql_mutex_unlock(log_lock);
+          thd->exit_cond(old_msg);
         }
         break;
             

=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc	2010-08-26 14:54:39 +0000
+++ b/sql/set_var.cc	2010-09-08 07:09:13 +0000
@@ -108,7 +108,7 @@ void sys_var_end()
   my_hash_free(&system_variable_hash);
 
   for (sys_var *var=all_sys_vars.first; var; var= var->next)
-    var->~sys_var();
+    var->cleanup();
 
   DBUG_VOID_RETURN;
 }

=== modified file 'sql/set_var.h'
--- a/sql/set_var.h	2010-07-23 20:59:42 +0000
+++ b/sql/set_var.h	2010-09-09 13:04:25 +0000
@@ -91,11 +91,13 @@ public:
           longlong def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg,
           on_check_function on_check_func, on_update_function on_update_func,
           uint deprecated_version, const char *substitute, int parse_flag);
+
+  virtual ~sys_var() {}
+
   /**
-    The instance should only be destroyed on shutdown, as it doesn't unlink
-    itself from the chain.
+    All the cleanup procedures should be performed here
   */
-  virtual ~sys_var() {}
+  virtual void cleanup() {}
   /**
     downcast for sys_var_pluginvar. Returns this if it's an instance
     of sys_var_pluginvar, and 0 otherwise.

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2010-08-30 08:38:30 +0000
+++ b/sql/sql_insert.cc	2010-09-01 13:14:50 +0000
@@ -621,6 +621,32 @@ bool open_and_lock_for_insert_delayed(TH
 
 
 /**
+  Create a new query string for removing DELAYED keyword for
+  multi INSERT DEALAYED statement.
+
+  @param[in] thd                 Thread handler
+  @param[in] buf                 Query string
+
+  @return
+             0           ok
+             1           error
+*/
+static int
+create_insert_stmt_from_insert_delayed(THD *thd, String *buf)
+{
+  /* Append the part of thd->query before "DELAYED" keyword */
+  if (buf->append(thd->query(),
+                  thd->lex->keyword_delayed_begin - thd->query()))
+    return 1;
+  /* Append the part of thd->query after "DELAYED" keyword */
+  if (buf->append(thd->lex->keyword_delayed_begin + 7))
+    return 1;
+
+  return 0;
+}
+
+
+/**
   INSERT statement implementation
 
   @note Like implementations of other DDL/DML in MySQL, this function
@@ -999,13 +1025,28 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
 	such case the flag is ignored for constructing binlog event.
 	*/
 	DBUG_ASSERT(thd->killed != THD::KILL_BAD_DATA || error > 0);
-	if (thd->binlog_query(THD::ROW_QUERY_TYPE,
-			      thd->query(), thd->query_length(),
-			      transactional_table, FALSE, FALSE,
-                              errcode))
+        if (was_insert_delayed && table_list->lock_type ==  TL_WRITE)
         {
+          /* Binlog multi INSERT DELAYED as INSERT without DELAYED. */
+          String log_query;
+          if (create_insert_stmt_from_insert_delayed(thd, &log_query))
+          {
+            sql_print_error("Event Error: An error occurred while creating query string"
+                            "for INSERT DELAYED stmt, before writing it into binary log.");
+
+            error= 1;
+          }
+          else if (thd->binlog_query(THD::ROW_QUERY_TYPE,
+                                     log_query.c_ptr(), log_query.length(),
+                                     transactional_table, FALSE, FALSE,
+                                     errcode))
+            error= 1;
+        }
+        else if (thd->binlog_query(THD::ROW_QUERY_TYPE,
+			           thd->query(), thd->query_length(),
+			           transactional_table, FALSE, FALSE,
+                                   errcode))
 	  error= 1;
-	}
       }
     }
     DBUG_ASSERT(transactional_table || !changed || 

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2010-08-30 08:38:30 +0000
+++ b/sql/sql_lex.h	2010-09-01 13:14:50 +0000
@@ -2366,8 +2366,14 @@ struct LEX: public Query_tables_list
 
     This pointer is required to add possibly omitted DEFINER-clause to the
     DDL-statement before dumping it to the binlog.
+
+    keyword_delayed_begin points to the begin of the DELAYED keyword in
+    INSERT DELAYED statement.
   */
-  const char *stmt_definition_begin;
+  union {
+    const char *stmt_definition_begin;
+    const char *keyword_delayed_begin;
+  };
 
   const char *stmt_definition_end;
 

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2010-08-23 17:02:22 +0000
+++ b/sql/sql_plugin.cc	2010-09-21 21:26:13 +0000
@@ -519,7 +519,7 @@ static st_plugin_dl *plugin_dl_add(const
       /* no op */;
 
     cur= (struct st_mysql_plugin*)
-          my_malloc(i*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME));
+      my_malloc((i+1)*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME));
     if (!cur)
     {
       free_plugin_mem(&plugin_dl);

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2010-08-31 07:53:09 +0000
+++ b/sql/sql_yacc.yy	2010-09-01 13:14:50 +0000
@@ -10611,8 +10611,8 @@ insert_lock_option:
         | LOW_PRIORITY  { $$= TL_WRITE_LOW_PRIORITY; }
         | DELAYED_SYM
         {
+          Lex->keyword_delayed_begin= YYLIP->get_tok_start();
           $$= TL_WRITE_DELAYED;
-          Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_DELAYED);
         }
         | HIGH_PRIORITY { $$= TL_WRITE; }
         ;
@@ -10621,8 +10621,8 @@ replace_lock_option:
           opt_low_priority { $$= $1; }
         | DELAYED_SYM
         {
+          Lex->keyword_delayed_begin= YYLIP->get_tok_start();
           $$= TL_WRITE_DELAYED;
-          Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_DELAYED);
         }
         ;
 

=== modified file 'sql/sys_vars.h'
--- a/sql/sys_vars.h	2010-08-12 14:08:21 +0000
+++ b/sql/sys_vars.h	2010-09-08 07:09:13 +0000
@@ -385,7 +385,7 @@ public:
     DBUG_ASSERT(scope() == GLOBAL);
     DBUG_ASSERT(size == sizeof(char *));
   }
-  ~Sys_var_charptr()
+  void cleanup()
   {
     if (flags & ALLOCATED)
       my_free(global_var(char*));

=== modified file 'storage/perfschema/pfs_engine_table.cc'
--- a/storage/perfschema/pfs_engine_table.cc	2010-08-12 15:25:01 +0000
+++ b/storage/perfschema/pfs_engine_table.cc	2010-09-20 20:59:48 +0000
@@ -223,6 +223,8 @@ int PFS_engine_table::read_row(TABLE *ta
                                Field **fields)
 {
   my_bitmap_map *org_bitmap;
+  Field *f;
+  Field **fields_reset;
 
   /*
     Make sure the table structure is as expected before mapping
@@ -240,6 +242,16 @@ int PFS_engine_table::read_row(TABLE *ta
 
   /* We internally write to Fields to support the read interface */
   org_bitmap= dbug_tmp_use_all_columns(table, table->write_set);
+
+  /*
+    Some callers of the storage engine interface do not honor the
+    f->is_null() flag, and will attempt to read the data itself.
+    A known offender is mysql_checksum_table().
+    For robustness, reset every field.
+  */
+  for (fields_reset= fields; (f= *fields_reset) ; fields_reset++)
+    f->reset();
+
   int result= read_row_values(table, buf, fields, read_all);
   dbug_tmp_restore_column_map(table->write_set, org_bitmap);
 

=== modified file 'storage/perfschema/table_events_waits.cc'
--- a/storage/perfschema/table_events_waits.cc	2010-08-12 10:21:22 +0000
+++ b/storage/perfschema/table_events_waits.cc	2010-09-15 20:46:26 +0000
@@ -187,7 +187,7 @@ void table_events_waits_common::clear_ob
 */
 void table_events_waits_common::make_row(bool thread_own_wait,
                                          PFS_thread *pfs_thread,
-                                         PFS_events_waits *wait)
+                                         volatile PFS_events_waits *wait)
 {
   pfs_lock lock;
   PFS_thread *safe_thread;
@@ -260,21 +260,27 @@ void table_events_waits_common::make_row
       m_row.m_object_type= "TEMPORARY TABLE";
       m_row.m_object_type_length= 15;
     }
-    memcpy(m_row.m_object_schema, wait->m_schema_name,
-           wait->m_schema_name_length);
     m_row.m_object_schema_length= wait->m_schema_name_length;
-    memcpy(m_row.m_object_name, wait->m_object_name,
-           wait->m_object_name_length);
+    if (unlikely((m_row.m_object_schema_length == 0) ||
+                 (m_row.m_object_schema_length > sizeof(m_row.m_object_schema))))
+      return;
+    memcpy(m_row.m_object_schema, wait->m_schema_name, m_row.m_object_schema_length);
     m_row.m_object_name_length= wait->m_object_name_length;
+    if (unlikely((m_row.m_object_name_length == 0) ||
+                 (m_row.m_object_name_length > sizeof(m_row.m_object_name))))
+      return;
+    memcpy(m_row.m_object_name, wait->m_object_name, m_row.m_object_name_length);
     safe_class= &global_table_class;
     break;
   case WAIT_CLASS_FILE:
     m_row.m_object_type= "FILE";
     m_row.m_object_type_length= 4;
     m_row.m_object_schema_length= 0;
-    memcpy(m_row.m_object_name, wait->m_object_name,
-           wait->m_object_name_length);
     m_row.m_object_name_length= wait->m_object_name_length;
+    if (unlikely((m_row.m_object_name_length == 0) ||
+                 (m_row.m_object_name_length > sizeof(m_row.m_object_name))))
+      return;
+    memcpy(m_row.m_object_name, wait->m_object_name, m_row.m_object_name_length);
     safe_class= sanitize_file_class((PFS_file_class*) wait->m_class);
     break;
   case NO_WAIT_CLASS:

=== modified file 'storage/perfschema/table_events_waits.h'
--- a/storage/perfschema/table_events_waits.h	2010-07-23 17:08:41 +0000
+++ b/storage/perfschema/table_events_waits.h	2010-09-15 20:46:26 +0000
@@ -139,7 +139,7 @@ protected:
   void clear_object_columns();
 
   void make_row(bool thread_own_wait, PFS_thread *pfs_thread,
-                PFS_events_waits *wait);
+                volatile PFS_events_waits *wait);
 
   /** Current row. */
   row_events_waits m_row;

=== modified file 'strings/ctype-ucs2.c'
--- a/strings/ctype-ucs2.c	2010-09-13 10:04:11 +0000
+++ b/strings/ctype-ucs2.c	2010-09-28 15:29:26 +0000
@@ -1470,7 +1470,7 @@ my_strnncoll_utf16_bin(CHARSET_INFO *cs,
     }
     if (s_wc != t_wc)
     {
-      return  s_wc > t_wc ? 1 : -1;
+      return  my_bincmp(s, s + s_res, t, t + t_res);
     }
     
     s+= s_res;
@@ -1512,7 +1512,7 @@ my_strnncollsp_utf16_bin(CHARSET_INFO *c
 
     if (s_wc != t_wc)
     {
-      return s_wc > t_wc ? 1 : -1;
+      return my_bincmp(s, s + s_res, t, t + t_res);
     }
 
     s+= s_res;
@@ -1695,8 +1695,8 @@ static MY_COLLATION_HANDLER my_collation
   NULL,                /* init */
   my_strnncoll_utf16_bin,
   my_strnncollsp_utf16_bin,
-  my_strnxfrm_unicode,
-  my_strnxfrmlen_simple,
+  my_strnxfrm_unicode_full_bin,
+  my_strnxfrmlen_unicode_full_bin,
   my_like_range_utf16,
   my_wildcmp_utf16_bin,
   my_strcasecmp_mb2_or_mb4,
@@ -2724,8 +2724,8 @@ static MY_COLLATION_HANDLER my_collation
   NULL, /* init */
   my_strnncoll_utf32_bin,
   my_strnncollsp_utf32_bin,
-  my_strnxfrm_unicode,
-  my_strnxfrmlen_utf32,
+  my_strnxfrm_unicode_full_bin,
+  my_strnxfrmlen_unicode_full_bin,
   my_like_range_utf32,
   my_wildcmp_utf32_bin,
   my_strcasecmp_mb2_or_mb4,

=== modified file 'strings/ctype-utf8.c'
--- a/strings/ctype-utf8.c	2010-09-13 10:04:11 +0000
+++ b/strings/ctype-utf8.c	2010-09-28 15:29:26 +0000
@@ -4887,7 +4887,13 @@ my_strxfrm_pad_unicode(uchar *str, uchar
 
 
 /*
-  This function is shared between utf8mb3/utf8mb4/ucs2/utf16/utf32
+  Store sorting weights using 2 bytes per character.
+
+  This function is shared between
+  - utf8mb3_general_ci, utf8_bin, ucs2_general_ci, ucs2_bin
+    which support BMP only (U+0000..U+FFFF).
+  - utf8mb4_general_ci, utf16_general_ci, utf32_general_ci,
+    which map all supplementary characters to weight 0xFFFD.
 */
 size_t
 my_strnxfrm_unicode(CHARSET_INFO *cs,
@@ -4929,6 +4935,88 @@ my_strnxfrm_unicode(CHARSET_INFO *cs,
 }
 
 
+/*
+  Store sorting weights using 3 bytes per character.
+  This function is shared between utf8mb4_bin, utf16_bin, utf32_bin.
+*/
+size_t
+my_strnxfrm_unicode_full_bin(CHARSET_INFO *cs,
+                             uchar *dst, size_t dstlen, uint nweights,
+                             const uchar *src, size_t srclen, uint flags)
+{
+  my_wc_t wc;
+  uchar *dst0= dst;
+  uchar *de= dst + dstlen;
+  const uchar *se = src + srclen;
+
+  LINT_INIT(wc);
+  DBUG_ASSERT(src);
+  DBUG_ASSERT(cs->state & MY_CS_BINSORT);
+
+  for ( ; dst < de && nweights; nweights--)
+  {
+    int res;
+    if ((res= cs->cset->mb_wc(cs, &wc, src, se)) <= 0)
+      break;
+    src+= res;
+    if (cs->mbminlen == 2) /* utf16_bin */
+    {
+      /*
+        Reorder code points to weights as follows:
+        U+0000..U+D7FF    -> [00][00][00]..[00][D7][FF] BMP part #1
+        U+10000..U+10FFFF -> [01][00][00]..[10][FF][FF] Supplementary
+        U+E000..U+FFFF    -> [20][E0][00]..[20][FF][FF] BMP part #2
+      */
+      if (wc >= 0xE000 && wc <= 0xFFFF)
+        wc+= 0x200000;
+    }
+    *dst++= (uchar) (wc >> 16);
+    if (dst < de)
+    {
+      *dst++= (uchar) ((wc >> 8) & 0xFF);
+      if (dst < de)
+        *dst++= (uchar) (wc & 0xFF);
+    }
+  }
+
+  if (flags & MY_STRXFRM_PAD_WITH_SPACE)
+  {
+    for ( ; dst < de && nweights; nweights--)
+    {
+      *dst++= 0x00;
+      if (dst < de)
+      {
+        *dst++= 0x00;
+        if (dst < de)
+          *dst++= 0x20;
+      }
+    }
+  }
+  
+  my_strxfrm_desc_and_reverse(dst0, dst, flags, 0);
+
+  if (flags & MY_STRXFRM_PAD_TO_MAXLEN)
+  {
+    while (dst < de)
+    {
+      *dst++= 0x00;
+      if (dst < de)
+      {
+        *dst++= 0x00;
+        if (dst < de)
+          *dst++= 0x20;
+      }
+    }
+  }
+  return dst - dst0;
+}
+
+
+size_t
+my_strnxfrmlen_unicode_full_bin(CHARSET_INFO *cs, size_t len)
+{
+  return ((len + 3) / cs->mbmaxlen) * 3;
+}
 #endif /* HAVE_UNIDATA */
 
 
@@ -8099,8 +8187,8 @@ static MY_COLLATION_HANDLER my_collation
     NULL,		/* init */
     my_strnncoll_mb_bin,
     my_strnncollsp_mb_bin,
-    my_strnxfrm_unicode,
-    my_strnxfrmlen_utf8mb4,
+    my_strnxfrm_unicode_full_bin,
+    my_strnxfrmlen_unicode_full_bin,
     my_like_range_mb,
     my_wildcmp_mb_bin,
     my_strcasecmp_mb_bin,

=== modified file 'strings/my_vsnprintf.c'
--- a/strings/my_vsnprintf.c	2009-12-28 12:54:16 +0000
+++ b/strings/my_vsnprintf.c	2010-09-15 11:33:22 +0000
@@ -255,7 +255,7 @@ static char *process_int_arg(char *to, c
   if ((to_length= (size_t) (end-to)) < 16 || length)
     store_start= buff;
 
-  if (arg_type == 'd')
+  if (arg_type == 'd' || arg_type == 'i')
     store_end= longlong10_to_str(par, store_start, -10);
   else if (arg_type == 'u')
     store_end= longlong10_to_str(par, store_start, 10);
@@ -399,6 +399,7 @@ start:
         args_arr[i].double_arg= va_arg(ap, double);
         break;
       case 'd':
+      case 'i':
       case 'u':
       case 'x':
       case 'X':
@@ -406,7 +407,7 @@ start:
       case 'p':
         if (args_arr[i].have_longlong)
           args_arr[i].longlong_arg= va_arg(ap,longlong);
-        else if (args_arr[i].arg_type == 'd')
+        else if (args_arr[i].arg_type == 'd' || args_arr[i].arg_type == 'i')
           args_arr[i].longlong_arg= va_arg(ap, int);
         else
           args_arr[i].longlong_arg= va_arg(ap, uint);
@@ -458,6 +459,7 @@ start:
         break;
       }
       case 'd':
+      case 'i':
       case 'u':
       case 'x':
       case 'X':
@@ -472,7 +474,7 @@ start:
 
         if (args_arr[print_arr[i].arg_idx].have_longlong)
           larg = args_arr[print_arr[i].arg_idx].longlong_arg;
-        else if (print_arr[i].arg_type == 'd')
+        else if (print_arr[i].arg_type == 'd' || print_arr[i].arg_type == 'i' )
           larg = (int) args_arr[print_arr[i].arg_idx].longlong_arg;
         else
           larg= (uint) args_arr[print_arr[i].arg_idx].longlong_arg;
@@ -615,8 +617,8 @@ size_t my_vsnprintf_ex(CHARSET_INFO *cs,
       to= process_dbl_arg(to, end, width, d, *fmt);
       continue;
     }
-    else if (*fmt == 'd' || *fmt == 'u' || *fmt == 'x' || *fmt == 'X' ||
-             *fmt == 'p' || *fmt == 'o')
+    else if (*fmt == 'd' || *fmt == 'i' || *fmt == 'u' || *fmt == 'x' || 
+             *fmt == 'X' || *fmt == 'p' || *fmt == 'o')
     {
       /* Integer parameter */
       longlong larg;
@@ -625,7 +627,7 @@ size_t my_vsnprintf_ex(CHARSET_INFO *cs,
 
       if (have_longlong)
         larg = va_arg(ap,longlong);
-      else if (*fmt == 'd')
+      else if (*fmt == 'd' || *fmt == 'i')
         larg = va_arg(ap, int);
       else
         larg= va_arg(ap, uint);

=== modified file 'unittest/mysys/my_vsnprintf-t.c'
--- a/unittest/mysys/my_vsnprintf-t.c	2009-12-28 12:54:16 +0000
+++ b/unittest/mysys/my_vsnprintf-t.c	2010-09-15 11:33:22 +0000
@@ -31,7 +31,7 @@ void test1(const char *res, const char *
 
 int main(void)
 {
-  plan(54);
+  plan(58);
 
   test1("Constant string",
         "Constant string");
@@ -44,6 +44,8 @@ int main(void)
         "Format specifier c %c", '!');
   test1("Format specifier d 1",
         "Format specifier d %d", 1);
+  test1("Format specifier i 1",
+        "Format specifier i %i", 1);
   test1("Format specifier u 2",
         "Format specifier u %u", 2);
   test1("Format specifier o 375",
@@ -77,6 +79,9 @@ int main(void)
   test1("Length modifiers work: 1 * -1 * 2 * 3",
         "Length modifiers work: %d * %ld * %lld * %zd", 1, -1L, 2LL, (size_t)3);
 
+  test1("Length modifiers work: 1 * -1 * 2 * 3",
+        "Length modifiers work: %i * %li * %lli * %zd", 1, -1L, 2LL, (size_t)3);
+
   test1("long long X: 123456789abcdef0",
         "long long X: %llx", 0x123456789abcdef0LL);
 
@@ -121,6 +126,10 @@ int main(void)
         "Hello int, %d", 1);
   test1("Hello int, -1",
         "Hello int, %d", -1);
+  test1("Hello int, 1",
+        "Hello int, %i", 1);
+  test1("Hello int, -1",
+        "Hello int, %i", -1);
   test1("Hello string 'I am a string'",
         "Hello string '%s'", "I am a string");
   test1("Hello hack hack hack hack hack hack hack 1",

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-mtr branch (bjorn.munch:2976 to 2978) Bjorn Munch21 Oct