List:Commits« Previous MessageNext Message »
From:Mattias Jonsson Date:February 14 2011 10:42am
Subject:bzr push into mysql-trunk branch (mattias.jonsson:3641 to 3642) Bug#60114
View as plain text  
 3642 Mattias Jonsson	2011-02-14
      Disabled newly added DBUG_ASSERT because of bug#60114.
     @ sql/handler.cc
        Disabled newly added DBUG_ASSERT because of bug#60114.

    modified:
      sql/handler.cc
 3641 Mattias Jonsson	2011-02-14 [merge]
      Merging WL#5217 into an updated mysql-trunk

    added:
      mysql-test/collections/mysql-trunk-wl5217.push
      mysql-test/r/partition_explicit_prune.result
      mysql-test/t/partition_explicit_prune.test
    modified:
      include/my_base.h
      include/welcome_copyright_notice.h
      mysql-test/r/partition_exchange.result
      mysql-test/suite/parts/inc/partition_fail.inc
      mysql-test/suite/parts/r/partition_exch_qa_13.result
      mysql-test/suite/parts/r/partition_exch_qa_2.result
      mysql-test/suite/parts/r/partition_mgm_lc0_archive.result
      mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result
      mysql-test/suite/parts/r/partition_mgm_lc0_memory.result
      mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result
      mysql-test/suite/parts/r/partition_mgm_lc1_archive.result
      mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result
      mysql-test/suite/parts/r/partition_mgm_lc1_memory.result
      mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result
      mysql-test/suite/parts/r/partition_mgm_lc2_archive.result
      mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result
      mysql-test/suite/parts/r/partition_mgm_lc2_memory.result
      mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result
      mysql-test/suite/parts/r/partition_repair_myisam.result
      mysql-test/suite/parts/t/partition_debug_myisam.test
      mysql-test/suite/parts/t/partition_repair_myisam.test
      mysql-test/t/partition_binlog.test
      mysys/hash.c
      mysys/my_handler.c
      mysys/my_handler_errors.h
      sql/ha_partition.cc
      sql/ha_partition.h
      sql/handler.cc
      sql/handler.h
      sql/mysqld.cc
      sql/opt_range.cc
      sql/partition_info.cc
      sql/partition_info.h
      sql/share/errmsg-utf8.txt
      sql/sql_base.cc
      sql/sql_class.h
      sql/sql_lex.cc
      sql/sql_lex.h
      sql/sql_parse.cc
      sql/sql_partition.cc
      sql/sql_table.cc
      sql/sql_table.h
      sql/sql_yacc.yy
      sql/table.cc
      sql/table.h
=== modified file 'README'
--- a/README	2010-11-24 15:25:25 +0000
+++ b/README	2011-02-08 15:54:12 +0000
@@ -5,7 +5,7 @@ For the avoidance of doubt, this particu
 is released under the version 2 of the GNU General Public License. 
 MySQL is brought to you by the MySQL team at Oracle.
 
-Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
 License information can be found in the COPYING file.
 

=== modified file 'client/my_readline.h'
--- a/client/my_readline.h	2009-09-23 21:32:31 +0000
+++ b/client/my_readline.h	2011-02-05 05:04:15 +0000
@@ -28,11 +28,13 @@ typedef struct st_line_buffer
   uint eof;
   ulong max_size;
   ulong read_length;		/* Length of last read string */
+  int error;
+  bool truncated;
 } LINE_BUFFER;
 
 extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
 extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
-extern char *batch_readline(LINE_BUFFER *buffer, bool *truncated);
+extern char *batch_readline(LINE_BUFFER *buffer);
 extern void batch_readline_end(LINE_BUFFER *buffer);
 
 #endif /* CLIENT_MY_READLINE_INCLUDED */

=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2011-01-16 04:02:29 +0000
+++ b/client/mysql.cc	2011-02-09 06:56:59 +0000
@@ -1128,6 +1128,8 @@ int main(int argc,char *argv[])
   if (status.batch && !status.line_buff &&
       !(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin)))
   {
+    put_info("Can't initialize batch_readline - may be the input source is "
+             "a directory or a block device.", INFO_ERROR, 0);
     free_defaults(defaults_argv);
     my_end(0);
     exit(1);
@@ -1843,14 +1845,13 @@ static int read_and_execute(bool interac
   ulong line_number=0;
   bool ml_comment= 0;  
   COMMANDS *com;
-  bool truncated= 0;
   status.exit_status=1;
-  
+
   for (;;)
   {
     if (!interactive)
     {
-      line=batch_readline(status.line_buff, &truncated);
+      line=batch_readline(status.line_buff);
       /*
         Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF.
         Editors like "notepad" put this marker in
@@ -1913,9 +1914,13 @@ static int read_and_execute(bool interac
       if (opt_outfile && line)
 	fprintf(OUTFILE, "%s\n", line);
     }
-    if (!line)					// End of file
+    // End of file or system error
+    if (!line)
     {
-      status.exit_status=0;
+      if (status.line_buff && status.line_buff->error)
+        status.exit_status= 1;
+      else
+        status.exit_status= 0;
       break;
     }
 
@@ -1936,7 +1941,8 @@ static int read_and_execute(bool interac
 #endif
       continue;
     }
-    if (add_line(glob_buffer,line,&in_string,&ml_comment, truncated))
+    if (add_line(glob_buffer, line, &in_string, &ml_comment,
+                 status.line_buff ? status.line_buff->truncated : 0))
       break;
   }
   /* if in batch mode, send last query even if it doesn't end with \g or go */

=== modified file 'client/readline.cc'
--- a/client/readline.cc	2010-07-08 21:20:08 +0000
+++ b/client/readline.cc	2011-02-09 11:16:33 +0000
@@ -18,18 +18,28 @@
 #include <my_global.h>
 #include <my_sys.h>
 #include <m_string.h>
+#include <my_dir.h>
 #include "my_readline.h"
 
 static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,
 			    ulong max_size);
 static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str);
 static size_t fill_buffer(LINE_BUFFER *buffer);
-static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated);
+static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length);
 
 
 LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
 {
   LINE_BUFFER *line_buff;
+  MY_STAT input_file_stat;
+
+#ifndef __WIN__
+  if (my_fstat(fileno(file), &input_file_stat, MYF(MY_WME)) ||
+      MY_S_ISDIR(input_file_stat.st_mode) ||
+      MY_S_ISBLK(input_file_stat.st_mode))
+    return 0;
+#endif
+
   if (!(line_buff=(LINE_BUFFER*)
         my_malloc(sizeof(*line_buff),MYF(MY_WME | MY_ZEROFILL))))
     return 0;
@@ -42,13 +52,12 @@ LINE_BUFFER *batch_readline_init(ulong m
 }
 
 
-char *batch_readline(LINE_BUFFER *line_buff, bool *truncated)
+char *batch_readline(LINE_BUFFER *line_buff)
 {
   char *pos;
   ulong out_length;
-  DBUG_ASSERT(truncated != NULL);
 
-  if (!(pos=intern_read_line(line_buff,&out_length, truncated)))
+  if (!(pos=intern_read_line(line_buff, &out_length)))
     return 0;
   if (out_length && pos[out_length-1] == '\n')
     if (--out_length && pos[out_length-1] == '\r')  /* Remove '\n' */
@@ -162,7 +171,10 @@ static size_t fill_buffer(LINE_BUFFER *b
     if (!(buffer->buffer = (char*) my_realloc(buffer->buffer,
 					      buffer->bufread+1,
 					      MYF(MY_WME | MY_FAE))))
-      return (uint) -1;
+    {
+      buffer->error= my_errno;
+      return (size_t) -1;
+    }
     buffer->start_of_line=buffer->buffer+start_offset;
     buffer->end=buffer->buffer+bufbytes;
   }
@@ -177,7 +189,10 @@ static size_t fill_buffer(LINE_BUFFER *b
   /* Read in new stuff. */
   if ((read_count= my_read(buffer->file, (uchar*) buffer->end, read_count,
 			   MYF(MY_WME))) == MY_FILE_ERROR)
+  {
+    buffer->error= my_errno;
     return (size_t) -1;
+  }
 
   DBUG_PRINT("fill_buff", ("Got %lu bytes", (ulong) read_count));
 
@@ -198,8 +213,7 @@ static size_t fill_buffer(LINE_BUFFER *b
 }
 
 
-
-char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated)
+char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length)
 {
   char *pos;
   size_t length;
@@ -214,22 +228,25 @@ char *intern_read_line(LINE_BUFFER *buff
     if (pos == buffer->end)
     {
       /*
-        fill_buffer() can return 0 either on EOF in which case we abort
-        or when the internal buffer has hit the size limit. In the latter case
-        return what we have read so far and signal string truncation.
+        fill_buffer() can return NULL on EOF (in which case we abort),
+        on error, or when the internal buffer has hit the size limit.
+        In the latter case return what we have read so far and signal
+        string truncation.
       */
-      if (!(length=fill_buffer(buffer)) || length == (uint) -1)
+      if (!(length= fill_buffer(buffer)))
       {
         if (buffer->eof)
           DBUG_RETURN(0);
       }
+      else if (length == (size_t) -1)
+        DBUG_RETURN(NULL);
       else
         continue;
       pos--;					/* break line here */
-      *truncated= 1;
+      buffer->truncated= 1;
     }
     else
-      *truncated= 0;
+      buffer->truncated= 0;
     buffer->end_of_line=pos+1;
     *out_length=(ulong) (pos + 1 - buffer->eof - buffer->start_of_line);
     DBUG_RETURN(buffer->start_of_line);

=== modified file 'cmake/cpack_source_ignore_files.cmake'
--- a/cmake/cpack_source_ignore_files.cmake	2010-07-20 09:37:50 +0000
+++ b/cmake/cpack_source_ignore_files.cmake	2011-02-10 10:26:23 +0000
@@ -51,8 +51,5 @@ include/config\\\\.h$
 include/my_config\\\\.h$
 /autom4te\\\\.cache/
 errmsg\\\\.sys$
-run_collection_test-bt.cmake
-run_collection_test-bt-debug.cmake
-run_collection_test-bt-fast.cmake
 #
 )

=== modified file 'include/my_pthread.h'
--- a/include/my_pthread.h	2011-01-11 09:09:21 +0000
+++ b/include/my_pthread.h	2011-02-08 15:54:12 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'include/mysql/plugin.h'
--- a/include/mysql/plugin.h	2010-10-21 09:49:16 +0000
+++ b/include/mysql/plugin.h	2011-01-21 14:03:58 +0000
@@ -48,6 +48,8 @@ class Item;
 #define MYSQL_THD void*
 #endif
 
+typedef void * MYSQL_PLUGIN;
+
 #include <mysql/services.h>
 
 #define MYSQL_XIDDATASIZE 128
@@ -409,8 +411,8 @@ struct st_mysql_plugin
   const char *author;   /* plugin author (for I_S.PLUGINS)              */
   const char *descr;    /* general descriptive text (for I_S.PLUGINS)   */
   int license;          /* the plugin license (PLUGIN_LICENSE_XXX)      */
-  int (*init)(void *);  /* the function to invoke when plugin is loaded */
-  int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
+  int (*init)(MYSQL_PLUGIN);  /* the function to invoke when plugin is loaded */
+  int (*deinit)(MYSQL_PLUGIN);/* the function to invoke when plugin is unloaded */
   unsigned int version; /* plugin version (for I_S.PLUGINS)             */
   struct st_mysql_show_var *status_vars;
   struct st_mysql_sys_var **system_vars;

=== modified file 'include/mysql/plugin_audit.h.pp'
--- a/include/mysql/plugin_audit.h.pp	2010-12-14 14:34:23 +0000
+++ b/include/mysql/plugin_audit.h.pp	2011-02-08 17:48:20 +0000
@@ -1,4 +1,5 @@
 #include "plugin.h"
+typedef void * MYSQL_PLUGIN;
 #include <mysql/services.h>
 #include <mysql/service_my_snprintf.h>
 extern struct my_snprintf_service_st {
@@ -52,6 +53,19 @@ extern struct my_thread_scheduler_servic
 } *my_thread_scheduler_service;
 int my_thread_scheduler_set(struct scheduler_functions *scheduler);
 int my_thread_scheduler_reset();
+#include <mysql/service_my_plugin_log.h>
+enum plugin_log_level
+{
+  MY_ERROR_LEVEL,
+  MY_WARNING_LEVEL,
+  MY_INFORMATION_LEVEL
+};
+extern struct my_plugin_log_service
+{
+  int (*my_plugin_log_message)(MYSQL_PLUGIN *, enum plugin_log_level, const char *, ...);
+} *my_plugin_log_service;
+int my_plugin_log_message(MYSQL_PLUGIN *plugin, enum plugin_log_level level,
+                          const char *format, ...);
 struct st_mysql_xid {
   long formatID;
   long gtrid_length;
@@ -88,8 +102,8 @@ struct st_mysql_plugin
   const char *author;
   const char *descr;
   int license;
-  int (*init)(void *);
-  int (*deinit)(void *);
+  int (*init)(MYSQL_PLUGIN);
+  int (*deinit)(MYSQL_PLUGIN);
   unsigned int version;
   struct st_mysql_show_var *status_vars;
   struct st_mysql_sys_var **system_vars;

=== modified file 'include/mysql/plugin_auth.h.pp'
--- a/include/mysql/plugin_auth.h.pp	2010-10-05 12:26:49 +0000
+++ b/include/mysql/plugin_auth.h.pp	2011-02-08 17:48:20 +0000
@@ -1,4 +1,5 @@
 #include <mysql/plugin.h>
+typedef void * MYSQL_PLUGIN;
 #include <mysql/services.h>
 #include <mysql/service_my_snprintf.h>
 extern struct my_snprintf_service_st {
@@ -52,6 +53,19 @@ extern struct my_thread_scheduler_servic
 } *my_thread_scheduler_service;
 int my_thread_scheduler_set(struct scheduler_functions *scheduler);
 int my_thread_scheduler_reset();
+#include <mysql/service_my_plugin_log.h>
+enum plugin_log_level
+{
+  MY_ERROR_LEVEL,
+  MY_WARNING_LEVEL,
+  MY_INFORMATION_LEVEL
+};
+extern struct my_plugin_log_service
+{
+  int (*my_plugin_log_message)(MYSQL_PLUGIN *, enum plugin_log_level, const char *, ...);
+} *my_plugin_log_service;
+int my_plugin_log_message(MYSQL_PLUGIN *plugin, enum plugin_log_level level,
+                          const char *format, ...);
 struct st_mysql_xid {
   long formatID;
   long gtrid_length;
@@ -88,8 +102,8 @@ struct st_mysql_plugin
   const char *author;
   const char *descr;
   int license;
-  int (*init)(void *);
-  int (*deinit)(void *);
+  int (*init)(MYSQL_PLUGIN);
+  int (*deinit)(MYSQL_PLUGIN);
   unsigned int version;
   struct st_mysql_show_var *status_vars;
   struct st_mysql_sys_var **system_vars;

=== modified file 'include/mysql/plugin_ftparser.h.pp'
--- a/include/mysql/plugin_ftparser.h.pp	2010-08-30 14:07:40 +0000
+++ b/include/mysql/plugin_ftparser.h.pp	2011-02-08 17:48:20 +0000
@@ -1,4 +1,5 @@
 #include "plugin.h"
+typedef void * MYSQL_PLUGIN;
 #include <mysql/services.h>
 #include <mysql/service_my_snprintf.h>
 extern struct my_snprintf_service_st {
@@ -52,6 +53,19 @@ extern struct my_thread_scheduler_servic
 } *my_thread_scheduler_service;
 int my_thread_scheduler_set(struct scheduler_functions *scheduler);
 int my_thread_scheduler_reset();
+#include <mysql/service_my_plugin_log.h>
+enum plugin_log_level
+{
+  MY_ERROR_LEVEL,
+  MY_WARNING_LEVEL,
+  MY_INFORMATION_LEVEL
+};
+extern struct my_plugin_log_service
+{
+  int (*my_plugin_log_message)(MYSQL_PLUGIN *, enum plugin_log_level, const char *, ...);
+} *my_plugin_log_service;
+int my_plugin_log_message(MYSQL_PLUGIN *plugin, enum plugin_log_level level,
+                          const char *format, ...);
 struct st_mysql_xid {
   long formatID;
   long gtrid_length;
@@ -88,8 +102,8 @@ struct st_mysql_plugin
   const char *author;
   const char *descr;
   int license;
-  int (*init)(void *);
-  int (*deinit)(void *);
+  int (*init)(MYSQL_PLUGIN);
+  int (*deinit)(MYSQL_PLUGIN);
   unsigned int version;
   struct st_mysql_show_var *status_vars;
   struct st_mysql_sys_var **system_vars;

=== added file 'include/mysql/service_my_plugin_log.h'
--- a/include/mysql/service_my_plugin_log.h	1970-01-01 00:00:00 +0000
+++ b/include/mysql/service_my_plugin_log.h	2011-02-08 17:48:20 +0000
@@ -0,0 +1,64 @@
+/*  Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; version 2 of the
+    License.
+    
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+    GNU General Public License for more details.
+    
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+/**
+  @file
+  This service provides functions to report error conditions and log to 
+  mysql error log.
+*/
+
+#ifndef MYSQL_SERVICE_MY_PLUGIN_LOG_INCLUDED
+#define MYSQL_SERVICE_MY_PLUGIN_LOG_INCLUDED
+
+#ifndef MYSQL_ABI_CHECK
+#include <stdarg.h>
+#endif
+
+/* keep in sync with the loglevel enum in my_sys.h */
+enum plugin_log_level
+{
+  MY_ERROR_LEVEL,
+  MY_WARNING_LEVEL,
+  MY_INFORMATION_LEVEL
+};  
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern struct my_plugin_log_service
+{
+  /** write a message to the log */
+  int (*my_plugin_log_message)(MYSQL_PLUGIN *, enum plugin_log_level, const char *, ...);
+} *my_plugin_log_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+
+#define my_plugin_log_message my_plugin_log_service->my_plugin_log_message
+
+#else
+
+int my_plugin_log_message(MYSQL_PLUGIN *plugin, enum plugin_log_level level,
+                          const char *format, ...);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

=== modified file 'include/mysql/services.h'
--- a/include/mysql/services.h	2010-06-07 14:01:39 +0000
+++ b/include/mysql/services.h	2011-02-08 17:48:20 +0000
@@ -22,6 +22,7 @@ extern "C" {
 #include <mysql/service_thd_alloc.h>
 #include <mysql/service_thd_wait.h>
 #include <mysql/service_thread_scheduler.h>
+#include <mysql/service_my_plugin_log.h>
 
 #ifdef __cplusplus
 }

=== modified file 'include/service_versions.h'
--- a/include/service_versions.h	2010-06-07 14:01:39 +0000
+++ b/include/service_versions.h	2011-02-08 17:48:20 +0000
@@ -23,3 +23,4 @@
 #define VERSION_thd_alloc       0x0100
 #define VERSION_thd_wait        0x0100
 #define VERSION_my_thread_scheduler 0x0100
+#define VERSION_my_plugin_log 0x0100

=== modified file 'libmysqld/CMakeLists.txt'
--- a/libmysqld/CMakeLists.txt	2010-12-17 09:41:21 +0000
+++ b/libmysqld/CMakeLists.txt	2011-02-02 08:30:13 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,81 +17,55 @@ ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDE
  ${SSL_DEFINES})
 
 INCLUDE_DIRECTORIES(
-${CMAKE_SOURCE_DIR}/include 
-${CMAKE_SOURCE_DIR}/libmysql
-${CMAKE_SOURCE_DIR}/libmysqld
-${CMAKE_SOURCE_DIR}/sql
-${CMAKE_BINARY_DIR}/sql 
-${CMAKE_SOURCE_DIR}/regex
-${ZLIB_INCLUDE_DIR}
-${SSL_INCLUDE_DIRS}
-${SSL_INTERNAL_INCLUDE_DIRS}
-${CMAKE_SOURCE_DIR}/sql/backup
+  ${CMAKE_SOURCE_DIR}/include 
+  ${CMAKE_SOURCE_DIR}/libmysql
+  ${CMAKE_SOURCE_DIR}/libmysqld
+  ${CMAKE_SOURCE_DIR}/sql
+  ${CMAKE_BINARY_DIR}/sql 
+  ${CMAKE_SOURCE_DIR}/regex
+  ${ZLIB_INCLUDE_DIR}
+  ${SSL_INCLUDE_DIRS}
+  ${SSL_INTERNAL_INCLUDE_DIRS}
+  ${CMAKE_SOURCE_DIR}/sql/backup
 )
 
 SET(GEN_SOURCES
-${CMAKE_BINARY_DIR}/sql/sql_yacc.h 
-${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
-${CMAKE_BINARY_DIR}/sql/lex_hash.h 
+  ${CMAKE_BINARY_DIR}/sql/sql_yacc.h 
+  ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
+  ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
+  ${CMAKE_BINARY_DIR}/sql/lex_hash.h 
 )
 
 SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED TRUE)
 
-SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc 
-           ../libmysql/libmysql.c ../libmysql/errmsg.c ../client/get_password.c
-           ../sql-common/client.c ../sql-common/my_time.c 
-           ../sql-common/my_user.c ../sql-common/pack.c
-           ../sql-common/client_plugin.c
-           ../sql/password.c ../sql/discover.cc ../sql/derror.cc 
-           ../sql/field.cc ../sql/field_conv.cc
-           ../sql/filesort_utils.cc
-           ../sql/filesort.cc ../sql/gstream.cc
-           ../sql/handler.cc ../sql/hash_filo.cc ../sql/hostname.cc 
-           ../sql/init.cc ../sql/item_buff.cc ../sql/item_cmpfunc.cc 
-           ../sql/item.cc ../sql/item_create.cc ../sql/item_func.cc 
-           ../sql/item_geofunc.cc ../sql/item_row.cc ../sql/item_strfunc.cc 
-           ../sql/item_subselect.cc ../sql/item_sum.cc ../sql/item_timefunc.cc 
-           ../sql/item_xmlfunc.cc ../sql/key.cc ../sql/lock.cc ../sql/log.cc 
-           ../sql/log_event.cc ../sql/mf_iocache.cc ../sql/my_decimal.cc 
-           ../sql/net_serv.cc ../sql/opt_range.cc ../sql/opt_sum.cc 
-           ../sql/parse_file.cc ../sql/procedure.cc ../sql/protocol.cc 
-           ../sql/records.cc ../sql/rpl_filter.cc
-           ../sql/rpl_record.cc ../sql/sha2.cc ../sql/des_key_file.cc
-           ../sql/rpl_injector.cc ../sql/set_var.cc ../sql/spatial.cc 
-           ../sql/sp_cache.cc ../sql/sp.cc ../sql/sp_head.cc 
-           ../sql/sp_pcontext.cc ../sql/sp_rcontext.cc ../sql/sql_acl.cc 
-           ../sql/sql_alloc_error_handler.cc
-           ../sql/sql_analyse.cc ../sql/sql_base.cc ../sql/sql_cache.cc 
-           ../sql/sql_class.cc ../sql/sql_crypt.cc ../sql/sql_cursor.cc 
-           ../sql/sql_db.cc ../sql/sql_delete.cc ../sql/sql_derived.cc 
-           ../sql/sql_do.cc ../sql/sql_error.cc ../sql/sql_handler.cc 
-           ../sql/sql_help.cc ../sql/sql_insert.cc ../sql/sql_join_cache.cc
-           ../sql/datadict.cc ../sql/sql_admin.cc ../sql/sql_truncate.cc
-           ../sql/sql_reload.cc
-           ../sql/sql_lex.cc ../sql/keycaches.cc
-           ../sql/sql_list.cc ../sql/sql_load.cc ../sql/sql_locale.cc 
-           ../sql/sql_binlog.cc ../sql/sql_manager.cc
-           ../sql/sql_parse.cc ../sql/sql_partition.cc ../sql/sql_plugin.cc 
-           ../sql/debug_sync.cc
-           ../sql/sql_prepare.cc ../sql/sql_rename.cc
-           ../sql/sql_select.cc ../sql/sql_servers.cc
-           ../sql/sql_show.cc ../sql/sql_state.c ../sql/sql_string.cc
-           ../sql/sql_tablespace.cc ../sql/sql_table.cc ../sql/sql_test.cc
-           ../sql/sql_trigger.cc ../sql/sql_udf.cc ../sql/sql_union.cc
-           ../sql/sql_update.cc ../sql/sql_view.cc ../sql/sql_profile.cc
-           ../sql/strfunc.cc ../sql/table.cc ../sql/thr_malloc.cc
-           ../sql/sql_time.cc ../sql/tztime.cc ../sql/uniques.cc ../sql/unireg.cc
-           ../sql/partition_info.cc ../sql/sql_connect.cc 
-           ../sql/scheduler.cc ../sql/sql_audit.cc
-           ../sql/sql_alter.cc ../sql/sql_partition_admin.cc
-           ../sql/event_parse_data.cc
-           ../sql/sql_signal.cc ../sql/rpl_handler.cc
-           ../sql/rpl_utility.cc ../sql/rpl_reporting.cc ../sql/binlog.cc 
-           ../sql/sys_vars.cc ../sql/gcalc_slicescan.cc ../sql/gcalc_tools.cc
-           ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
-           ../sql/mdl.cc ../sql/transaction.cc ../sql/sql_bootstrap.cc
-           ${GEN_SOURCES}
-           ${MYSYS_LIBWRAP_SOURCE}
+FOREACH(file ${SQL_EXPORTED_SOURCES})
+  LIST(APPEND IMPORTED_SOURCES "../sql/${file}")
+ENDFOREACH()
+
+SET(SQL_EMBEDDED_SOURCES
+  emb_qcache.cc
+  lib_sql.cc 
+  libmysqld.c
+  ${GEN_SOURCES}
+  ${MYSYS_LIBWRAP_SOURCE}
+  ../client/get_password.c
+  ../libmysql/errmsg.c
+  ../libmysql/libmysql.c
+  ../sql-common/client.c
+  ../sql-common/client_plugin.c
+  ../sql-common/my_time.c 
+  ../sql-common/my_user.c
+  ../sql-common/pack.c
+  ../sql/binlog.cc 
+  ../sql/event_parse_data.cc
+  ../sql/hash_filo.cc
+  ../sql/log_event.cc
+  ../sql/rpl_filter.cc
+  ../sql/rpl_injector.cc
+  ../sql/rpl_record.cc
+  ../sql/rpl_reporting.cc
+  ../sql/rpl_utility.cc
+  ${IMPORTED_SOURCES}
 )
 
 

=== modified file 'libservices/CMakeLists.txt'
--- a/libservices/CMakeLists.txt	2010-11-13 22:16:52 +0000
+++ b/libservices/CMakeLists.txt	2011-02-08 17:48:20 +0000
@@ -19,6 +19,7 @@ SET(MYSQLSERVICES_SOURCES
   my_snprintf_service.c
   thd_alloc_service.c
   thd_wait_service.c
+  my_plugin_log_service.c
   my_thread_scheduler_service.c)
 
 ADD_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES})

=== added file 'libservices/my_plugin_log_service.c'
--- a/libservices/my_plugin_log_service.c	1970-01-01 00:00:00 +0000
+++ b/libservices/my_plugin_log_service.c	2011-02-08 17:48:20 +0000
@@ -0,0 +1,18 @@
+/*  Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; version 2 of the
+    License.
+    
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+    GNU General Public License for more details.
+    
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#include <service_versions.h>
+SERVICE_VERSION *my_plugin_log_service= (void*)VERSION_my_plugin_log;

=== modified file 'mysql-test/CMakeLists.txt'
--- a/mysql-test/CMakeLists.txt	2010-11-14 18:09:32 +0000
+++ b/mysql-test/CMakeLists.txt	2011-02-10 09:06:39 +0000
@@ -93,7 +93,7 @@ ADD_CUSTOM_TARGET(test-force
   COMMAND perl ./mysql-test-run.pl --force ${EXP}
 )
 
-FOREACH(collection test-bt test-bt-fast test-bt-debug)
+FOREACH(collection)
   IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/collections/${collection})
     MESSAGE(FATAL_ERROR 
       "${CMAKE_CURRENT_SOURCE_DIR}/collections/${collection} does not exist")

=== modified file 'mysql-test/collections/default.daily'
--- a/mysql-test/collections/default.daily	2010-10-05 11:33:54 +0000
+++ b/mysql-test/collections/default.daily	2011-02-11 12:10:00 +0000
@@ -1,5 +1,15 @@
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=n_mix          --vardir=var-n_mix                  --mysqld=--binlog-format=mixed
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=ps_row         --vardir=var-ps_row   --ps-protocol --mysqld=--binlog-format=row
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=embedded       --vardir=var-emebbed  --embedded
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=funcs_1        --vardir=var-funcs_1                                              --suite=funcs_1
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_row --vardir=var-rpl_binlog_row --mysqld=--binlog-format=row --suite=rpl,binlog --skip-ndb
+perl mysql-test-run.pl --force --timer  --debug-server --parallel=auto --experimental=collections/default.experimental --comment=normal               --vardir=var-normal                                                                  --report-features --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer  --debug-server --parallel=auto --experimental=collections/default.experimental --comment=n_mix                --vardir=var-n_mix                                  --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer  --debug-server --parallel=auto --experimental=collections/default.experimental --comment=row                --vardir=var-row                                  --mysqld=--binlog-format=row --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer  --debug-server --parallel=auto --experimental=collections/default.experimental --comment=ps_row               --vardir=var-ps_row                                 --mysqld=--binlog-format=row     --ps-protocol --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer  --debug-server --parallel=auto --experimental=collections/default.experimental --comment=embedded             --vardir=var-embedded                                                                --embedded
+perl mysql-test-run.pl --force --timer  --debug-server --parallel=auto --experimental=collections/default.experimental --comment=ps                   --vardir=var-ps                                                                --ps-protocol --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer  --debug-server --parallel=auto --experimental=collections/default.experimental --comment=funcs_1              --vardir=var-funcs_1             --suite=funcs_1
+perl mysql-test-run.pl --force --timer  --debug-server --parallel=auto --experimental=collections/default.experimental --comment=ps_funcs1            --vardir=var-ps_funcs_1          --suite=funcs_1                                     --ps-protocol
+perl mysql-test-run.pl --force --timer  --debug-server --parallel=auto --experimental=collections/default.experimental --comment=funcs2               --vardir=var-funcs2              --suite=funcs_2
+perl mysql-test-run.pl --force --timer  --debug-server --parallel=auto --experimental=collections/default.experimental --comment=partitions           --vardir=var-parts               --suite=parts
+perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=stress               --vardir=var-stress              --suite=stress
+perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=jp                   --vardir=var-jp                  --suite=jp
+perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=nist                 --vardir=var-nist                --suite=nist
+perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=nist+ps              --vardir=var-ps_nist             --suite=nist                                        --ps-protocol
+perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_checksum  --vardir=var-rpl_binlog_checksum --suite=rpl,binlog --mysqld=--binlog-checksum=CRC32 --skip-test-list=collections/disabled-daily.list

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2011-02-02 11:52:59 +0000
+++ b/mysql-test/collections/default.experimental	2011-02-09 16:33:45 +0000
@@ -8,7 +8,6 @@ funcs_1.charset_collation_1             
 innodb.innodb_information_schema         # Bug#48883 2010-05-11 alik Test "innodb_information_schema" takes fewer locks than expected
 
 main.func_math @freebsd                  # Bug#43020 2010-05-04 alik main.func_math fails on FreeBSD in PB2
-main.gis                                 # Bug#52208 2010-11-24 alik gis fails on some platforms (Solaris, HP-UX, Linux)
 main.gis-rtree @freebsd                  # Bug#38965 2010-05-04 alik test cases gis-rtree, type_float, type_newdecimal fail in embedded server
 main.lock_multi_bug38499                 # Bug#47448 2009-09-19 alik main.lock_multi_bug38499 times out sporadically
 main.mysqlslap @windows                  # Bug#54024 2010-08-10 alik mysqlslap fails sporadically starting from Dahlia
@@ -42,43 +41,3 @@ main.gis-rtree                          
 main.type_float                          # svoj: due to BUG#38965
 main.type_newdecimal                     # svoj: due to BUG#38965
 
-perfschema.ortho_iter                        # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.event_aggregate                   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_off               # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_global_2u_2t      # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_global_2u_3t      # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_global_4u_2t      # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_global_4u_3t      # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_hist_2u_2t        # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_hist_2u_3t        # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_hist_4u_2t        # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_hist_4u_3t        # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_thread_2u_2t      # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_thread_2u_3t      # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_thread_4u_2t      # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_aggregate_thread_4u_3t      # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_global_2u_2t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_global_2u_3t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_global_4u_2t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_global_4u_3t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_hist_2u_2t     # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_hist_2u_3t     # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_hist_4u_2t     # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_hist_4u_3t     # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_thread_2u_2t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_thread_2u_3t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_thread_4u_2t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_io_aggregate_thread_4u_3t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_global_2u_2t # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_global_2u_3t # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_global_4u_2t # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_global_4u_3t # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_hist_2u_2t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_hist_2u_3t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_hist_4u_2t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_hist_4u_3t   # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_thread_2u_2t # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_thread_2u_3t # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_thread_4u_2t # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-perfschema.table_lock_aggregate_thread_4u_3t # BUG#59740 2011-02-26 Marc Alff Test fails on FreeBSD
-

=== modified file 'mysql-test/collections/default.push'
--- a/mysql-test/collections/default.push	2010-11-29 15:42:42 +0000
+++ b/mysql-test/collections/default.push	2011-02-08 06:34:01 +0000
@@ -1,5 +1,4 @@
 perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=ps_row --vardir=var-ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=embedded --vardir=var-emebbed  --embedded --experimental=collections/default.experimental --skip-ndb
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=rpl_binlog_row --vardir=var-rpl_binlog_row  --suite=rpl,binlog --mysqld=--binlog-format=row --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
+perl mysql-test-run.pl --timer --force --parallel=auto --comment=main_ps_row --vardir=var-main-ps_row --suite=main --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
+perl mysql-test-run.pl --timer --force --parallel=auto --comment=main_embedded --vardir=var-main_emebbed  --suite=main --embedded --experimental=collections/default.experimental --skip-ndb
 perl mysql-test-run.pl --timer --force --parallel=auto --comment=funcs_1 --vardir=var-funcs_1 --suite=funcs_1 --experimental=collections/default.experimental --skip-ndb

=== added file 'mysql-test/collections/default.release'
--- a/mysql-test/collections/default.release	1970-01-01 00:00:00 +0000
+++ b/mysql-test/collections/default.release	2011-02-09 19:41:12 +0000
@@ -0,0 +1,11 @@
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=debug      --vardir=var-debug                       --skip-ndbcluster --skip-rpl --report-features --debug-server
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=normal     --vardir=var-normal                      --skip-ndbcluster --report-features
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=ps         --vardir=var-ps                          --skip-ndbcluster --ps-protocol
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=funcs1+ps  --vardir=var-funcs_1_ps --suite=funcs_1  --ps-protocol
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=funcs2     --vardir=var-funcs2     --suite=funcs_2
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=partitions --vardir=var-parts      --suite=parts
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=stress     --vardir=var-stress     --suite=stress
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=jp         --vardir=var-jp         --suite=jp
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=embedded   --vardir=var-embedded                    --embedded-server --skip-rpl --skip-ndbcluster
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=nist       --vardir=var-nist       --suite=nist
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=nist+ps    --vardir=var-nist_ps    --suite=nist     --ps-protocol

=== modified file 'mysql-test/collections/default.weekly'
--- a/mysql-test/collections/default.weekly	2011-01-06 11:23:59 +0000
+++ b/mysql-test/collections/default.weekly	2011-02-08 13:56:25 +0000
@@ -1,2 +1,8 @@
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=1st       --experimental=collections/default.experimental 1st
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=big-tests --experimental=collections/default.experimental --vardir=var-big-tests --big-test --testcase-timeout=60 --suite-timeout=600 main.alter_table-big main.archive-big main.count_distinct3 main.create-big main.events_stress main.events_time_zone main.information_schema-big main.log_tables-big main.merge-big main.mysqlbinlog_row_big main.read_many_rows_innodb main.ssl-big main.sum_distinct-big main.type_newdecimal-big main.variables-big parts.part_supported_sql_func_innodb parts.partition_alter1_1_2_innodb parts.partition_alter1_2_innodb parts.partition_alter2_1_1_innodb parts.partition_alter2_1_2_innodb parts.partition_alter2_2_2_innodb parts.partition_alter4_innodb funcs_1.myisam_views-big
+perl mysql-test-run.pl --timer --force --debug-server --parallel=auto  --comment=big-tests --experimental=collections/default.experimental --vardir=var-big-tests --big-test --testcase-timeout=60 --suite-timeout=600 main.alter_table-big main.archive-big main.count_distinct3 main.create-big main.events_stress main.events_time_zone main.information_schema-big main.log_tables-big main.merge-big main.mysqlbinlog_row_big main.read_many_rows_innodb main.ssl-big main.sum_distinct-big main.type_newdecimal-big main.variables-big parts.part_supported_sql_func_innodb parts.partition_alter1_1_2_innodb parts.partition_alter1_2_innodb parts.partition_alter2_1_1_innodb parts.partition_alter2_1_2_innodb parts.partition_alter2_2_2_innodb parts.partition_alter4_innodb funcs_1.myisam_views-big
+perl mysql-test-run.pl --timer --force --debug-server --parallel=auto  --comment=eits-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam 
+perl mysql-test-run.pl --timer --force --debug-server --parallel=auto --comment=eits-rpl-binlog-row-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=row
+perl mysql-test-run.pl --timer --force --debug-server --parallel=auto  --comment=eits-rpl-binlog-mixed-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=mixed
+perl mysql-test-run.pl --timer --force --debug-server --parallel=auto --comment=eits-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb
+perl mysql-test-run.pl --timer --force --debug-server --parallel=auto --comment=eits-rpl-binlog-row-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=row
+perl mysql-test-run.pl --timer --force --debug-server --parallel=auto --comment=eits-rpl-binlog-mixed-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=mixed
+perl mysql-test-run.pl --timer --force --debug-server --parallel=auto --comment=all_binlog_checksum --experimental=collections/default.experimental --mysqld=--binlog-checksum=CRC32 --vardir=var-all_binlog_checksum --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema

=== added file 'mysql-test/collections/disabled-daily.list'
--- a/mysql-test/collections/disabled-daily.list	1970-01-01 00:00:00 +0000
+++ b/mysql-test/collections/disabled-daily.list	2011-02-11 12:10:00 +0000
@@ -0,0 +1,9 @@
+rpl.rpl_semi_sync_event : lsoares 2011-02-11 Anitha asked me to disable this until plugin issues on windows are fixed.
+rpl.rpl.rpl_semi_sync : lsoares 2011-02-11 Anitha asked me to disable this until plugin issues on windows are fixed.
+sys_vars.rpl_semi_sync_master_enabled_basic : lsoares 2011-02-11 Anitha asked me to disable this until plugin issues on windows are fixed.
+sys_vars.rpl_semi_sync_master_timeout_basic : lsoares 2011-02-11 Anitha asked me to disable this until plugin issues on windows are fixed.
+sys_vars.rpl_semi_sync_master_trace_level_basic : lsoares 2011-02-11 Anitha asked me to disable this until plugin issues on windows are fixed.
+sys_vars.rpl_semi_sync_master_wait_no_slave_basic : lsoares 2011-02-11 Anitha asked me to disable this until plugin issues on windows are fixed.
+sys_vars.rpl_semi_sync_slave_enabled_basic : lsoares 2011-02-11 Anitha asked me to disable this until plugin issues on windows are fixed.
+sys_vars.rpl_semi_sync_slave_trace_level_basic : lsoares 2011-02-11 Anitha asked me to disable this until plugin issues on windows are fixed.
+sys_vars.all_vars : lsoares 2011-02-11 Anitha asked me to disable this until plugin issues on windows are fixed.

=== removed file 'mysql-test/collections/mysql-5.1-innodb.push'
--- a/mysql-test/collections/mysql-5.1-innodb.push	2010-11-22 10:27:04 +0000
+++ b/mysql-test/collections/mysql-5.1-innodb.push	1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=ps_row --vardir=var-ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=embedded --vardir=var-emebbed  --embedded --experimental=collections/default.experimental --skip-ndb
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=rpl_binlog_row --vardir=var-rpl_binlog_row  --suite=rpl,binlog --mysqld=--binlog-format=row --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=funcs_1 --vardir=var-funcs_1 --suite=funcs_1 --experimental=collections/default.experimental --skip-ndb

=== removed file 'mysql-test/collections/mysql-5.5-innodb.push'
--- a/mysql-test/collections/mysql-5.5-innodb.push	2010-11-22 10:27:04 +0000
+++ b/mysql-test/collections/mysql-5.5-innodb.push	1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=ps_row --vardir=var-ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=embedded --vardir=var-emebbed  --embedded --experimental=collections/default.experimental --skip-ndb
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=rpl_binlog_row --vardir=var-rpl_binlog_row  --suite=rpl,binlog --mysqld=--binlog-format=row --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=funcs_1 --vardir=var-funcs_1 --suite=funcs_1 --experimental=collections/default.experimental --skip-ndb

=== removed file 'mysql-test/collections/mysql-next-mr-wl2540.push'
--- a/mysql-test/collections/mysql-next-mr-wl2540.push	2010-11-11 23:33:21 +0000
+++ b/mysql-test/collections/mysql-next-mr-wl2540.push	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_checksum  --mysqld=--binlog-checksum=CRC32  --vardir=var-rpl_binlog_checksum --suite=binlog,rpl --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=n_mix          --vardir=var-n_mix                        --mysqld=--binlog-format=mixed  --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=ps_row         --vardir=var-ps_row         --ps-protocol --mysqld=--binlog-format=row    --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=embedded       --vardir=var-emebbed        --embedded                                    --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_row --vardir=var-rpl_binlog_row               --mysqld=--binlog-format=row    --suite=rpl,binlog --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=funcs_1        --vardir=var-funcs_1                                                      --suite=funcs_1

=== removed file 'mysql-test/collections/mysql-trunk-innodb.push'
--- a/mysql-test/collections/mysql-trunk-innodb.push	2010-11-22 10:29:44 +0000
+++ b/mysql-test/collections/mysql-trunk-innodb.push	1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=n_mix          --vardir=var-n_mix                        --mysqld=--binlog-format=mixed  --suite=main,binlog,innodb,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=ps_row         --vardir=var-ps_row         --ps-protocol --mysqld=--binlog-format=row    --suite=main,binlog,innodb,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=embedded       --vardir=var-emebbed        --embedded                                    --suite=main,binlog,innodb,rpl,sys_vars,perfschema
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_row --vardir=var-rpl_binlog_row               --mysqld=--binlog-format=row    --suite=rpl,binlog --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=funcs_1        --vardir=var-funcs_1                                                      --suite=funcs_1

=== removed file 'mysql-test/collections/mysql-trunk.daily'
--- a/mysql-test/collections/mysql-trunk.daily	2011-01-27 00:57:39 +0000
+++ b/mysql-test/collections/mysql-trunk.daily	1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
-
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=normal               --vardir=var-normal                                                                  --report-features
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=n_mix                --vardir=var-n_mix                                  --mysqld=--binlog-format=mixed
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_row       --vardir=var-rpl_binlog_row      --suite=rpl,binlog --mysqld=--binlog-format=row     --skip-ndb
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=ps_row               --vardir=var-ps_row                                 --mysqld=--binlog-format=row     --ps-protocol
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=embedded             --vardir=var-embedded                                                                --embedded
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=funcs_1              --vardir=var-funcs_1             --suite=funcs_1
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=ps_funcs1            --vardir=var-ps_funcs_1          --suite=funcs_1                                     --ps-protocol
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=funcs2               --vardir=var-funcs2              --suite=funcs_2
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=partitions           --vardir=var-parts               --suite=parts
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=stress               --vardir=var-stress              --suite=stress
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=jp                   --vardir=var-jp                  --suite=jp
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=nist                 --vardir=var-nist                --suite=nist
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=nist+ps              --vardir=var-ps_nist             --suite=nist                                        --ps-protocol
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_checksum  --vardir=var-rpl_binlog_checksum --suite=rpl,binlog --mysqld=--binlog-checksum=CRC32

=== removed file 'mysql-test/collections/mysql-trunk.push'
--- a/mysql-test/collections/mysql-trunk.push	2010-12-10 06:37:44 +0000
+++ b/mysql-test/collections/mysql-trunk.push	1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=main_ps_row --vardir=var-main-ps_row --suite=main --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=main_embedded --vardir=var-main_emebbed  --suite=main --embedded --experimental=collections/default.experimental --skip-ndb
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=funcs_1 --vardir=var-funcs_1 --suite=funcs_1 --experimental=collections/default.experimental --skip-ndb

=== removed file 'mysql-test/collections/mysql-trunk.weekly'
--- a/mysql-test/collections/mysql-trunk.weekly	2011-01-06 11:28:20 +0000
+++ b/mysql-test/collections/mysql-trunk.weekly	1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
-perl mysql-test-run.pl --timer --force --comment=1st --experimental=collections/default.experimental 1st
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=all_binlog_checksum --experimental=collections/default.experimental --mysqld=--binlog-checksum=CRC32 --vardir=var-all_binlog_checksum --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=big-tests --experimental=collections/default.experimental --vardir=var-big-tests --big-test --testcase-timeout=60 --suite-timeout=600 main.alter_table-big main.archive-big main.count_distinct3 main.create-big main.events_stress main.events_time_zone main.information_schema-big main.log_tables-big main.merge-big main.mysqlbinlog_row_big main.read_many_rows_innodb main.ssl-big main.sum_distinct-big main.type_newdecimal-big main.variables-big parts.part_supported_sql_func_innodb parts.partition_alter1_1_2_innodb parts.partition_alter1_2_innodb parts.partition_alter2_1_1_innodb parts.partition_alter2_1_2_innodb parts.partition_alter2_2_2_innodb parts.partition_alter4_innodb 
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-row-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=row
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-mixed-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=mixed
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-row-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=row
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-mixed-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=mixed

=== removed file 'mysql-test/collections/test-bt'
--- a/mysql-test/collections/test-bt	2010-12-03 14:43:49 +0000
+++ b/mysql-test/collections/test-bt	1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=normal  --skip-ndbcluster --report-features --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=ps --skip-ndbcluster --ps-protocol --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=funcs1+ps  --suite=funcs_1 --ps-protocol --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=funcs2     --suite=funcs_2 --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=partitions --suite=parts   --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=stress     --suite=stress  --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=jp         --suite=jp      --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=embedded  --embedded-server --skip-rpl --skip-ndbcluster --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=nist --suite=nist --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=nist+ps --suite=nist --ps-protocol --experimental=collections/default.experimental

=== removed file 'mysql-test/collections/test-bt-debug'
--- a/mysql-test/collections/test-bt-debug	2010-12-03 14:43:49 +0000
+++ b/mysql-test/collections/test-bt-debug	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=debug --skip-ndbcluster --skip-rpl --report-features --experimental=collections/default.experimental

=== removed file 'mysql-test/collections/test-bt-debug-fast'

=== removed file 'mysql-test/collections/test-bt-fast'
--- a/mysql-test/collections/test-bt-fast	2010-12-03 14:43:49 +0000
+++ b/mysql-test/collections/test-bt-fast	1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=ps  --skip-ndbcluster --ps-protocol --report-features --experimental=collections/default.experimental
-perl mysql-test-run.pl --force --timer --parallel=auto --comment=stress --suite=stress --experimental=collections/default.experimental

=== modified file 'mysql-test/include/ctype_numconv.inc'
--- a/mysql-test/include/ctype_numconv.inc	2010-12-02 13:44:21 +0000
+++ b/mysql-test/include/ctype_numconv.inc	2011-02-10 13:41:16 +0000
@@ -1750,6 +1750,35 @@ DROP TABLE t1;
 
 
 --echo #
+--echo # Bug #31384 	DATE_ADD() and DATE_SUB() return binary data
+--echo #
+SELECT @@collation_connection, @@character_set_results;
+CREATE TABLE t1 AS
+SELECT
+  DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
+  DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+  DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+  DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+--enable_metadata
+# PS protocol gives different "Max length" value for DATETIME.
+--disable_ps_protocol
+SELECT
+  DATE_SUB('2007-08-03', INTERVAL 1 DAY) AS field_str1,
+  DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+  DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+  DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+--disable_metadata
+--enable_ps_protocol
+SELECT
+  HEX(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
+  HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2,
+  HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
+  HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
+ 
+
+--echo #
 --echo # Bug#52159 returning time type from function and empty left join causes debug assertion
 --echo #
 CREATE FUNCTION f1() RETURNS TIME RETURN 1;

=== modified file 'mysql-test/include/icp_tests.inc'
--- a/mysql-test/include/icp_tests.inc	2011-01-30 16:55:22 +0000
+++ b/mysql-test/include/icp_tests.inc	2011-01-31 11:56:15 +0000
@@ -798,3 +798,26 @@ SELECT pk FROM t1 WHERE c1 <> 1 HAVING p
 SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5;
 
 DROP TABLE t1;
+
+--echo #
+--echo # Bug#59483 "Crash on INSERT/REPLACE in
+--echo #            rec_convert_dtuple_to_rec_comp with ICP on"
+--echo #
+
+CREATE TABLE t1 (
+ pk INTEGER AUTO_INCREMENT PRIMARY KEY,
+ i1 INTEGER,
+ c1 CHAR(6),
+ i2 INTEGER NOT NULL,
+ KEY (i2)
+);
+
+INSERT INTO t1 VALUES
+ (NULL, 4, 'that', 8),
+ (NULL, 1, 'she', 6),
+ (NULL, 6, 'tell', 2);
+
+SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE;
+INSERT INTO t1 (i2) VALUES (1);
+
+DROP TABLE t1;

=== modified file 'mysql-test/include/mysqlhotcopy.inc'
--- a/mysql-test/include/mysqlhotcopy.inc	2011-01-29 12:15:56 +0000
+++ b/mysql-test/include/mysqlhotcopy.inc	2011-02-08 09:56:04 +0000
@@ -107,7 +107,7 @@ DROP DATABASE hotcopy_save;
 --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
 --list_files $MYSQLD_DATADIR/hotcopy_save
 --replace_result $MASTER_MYSOCK MASTER_MYSOCK
---error 9,2304
+--error 9,11,2304
 --exec $MYSQLHOTCOPY --quiet -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save
 --replace_result $MASTER_MYSOCK MASTER_MYSOCK
 --exec $MYSQLHOTCOPY --quiet --allowold -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save

=== modified file 'mysql-test/include/order_by.inc'
--- a/mysql-test/include/order_by.inc	2011-02-02 13:41:10 +0000
+++ b/mysql-test/include/order_by.inc	2011-02-07 09:46:53 +0000
@@ -1690,6 +1690,23 @@ LIMIT 2;
 DROP TABLE t1, t2;
 
 
+--echo #
+--echo # Bug #59110: Memory leak of QUICK_SELECT_I allocated memory 
+--echo #  and
+--echo # Bug #59308: Incorrect result for 
+--echo               SELECT DISTINCT <col>... ORDER BY <col> DESC 
+--echo
+--echo # Use Valgrind to detect #59110!
+--echo #
+
+CREATE TABLE t1 (a INT,KEY (a));
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+EXPLAIN SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+
+DROP TABLE t1;
+
 --echo End of 5.1 tests
 
 

=== modified file 'mysql-test/include/rpl_sync.inc'
--- a/mysql-test/include/rpl_sync.inc	2010-12-19 17:07:28 +0000
+++ b/mysql-test/include/rpl_sync.inc	2011-02-03 16:09:33 +0000
@@ -88,7 +88,7 @@ while ($_rpl_i) {
       {
         --echo Sync IO: $_rpl_slave_io_running; Sync SQL: $_rpl_slave_sql_running
       }
-      --let $_rpl_slave_io_running= `SELECT IF('$_rpl_slave_io_running' = 'Yes', 1, '')`
+      --let $_rpl_slave_io_running= `SELECT IF('$_rpl_slave_io_running' != 'No', 1, '')`
       --let $_rpl_slave_sql_running= `SELECT IF('$_rpl_slave_sql_running' = 'Yes', 1, '')`
       if ($_rpl_slave_io_running)
       {

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2011-01-29 23:40:42 +0000
+++ b/mysql-test/mysql-test-run.pl	2011-02-09 15:35:49 +0000
@@ -192,6 +192,7 @@ my $opt_explain_protocol;
 our $opt_debug;
 my $debug_d= "d";
 my $opt_debug_common;
+our $opt_debug_server;
 our @opt_cases;                  # The test cases names in argv
 our $opt_embedded_server;
 
@@ -981,6 +982,7 @@ sub command_line_setup {
              # Debugging
              'debug'                    => \$opt_debug,
              'debug-common'             => \$opt_debug_common,
+             'debug-server'             => \$opt_debug_server,
              'gdb'                      => \$opt_gdb,
              'client-gdb'               => \$opt_client_gdb,
              'manual-gdb'               => \$opt_manual_gdb,
@@ -1137,6 +1139,9 @@ sub command_line_setup {
 
   ($auth_plugin)= find_plugin("auth_test_plugin", "plugin/auth");
 
+  # --debug[-common] implies we run debug server
+  $opt_debug_server= 1 if $opt_debug || $opt_debug_common;
+
   if (using_extern())
   {
     # Connect to the running mysqld and find out what it supports
@@ -1789,7 +1794,7 @@ sub find_mysqld {
   my @mysqld_names= ("mysqld", "mysqld-max-nt", "mysqld-max",
 		     "mysqld-nt");
 
-  if ( $opt_debug ){
+  if ( $opt_debug_server ){
     # Put mysqld-debug first in the list of binaries to look for
     mtr_verbose("Adding mysqld-debug first in list of binaries to look for");
     unshift(@mysqld_names, "mysqld-debug");
@@ -1886,9 +1891,12 @@ sub executable_setup () {
 sub client_debug_arg($$) {
   my ($args, $client_name)= @_;
 
+  # Workaround for Bug #50627: drop any debug opt
+  return if $client_name =~ /^mysqlbinlog/;
+
   if ( $opt_debug ) {
     mtr_add_arg($args,
-		"--debug=$debug_d:t:A,%s/log/%s.trace",
+		"--loose-debug=$debug_d:t:A,%s/log/%s.trace",
 		$path_vardir_trace, $client_name)
   }
 }
@@ -2015,8 +2023,8 @@ sub read_plugin_defs($)
     or mtr_error("Can't read plugin defintions file $defs_file");
 
   # Need to check if we will be running mysqld-debug
-  if ($opt_debug) {
-    $running_debug= 1 if find_mysqld($basedir) =~ /-debug$/;
+  if ($opt_debug_server) {
+    $running_debug= 1 if find_mysqld($basedir) =~ /mysqld-debug/;
   }
 
   while (<PLUGDEF>) {
@@ -2162,6 +2170,16 @@ sub environment_setup {
   $ENV{'MYSQL_LIBDIR'}=       "$basedir/lib";
   $ENV{'MYSQL_SHAREDIR'}=     $path_language;
   $ENV{'MYSQL_CHARSETSDIR'}=  $path_charsetsdir;
+  
+  if (IS_WINDOWS)
+  {
+    $ENV{'SECURE_LOAD_PATH'}= $glob_mysql_test_dir."\\std_data";
+  }
+  else
+  {
+    $ENV{'SECURE_LOAD_PATH'}= $glob_mysql_test_dir."/std_data";
+  }
+    
 
   # ----------------------------------------------------
   # Setup env for NDB
@@ -2515,9 +2533,9 @@ sub check_debug_support ($) {
     #mtr_report(" - binaries are not debug compiled");
     $debug_compiled_binaries= 0;
 
-    if ( $opt_debug )
+    if ( $opt_debug_server )
     {
-      mtr_error("Can't use --debug, binaries does not support it");
+      mtr_error("Can't use --debug[-server], binary does not support it");
     }
     return;
   }
@@ -5788,6 +5806,8 @@ Options for debugging the product
   debug                 Dump trace output for all servers and client programs
   debug-common          Same as debug, but sets 'd' debug flags to
                         "query,info,error,enter,exit"
+  debug-server          Use debug version of server, but without turning on
+                        tracing
   debugger=NAME         Start mysqld in the selected debugger
   gdb                   Start the mysqld(s) in gdb
   manual-debug          Let user manually start mysqld in debugger, before

=== modified file 'mysql-test/r/ctype_binary.result'
--- a/mysql-test/r/ctype_binary.result	2010-12-15 12:25:38 +0000
+++ b/mysql-test/r/ctype_binary.result	2011-02-10 08:47:05 +0000
@@ -2790,6 +2790,46 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	range	date_column	date_column	9	NULL	1	Using index condition
 DROP TABLE t1;
 #
+# Bug #31384 	DATE_ADD() and DATE_SUB() return binary data
+#
+SELECT @@collation_connection, @@character_set_results;
+@@collation_connection	@@character_set_results
+binary	binary
+CREATE TABLE t1 AS
+SELECT
+DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
+DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `field_str1` varbinary(29) DEFAULT NULL,
+  `field1_str2` varbinary(29) DEFAULT NULL,
+  `field_date` date DEFAULT NULL,
+  `field_datetime` datetime DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SELECT
+DATE_SUB('2007-08-03', INTERVAL 1 DAY) AS field_str1,
+DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def					field_str1	254	29	10	Y	128	31	63
+def					field1_str2	254	29	19	Y	128	31	63
+def					field_date	10	29	10	Y	128	31	63
+def					field_datetime	12	29	19	Y	128	31	63
+field_str1	field1_str2	field_date	field_datetime
+2007-08-02	2007-08-03 17:32:00	2007-08-02	2007-08-03 17:32:00
+SELECT
+HEX(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
+HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2,
+HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
+HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
+field_str1	field1_str2	field_date	field_datetime
+323030372D30382D30322032333A35393A3030	323030372D30382D30332031373A33323A3030	323030372D30382D3032	323030372D30382D30332031373A33323A3030
+#
 # Bug#52159 returning time type from function and empty left join causes debug assertion
 #
 CREATE FUNCTION f1() RETURNS TIME RETURN 1;

=== modified file 'mysql-test/r/ctype_cp1251.result'
--- a/mysql-test/r/ctype_cp1251.result	2010-12-15 12:25:38 +0000
+++ b/mysql-test/r/ctype_cp1251.result	2011-02-10 08:47:05 +0000
@@ -3180,6 +3180,46 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	range	date_column	date_column	9	NULL	1	Using index condition
 DROP TABLE t1;
 #
+# Bug #31384 	DATE_ADD() and DATE_SUB() return binary data
+#
+SELECT @@collation_connection, @@character_set_results;
+@@collation_connection	@@character_set_results
+cp1251_general_ci	cp1251
+CREATE TABLE t1 AS
+SELECT
+DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
+DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `field_str1` varchar(29) CHARACTER SET cp1251 DEFAULT NULL,
+  `field1_str2` varchar(29) CHARACTER SET cp1251 DEFAULT NULL,
+  `field_date` date DEFAULT NULL,
+  `field_datetime` datetime DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SELECT
+DATE_SUB('2007-08-03', INTERVAL 1 DAY) AS field_str1,
+DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def					field_str1	254	29	10	Y	0	31	51
+def					field1_str2	254	29	19	Y	0	31	51
+def					field_date	10	29	10	Y	128	31	63
+def					field_datetime	12	29	19	Y	128	31	63
+field_str1	field1_str2	field_date	field_datetime
+2007-08-02	2007-08-03 17:32:00	2007-08-02	2007-08-03 17:32:00
+SELECT
+HEX(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
+HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2,
+HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
+HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
+field_str1	field1_str2	field_date	field_datetime
+323030372D30382D30322032333A35393A3030	323030372D30382D30332031373A33323A3030	323030372D30382D3032	323030372D30382D30332031373A33323A3030
+#
 # Bug#52159 returning time type from function and empty left join causes debug assertion
 #
 CREATE FUNCTION f1() RETURNS TIME RETURN 1;

=== modified file 'mysql-test/r/ctype_latin1.result'
--- a/mysql-test/r/ctype_latin1.result	2011-01-03 14:50:58 +0000
+++ b/mysql-test/r/ctype_latin1.result	2011-02-10 08:47:05 +0000
@@ -3209,6 +3209,46 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	range	date_column	date_column	9	NULL	1	Using index condition
 DROP TABLE t1;
 #
+# Bug #31384 	DATE_ADD() and DATE_SUB() return binary data
+#
+SELECT @@collation_connection, @@character_set_results;
+@@collation_connection	@@character_set_results
+latin1_swedish_ci	latin1
+CREATE TABLE t1 AS
+SELECT
+DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
+DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `field_str1` varchar(29) DEFAULT NULL,
+  `field1_str2` varchar(29) DEFAULT NULL,
+  `field_date` date DEFAULT NULL,
+  `field_datetime` datetime DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SELECT
+DATE_SUB('2007-08-03', INTERVAL 1 DAY) AS field_str1,
+DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def					field_str1	254	29	10	Y	0	31	8
+def					field1_str2	254	29	19	Y	0	31	8
+def					field_date	10	29	10	Y	128	31	63
+def					field_datetime	12	29	19	Y	128	31	63
+field_str1	field1_str2	field_date	field_datetime
+2007-08-02	2007-08-03 17:32:00	2007-08-02	2007-08-03 17:32:00
+SELECT
+HEX(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
+HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2,
+HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
+HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
+field_str1	field1_str2	field_date	field_datetime
+323030372D30382D30322032333A35393A3030	323030372D30382D30332031373A33323A3030	323030372D30382D3032	323030372D30382D30332031373A33323A3030
+#
 # Bug#52159 returning time type from function and empty left join causes debug assertion
 #
 CREATE FUNCTION f1() RETURNS TIME RETURN 1;

=== modified file 'mysql-test/r/ctype_ucs.result'
--- a/mysql-test/r/ctype_ucs.result	2011-01-18 07:16:49 +0000
+++ b/mysql-test/r/ctype_ucs.result	2011-02-10 08:47:05 +0000
@@ -4098,6 +4098,46 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 DROP TABLE t1;
 #
+# Bug #31384 	DATE_ADD() and DATE_SUB() return binary data
+#
+SELECT @@collation_connection, @@character_set_results;
+@@collation_connection	@@character_set_results
+ucs2_general_ci	latin1
+CREATE TABLE t1 AS
+SELECT
+DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
+DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `field_str1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL,
+  `field1_str2` varchar(29) CHARACTER SET ucs2 DEFAULT NULL,
+  `field_date` date DEFAULT NULL,
+  `field_datetime` datetime DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SELECT
+DATE_SUB('2007-08-03', INTERVAL 1 DAY) AS field_str1,
+DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def					field_str1	254	29	10	Y	0	31	8
+def					field1_str2	254	29	19	Y	0	31	8
+def					field_date	10	29	10	Y	128	31	63
+def					field_datetime	12	29	19	Y	128	31	63
+field_str1	field1_str2	field_date	field_datetime
+2007-08-02	2007-08-03 17:32:00	2007-08-02	2007-08-03 17:32:00
+SELECT
+HEX(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
+HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2,
+HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
+HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
+field_str1	field1_str2	field_date	field_datetime
+0032003000300037002D00300038002D00300032002000320033003A00350039003A00300030	0032003000300037002D00300038002D00300033002000310037003A00330032003A00300030	323030372D30382D3032	323030372D30382D30332031373A33323A3030
+#
 # Bug#52159 returning time type from function and empty left join causes debug assertion
 #
 CREATE FUNCTION f1() RETURNS TIME RETURN 1;

=== modified file 'mysql-test/r/ctype_utf8.result'
--- a/mysql-test/r/ctype_utf8.result	2011-01-03 14:50:58 +0000
+++ b/mysql-test/r/ctype_utf8.result	2011-02-10 08:47:05 +0000
@@ -5012,6 +5012,46 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	range	date_column	date_column	9	NULL	1	Using index condition
 DROP TABLE t1;
 #
+# Bug #31384 	DATE_ADD() and DATE_SUB() return binary data
+#
+SELECT @@collation_connection, @@character_set_results;
+@@collation_connection	@@character_set_results
+utf8_general_ci	utf8
+CREATE TABLE t1 AS
+SELECT
+DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
+DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `field_str1` varchar(29) CHARACTER SET utf8 DEFAULT NULL,
+  `field1_str2` varchar(29) CHARACTER SET utf8 DEFAULT NULL,
+  `field_date` date DEFAULT NULL,
+  `field_datetime` datetime DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SELECT
+DATE_SUB('2007-08-03', INTERVAL 1 DAY) AS field_str1,
+DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
+DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
+DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def					field_str1	254	87	10	Y	0	31	33
+def					field1_str2	254	87	19	Y	0	31	33
+def					field_date	10	29	10	Y	128	31	63
+def					field_datetime	12	29	19	Y	128	31	63
+field_str1	field1_str2	field_date	field_datetime
+2007-08-02	2007-08-03 17:32:00	2007-08-02	2007-08-03 17:32:00
+SELECT
+HEX(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
+HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2,
+HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
+HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
+field_str1	field1_str2	field_date	field_datetime
+323030372D30382D30322032333A35393A3030	323030372D30382D30332031373A33323A3030	323030372D30382D3032	323030372D30382D30332031373A33323A3030
+#
 # Bug#52159 returning time type from function and empty left join causes debug assertion
 #
 CREATE FUNCTION f1() RETURNS TIME RETURN 1;

=== modified file 'mysql-test/r/grant.result'
--- a/mysql-test/r/grant.result	2011-01-24 15:47:16 +0000
+++ b/mysql-test/r/grant.result	2011-02-08 15:54:12 +0000
@@ -1378,6 +1378,80 @@ CURRENT_USER()
 root@localhost
 SET PASSWORD FOR CURRENT_USER() = PASSWORD("admin");
 SET PASSWORD FOR CURRENT_USER() = PASSWORD("");
+
+# Bug#57952
+
+DROP DATABASE IF EXISTS mysqltest1;
+DROP DATABASE IF EXISTS mysqltest2;
+CREATE DATABASE mysqltest1;
+CREATE DATABASE mysqltest2;
+use mysqltest1;
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (1, 1);
+CREATE TABLE t2(a INT);
+INSERT INTO t2 VALUES (2);
+CREATE TABLE mysqltest2.t3(a INT);
+INSERT INTO mysqltest2.t3 VALUES (4);
+CREATE USER testuser@localhost;
+GRANT CREATE ROUTINE, EXECUTE ON mysqltest1.* TO testuser@localhost;
+GRANT SELECT(b) ON t1 TO testuser@localhost;
+GRANT SELECT    ON t2 TO testuser@localhost;
+GRANT SELECT    ON mysqltest2.* TO testuser@localhost;
+
+# Connection: bug57952_con1 (testuser@localhost, db: mysqltest1)
+PREPARE s1 FROM 'SELECT b FROM t1';
+PREPARE s2 FROM 'SELECT a FROM t2';
+PREPARE s3 FROM 'SHOW TABLES FROM mysqltest2';
+CREATE PROCEDURE p1() SELECT b FROM t1;
+CREATE PROCEDURE p2() SELECT a FROM t2;
+CREATE PROCEDURE p3() SHOW TABLES FROM mysqltest2;
+CALL p1;
+b
+1
+CALL p2;
+a
+2
+CALL p3;
+Tables_in_mysqltest2
+t3
+
+# Connection: default
+REVOKE SELECT ON t1 FROM testuser@localhost;
+GRANT SELECT(a) ON t1 TO testuser@localhost;
+REVOKE SELECT ON t2 FROM testuser@localhost;
+REVOKE SELECT ON mysqltest2.* FROM testuser@localhost;
+
+# Connection: bug57952_con1 (testuser@localhost, db: mysqltest1)
+#   - Check column-level privileges...
+EXECUTE s1;
+ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'b' in table 't1'
+SELECT b FROM t1;
+ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'b' in table 't1'
+EXECUTE s1;
+ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'b' in table 't1'
+CALL p1;
+ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'b' in table 't1'
+#   - Check table-level privileges...
+SELECT a FROM t2;
+ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table 't2'
+EXECUTE s2;
+ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table 't2'
+CALL p2;
+ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for table 't2'
+#   - Check database-level privileges...
+SHOW TABLES FROM mysqltest2;
+ERROR 42000: Access denied for user 'testuser'@'localhost' to database 'mysqltest2'
+EXECUTE s3;
+ERROR 42000: Access denied for user 'testuser'@'localhost' to database 'mysqltest2'
+CALL p3;
+ERROR 42000: Access denied for user 'testuser'@'localhost' to database 'mysqltest2'
+
+# Connection: default
+DROP DATABASE mysqltest1;
+DROP DATABASE mysqltest2;
+DROP USER testuser@localhost;
+use test;
+
 End of 5.0 tests
 set names utf8;
 grant select on test.* to юзер_юзер@localhost;

=== modified file 'mysql-test/r/innodb_icp.result'
--- a/mysql-test/r/innodb_icp.result	2011-01-30 16:55:22 +0000
+++ b/mysql-test/r/innodb_icp.result	2011-01-31 11:56:15 +0000
@@ -739,5 +739,25 @@ SELECT pk FROM t1 WHERE c1 <> 1 HAVING p
 pk
 3
 DROP TABLE t1;
+#
+# Bug#59483 "Crash on INSERT/REPLACE in
+#            rec_convert_dtuple_to_rec_comp with ICP on"
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT PRIMARY KEY,
+i1 INTEGER,
+c1 CHAR(6),
+i2 INTEGER NOT NULL,
+KEY (i2)
+);
+INSERT INTO t1 VALUES
+(NULL, 4, 'that', 8),
+(NULL, 1, 'she', 6),
+(NULL, 6, 'tell', 2);
+SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE;
+pk	i1	c1	i2
+2	1	she	6
+INSERT INTO t1 (i2) VALUES (1);
+DROP TABLE t1;
 set default_storage_engine= @save_storage_engine;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/innodb_icp_all.result'
--- a/mysql-test/r/innodb_icp_all.result	2011-02-02 13:23:58 +0000
+++ b/mysql-test/r/innodb_icp_all.result	2011-02-09 15:30:19 +0000
@@ -599,6 +599,23 @@ select 1 from t1 where b <= 1 and a <> '
 1
 drop table t1;
 #
+# Bug#59259 "Incorrect rows returned for a correlated subquery
+#            when ICP is on"
+#
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (11,0);
+INSERT INTO t1 VALUES (12,5);
+INSERT INTO t1 VALUES (15,0);
+CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (11,1);
+INSERT INTO t2 VALUES (12,2);
+INSERT INTO t2 VALUES (15,4);
+SELECT * FROM t1
+WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE t1.i);
+pk	i
+12	5
+DROP TABLE t1, t2;
+#
 # Bug #58816 "Extra temporary duplicate rows in result set when 
 #             switching ICP off"
 #
@@ -673,6 +690,33 @@ id	select_type	table	type	possible_keys	
 
 DROP TABLE t1,t2;
 #
+# Bug#59186 Wrong results of join when ICP is enabled
+#
+CREATE TABLE t1 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,'y'),(0,'or');
+CREATE TABLE t2 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+c2 VARCHAR(6) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE');
+EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	1	Using index condition
+1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	2	Using index condition; Using where; Using join buffer (BNL, incremental buffers)
+SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+c2
+DROP TABLE t1, t2;
+#
 # Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when 
 #            ICP is enabled"
 # 

=== modified file 'mysql-test/r/innodb_icp_none.result'
--- a/mysql-test/r/innodb_icp_none.result	2011-01-30 16:55:22 +0000
+++ b/mysql-test/r/innodb_icp_none.result	2011-01-31 11:56:15 +0000
@@ -738,5 +738,25 @@ SELECT pk FROM t1 WHERE c1 <> 1 HAVING p
 pk
 3
 DROP TABLE t1;
+#
+# Bug#59483 "Crash on INSERT/REPLACE in
+#            rec_convert_dtuple_to_rec_comp with ICP on"
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT PRIMARY KEY,
+i1 INTEGER,
+c1 CHAR(6),
+i2 INTEGER NOT NULL,
+KEY (i2)
+);
+INSERT INTO t1 VALUES
+(NULL, 4, 'that', 8),
+(NULL, 1, 'she', 6),
+(NULL, 6, 'tell', 2);
+SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE;
+pk	i1	c1	i2
+2	1	she	6
+INSERT INTO t1 (i2) VALUES (1);
+DROP TABLE t1;
 set default_storage_engine= @save_storage_engine;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/join_outer_jcl6.result'
--- a/mysql-test/r/join_outer_jcl6.result	2011-01-13 15:37:54 +0000
+++ b/mysql-test/r/join_outer_jcl6.result	2011-02-02 15:05:14 +0000
@@ -1507,6 +1507,148 @@ WHERE 7;
 col_datetime_key
 NULL
 DROP TABLE BB;
+#
+# Bug#58490: Incorrect result in multi level OUTER JOIN
+# in combination with IS NULL
+#
+CREATE TABLE t1 (i INT NOT NULL);
+INSERT INTO t1 VALUES (0),    (2),(3),(4);
+CREATE TABLE t2 (i INT NOT NULL);
+INSERT INTO t2 VALUES (0),(1),    (3),(4);
+CREATE TABLE t3 (i INT NOT NULL);
+INSERT INTO t3 VALUES (0),(1),(2),    (4);
+CREATE TABLE t4 (i INT NOT NULL);
+INSERT INTO t4 VALUES (0),(1),(2),(3)   ;
+SELECT * FROM
+t1 LEFT JOIN
+( t2 LEFT JOIN
+( t3 LEFT JOIN
+t4
+ON t4.i = t3.i
+)
+ON t3.i = t2.i
+)
+ON t2.i = t1.i
+;
+i	i	i	i
+0	0	0	0
+2	NULL	NULL	NULL
+3	3	NULL	NULL
+4	4	4	NULL
+SELECT * FROM
+t1 LEFT JOIN
+( t2 LEFT JOIN
+( t3 LEFT JOIN
+t4
+ON t4.i = t3.i
+)
+ON t3.i = t2.i
+)
+ON t2.i = t1.i
+WHERE t4.i IS NULL;
+i	i	i	i
+2	NULL	NULL	NULL
+3	3	NULL	NULL
+4	4	4	NULL
+SELECT * FROM
+t1 LEFT JOIN
+( ( t2 LEFT JOIN
+t3
+ON t3.i = t2.i
+)
+)
+ON t2.i = t1.i
+WHERE t3.i IS NULL;
+i	i	i
+2	NULL	NULL
+3	3	NULL
+SELECT * FROM
+t1 LEFT JOIN
+( ( t2 LEFT JOIN
+t3
+ON t3.i = t2.i
+)
+JOIN t4
+ON t4.i=t2.i
+)
+ON t2.i = t1.i
+WHERE t3.i IS NULL;
+i	i	i	i
+2	NULL	NULL	NULL
+3	3	NULL	3
+4	NULL	NULL	NULL
+SELECT * FROM
+t1 LEFT JOIN
+( ( t2 LEFT JOIN
+t3
+ON t3.i = t2.i
+)
+JOIN (t4 AS t4a JOIN t4 AS t4b ON t4a.i=t4b.i)
+ON t4a.i=t2.i
+)
+ON t2.i = t1.i
+WHERE t3.i IS NULL;
+i	i	i	i	i
+2	NULL	NULL	NULL	NULL
+3	3	NULL	3	3
+4	NULL	NULL	NULL	NULL
+SELECT * FROM
+t1 LEFT JOIN
+( ( t2 LEFT JOIN
+t3
+ON t3.i = t2.i
+)
+JOIN (t4 AS t4a, t4 AS t4b)
+ON t4a.i=t2.i
+)
+ON t2.i = t1.i
+WHERE t3.i IS NULL;
+i	i	i	i	i
+2	NULL	NULL	NULL	NULL
+3	3	NULL	3	0
+3	3	NULL	3	1
+3	3	NULL	3	2
+3	3	NULL	3	3
+4	NULL	NULL	NULL	NULL
+DROP TABLE t1,t2,t3,t4;
+#
+# Bug#49322(Duplicate): Server is adding extra NULL row
+# on processing a WHERE clause
+#
+CREATE TABLE h (pk INT NOT NULL, col_int_key INT);
+INSERT INTO h VALUES (1,NULL),(4,2),(5,2),(3,4),(2,8);
+CREATE TABLE m (pk INT NOT NULL, col_int_key INT);
+INSERT INTO m VALUES (1,2),(2,7),(3,5),(4,7),(5,5),(6,NULL),(7,NULL),(8,9);
+CREATE TABLE k (pk INT NOT NULL, col_int_key INT);
+INSERT INTO k VALUES (1,9),(2,2),(3,5),(4,2),(5,7),(6,0),(7,5);
+SELECT TABLE1.pk FROM k TABLE1
+RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key
+RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key;
+pk
+2
+2
+4
+4
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+SELECT TABLE1.pk FROM k TABLE1
+RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key
+RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key
+WHERE TABLE1.pk IS NULL;
+pk
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+DROP TABLE h,m,k;
 End of 5.1 tests
 #
 # Bug#54235 Extra rows with join_cache_level=4,6,8 and two LEFT JOIN

=== modified file 'mysql-test/r/myisam_icp.result'
--- a/mysql-test/r/myisam_icp.result	2011-01-30 16:55:22 +0000
+++ b/mysql-test/r/myisam_icp.result	2011-01-31 11:56:15 +0000
@@ -737,4 +737,24 @@ SELECT pk FROM t1 WHERE c1 <> 1 HAVING p
 pk
 3
 DROP TABLE t1;
+#
+# Bug#59483 "Crash on INSERT/REPLACE in
+#            rec_convert_dtuple_to_rec_comp with ICP on"
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT PRIMARY KEY,
+i1 INTEGER,
+c1 CHAR(6),
+i2 INTEGER NOT NULL,
+KEY (i2)
+);
+INSERT INTO t1 VALUES
+(NULL, 4, 'that', 8),
+(NULL, 1, 'she', 6),
+(NULL, 6, 'tell', 2);
+SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE;
+pk	i1	c1	i2
+2	1	she	6
+INSERT INTO t1 (i2) VALUES (1);
+DROP TABLE t1;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/myisam_icp_all.result'
--- a/mysql-test/r/myisam_icp_all.result	2011-02-02 13:23:58 +0000
+++ b/mysql-test/r/myisam_icp_all.result	2011-02-09 15:30:19 +0000
@@ -597,6 +597,23 @@ select 1 from t1 where b <= 1 and a <> '
 1
 drop table t1;
 #
+# Bug#59259 "Incorrect rows returned for a correlated subquery
+#            when ICP is on"
+#
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (11,0);
+INSERT INTO t1 VALUES (12,5);
+INSERT INTO t1 VALUES (15,0);
+CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (11,1);
+INSERT INTO t2 VALUES (12,2);
+INSERT INTO t2 VALUES (15,4);
+SELECT * FROM t1
+WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE t1.i);
+pk	i
+12	5
+DROP TABLE t1, t2;
+#
 # Bug #58816 "Extra temporary duplicate rows in result set when 
 #             switching ICP off"
 #
@@ -671,6 +688,33 @@ id	select_type	table	type	possible_keys	
 
 DROP TABLE t1,t2;
 #
+# Bug#59186 Wrong results of join when ICP is enabled
+#
+CREATE TABLE t1 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,'y'),(0,'or');
+CREATE TABLE t2 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+c2 VARCHAR(6) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE');
+EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	2	Using index condition
+1	SIMPLE	t2	range	PRIMARY	PRIMARY	4	NULL	2	Using index condition; Using where; Using join buffer (BNL, incremental buffers)
+SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+c2
+DROP TABLE t1, t2;
+#
 # Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when 
 #            ICP is enabled"
 # 

=== modified file 'mysql-test/r/myisam_icp_none.result'
--- a/mysql-test/r/myisam_icp_none.result	2011-01-30 16:55:22 +0000
+++ b/mysql-test/r/myisam_icp_none.result	2011-01-31 11:56:15 +0000
@@ -736,4 +736,24 @@ SELECT pk FROM t1 WHERE c1 <> 1 HAVING p
 pk
 3
 DROP TABLE t1;
+#
+# Bug#59483 "Crash on INSERT/REPLACE in
+#            rec_convert_dtuple_to_rec_comp with ICP on"
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT PRIMARY KEY,
+i1 INTEGER,
+c1 CHAR(6),
+i2 INTEGER NOT NULL,
+KEY (i2)
+);
+INSERT INTO t1 VALUES
+(NULL, 4, 'that', 8),
+(NULL, 1, 'she', 6),
+(NULL, 6, 'tell', 2);
+SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE;
+pk	i1	c1	i2
+2	1	she	6
+INSERT INTO t1 (i2) VALUES (1);
+DROP TABLE t1;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/not_embedded_server.result'
--- a/mysql-test/r/not_embedded_server.result	2011-01-07 12:08:05 +0000
+++ b/mysql-test/r/not_embedded_server.result	2011-02-04 04:59:55 +0000
@@ -3,6 +3,10 @@ SHOW VARIABLES like 'slave_skip_errors';
 Variable_name	Value
 slave_skip_errors	OFF
 #
+# Bug#58026: massive recursion and crash in regular expression handling
+#
+SELECT '1' RLIKE RPAD('1', 10000, '(');
+#
 # WL#4284: Transactional DDL locking
 #
 # FLUSH PRIVILEGES should not implicitly unlock locked tables.

=== modified file 'mysql-test/r/order_by_all.result'
--- a/mysql-test/r/order_by_all.result	2011-02-02 13:41:10 +0000
+++ b/mysql-test/r/order_by_all.result	2011-02-07 09:46:53 +0000
@@ -2524,6 +2524,31 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	index	NULL	a	8	NULL	10	Using index; Using temporary; Using filesort
 1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.b	1	Using where
 DROP TABLE t1, t2;
+#
+# Bug #59110: Memory leak of QUICK_SELECT_I allocated memory 
+#  and
+# Bug #59308: Incorrect result for 
+SELECT DISTINCT <col>... ORDER BY <col> DESC 
+
+# Use Valgrind to detect #59110!
+#
+CREATE TABLE t1 (a INT,KEY (a));
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+EXPLAIN SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index; Using filesort
+SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+a	1
+10	1
+9	1
+8	1
+7	1
+6	1
+5	1
+4	1
+3	1
+2	1
+DROP TABLE t1;
 End of 5.1 tests
 #
 # Bug #38745: MySQL 5.1 optimizer uses filesort for ORDER BY

=== modified file 'mysql-test/r/order_by_icp_mrr.result'
--- a/mysql-test/r/order_by_icp_mrr.result	2011-02-02 13:41:10 +0000
+++ b/mysql-test/r/order_by_icp_mrr.result	2011-02-07 09:46:53 +0000
@@ -2524,6 +2524,31 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	index	NULL	a	8	NULL	10	Using index; Using temporary; Using filesort
 1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.b	1	Using where
 DROP TABLE t1, t2;
+#
+# Bug #59110: Memory leak of QUICK_SELECT_I allocated memory 
+#  and
+# Bug #59308: Incorrect result for 
+SELECT DISTINCT <col>... ORDER BY <col> DESC 
+
+# Use Valgrind to detect #59110!
+#
+CREATE TABLE t1 (a INT,KEY (a));
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+EXPLAIN SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index; Using filesort
+SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+a	1
+10	1
+9	1
+8	1
+7	1
+6	1
+5	1
+4	1
+3	1
+2	1
+DROP TABLE t1;
 End of 5.1 tests
 #
 # Bug #38745: MySQL 5.1 optimizer uses filesort for ORDER BY

=== modified file 'mysql-test/r/order_by_none.result'
--- a/mysql-test/r/order_by_none.result	2011-02-02 13:41:10 +0000
+++ b/mysql-test/r/order_by_none.result	2011-02-07 09:46:53 +0000
@@ -2523,6 +2523,31 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	index	NULL	a	8	NULL	10	Using index; Using temporary; Using filesort
 1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.b	1	Using where
 DROP TABLE t1, t2;
+#
+# Bug #59110: Memory leak of QUICK_SELECT_I allocated memory 
+#  and
+# Bug #59308: Incorrect result for 
+SELECT DISTINCT <col>... ORDER BY <col> DESC 
+
+# Use Valgrind to detect #59110!
+#
+CREATE TABLE t1 (a INT,KEY (a));
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+EXPLAIN SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index; Using filesort
+SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+a	1
+10	1
+9	1
+8	1
+7	1
+6	1
+5	1
+4	1
+3	1
+2	1
+DROP TABLE t1;
 End of 5.1 tests
 #
 # Bug #38745: MySQL 5.1 optimizer uses filesort for ORDER BY

=== modified file 'mysql-test/r/plugin_auth.result'
--- a/mysql-test/r/plugin_auth.result	2011-01-31 15:55:58 +0000
+++ b/mysql-test/r/plugin_auth.result	2011-02-08 17:48:20 +0000
@@ -1,3 +1,4 @@
+CALL mtr.add_suppression("Plugin test_plugin_server reported: 'Wrong password supplied for plug_dest'");
 SELECT PLUGIN_STATUS, PLUGIN_TYPE, PLUGIN_DESCRIPTION
 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME='test_plugin_server';
 PLUGIN_STATUS	ACTIVE

=== modified file 'mysql-test/r/plugin_auth_qa_1.result'
--- a/mysql-test/r/plugin_auth_qa_1.result	2010-10-20 14:56:09 +0000
+++ b/mysql-test/r/plugin_auth_qa_1.result	2011-02-08 17:48:20 +0000
@@ -1,3 +1,4 @@
+CALL mtr.add_suppression("Plugin test_plugin_server reported: 'Wrong password supplied for plug_dest'");
 CREATE DATABASE test_user_db;
 SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
 user	plugin	authentication_string

=== modified file 'mysql-test/r/range_all.result'
--- a/mysql-test/r/range_all.result	2011-02-01 12:47:39 +0000
+++ b/mysql-test/r/range_all.result	2011-02-02 15:05:14 +0000
@@ -1690,7 +1690,7 @@ pk	i4
 EXPLAIN
 SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	i4_uq	i4_uq	5	NULL	3	Using where
+1	SIMPLE	t1	range	i4_uq	i4_uq	5	NULL	3	Using index condition; Using MRR
 SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
 pk	i4
 1	10
@@ -1699,7 +1699,7 @@ pk	i4
 EXPLAIN
 SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	i4_uq	i4_uq	5	NULL	1	Using where
+1	SIMPLE	t1	range	i4_uq	i4_uq	5	NULL	1	Using index condition; Using MRR
 SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10;
 pk	i4
 1	10
@@ -1733,7 +1733,7 @@ pk	i4
 EXPLAIN
 SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	i4_uq	i4_uq	5	NULL	2	Using where
+1	SIMPLE	t1	range	i4_uq	i4_uq	5	NULL	2	Using index condition; Using MRR
 SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
 pk	i4
 1	10
@@ -1748,7 +1748,7 @@ pk	i4
 EXPLAIN
 SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	i4_uq	i4_uq	5	NULL	1	Using where
+1	SIMPLE	t1	range	i4_uq	i4_uq	5	NULL	1	Using index condition; Using MRR
 SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
 pk	i4
 1	10
@@ -1757,14 +1757,14 @@ EXPLAIN
 SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	i4_uq	NULL	NULL	NULL	3	
-1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.i4	1	Using where
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.i4	1	Using index condition
 SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
 pk	i4	pk	i4
 EXPLAIN
 SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	i4_uq	NULL	NULL	NULL	3	
-1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.i4	1	Using where
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.i4	1	Using index condition
 SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
 pk	i4	pk	i4
 DROP TABLE t1;

=== added file 'mysql-test/r/ssl_and_innodb.result'
--- a/mysql-test/r/ssl_and_innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/ssl_and_innodb.result	2011-02-07 23:54:23 +0000
@@ -0,0 +1,8 @@
+CREATE TABLE t1(a int) engine=innodb;
+INSERT INTO t1 VALUES (1);
+SELECT DISTINCT
+convert((SELECT des_decrypt(2,1) AS a FROM t1 WHERE @a:=1), signed) as d
+FROM t1 ;
+d
+2
+DROP TABLE t1;

=== modified file 'mysql-test/r/subquery_all.result'
--- a/mysql-test/r/subquery_all.result	2011-01-25 10:28:21 +0000
+++ b/mysql-test/r/subquery_all.result	2011-02-02 15:05:14 +0000
@@ -6152,6 +6152,32 @@ HAVING t2s.i = 999
 ) IS UNKNOWN;
 i
 DROP TABLE t1,t1s,t2s;
+#
+# Bug #56690  Wrong results with subquery with 
+# GROUP BY inside < ANY clause
+#
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY,
+number INT,
+KEY key_number (number)
+);
+INSERT INTO t1 VALUES (8,8);
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY,
+number INT,
+KEY key_number (number)
+);
+INSERT INTO t2 VALUES (1,2);
+INSERT INTO t2 VALUES (2,8);
+INSERT INTO t2 VALUES (3,NULL);
+INSERT INTO t2 VALUES (4,166);
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2 GROUP BY number);
+pk	number
+8	8
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2);
+pk	number
+8	8
+DROP TABLE t1,t2;
 End of 5.1 tests
 #
 # BUG#50257: Missing info in REF column of the EXPLAIN 

=== modified file 'mysql-test/r/subquery_all_jcl6.result'
--- a/mysql-test/r/subquery_all_jcl6.result	2011-01-25 10:28:21 +0000
+++ b/mysql-test/r/subquery_all_jcl6.result	2011-02-02 15:05:14 +0000
@@ -6156,6 +6156,32 @@ HAVING t2s.i = 999
 ) IS UNKNOWN;
 i
 DROP TABLE t1,t1s,t2s;
+#
+# Bug #56690  Wrong results with subquery with 
+# GROUP BY inside < ANY clause
+#
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY,
+number INT,
+KEY key_number (number)
+);
+INSERT INTO t1 VALUES (8,8);
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY,
+number INT,
+KEY key_number (number)
+);
+INSERT INTO t2 VALUES (1,2);
+INSERT INTO t2 VALUES (2,8);
+INSERT INTO t2 VALUES (3,NULL);
+INSERT INTO t2 VALUES (4,166);
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2 GROUP BY number);
+pk	number
+8	8
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2);
+pk	number
+8	8
+DROP TABLE t1,t2;
 End of 5.1 tests
 #
 # BUG#50257: Missing info in REF column of the EXPLAIN 

=== modified file 'mysql-test/r/subquery_nomat_nosj_jcl6.result'
--- a/mysql-test/r/subquery_nomat_nosj_jcl6.result	2011-01-25 10:28:21 +0000
+++ b/mysql-test/r/subquery_nomat_nosj_jcl6.result	2011-02-02 15:05:14 +0000
@@ -6156,6 +6156,32 @@ HAVING t2s.i = 999
 ) IS UNKNOWN;
 i
 DROP TABLE t1,t1s,t2s;
+#
+# Bug #56690  Wrong results with subquery with 
+# GROUP BY inside < ANY clause
+#
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY,
+number INT,
+KEY key_number (number)
+);
+INSERT INTO t1 VALUES (8,8);
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY,
+number INT,
+KEY key_number (number)
+);
+INSERT INTO t2 VALUES (1,2);
+INSERT INTO t2 VALUES (2,8);
+INSERT INTO t2 VALUES (3,NULL);
+INSERT INTO t2 VALUES (4,166);
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2 GROUP BY number);
+pk	number
+8	8
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2);
+pk	number
+8	8
+DROP TABLE t1,t2;
 End of 5.1 tests
 #
 # BUG#50257: Missing info in REF column of the EXPLAIN 

=== modified file 'mysql-test/r/subquery_none_jcl6.result'
--- a/mysql-test/r/subquery_none_jcl6.result	2011-01-25 10:28:21 +0000
+++ b/mysql-test/r/subquery_none_jcl6.result	2011-02-02 15:05:14 +0000
@@ -6155,6 +6155,32 @@ HAVING t2s.i = 999
 ) IS UNKNOWN;
 i
 DROP TABLE t1,t1s,t2s;
+#
+# Bug #56690  Wrong results with subquery with 
+# GROUP BY inside < ANY clause
+#
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY,
+number INT,
+KEY key_number (number)
+);
+INSERT INTO t1 VALUES (8,8);
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY,
+number INT,
+KEY key_number (number)
+);
+INSERT INTO t2 VALUES (1,2);
+INSERT INTO t2 VALUES (2,8);
+INSERT INTO t2 VALUES (3,NULL);
+INSERT INTO t2 VALUES (4,166);
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2 GROUP BY number);
+pk	number
+8	8
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2);
+pk	number
+8	8
+DROP TABLE t1,t2;
 End of 5.1 tests
 #
 # BUG#50257: Missing info in REF column of the EXPLAIN 

=== modified file 'mysql-test/r/type_year.result'
--- a/mysql-test/r/type_year.result	2010-03-22 13:28:51 +0000
+++ b/mysql-test/r/type_year.result	2011-01-12 10:27:31 +0000
@@ -341,4 +341,18 @@ ta_y	s	tb_y	s
 2001	2001	2001	2001
 DROP TABLE t1;
 #
+# Bug #59211: Select Returns Different Value for min(year) Function
+#
+CREATE TABLE t1(c1 YEAR(4));
+INSERT INTO t1 VALUES (1901),(2155),(0000);
+SELECT * FROM t1;
+c1
+1901
+2155
+0000
+SELECT COUNT(*) AS total_rows, MIN(c1) AS min_value, MAX(c1) FROM t1;
+total_rows	min_value	MAX(c1)
+3	0	2155
+DROP TABLE t1;
+#
 End of 5.1 tests

=== modified file 'mysql-test/r/user_var.result'
--- a/mysql-test/r/user_var.result	2010-11-22 09:13:46 +0000
+++ b/mysql-test/r/user_var.result	2010-12-08 14:36:52 +0000
@@ -448,6 +448,12 @@ DROP TABLE t1;
 select @v:=@v:=sum(1) from dual;
 @v:=@v:=sum(1)
 1
+CREATE TABLE t1(a DECIMAL(31,21));
+INSERT INTO t1 VALUES (0);
+SELECT (@v:=a) <> (@v:=1) FROM t1;
+(@v:=a) <> (@v:=1)
+1
+DROP TABLE t1;
 End of 5.1 tests
 DROP TABLE IF EXISTS t1;
 CREATE TABLE t1(f1 INT AUTO_INCREMENT, PRIMARY KEY(f1));

=== modified file 'mysql-test/r/variables.result'
--- a/mysql-test/r/variables.result	2010-11-29 16:27:58 +0000
+++ b/mysql-test/r/variables.result	2011-02-10 08:52:44 +0000
@@ -1723,6 +1723,28 @@ drop table t1;
 drop function t1_min;
 drop function t1_max;
 #
+# Bug #59884: setting charset to 2048 crashes
+#
+set session character_set_results = 2048;
+ERROR 42000: Unknown character set: '2048'
+set session character_set_client=2048;
+ERROR 42000: Unknown character set: '2048'
+set session character_set_connection=2048;
+ERROR 42000: Unknown character set: '2048'
+set session character_set_server=2048;
+ERROR 42000: Unknown character set: '2048'
+set session collation_server=2048;
+ERROR HY000: Unknown collation: '2048'
+set session character_set_filesystem=2048;
+ERROR 42000: Unknown character set: '2048'
+set session character_set_database=2048;
+ERROR 42000: Unknown character set: '2048'
+set session collation_connection=2048;
+ERROR HY000: Unknown collation: '2048'
+set session collation_database=2048;
+ERROR HY000: Unknown collation: '2048'
+End of 5.5 tests
+#
 # Bug#57035 'ulonglong sql_mode' stored into ulong, is risky and causes
 #           compiler warning
 #

=== modified file 'mysql-test/suite/binlog/r/binlog_unsafe.result'
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result	2010-12-21 10:14:02 +0000
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result	2010-12-23 11:41:50 +0000
@@ -2418,7 +2418,7 @@ INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
 DROP TABLE t1,t2;
 "Should NOT have any warning message issued in the following func7() and trig"
 CREATE TABLE t1 (a INT);
-CREATE TABLE t2 (a CHAR(40));
+CREATE TABLE t2 (a TEXT);
 CREATE TABLE trigger_table (a CHAR(7));
 CREATE FUNCTION func7()
 RETURNS INT

=== modified file 'mysql-test/suite/binlog/t/binlog_unsafe.test'
--- a/mysql-test/suite/binlog/t/binlog_unsafe.test	2010-12-21 10:14:02 +0000
+++ b/mysql-test/suite/binlog/t/binlog_unsafe.test	2010-12-23 11:41:50 +0000
@@ -481,7 +481,7 @@ DROP TABLE t1,t2;
 
 --echo "Should NOT have any warning message issued in the following func7() and trig"
 CREATE TABLE t1 (a INT);
-CREATE TABLE t2 (a CHAR(40));
+CREATE TABLE t2 (a TEXT);
 CREATE TABLE trigger_table (a CHAR(7));
 DELIMITER |;
 CREATE FUNCTION func7()

=== modified file 'mysql-test/suite/engines/funcs/r/ps_string_not_null.result'
Binary files a/mysql-test/suite/engines/funcs/r/ps_string_not_null.result	2010-03-18 06:42:07 +0000 and b/mysql-test/suite/engines/funcs/r/ps_string_not_null.result	2011-02-07 05:40:35 +0000 differ

=== modified file 'mysql-test/suite/engines/funcs/t/ps_string_not_null.test'
--- a/mysql-test/suite/engines/funcs/t/ps_string_not_null.test	2010-03-18 06:42:07 +0000
+++ b/mysql-test/suite/engines/funcs/t/ps_string_not_null.test	2011-02-07 05:40:35 +0000
@@ -1,5 +1,5 @@
 --disable_warnings
-DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t1;
 --enable_warnings
 CREATE TABLE t1(c1 CHAR(100) NOT NULL);
 PREPARE stmt1 FROM 'INSERT INTO t1 (c1) VALUES(?)';

=== added file 'mysql-test/suite/innodb/r/innodb-autoinc-56228.result'
--- a/mysql-test/suite/innodb/r/innodb-autoinc-56228.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb-autoinc-56228.result	2010-11-30 11:03:30 +0000
@@ -0,0 +1,30 @@
+DROP TABLE IF EXISTS t1_56228;
+Warnings:
+Note	1051	Unknown table 'test.t1_56228'
+DROP TABLE IF EXISTS t2_56228;
+Warnings:
+Note	1051	Unknown table 'test.t2_56228'
+DROP FUNCTION IF EXISTS bug56228;
+Warnings:
+Note	1305	FUNCTION test.bug56228 does not exist
+CREATE TEMPORARY TABLE t1_56228(
+c1 iNT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TEMPORARY TABLE t2_56228(
+c1 iNT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
+CREATE FUNCTION bug56228() RETURNS INT DETERMINISTIC
+BEGIN
+INSERT INTO t1_56228 VALUES(NULL);
+INSERT INTO t2_56228 VALUES(NULL);
+INSERT INTO t1_56228 VALUES(NULL);
+INSERT INTO t2_56228 VALUES(NULL);
+DROP TEMPORARY TABLE t1_56228;
+RETURN 42;
+END //
+SELECT bug56228();
+bug56228()
+42
+DROP FUNCTION bug56228;
+DROP TEMPORARY TABLE t2_56228;
+DROP TEMPORARY TABLE IF EXISTS t1_56228;
+Warnings:
+Note	1051	Unknown table 'test.t1_56228'

=== added file 'mysql-test/suite/innodb/t/innodb-autoinc-56228-master.opt'
--- a/mysql-test/suite/innodb/t/innodb-autoinc-56228-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb-autoinc-56228-master.opt	2010-11-30 10:44:06 +0000
@@ -0,0 +1 @@
+--innodb_autoinc_lock_mode=0

=== added file 'mysql-test/suite/innodb/t/innodb-autoinc-56228.test'
--- a/mysql-test/suite/innodb/t/innodb-autoinc-56228.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb-autoinc-56228.test	2010-11-30 10:44:06 +0000
@@ -0,0 +1,33 @@
+-- source include/have_innodb.inc
+
+##
+# Bug #56228: dropping tables from within an active statement crashes server
+#
+DROP TABLE IF EXISTS t1_56228;
+DROP TABLE IF EXISTS t2_56228;
+DROP FUNCTION IF EXISTS bug56228;
+
+CREATE TEMPORARY TABLE t1_56228(
+	c1 iNT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TEMPORARY TABLE t2_56228(
+	c1 iNT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
+
+DELIMITER //;
+
+CREATE FUNCTION bug56228() RETURNS INT DETERMINISTIC
+BEGIN
+ INSERT INTO t1_56228 VALUES(NULL);
+ INSERT INTO t2_56228 VALUES(NULL);
+ INSERT INTO t1_56228 VALUES(NULL);
+ INSERT INTO t2_56228 VALUES(NULL);
+ DROP TEMPORARY TABLE t1_56228;
+ RETURN 42;
+END //
+
+DELIMITER ;//
+
+SELECT bug56228();
+
+DROP FUNCTION bug56228;
+DROP TEMPORARY TABLE t2_56228;
+DROP TEMPORARY TABLE IF EXISTS t1_56228;

=== modified file 'mysql-test/suite/perfschema/include/event_aggregate_setup.inc'
--- a/mysql-test/suite/perfschema/include/event_aggregate_setup.inc	2010-12-09 16:39:45 +0000
+++ b/mysql-test/suite/perfschema/include/event_aggregate_setup.inc	2011-02-09 16:33:45 +0000
@@ -97,6 +97,9 @@ update performance_schema.setup_instrume
                  'wait/synch/rwlock/sql/LOCK_grant',
                  'wait/io/file/sql/query_log');
 
+# Start from a known clean state, to avoid noise from previous tests
+flush tables;
+flush status;
 truncate performance_schema.events_waits_summary_by_thread_by_event_name;
 truncate performance_schema.events_waits_summary_global_by_event_name;
 truncate performance_schema.events_waits_history_long;

=== added file 'mysql-test/suite/perfschema/r/all_tests.result'
--- a/mysql-test/suite/perfschema/r/all_tests.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/all_tests.result	2011-02-09 15:22:04 +0000
@@ -0,0 +1,21 @@
+drop table if exists t1;
+drop table if exists t2;
+create table t1 (test_name text);
+create table t2 (test_name text);
+load data infile "MYSQLTEST_VARDIR/tmp/perfschema-all_tests.txt" into table t1;
+insert into t2 select concat('ddl_', table_name, '.test') from information_schema.tables
+where table_schema='performance_schema';
+insert into t2 select concat('dml_', table_name, '.test') from information_schema.tables
+where table_schema='performance_schema';
+update t2 set test_name= replace(test_name, "events_waits_summary_", "ews_");
+update t2 set test_name= replace(test_name, "events_stages_summary_", "esgs_");
+update t2 set test_name= replace(test_name, "events_statements_summary_", "esms_");
+update t2 set test_name= replace(test_name, "file_summary_", "fs_");
+update t2 set test_name= replace(test_name, "objects_summary_", "os_");
+update t2 set test_name= replace(test_name, "table_io_waits_summary_", "tiws_");
+update t2 set test_name= replace(test_name, "table_lock_waits_summary_", "tlws_");
+delete from t2 where t2.test_name in (select t1.test_name from t1);
+select test_name as `MISSING DDL/DML TESTS` from t2;
+MISSING DDL/DML TESTS
+drop table t1;
+drop table t2;

=== added file 'mysql-test/suite/perfschema/r/ddl_threads.result'
--- a/mysql-test/suite/perfschema/r/ddl_threads.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/ddl_threads.result	2011-02-09 15:22:04 +0000
@@ -0,0 +1,8 @@
+alter table performance_schema.threads add column foo integer;
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
+truncate table performance_schema.threads;
+ERROR HY000: Invalid performance_schema usage.
+ALTER TABLE performance_schema.threads ADD INDEX test_index(PROCESSLIST_ID);
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
+CREATE UNIQUE INDEX test_index ON performance_schema.threads(PROCESSLIST_ID);
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'

=== removed file 'mysql-test/suite/perfschema/r/dml_file_summary_by_event_name.result'
--- a/mysql-test/suite/perfschema/r/dml_file_summary_by_event_name.result	2010-12-01 18:46:51 +0000
+++ b/mysql-test/suite/perfschema/r/dml_file_summary_by_event_name.result	1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
-select * from performance_schema.file_summary_by_event_name
-where event_name like 'Wait/io/%' limit 1;
-select * from performance_schema.file_summary_by_event_name
-where event_name='FOO';
-insert into performance_schema.file_summary_by_event_name
-set event_name='FOO', count_read=1, count_write=2,
-sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
-ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
-update performance_schema.file_summary_by_event_name
-set count_read=12;
-ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
-update performance_schema.file_summary_by_event_name
-set count_write=12 where event_name like "FOO";
-ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
-delete from performance_schema.file_summary_by_event_name
-where count_read=1;
-ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
-delete from performance_schema.file_summary_by_event_name;
-ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
-LOCK TABLES performance_schema.file_summary_by_event_name READ;
-ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
-UNLOCK TABLES;
-LOCK TABLES performance_schema.file_summary_by_event_name WRITE;
-ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
-UNLOCK TABLES;

=== removed file 'mysql-test/suite/perfschema/r/dml_file_summary_by_instance.result'
--- a/mysql-test/suite/perfschema/r/dml_file_summary_by_instance.result	2010-12-01 18:46:51 +0000
+++ b/mysql-test/suite/perfschema/r/dml_file_summary_by_instance.result	1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
-select * from performance_schema.file_summary_by_instance
-where event_name like 'Wait/io/%' limit 1;
-select * from performance_schema.file_summary_by_instance
-where event_name='FOO';
-insert into performance_schema.file_summary_by_instance
-set event_name='FOO', count_read=1, count_write=2,
-sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
-ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
-update performance_schema.file_summary_by_instance
-set count_read=12;
-ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
-update performance_schema.file_summary_by_instance
-set count_write=12 where event_name like "FOO";
-ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
-delete from performance_schema.file_summary_by_instance
-where count_read=1;
-ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
-delete from performance_schema.file_summary_by_instance;
-ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
-LOCK TABLES performance_schema.file_summary_by_instance READ;
-ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
-UNLOCK TABLES;
-LOCK TABLES performance_schema.file_summary_by_instance WRITE;
-ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
-UNLOCK TABLES;

=== added file 'mysql-test/suite/perfschema/r/dml_fs_by_event_name.result'
--- a/mysql-test/suite/perfschema/r/dml_fs_by_event_name.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/dml_fs_by_event_name.result	2011-02-09 15:22:04 +0000
@@ -0,0 +1,25 @@
+select * from performance_schema.file_summary_by_event_name
+where event_name like 'Wait/io/%' limit 1;
+select * from performance_schema.file_summary_by_event_name
+where event_name='FOO';
+insert into performance_schema.file_summary_by_event_name
+set event_name='FOO', count_read=1, count_write=2,
+sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
+ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
+update performance_schema.file_summary_by_event_name
+set count_read=12;
+ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
+update performance_schema.file_summary_by_event_name
+set count_write=12 where event_name like "FOO";
+ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
+delete from performance_schema.file_summary_by_event_name
+where count_read=1;
+ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
+delete from performance_schema.file_summary_by_event_name;
+ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
+LOCK TABLES performance_schema.file_summary_by_event_name READ;
+ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
+UNLOCK TABLES;
+LOCK TABLES performance_schema.file_summary_by_event_name WRITE;
+ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'file_summary_by_event_name'
+UNLOCK TABLES;

=== added file 'mysql-test/suite/perfschema/r/dml_fs_by_instance.result'
--- a/mysql-test/suite/perfschema/r/dml_fs_by_instance.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/dml_fs_by_instance.result	2011-02-09 15:22:04 +0000
@@ -0,0 +1,25 @@
+select * from performance_schema.file_summary_by_instance
+where event_name like 'Wait/io/%' limit 1;
+select * from performance_schema.file_summary_by_instance
+where event_name='FOO';
+insert into performance_schema.file_summary_by_instance
+set event_name='FOO', count_read=1, count_write=2,
+sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
+ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
+update performance_schema.file_summary_by_instance
+set count_read=12;
+ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
+update performance_schema.file_summary_by_instance
+set count_write=12 where event_name like "FOO";
+ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
+delete from performance_schema.file_summary_by_instance
+where count_read=1;
+ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
+delete from performance_schema.file_summary_by_instance;
+ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
+LOCK TABLES performance_schema.file_summary_by_instance READ;
+ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
+UNLOCK TABLES;
+LOCK TABLES performance_schema.file_summary_by_instance WRITE;
+ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'file_summary_by_instance'
+UNLOCK TABLES;

=== added file 'mysql-test/suite/perfschema/t/all_tests.test'
--- a/mysql-test/suite/perfschema/t/all_tests.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/all_tests.test	2011-02-09 15:22:04 +0000
@@ -0,0 +1,78 @@
+# Copyright (c) 2009, 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
+
+--source include/not_embedded.inc
+
+#
+# Test based on mysql-test/suite/sys_vars/all_vars.test,
+# and adapted for the performance schema tables.
+#
+# This test verifies that *all* performance schema tables are tested
+# by the perfschema test suite.
+# In particular, every table there must be covered by:
+# - a ddl_<table_name>.test file.
+# - a dml_<table_name>.test file.
+#
+
+#
+# we can diff in perl or in sql, as it's my_SQL_test suite, do it in sql
+#
+
+perl;
+  use File::Basename;
+  my $dirname=dirname($ENV{MYSQLTEST_FILE});
+  my @all_tests=<$dirname/*.test>;
+  open(F, '>', "$ENV{MYSQLTEST_VARDIR}/tmp/perfschema-all_tests.txt") or die;
+  binmode F;
+  print F join "\n", sort map { basename $_ } @all_tests;
+EOF
+
+--disable_warnings
+drop table if exists t1;
+drop table if exists t2;
+--enable_warnings
+
+create table t1 (test_name text);
+create table t2 (test_name text);
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval load data infile "$MYSQLTEST_VARDIR/tmp/perfschema-all_tests.txt" into table t1;
+
+insert into t2 select concat('ddl_', table_name, '.test') from information_schema.tables
+  where table_schema='performance_schema';
+insert into t2 select concat('dml_', table_name, '.test') from information_schema.tables
+  where table_schema='performance_schema';
+
+# Abbreviations used for naming test files:
+update t2 set test_name= replace(test_name, "events_waits_summary_", "ews_");
+update t2 set test_name= replace(test_name, "events_stages_summary_", "esgs_");
+update t2 set test_name= replace(test_name, "events_statements_summary_", "esms_");
+update t2 set test_name= replace(test_name, "file_summary_", "fs_");
+update t2 set test_name= replace(test_name, "objects_summary_", "os_");
+update t2 set test_name= replace(test_name, "table_io_waits_summary_", "tiws_");
+update t2 set test_name= replace(test_name, "table_lock_waits_summary_", "tlws_");
+
+# Debug
+# select test_name as 'FOUND' from t1;
+# select test_name as 'EXPECTED' from t2;
+
+delete from t2 where t2.test_name in (select t1.test_name from t1);
+
+# If this fails, the test listed in the output is missing from the test suite.
+# The way to fix the failure is to implement the missing test, not silence this select.
+select test_name as `MISSING DDL/DML TESTS` from t2;
+
+drop table t1;
+drop table t2;
+

=== added file 'mysql-test/suite/perfschema/t/ddl_threads.test'
--- a/mysql-test/suite/perfschema/t/ddl_threads.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/ddl_threads.test	2011-02-09 15:22:04 +0000
@@ -0,0 +1,32 @@
+# Copyright (c) 2008, 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
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.threads add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.threads;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.threads ADD INDEX test_index(PROCESSLIST_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.threads(PROCESSLIST_ID);
+

=== removed file 'mysql-test/suite/perfschema/t/dml_file_summary_by_event_name.test'
--- a/mysql-test/suite/perfschema/t/dml_file_summary_by_event_name.test	2010-12-01 18:46:51 +0000
+++ b/mysql-test/suite/perfschema/t/dml_file_summary_by_event_name.test	1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
-# Copyright (c) 2009, 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
-
---disable_result_log
-select * from performance_schema.file_summary_by_event_name
-  where event_name like 'Wait/io/%' limit 1;
-
-select * from performance_schema.file_summary_by_event_name
-  where event_name='FOO';
---enable_result_log
-
---error ER_TABLEACCESS_DENIED_ERROR
-insert into performance_schema.file_summary_by_event_name
-  set event_name='FOO', count_read=1, count_write=2,
-  sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
-
---error ER_TABLEACCESS_DENIED_ERROR
-update performance_schema.file_summary_by_event_name
-  set count_read=12;
-
---error ER_TABLEACCESS_DENIED_ERROR
-update performance_schema.file_summary_by_event_name
-  set count_write=12 where event_name like "FOO";
-
---error ER_TABLEACCESS_DENIED_ERROR
-delete from performance_schema.file_summary_by_event_name
-  where count_read=1;
-
---error ER_TABLEACCESS_DENIED_ERROR
-delete from performance_schema.file_summary_by_event_name;
-
--- error ER_TABLEACCESS_DENIED_ERROR
-LOCK TABLES performance_schema.file_summary_by_event_name READ;
-UNLOCK TABLES;
-
--- error ER_TABLEACCESS_DENIED_ERROR
-LOCK TABLES performance_schema.file_summary_by_event_name WRITE;
-UNLOCK TABLES;
-

=== removed file 'mysql-test/suite/perfschema/t/dml_file_summary_by_instance.test'
--- a/mysql-test/suite/perfschema/t/dml_file_summary_by_instance.test	2010-12-01 18:46:51 +0000
+++ b/mysql-test/suite/perfschema/t/dml_file_summary_by_instance.test	1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
-# Copyright (c) 2009, 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
-
---disable_result_log
-select * from performance_schema.file_summary_by_instance
-  where event_name like 'Wait/io/%' limit 1;
-
-select * from performance_schema.file_summary_by_instance
-  where event_name='FOO';
---enable_result_log
-
---error ER_TABLEACCESS_DENIED_ERROR
-insert into performance_schema.file_summary_by_instance
-  set event_name='FOO', count_read=1, count_write=2,
-  sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
-
---error ER_TABLEACCESS_DENIED_ERROR
-update performance_schema.file_summary_by_instance
-  set count_read=12;
-
---error ER_TABLEACCESS_DENIED_ERROR
-update performance_schema.file_summary_by_instance
-  set count_write=12 where event_name like "FOO";
-
---error ER_TABLEACCESS_DENIED_ERROR
-delete from performance_schema.file_summary_by_instance
-  where count_read=1;
-
---error ER_TABLEACCESS_DENIED_ERROR
-delete from performance_schema.file_summary_by_instance;
-
--- error ER_TABLEACCESS_DENIED_ERROR
-LOCK TABLES performance_schema.file_summary_by_instance READ;
-UNLOCK TABLES;
-
--- error ER_TABLEACCESS_DENIED_ERROR
-LOCK TABLES performance_schema.file_summary_by_instance WRITE;
-UNLOCK TABLES;
-

=== added file 'mysql-test/suite/perfschema/t/dml_fs_by_event_name.test'
--- a/mysql-test/suite/perfschema/t/dml_fs_by_event_name.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/dml_fs_by_event_name.test	2011-02-09 15:22:04 +0000
@@ -0,0 +1,56 @@
+# Copyright (c) 2009, 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
+
+--disable_result_log
+select * from performance_schema.file_summary_by_event_name
+  where event_name like 'Wait/io/%' limit 1;
+
+select * from performance_schema.file_summary_by_event_name
+  where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.file_summary_by_event_name
+  set event_name='FOO', count_read=1, count_write=2,
+  sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.file_summary_by_event_name
+  set count_read=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.file_summary_by_event_name
+  set count_write=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.file_summary_by_event_name
+  where count_read=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.file_summary_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.file_summary_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.file_summary_by_event_name WRITE;
+UNLOCK TABLES;
+

=== added file 'mysql-test/suite/perfschema/t/dml_fs_by_instance.test'
--- a/mysql-test/suite/perfschema/t/dml_fs_by_instance.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/dml_fs_by_instance.test	2011-02-09 15:22:04 +0000
@@ -0,0 +1,56 @@
+# Copyright (c) 2009, 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
+
+--disable_result_log
+select * from performance_schema.file_summary_by_instance
+  where event_name like 'Wait/io/%' limit 1;
+
+select * from performance_schema.file_summary_by_instance
+  where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.file_summary_by_instance
+  set event_name='FOO', count_read=1, count_write=2,
+  sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.file_summary_by_instance
+  set count_read=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.file_summary_by_instance
+  set count_write=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.file_summary_by_instance
+  where count_read=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.file_summary_by_instance;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.file_summary_by_instance READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.file_summary_by_instance WRITE;
+UNLOCK TABLES;
+

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_cond_class-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_cond_class-master.opt	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_cond_class-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_cond_classes=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_cond_classes=0

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_cond_inst-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_cond_inst-master.opt	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_cond_inst-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_cond_instances=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_cond_instances=0

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_file_class-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_file_class-master.opt	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_file_class-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_file_classes=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_file_classes=0

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_file_inst-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_file_inst-master.opt	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_file_inst-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_file_instances=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_file_instances=0

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_mutex_class-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_mutex_class-master.opt	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_mutex_class-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_mutex_classes=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_mutex_classes=0

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_mutex_inst-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_mutex_inst-master.opt	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_mutex_inst-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_mutex_instances=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_mutex_instances=0

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_rwlock_class-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_rwlock_class-master.opt	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_rwlock_class-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_rwlock_classes=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_rwlock_classes=0

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_rwlock_inst-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_rwlock_inst-master.opt	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_rwlock_inst-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_rwlock_instances=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_rwlock_instances=0

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_table_hdl-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_table_hdl-master.opt	2010-05-17 10:05:47 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_table_hdl-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_table_handles=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_table_handles=0

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_table_inst-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_table_inst-master.opt	2010-05-17 10:05:47 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_table_inst-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_table_instances=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_table_instances=0

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_thread_class-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_thread_class-master.opt	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_thread_class-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_thread_classes=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_thread_classes=0

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_thread_inst-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_thread_inst-master.opt	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_thread_inst-master.opt	2011-02-09 15:22:04 +0000
@@ -1 +1,2 @@
---loose-enable-performance-schema --loose-performance_schema_max_thread_instances=0
+--loose-enable-performance-schema
+--loose-performance_schema_max_thread_instances=0

=== modified file 'mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result'
--- a/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result	2011-02-03 16:09:33 +0000
@@ -121,11 +121,11 @@ Master D	12	D
 * Remove wrong event from C and restore B->C->D *
 include/stop_slave.inc
 DELETE FROM t1 WHERE a = 6;
-START SLAVE;
+include/start_slave.inc
 RESET MASTER;
 RESET SLAVE;
 include/rpl_change_topology.inc [new topology=1->2->3->4->1]
-START SLAVE;
+include/start_slave.inc
 include/rpl_sync.inc
 
 * Check data inserted before restoring schema A->B->C->D->A *

=== modified file 'mysql-test/suite/rpl/r/rpl_heartbeat_2slaves.result'
--- a/mysql-test/suite/rpl/r/rpl_heartbeat_2slaves.result	2010-12-19 17:15:12 +0000
+++ b/mysql-test/suite/rpl/r/rpl_heartbeat_2slaves.result	2011-02-04 19:07:48 +0000
@@ -2,13 +2,21 @@ include/rpl_init.inc [topology=1->2,1->3
 include/rpl_connect.inc [creating master]
 include/rpl_connect.inc [creating slave_1]
 include/rpl_connect.inc [creating slave_2]
+include/stop_slave.inc
+CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD = 0.1;
+include/start_slave.inc
+include/stop_slave.inc
+CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD = 1;
+include/start_slave.inc
 Slave has received heartbeat event
-slave_2 has received heartbeat event
-slave_1 has received more heartbeats than slave_2 (1 means 'yes'): 0
+include/assert.inc [slave_1 should have received more heartbeats than slave_2]
 
 include/rpl_stop_slaves.inc
 include/rpl_change_topology.inc [new topology=1->3->2]
 include/rpl_start_slaves.inc
+include/stop_slave.inc
+CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD=0.1;
+include/start_slave.inc
 slave_1 has received heartbeat event
 [on master]
 CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10), c LONGTEXT);
@@ -26,7 +34,7 @@ Tables_in_test
 [on master]
 creating updates on master and send to slave_2 during 5 second
 [on slave_1]
-slave_1 has received heartbeats (1 means 'yes'): 0
+include/assert.inc [slave_1 should have received heartbeats]
 
 *** Clean up ***
 DROP TABLE t1;

=== modified file 'mysql-test/suite/rpl/r/rpl_loaddatalocal.result'
--- a/mysql-test/suite/rpl/r/rpl_loaddatalocal.result	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_loaddatalocal.result	2011-01-12 09:31:32 +0000
@@ -74,6 +74,21 @@ LOAD/*!99999 special comments that do no
 SET sql_mode='PIPES_AS_CONCAT,ANSI_QUOTES,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER';
 LOAD DATA LOCAL INFILE 'MYSQLD_DATADIR/bug43746.sql' INTO TABLE t1;
 [slave]
+
+Bug #59267:
+"LOAD DATA LOCAL INFILE not executed on slave with SBR"
+
+[master]
+SELECT * INTO OUTFILE 'MYSQLD_DATADIR/bug59267.sql' FROM t1;
+TRUNCATE TABLE t1;
+LOAD DATA LOCAL INFILE 'MYSQLD_DATADIR/bug59267.sql' INTO TABLE t1;
+SELECT 'Master', COUNT(*) FROM t1;
+Master	COUNT(*)
+Master	44
+[slave]
+SELECT 'Slave', COUNT(*) FROM t1;
+Slave	COUNT(*)
+Slave	44
 [master]
 DROP TABLE t1;
 SET SESSION sql_mode=@old_mode;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_event_max_size.result'
--- a/mysql-test/suite/rpl/r/rpl_row_event_max_size.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_event_max_size.result	2011-02-10 10:33:25 +0000
@@ -65,7 +65,5 @@ include/wait_for_slave_io_error.inc [err
 Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master''
 ==== clean up ====
 include/stop_slave_sql.inc
-Warnings:
-Note	1255	Slave already has been stopped
 RESET SLAVE;
 include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/disabled.def'
--- a/mysql-test/suite/rpl/t/disabled.def	2011-01-31 13:44:38 +0000
+++ b/mysql-test/suite/rpl/t/disabled.def	2011-02-09 09:28:32 +0000
@@ -12,7 +12,6 @@
 
 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
-rpl_row_event_max_size    : Bug#55675 2010-10-25 andrei mysql_binlog_send attempts to read events partly
 rpl_delayed_slave         : Bug#57514 2010-11-09 andrei rpl_delayed_slave fails sporadically in pb
 rpl_row_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out
 rpl_stm_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out

=== modified file 'mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test'
--- a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test	2011-02-04 15:00:14 +0000
@@ -178,7 +178,7 @@ SELECT 'Master D',a,b FROM t1 WHERE c = 
 source include/stop_slave.inc;
 --connection server_3
 DELETE FROM t1 WHERE a = 6;
-START SLAVE;
+--source include/start_slave.inc
 --connection server_2
 --sync_slave_with_master server_3
 RESET MASTER;
@@ -192,7 +192,7 @@ RESET SLAVE;
 --source include/rpl_change_topology.inc
 #--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3 $file_d LOG_FILE $pos_d LOG_POS 
 #--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SERVER_MYPORT_3,master_user='root',master_log_file='$file_d',master_log_pos=$pos_d
-START SLAVE;
+--source include/start_slave.inc
 --connection server_3
 --sync_slave_with_master server_4
 --source include/rpl_sync.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_heartbeat_2slaves.test'
--- a/mysql-test/suite/rpl/t/rpl_heartbeat_2slaves.test	2010-12-19 17:15:12 +0000
+++ b/mysql-test/suite/rpl/t/rpl_heartbeat_2slaves.test	2011-02-04 19:07:48 +0000
@@ -20,7 +20,19 @@
 --source include/rpl_connect.inc
 
 #
-# Testing heartbeat
+# Set different heartbeat periods for slaves
+#
+--connection slave_1
+--source include/stop_slave.inc
+CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD = 0.1;
+--source include/start_slave.inc
+--connection slave_2
+--source include/stop_slave.inc
+CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD = 1;
+--source include/start_slave.inc
+
+#
+# Testing heartbeat for one master and two slaves
 #
 
 # Check that heartbeat events sent to both slaves with correct periods
@@ -35,15 +47,11 @@ let $status_var= slave_received_heartbea
 let $status_var_value= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
 let $status_var_comparsion= >;
 --source include/wait_for_status_var.inc
-let $slave_2_rcvd_heartbeats= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
---echo slave_2 has received heartbeat event
---connection slave_1
-let $slave_1_rcvd_heartbeats= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
-let $result= query_get_value(SELECT ($slave_1_rcvd_heartbeats DIV $slave_2_rcvd_heartbeats) > 1 AS Result, Result, 1);
---echo slave_1 has received more heartbeats than slave_2 (1 means 'yes'): $result
+--let $assert_cond= [slave_1:SHOW STATUS LIKE "slave_received_heartbeats", Value, 1] > [slave_2:SHOW STATUS LIKE "slave_received_heartbeats", Value, 1]
+--let $assert_text= slave_1 should have received more heartbeats than slave_2
+--source include/assert.inc
 --echo
 
-
 # Create topology master->slave_2->slave_1 and check that slave_1
 # receives heartbeat while slave_2 gets data.
 
@@ -54,6 +62,10 @@ let $result= query_get_value(SELECT ($sl
 --let $rpl_topology= 1->3->2
 --source include/rpl_change_topology.inc
 --source include/rpl_start_slaves.inc
+--connection slave_1
+--source include/stop_slave.inc
+CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD=0.1;
+--source include/start_slave.inc
 
 # Check heartbeat for new replication channel slave_2->slave
 let $status_var= slave_received_heartbeats;
@@ -93,8 +105,6 @@ while ($i) {
     let $time_before = `SELECT NOW()`;
   }
   if (`SELECT ((1-$k)*TIMESTAMPDIFF(SECOND,'$time_before',NOW())) > 5`) {
-    --connection slave_1
-    let $slave_1_rcvd_heartbeats_after= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);    
     let $i= 0;
   }
   --connection master
@@ -104,8 +114,9 @@ while ($i) {
 --enable_query_log
 --connection slave_1
 --echo [on slave_1]
-let $result= query_get_value(SELECT ($slave_1_rcvd_heartbeats_after - $slave_1_rcvd_heartbeats_before) > 0 AS Result, Result, 1);
---echo slave_1 has received heartbeats (1 means 'yes'): $result
+--let $assert_cond= [SHOW STATUS LIKE "slave_received_heartbeats", Value, 1] > $slave_1_rcvd_heartbeats_before
+--let $assert_text= slave_1 should have received heartbeats
+--source include/assert.inc
 --echo
 
 #

=== modified file 'mysql-test/suite/rpl/t/rpl_loaddatalocal.test'
--- a/mysql-test/suite/rpl/t/rpl_loaddatalocal.test	2010-12-19 17:15:12 +0000
+++ b/mysql-test/suite/rpl/t/rpl_loaddatalocal.test	2011-01-12 09:31:32 +0000
@@ -151,12 +151,34 @@ eval LOAD DATA LOCAL INFILE '$MYSQLD_DAT
 --echo [slave]
 sync_slave_with_master;
 
-# cleanup
+--echo
+--echo  Bug #59267:
+--echo "LOAD DATA LOCAL INFILE not executed on slave with SBR"
+--echo
 
---remove_file $MYSQLD_DATADIR/bug43746.sql
+--echo [master]
+connection master;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval SELECT * INTO OUTFILE '$MYSQLD_DATADIR/bug59267.sql' FROM t1;
+TRUNCATE TABLE t1;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD DATA LOCAL INFILE '$MYSQLD_DATADIR/bug59267.sql' INTO TABLE t1;
+
+SELECT 'Master', COUNT(*) FROM t1;
 
+--echo [slave]
+--sync_slave_with_master
+SELECT 'Slave', COUNT(*) FROM t1;
+
+# cleanup
 --echo [master]
 connection master;
+
+--remove_file $MYSQLD_DATADIR/bug43746.sql
+--remove_file $MYSQLD_DATADIR/bug59267.sql
+
 DROP TABLE t1;
 SET SESSION sql_mode=@old_mode;
 

=== added file 'mysql-test/suite/sys_vars/r/secure_file_priv2.result'
--- a/mysql-test/suite/sys_vars/r/secure_file_priv2.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/secure_file_priv2.result	2010-12-16 10:49:40 +0000
@@ -0,0 +1,6 @@
+CREATE TABLE t1 (c1 INT);
+LOAD DATA INFILE "t1.MYI" into table t1;
+ERROR HY000: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
+LOAD DATA INFILE "/test" into table t1;
+ERROR HY000: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
+DROP TABLE t1;

=== added file 'mysql-test/suite/sys_vars/t/secure_file_priv2-master.opt'
--- a/mysql-test/suite/sys_vars/t/secure_file_priv2-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/secure_file_priv2-master.opt	2010-12-16 10:49:40 +0000
@@ -0,0 +1 @@
+--secure_file_priv=$SECURE_LOAD_PATH

=== added file 'mysql-test/suite/sys_vars/t/secure_file_priv2.test'
--- a/mysql-test/suite/sys_vars/t/secure_file_priv2.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/secure_file_priv2.test	2010-12-16 10:49:40 +0000
@@ -0,0 +1,23 @@
+#
+# Bug58747 breaks secure_file_priv+not secure yet+still accesses other folders
+#
+CREATE TABLE t1 (c1 INT);
+#
+# Before the patch this statement failed with
+# Linux:
+#  -> errno 13: 'Can't get stat of '
+# Windows:
+#  -> Warning 1366 Incorrect integer value: '■■☺' for
+#  ->              column 'c1' at row 1
+# Now it should consistently fail with ER_OPTION_PREVENTS_STATEMENT
+# on all platforms.
+--error ER_OPTION_PREVENTS_STATEMENT
+LOAD DATA INFILE "t1.MYI" into table t1;
+
+#
+# The following test makes the assuption that /test isn't a valid path in any
+# operating system running the test suite.
+--error ER_OPTION_PREVENTS_STATEMENT
+LOAD DATA INFILE "/test" into table t1;
+
+DROP TABLE t1;

=== modified file 'mysql-test/t/grant.test'
--- a/mysql-test/t/grant.test	2010-10-19 09:26:45 +0000
+++ b/mysql-test/t/grant.test	2010-12-15 16:15:40 +0000
@@ -1295,6 +1295,107 @@ SELECT CURRENT_USER();
 SET PASSWORD FOR CURRENT_USER() = PASSWORD("admin");
 SET PASSWORD FOR CURRENT_USER() = PASSWORD("");
 
+#
+# Bug#57952: privilege change is not taken into account by EXECUTE.
+#
+
+--echo
+--echo # Bug#57952
+--echo
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1;
+DROP DATABASE IF EXISTS mysqltest2;
+--enable_warnings
+
+CREATE DATABASE mysqltest1;
+CREATE DATABASE mysqltest2;
+
+use mysqltest1;
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (1, 1);
+
+CREATE TABLE t2(a INT);
+INSERT INTO t2 VALUES (2);
+
+CREATE TABLE mysqltest2.t3(a INT);
+INSERT INTO mysqltest2.t3 VALUES (4);
+
+CREATE USER testuser@localhost;
+GRANT CREATE ROUTINE, EXECUTE ON mysqltest1.* TO testuser@localhost;
+GRANT SELECT(b) ON t1 TO testuser@localhost;
+GRANT SELECT    ON t2 TO testuser@localhost;
+GRANT SELECT    ON mysqltest2.* TO testuser@localhost;
+
+--echo
+--echo # Connection: bug57952_con1 (testuser@localhost, db: mysqltest1)
+--connect (bug57952_con1,localhost,testuser,,mysqltest1)
+PREPARE s1 FROM 'SELECT b FROM t1';
+PREPARE s2 FROM 'SELECT a FROM t2';
+PREPARE s3 FROM 'SHOW TABLES FROM mysqltest2';
+
+CREATE PROCEDURE p1() SELECT b FROM t1;
+CREATE PROCEDURE p2() SELECT a FROM t2;
+CREATE PROCEDURE p3() SHOW TABLES FROM mysqltest2;
+
+CALL p1;
+CALL p2;
+CALL p3;
+
+--echo
+--echo # Connection: default
+--connection default
+REVOKE SELECT ON t1 FROM testuser@localhost;
+GRANT SELECT(a) ON t1 TO testuser@localhost;
+REVOKE SELECT ON t2 FROM testuser@localhost;
+REVOKE SELECT ON mysqltest2.* FROM testuser@localhost;
+
+--echo
+--echo # Connection: bug57952_con1 (testuser@localhost, db: mysqltest1)
+--connection bug57952_con1
+--echo #   - Check column-level privileges...
+--error ER_COLUMNACCESS_DENIED_ERROR
+EXECUTE s1;
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+SELECT b FROM t1;
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+EXECUTE s1;
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+CALL p1;
+
+--echo #   - Check table-level privileges...
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT a FROM t2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+EXECUTE s2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+CALL p2;
+
+--echo #   - Check database-level privileges...
+--error ER_DBACCESS_DENIED_ERROR
+SHOW TABLES FROM mysqltest2;
+
+--error ER_DBACCESS_DENIED_ERROR
+EXECUTE s3;
+
+--error ER_DBACCESS_DENIED_ERROR
+CALL p3;
+
+--echo
+--echo # Connection: default
+--connection default
+--disconnect bug57952_con1
+DROP DATABASE mysqltest1;
+DROP DATABASE mysqltest2;
+DROP USER testuser@localhost;
+use test;
+--echo
+
 --echo End of 5.0 tests
 
 #

=== modified file 'mysql-test/t/mysql.test'
--- a/mysql-test/t/mysql.test	2010-12-01 07:01:44 +0000
+++ b/mysql-test/t/mysql.test	2011-02-05 05:06:29 +0000
@@ -425,6 +425,12 @@ drop table t1;
 --echo
 --exec $MYSQL --skip-column-names --vertical test -e "select 1 as a"
 
+#
+# Bug#57450: mysql client enter in an infinite loop if the standard input is a directory
+#
+--error 1
+--exec $MYSQL < .
+
 --echo
 
 --echo #

=== modified file 'mysql-test/t/not_embedded_server.test'
--- a/mysql-test/t/not_embedded_server.test	2011-01-07 12:08:05 +0000
+++ b/mysql-test/t/not_embedded_server.test	2011-02-04 04:59:55 +0000
@@ -14,6 +14,16 @@ call mtr.add_suppression("Can't open and
 
 SHOW VARIABLES like 'slave_skip_errors';
 
+--echo #
+--echo # Bug#58026: massive recursion and crash in regular expression handling
+--echo #
+
+--disable_result_log
+--error ER_STACK_OVERRUN_NEED_MORE
+SELECT '1' RLIKE RPAD('1', 10000, '(');
+--enable_result_log
+
+
 # End of 5.1 tests
 
 --echo #

=== modified file 'mysql-test/t/plugin_auth.test'
--- a/mysql-test/t/plugin_auth.test	2011-01-31 15:55:58 +0000
+++ b/mysql-test/t/plugin_auth.test	2011-02-08 17:48:20 +0000
@@ -1,6 +1,7 @@
 --source include/have_plugin_auth.inc
 --source include/not_embedded.inc
 --source include/mysql_upgrade_preparation.inc
+CALL mtr.add_suppression("Plugin test_plugin_server reported: 'Wrong password supplied for plug_dest'");
 
 query_vertical SELECT PLUGIN_STATUS, PLUGIN_TYPE, PLUGIN_DESCRIPTION
   FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME='test_plugin_server';

=== modified file 'mysql-test/t/plugin_auth_qa_1.test'
--- a/mysql-test/t/plugin_auth_qa_1.test	2010-10-25 10:24:26 +0000
+++ b/mysql-test/t/plugin_auth_qa_1.test	2011-02-08 17:48:20 +0000
@@ -2,6 +2,7 @@
 
 --source include/have_plugin_auth.inc
 --source include/not_embedded.inc
+CALL mtr.add_suppression("Plugin test_plugin_server reported: 'Wrong password supplied for plug_dest'");
 
 CREATE DATABASE test_user_db;
 

=== added file 'mysql-test/t/ssl_and_innodb.test'
--- a/mysql-test/t/ssl_and_innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/ssl_and_innodb.test	2011-02-07 23:54:23 +0000
@@ -0,0 +1,11 @@
+-- source include/have_innodb.inc
+-- source include/have_ssl_crypto_functs.inc
+
+CREATE TABLE t1(a int) engine=innodb;
+INSERT INTO t1 VALUES (1);
+
+SELECT DISTINCT
+convert((SELECT des_decrypt(2,1) AS a FROM t1 WHERE @a:=1), signed) as d
+FROM t1 ;
+
+DROP TABLE t1;

=== modified file 'mysql-test/t/type_year.test'
--- a/mysql-test/t/type_year.test	2010-03-22 13:28:51 +0000
+++ b/mysql-test/t/type_year.test	2011-01-12 10:27:31 +0000
@@ -150,5 +150,15 @@ SELECT ta.y AS ta_y, ta.s, tb.y AS tb_y,
 DROP TABLE t1;
 
 --echo #
+--echo # Bug #59211: Select Returns Different Value for min(year) Function
+--echo #
+
+CREATE TABLE t1(c1 YEAR(4));
+INSERT INTO t1 VALUES (1901),(2155),(0000);
+SELECT * FROM t1;
+SELECT COUNT(*) AS total_rows, MIN(c1) AS min_value, MAX(c1) FROM t1;
+DROP TABLE t1;
+
+--echo #
 
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/user_var.test'
--- a/mysql-test/t/user_var.test	2010-11-22 09:13:46 +0000
+++ b/mysql-test/t/user_var.test	2010-12-08 14:36:52 +0000
@@ -351,6 +351,18 @@ DROP TABLE t1;
 
 select @v:=@v:=sum(1) from dual;
 
+#
+# Bug #57187: more user variable fun with multiple assignments and
+#             comparison in query
+#
+
+CREATE TABLE t1(a DECIMAL(31,21));
+INSERT INTO t1 VALUES (0);
+
+SELECT (@v:=a) <> (@v:=1) FROM t1;
+
+DROP TABLE t1;
+
 --echo End of 5.1 tests
 
 #

=== modified file 'mysql-test/t/variables.test'
--- a/mysql-test/t/variables.test	2011-02-02 18:31:39 +0000
+++ b/mysql-test/t/variables.test	2011-02-10 08:52:44 +0000
@@ -1467,6 +1467,32 @@ drop function t1_max;
 
 
 --echo #
+--echo # Bug #59884: setting charset to 2048 crashes
+--echo #
+
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_results = 2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_client=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_connection=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_server=2048;
+--error ER_UNKNOWN_COLLATION
+set session collation_server=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_filesystem=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_database=2048;
+--error ER_UNKNOWN_COLLATION
+set session collation_connection=2048;
+--error ER_UNKNOWN_COLLATION
+set session collation_database=2048;
+
+--echo End of 5.5 tests
+
+
+--echo #
 --echo # Bug#57035 'ulonglong sql_mode' stored into ulong, is risky and causes
 --echo #           compiler warning
 --echo #

=== modified file 'mysql-test/valgrind.supp'
--- a/mysql-test/valgrind.supp	2011-01-18 11:09:49 +0000
+++ b/mysql-test/valgrind.supp	2011-02-08 17:34:42 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -806,7 +806,6 @@
    fun:my_malloc
    fun:_lf_dynarray_lvalue
    fun:_lf_pinbox_get_pins
-   fun:lf_pinbox_get_pins
 }
 
 {
@@ -836,3 +835,126 @@
    fun:lf_hash_search
 }
 
+{
+   Bug 59874 Valgrind warning in InnoDB compression code
+   Memcheck:Cond
+   fun:*
+   fun:*
+   fun:deflate
+   fun:btr_store_big_rec_extern_fields_func
+   fun:row_ins_index_entry_low
+   fun:row_ins_index_entry
+   fun:row_ins_index_entry_step
+   fun:row_ins
+   fun:row_ins_step
+   fun:row_insert_for_mysql
+}
+
+{
+   In page0zip.c we have already checked that the memory is initialized before calling deflate()
+   Memcheck:Cond
+   fun:*
+   fun:*
+   fun:deflate
+   fun:page_zip_compress
+}
+
+{
+   In page0zip.c we have already checked that the memory is initialized before calling deflate()
+   Memcheck:Cond
+   fun:*
+   fun:*
+   fun:deflate
+   fun:page_zip_compress_deflate
+}
+
+{
+   In page0zip.c we have already checked that the memory is initialized before calling deflate()
+   Memcheck:Cond
+   obj:*/libz.so*
+   obj:*/libz.so*
+   fun:deflate
+   fun:page_zip_compress
+   fun:page_zip_reorganize
+   fun:page_cur_insert_rec_zip_reorg
+   fun:page_cur_insert_rec_zip
+   fun:page_cur_tuple_insert
+   fun:btr_cur_optimistic_insert
+   fun:btr_cur_pessimistic_insert
+   fun:row_ins_index_entry_low
+   fun:row_ins_index_entry
+   fun:row_ins_index_entry_step
+   fun:row_ins
+   fun:row_ins_step
+   fun:row_insert_for_mysql
+}
+
+{
+   In page0zip.c we have already checked that the memory is initialized before calling deflate()
+   Memcheck:Cond
+   obj:*/libz.so*
+   obj:*/libz.so*
+   fun:deflate
+   fun:page_zip_compress
+   fun:page_zip_reorganize
+   fun:page_cur_insert_rec_zip_reorg
+   fun:page_cur_insert_rec_zip
+   fun:page_cur_tuple_insert
+   fun:btr_cur_optimistic_insert
+   fun:row_ins_index_entry_low
+   fun:row_ins_index_entry
+   fun:row_ins_index_entry_step
+   fun:row_ins
+   fun:row_ins_step
+   fun:row_insert_for_mysql
+}
+
+{
+   In page0zip.c we have already checked that the memory is initialized before calling deflate()
+   Memcheck:Cond
+   obj:*/libz.so*
+   obj:*/libz.so*
+   fun:deflate
+   fun:page_zip_compress
+   fun:page_copy_rec_list_end
+   fun:page_move_rec_list_end
+   fun:btr_page_split_and_insert
+   fun:btr_root_raise_and_insert
+   fun:btr_cur_pessimistic_insert
+   fun:row_ins_index_entry_low
+   fun:row_ins_index_entry
+   fun:row_ins_index_entry_step
+   fun:row_ins
+   fun:row_ins_step
+   fun:row_insert_for_mysql
+}
+
+{
+   In page0zip.c we have already checked that the memory is initialized before calling deflate()
+   Memcheck:Cond
+   obj:*/libz.so*
+   obj:*/libz.so*
+   fun:deflate
+   fun:page_zip_compress
+   fun:page_cur_insert_rec_zip_reorg
+   fun:page_cur_insert_rec_zip
+   fun:page_cur_tuple_insert
+   fun:btr_cur_optimistic_insert
+   fun:btr_cur_pessimistic_insert
+   fun:row_ins_index_entry_low
+   fun:row_ins_index_entry
+   fun:row_ins_index_entry_step
+   fun:row_ins
+   fun:row_ins_step
+   fun:row_insert_for_mysql
+}
+
+{
+   Bug 59875 Valgrind warning in buf0buddy.c
+   Memcheck:Addr1
+   fun:mach_read_from_4
+   fun:buf_buddy_relocate
+   fun:buf_buddy_free_low
+   fun:buf_buddy_free
+   fun:buf_LRU_block_remove_hashed_page
+}

=== modified file 'mysys/charset.c'
--- a/mysys/charset.c	2010-12-20 10:28:06 +0000
+++ b/mysys/charset.c	2011-02-10 08:52:44 +0000
@@ -472,6 +472,7 @@ CHARSET_INFO *default_charset_info = &my
 
 void add_compiled_collation(CHARSET_INFO *cs)
 {
+  DBUG_ASSERT(cs->number < array_elements(all_charsets));
   all_charsets[cs->number]= cs;
   cs->state|= MY_CS_AVAILABLE;
 }
@@ -579,14 +580,17 @@ uint get_charset_number(const char *char
 
 const char *get_charset_name(uint charset_number)
 {
-  CHARSET_INFO *cs;
   my_pthread_once(&charsets_initialized, init_available_charsets);
 
-  cs=all_charsets[charset_number];
-  if (cs && (cs->number == charset_number) && cs->name )
-    return (char*) cs->name;
+  if (charset_number < array_elements(all_charsets))
+  {
+    CHARSET_INFO *cs= all_charsets[charset_number];
+
+    if (cs && (cs->number == charset_number) && cs->name)
+      return (char*) cs->name;
+  }
   
-  return (char*) "?";   /* this mimics find_type() */
+  return "?";   /* this mimics find_type() */
 }
 
 
@@ -596,6 +600,8 @@ get_internal_charset(MY_CHARSET_LOADER *
   char  buf[FN_REFLEN];
   CHARSET_INFO *cs;
 
+  DBUG_ASSERT(cs_number < array_elements(all_charsets));
+
   if ((cs= all_charsets[cs_number]))
   {
     if (cs->state & MY_CS_READY)  /* if CS is already initialized */
@@ -646,8 +652,8 @@ CHARSET_INFO *get_charset(uint cs_number
     return default_charset_info;
 
   my_pthread_once(&charsets_initialized, init_available_charsets);
-  
-  if (!cs_number || cs_number > array_elements(all_charsets))
+ 
+  if (cs_number >= array_elements(all_charsets)) 
     return NULL;
 
   my_charset_loader_init_mysys(&loader);

=== modified file 'mysys/my_fopen.c'
--- a/mysys/my_fopen.c	2011-01-07 19:30:52 +0000
+++ b/mysys/my_fopen.c	2011-02-08 15:47:33 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'mysys/my_getsystime.c'
--- a/mysys/my_getsystime.c	2011-01-12 20:36:39 +0000
+++ b/mysys/my_getsystime.c	2011-02-08 15:47:33 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
+/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'plugin/auth/auth_socket.c'
--- a/plugin/auth/auth_socket.c	2010-09-20 16:38:27 +0000
+++ b/plugin/auth/auth_socket.c	2011-01-11 14:53:14 +0000
@@ -79,7 +79,7 @@ mysql_declare_plugin(socket_auth)
 {
   MYSQL_AUTHENTICATION_PLUGIN,
   &socket_auth_handler,
-  "socket_peercred",
+  "auth_socket",
   "Sergei Golubchik",
   "Unix Socket based authentication",
   PLUGIN_LICENSE_GPL,

=== modified file 'plugin/auth/test_plugin.c'
--- a/plugin/auth/test_plugin.c	2011-01-31 15:32:57 +0000
+++ b/plugin/auth/test_plugin.c	2011-02-08 17:48:20 +0000
@@ -45,6 +45,20 @@
 /********************* SERVER SIDE ****************************************/
 
 /**
+ Handle assigned when loading the plugin. 
+ Used with the error reporting functions. 
+*/
+static MYSQL_PLUGIN plugin_info_ptr; 
+
+static int
+test_plugin_init (MYSQL_PLUGIN plugin_info)
+{
+  plugin_info_ptr= plugin_info;
+  return 0;
+}
+
+
+/**
   dialog test plugin mimicking the ordinary auth mechanism. Used to test the auth plugin API
 */
 static int auth_test_plugin(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
@@ -64,7 +78,12 @@ static int auth_test_plugin(MYSQL_PLUGIN
 
   /* fail if the password is wrong */
   if (strcmp((const char *) pkt, info->auth_string))
+  {
+    my_plugin_log_message(plugin_info_ptr, MY_ERROR_LEVEL, 
+                          "Wrong password supplied for %s", 
+                          info->auth_string);
     return CR_ERROR;
+  }
 
   /* copy auth string as a destination name to check it */
   strcpy (info->authenticated_as, info->auth_string);
@@ -72,6 +91,8 @@ static int auth_test_plugin(MYSQL_PLUGIN
   /* copy something into the external user name */
   strcpy (info->external_user, info->auth_string);
 
+  my_plugin_log_message(plugin_info_ptr, MY_INFORMATION_LEVEL, 
+                        "successfully authenticated user %s", info->authenticated_as);
   return CR_OK;
 }
 
@@ -120,7 +141,7 @@ mysql_declare_plugin(test_plugin)
   "Georgi Kodinov",
   "plugin API test plugin",
   PLUGIN_LICENSE_GPL,
-  NULL,
+  test_plugin_init,
   NULL,
   0x0100,
   NULL,

=== modified file 'regex/my_regex.h'
--- a/regex/my_regex.h	2010-07-30 08:34:23 +0000
+++ b/regex/my_regex.h	2011-02-04 05:11:09 +0000
@@ -30,6 +30,7 @@ typedef struct {
 
 
 /* === regcomp.c === */
+typedef int (*my_regex_stack_check_t)();
 extern int my_regcomp(my_regex_t *, const char *, int, CHARSET_INFO *charset);
 #define	MY_REG_BASIC	0000
 #define	MY_REG_EXTENDED	0001
@@ -78,7 +79,8 @@ extern void my_regfree(my_regex_t *);
 
 /* === reginit.c === */
 
-extern void my_regex_init(CHARSET_INFO *cs);	/* Should be called for multithread progs */
+/* Should be called for multithread progs */
+extern void my_regex_init(CHARSET_INFO *cs,  my_regex_stack_check_t func);
 extern void my_regex_end(void);	/* If one wants a clean end */
 
 #ifdef __cplusplus

=== modified file 'regex/regcomp.c'
--- a/regex/regcomp.c	2010-07-26 10:39:38 +0000
+++ b/regex/regcomp.c	2011-02-04 05:11:09 +0000
@@ -31,6 +31,9 @@ struct parse {
 	CHARSET_INFO *charset;	/* for ctype things  */
 };
 
+/* Check if there is enough stack space for recursion. */
+my_regex_stack_check_t my_regex_enough_mem_in_stack= NULL;
+
 #include "regcomp.ih"
 
 static char nuls[10];		/* place to point scanner in event of error */
@@ -117,7 +120,7 @@ CHARSET_INFO *charset;
 #	define	GOODFLAGS(f)	((f)&~MY_REG_DUMP)
 #endif
 
-	my_regex_init(charset);	/* Init cclass if neaded */
+	my_regex_init(charset, NULL);	/* Init cclass if neaded */
 	preg->charset=charset;
 	cflags = GOODFLAGS(cflags);
 	if ((cflags&MY_REG_EXTENDED) && (cflags&MY_REG_NOSPEC))
@@ -222,7 +225,15 @@ int stop;			/* character this ERE should
 		/* do a bunch of concatenated expressions */
 		conc = HERE();
 		while (MORE() && (c = PEEK()) != '|' && c != stop)
-			p_ere_exp(p);
+		{
+		  if (my_regex_enough_mem_in_stack &&
+		      my_regex_enough_mem_in_stack())
+		  {
+		    SETERROR(MY_REG_ESPACE);
+		    return;
+		  }
+		  p_ere_exp(p);
+		}
 		if(REQUIRE(HERE() != conc, MY_REG_EMPTY)) {}/* require nonempty */
 
 		if (!EAT('|'))

=== modified file 'regex/reginit.c'
--- a/regex/reginit.c	2008-02-18 22:29:39 +0000
+++ b/regex/reginit.c	2011-02-04 04:47:46 +0000
@@ -4,10 +4,12 @@
 #include <m_ctype.h>
 #include <m_string.h>
 #include "cclass.h"
+#include "my_regex.h"
 
 static my_bool regex_inited=0;
+extern my_regex_stack_check_t my_regex_enough_mem_in_stack;
 
-void my_regex_init(CHARSET_INFO *cs)
+void my_regex_init(CHARSET_INFO *cs, my_regex_stack_check_t func)
 {
   char buff[CCLASS_LAST][256];
   int  count[CCLASS_LAST];
@@ -16,6 +18,7 @@ void my_regex_init(CHARSET_INFO *cs)
   if (!regex_inited)
   {
     regex_inited=1;
+    my_regex_enough_mem_in_stack= func;
     bzero((uchar*) &count,sizeof(count));
 
     for (i=1 ; i<= 255; i++)
@@ -74,6 +77,7 @@ void my_regex_end()
     int i;
     for (i=0; i < CCLASS_LAST ; i++)
       free((char*) cclasses[i].chars);
+    my_regex_enough_mem_in_stack= NULL;
     regex_inited=0;
   }
 }

=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt	2011-01-03 13:12:01 +0000
+++ b/sql/CMakeLists.txt	2011-02-02 08:30:13 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -14,19 +14,19 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
 INCLUDE_DIRECTORIES(
-${CMAKE_SOURCE_DIR}/include 
-${CMAKE_SOURCE_DIR}/sql 
-${CMAKE_SOURCE_DIR}/regex 
-${ZLIB_INCLUDE_DIR}
-${SSL_INCLUDE_DIRS}
-${CMAKE_BINARY_DIR}/sql
+  ${CMAKE_SOURCE_DIR}/include 
+  ${CMAKE_SOURCE_DIR}/sql 
+  ${CMAKE_SOURCE_DIR}/regex 
+  ${ZLIB_INCLUDE_DIR}
+  ${SSL_INCLUDE_DIRS}
+  ${CMAKE_BINARY_DIR}/sql
 )
 
 SET(GEN_SOURCES
-${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h 
-${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
-${CMAKE_CURRENT_BINARY_DIR}/sql_builtin.cc
-${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h 
+  ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h 
+  ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
+  ${CMAKE_CURRENT_BINARY_DIR}/sql_builtin.cc
+  ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h 
 )
 
 SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED 1)
@@ -36,52 +36,142 @@ IF(SSL_DEFINES)
  ADD_DEFINITIONS(${SSL_DEFINES})
 ENDIF()
 
+SET(SQL_SHARED_SOURCES
+  datadict.cc
+  debug_sync.cc
+  derror.cc
+  des_key_file.cc
+  discover.cc
+  field.cc
+  field_conv.cc 
+  filesort.cc
+  filesort_utils.cc
+  gcalc_slicescan.cc
+  gcalc_tools.cc
+  gstream.cc
+  handler.cc
+  hostname.cc
+  init.cc
+  item.cc
+  item_buff.cc
+  item_cmpfunc.cc 
+  item_create.cc
+  item_func.cc
+  item_geofunc.cc
+  item_row.cc 
+  item_strfunc.cc
+  item_subselect.cc
+  item_sum.cc
+  item_timefunc.cc 
+  item_xmlfunc.cc 
+  key.cc
+  keycaches.cc
+  lock.cc
+  log.cc
+  mdl.cc
+  mf_iocache.cc
+  my_decimal.cc
+  net_serv.cc
+  opt_range.cc
+  opt_sum.cc 
+  parse_file.cc
+  partition_info.cc
+  password.c
+  procedure.cc 
+  protocol.cc
+  records.cc
+  rpl_handler.cc
+  scheduler.cc 
+  set_var.cc 
+  sha2.cc
+  sp.cc
+  sp_cache.cc
+  sp_head.cc
+  sp_pcontext.cc 
+  sp_rcontext.cc
+  spatial.cc
+  sql_acl.cc
+  sql_admin.cc
+  sql_alloc_error_handler.cc
+  sql_alter.cc
+  sql_analyse.cc
+  sql_audit.cc
+  sql_base.cc 
+  sql_bootstrap.cc
+  sql_cache.cc
+  sql_class.cc
+  sql_connect.cc
+  sql_crypt.cc
+  sql_cursor.cc
+  sql_db.cc
+  sql_delete.cc
+  sql_derived.cc
+  sql_do.cc 
+  sql_error.cc
+  sql_handler.cc
+  sql_help.cc
+  sql_insert.cc
+  sql_join_cache.cc
+  sql_lex.cc 
+  sql_list.cc
+  sql_load.cc
+  sql_locale.cc
+  sql_manager.cc
+  sql_parse.cc
+  sql_partition.cc
+  sql_partition_admin.cc
+  sql_plugin.cc
+  sql_prepare.cc
+  sql_profile.cc
+  sql_reload.cc
+  sql_rename.cc 
+  sql_select.cc
+  sql_servers.cc
+  sql_show.cc
+  sql_signal.cc
+  sql_state.c
+  sql_string.cc 
+  sql_table.cc
+  sql_tablespace.cc
+  sql_test.cc
+  sql_time.cc
+  sql_trigger.cc
+  sql_truncate.cc
+  sql_udf.cc
+  sql_union.cc
+  sql_update.cc
+  sql_view.cc
+  strfunc.cc
+  sys_vars.cc
+  table.cc
+  thr_malloc.cc 
+  transaction.cc
+  tztime.cc
+  uniques.cc
+  unireg.cc
+)
+
+SET(SQL_EXPORTED_SOURCES ${SQL_SHARED_SOURCES} PARENT_SCOPE)
 
-SET (SQL_SOURCE
-              ../sql-common/client.c derror.cc des_key_file.cc
-               discover.cc ../libmysql/errmsg.c field.cc  field_conv.cc 
-               filesort_utils.cc
-               filesort.cc gstream.cc sha2.cc
-               handler.cc hash_filo.h sql_plugin_services.h
-               hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc 
-               item_create.cc item_func.cc item_geofunc.cc item_row.cc 
-               item_strfunc.cc item_subselect.cc item_sum.cc item_timefunc.cc 
-               key.cc log.cc lock.cc
-               message.h mf_iocache.cc my_decimal.cc ../sql-common/my_time.c
-               mysqld.cc net_serv.cc  keycaches.cc
-               ../sql-common/client_plugin.c
-               opt_range.cc opt_range.h opt_sum.cc 
-               ../sql-common/pack.c parse_file.cc password.c procedure.cc 
-               protocol.cc records.cc set_var.cc 
-               sp.cc sp_cache.cc sp_head.cc sp_pcontext.cc 
-               sp_rcontext.cc spatial.cc sql_acl.cc sql_analyse.cc sql_base.cc 
-               sql_cache.cc sql_class.cc sql_client.cc sql_crypt.cc sql_crypt.h 
-               sql_cursor.cc sql_db.cc sql_delete.cc sql_derived.cc sql_do.cc 
-               sql_error.cc sql_handler.cc sql_help.cc sql_insert.cc sql_lex.cc 
-               sql_list.cc sql_load.cc sql_manager.cc sql_parse.cc
-               sql_partition.cc sql_plugin.cc sql_prepare.cc sql_rename.cc 
-               sql_join_cache.cc debug_sync.cc debug_sync.h
-               sql_select.cc sql_show.cc sql_state.c sql_string.cc 
-               sql_table.cc sql_test.cc sql_trigger.cc sql_udf.cc sql_union.cc
-               sql_update.cc sql_view.cc strfunc.cc table.cc thr_malloc.cc 
-               sql_time.cc tztime.cc uniques.cc unireg.cc item_xmlfunc.cc 
-               event_scheduler.cc event_data_objects.cc
-               event_queue.cc event_db_repository.cc 
-               sql_tablespace.cc events.cc ../sql-common/my_user.c 
-               partition_info.cc sql_locale.cc
-               sql_servers.cc sql_audit.cc
-               sql_connect.cc scheduler.cc 
-               sql_profile.cc event_parse_data.cc
-               sql_bootstrap.cc
-               sql_signal.cc mdl.cc
-               gcalc_slicescan.cc gcalc_tools.cc
-               sql_alloc_error_handler.cc
-               transaction.cc sys_vars.cc  rpl_handler.cc sql_truncate.cc
-               datadict.cc sql_reload.cc
-               sql_partition_admin.cc
-               sql_admin.cc sql_alter.cc
-               ${GEN_SOURCES}
-               ${MYSYS_LIBWRAP_SOURCE})
+SET(SQL_SOURCE
+  ${GEN_SOURCES}
+  ${MYSYS_LIBWRAP_SOURCE}
+  ${SQL_SHARED_SOURCES}
+  ../libmysql/errmsg.c
+  ../sql-common/client.c
+  ../sql-common/client_plugin.c
+  ../sql-common/my_time.c
+  ../sql-common/my_user.c 
+  ../sql-common/pack.c
+  event_data_objects.cc
+  event_db_repository.cc 
+  event_parse_data.cc
+  event_queue.cc
+  event_scheduler.cc
+  events.cc
+  mysqld.cc
+  sql_client.cc
+  )
 
 MYSQL_ADD_PLUGIN(partition ha_partition.cc STORAGE_ENGINE DEFAULT STATIC_ONLY
 RECOMPILE_FOR_EMBEDDED)

=== modified file 'sql/gcalc_slicescan.cc'
--- a/sql/gcalc_slicescan.cc	2010-11-08 11:34:12 +0000
+++ b/sql/gcalc_slicescan.cc	2011-02-03 13:51:02 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -62,15 +62,15 @@ void Gcalc_dyn_list::format_blk(void* bl
 }
 
 
-Gcalc_dyn_list::Item *Gcalc_dyn_list::alloc_new_blk()
+bool Gcalc_dyn_list::alloc_new_blk()
 {
   void *new_block= my_malloc(m_blk_size, MYF(MY_WME));
   if (!new_block)
-    return NULL;
+    return true;
   *m_blk_hook= new_block;
   m_blk_hook= (void**)new_block;
   format_blk(new_block);
-  return new_item();
+  return false;
 }
 
 
@@ -260,8 +260,8 @@ Gcalc_scan_iterator::Gcalc_scan_iterator
 Gcalc_scan_iterator::point
   *Gcalc_scan_iterator::new_slice(Gcalc_scan_iterator::point *example)
 {
-  point *result= NULL;
-  Gcalc_dyn_list::Item **result_hook= (Gcalc_dyn_list::Item **)&result;
+  Gcalc_dyn_list::Item *item_result= NULL;
+  Gcalc_dyn_list::Item **result_hook= &item_result;
   while (example)
   {
     *result_hook= new_slice_point();
@@ -269,6 +269,7 @@ Gcalc_scan_iterator::point
     example= example->get_next();
   }
   *result_hook= NULL;
+  point *result= static_cast<point*>(item_result);
   return result;
 }
 
@@ -321,13 +322,10 @@ static inline bool slice_first(const Gca
 
 int Gcalc_scan_iterator::insert_top_point()
 {
-  point *sp= m_slice1;
-  Gcalc_dyn_list::Item **prev_hook= (Gcalc_dyn_list::Item **)&m_slice1;
-  point *sp1;
   point *sp0= new_slice_point();
-
   if (!sp0)
     return 1;
+
   sp0->pi= m_cur_pi;
   sp0->next_pi= m_cur_pi->left;
   sp0->thread= m_cur_thread++;
@@ -338,7 +336,8 @@ int Gcalc_scan_iterator::insert_top_poin
     m_event1= scev_thread;
 
     /*Now just to increase the size of m_slice0 to be same*/
-    if (!(sp1= new_slice_point()))
+    point *sp1= new_slice_point();
+    if (!sp1)
       return 1;
     sp1->next= m_slice0;
     m_slice0= sp1;
@@ -354,15 +353,18 @@ int Gcalc_scan_iterator::insert_top_poin
      Binary search could probably make things faster here,
      but structures used aren't suitable, and the
      scan is usually not really long */
-  for (; sp && slice_first(sp, sp0);
-       prev_hook= &sp->next, sp=sp->get_next())
-  {}
+  point *sp= m_slice1;
+  point **prev_hook= &m_slice1;
+  for (; sp && slice_first(sp, sp0); sp=sp->get_next())
+  {
+    prev_hook= reinterpret_cast<point**>(&(sp->next));
+  }
 
   if (m_cur_pi->right)
   {
     m_event1= scev_two_threads;
     /*We have two threads so should decide which one will be first*/
-    sp1= new_slice_point();
+    point *sp1= new_slice_point();
     if (!sp1)
       return 1;
     sp1->pi= m_cur_pi;
@@ -549,7 +551,6 @@ int Gcalc_scan_iterator::add_intersectio
 int Gcalc_scan_iterator::find_intersections()
 {
   point *sp1= m_slice1;
-  Gcalc_dyn_list::Item **hook;
 
   m_n_intersections= 0;
   {
@@ -564,7 +565,8 @@ int Gcalc_scan_iterator::find_intersecti
     }
   }
 
-  hook= (Gcalc_dyn_list::Item **)&m_intersections;
+  Gcalc_dyn_list::Item **hook=
+    reinterpret_cast<Gcalc_dyn_list::Item **>(&m_intersections);
   bool intersections_found;
 
   point *last_possible_isc= NULL;

=== modified file 'sql/gcalc_slicescan.h'
--- a/sql/gcalc_slicescan.h	2010-11-05 09:34:03 +0000
+++ b/sql/gcalc_slicescan.h	2011-02-03 13:51:02 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -42,14 +42,14 @@ public:
   Item *new_item()
   {
     Item *result;
-    if (m_free)
-    {
-      result= m_free;
-      m_free= m_free->next;
-    }
-    else
-      result= alloc_new_blk();
+    if (!m_free && alloc_new_blk())
+      return NULL;
+
+    DBUG_ASSERT(m_free);
+    result= m_free;
+    m_free= m_free->next;
 
+    result->next= NULL;
     return result;
   }
   inline void free_item(Item *item)
@@ -83,7 +83,7 @@ protected:
   Item *m_free;
   Item *m_keep;
 
-  Item *alloc_new_blk();
+  bool alloc_new_blk();
   void format_blk(void* block);
   inline Item *ptr_add(Item *ptr, int n_items)
   {

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-02-02 22:02:29 +0000
+++ b/sql/handler.cc	2011-02-14 10:40:42 +0000
@@ -705,7 +705,7 @@ void ha_close_connection(THD* thd)
   end. Such nested transaction was internally referred to as
   a "statement transaction" and gave birth to the term.
 
-  <Historical note ends>
+  (Historical note ends)
 
   Since then a statement transaction is started for each statement
   that accesses transactional tables or uses the binary log.  If
@@ -2835,8 +2835,10 @@ void handler::get_auto_increment(ulonglo
 
 void handler::ha_release_auto_increment()
 {
+#ifdef BUG60114_IS_FIXED
   DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
               m_lock_type != F_UNLCK);
+#endif
   release_auto_increment();
   insert_id_for_cur_row= 0;
   auto_inc_interval_for_cur_row.replace(0, 0, 0);

=== modified file 'sql/item.h'
--- a/sql/item.h	2011-02-02 13:23:58 +0000
+++ b/sql/item.h	2011-02-10 09:30:20 +0000
@@ -3312,11 +3312,10 @@ class Item_cache: public Item_basic_cons
 protected:
   Item *example;
   table_map used_table_map;
-  /*
-    Field that this object will get value from. This is set/used by 
+  /**
+    Field that this object will get value from. This is used by 
     index-based subquery engines to detect and remove the equality injected 
     by IN->EXISTS transformation.
-    For all other uses of Item_cache, cached_field doesn't matter.
   */  
   Field *cached_field;
   enum enum_field_types cached_field_type;
@@ -3384,6 +3383,14 @@ public:
   {
     return (value_cached || cache_value()) && !null_value;
   }
+
+  /** 
+    If this item caches a field value, return pointer to underlying field.
+
+    @return Pointer to field, or NULL if this is not a cache for a field value.
+  */
+  Field* field() { return cached_field; }
+
   virtual void store(Item *item);
   virtual bool cache_value()= 0;
   bool basic_const_item() const

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2011-01-19 14:39:13 +0000
+++ b/sql/item_cmpfunc.cc	2011-02-08 15:54:12 +0000
@@ -1208,9 +1208,12 @@ get_year_value(THD *thd, Item ***item_ar
          value of 2000.
   */
   Item *real_item= item->real_item();
-  if (!(real_item->type() == Item::FIELD_ITEM &&
-        ((Item_field *)real_item)->field->type() == MYSQL_TYPE_YEAR &&
-        ((Item_field *)real_item)->field->field_length == 4))
+  Field *field= NULL;
+  if (real_item->type() == Item::FIELD_ITEM)
+    field= ((Item_field *)real_item)->field;
+  else if (real_item->type() == Item::CACHE_ITEM)
+    field= ((Item_cache *)real_item)->field();
+  if (!(field && field->type() == MYSQL_TYPE_YEAR && field->field_length == 4))
   {
     if (value < 70)
       value+= 100;

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2011-01-14 15:36:19 +0000
+++ b/sql/item_func.cc	2011-02-08 15:54:12 +0000
@@ -4496,7 +4496,7 @@ my_decimal *user_var_entry::val_decimal(
     int2my_decimal(E_DEC_FATAL_ERROR, *(longlong*) value, 0, val);
     break;
   case DECIMAL_RESULT:
-    val= (my_decimal *)value;
+    my_decimal2decimal((my_decimal *) value, val);
     break;
   case STRING_RESULT:
     str2my_decimal(E_DEC_FATAL_ERROR, value, length, collation.collation, val);

=== modified file 'sql/item_geofunc.h'
--- a/sql/item_geofunc.h	2011-01-12 17:24:53 +0000
+++ b/sql/item_geofunc.h	2011-02-08 15:54:12 +0000
@@ -1,7 +1,7 @@
 #ifndef ITEM_GEOFUNC_INCLUDED
 #define ITEM_GEOFUNC_INCLUDED
 
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2011-01-17 12:35:58 +0000
+++ b/sql/item_strfunc.cc	2011-02-10 08:47:05 +0000
@@ -71,7 +71,7 @@ String my_empty_string("",default_charse
   Normally conversion does not happen, and val_str_ascii() is immediately
   returned instead.
 */
-String *Item_str_ascii_func::val_str(String *str)
+String *Item_str_func::val_str_from_val_str_ascii(String *str, String *str2)
 {
   DBUG_ASSERT(fixed == 1);
 
@@ -83,19 +83,19 @@ String *Item_str_ascii_func::val_str(Str
     return res;
   }
   
-  DBUG_ASSERT(str != &ascii_buf);
+  DBUG_ASSERT(str != str2);
   
   uint errors;
-  String *res= val_str_ascii(&ascii_buf);
+  String *res= val_str_ascii(str);
   if (!res)
     return 0;
   
-  if ((null_value= str->copy(res->ptr(), res->length(),
-                             &my_charset_latin1, collation.collation,
-                             &errors)))
+  if ((null_value= str2->copy(res->ptr(), res->length(),
+                              &my_charset_latin1, collation.collation,
+                              &errors)))
     return 0;
   
-  return str;
+  return str2;
 }
 
 

=== modified file 'sql/item_strfunc.h'
--- a/sql/item_strfunc.h	2011-01-17 12:35:58 +0000
+++ b/sql/item_strfunc.h	2011-02-10 08:47:05 +0000
@@ -1,7 +1,7 @@
 #ifndef ITEM_STRFUNC_INCLUDED
 #define ITEM_STRFUNC_INCLUDED
 
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -51,6 +51,7 @@ public:
   enum Item_result result_type () const { return STRING_RESULT; }
   void left_right_max_length();
   bool fix_fields(THD *thd, Item **ref);
+  String *val_str_from_val_str_ascii(String *str, String *str2);
 };
 
 
@@ -66,8 +67,10 @@ public:
   Item_str_ascii_func(Item *a) :Item_str_func(a) {}
   Item_str_ascii_func(Item *a,Item *b) :Item_str_func(a,b) {}
   Item_str_ascii_func(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
-  String *val_str_convert_from_ascii(String *str, String *ascii_buf);
-  String *val_str(String *str);
+  String *val_str(String *str)
+  {
+    return val_str_from_val_str_ascii(str, &ascii_buf);
+  }
   virtual String *val_str_ascii(String *)= 0;
 };
 
@@ -382,7 +385,9 @@ public:
   {
     maybe_null=1;
     /* 9 = MAX ((8- (arg_len % 8)) + 1) */
-    max_length = args[0]->max_length - 9;
+    max_length= args[0]->max_length;
+    if (max_length >= 9U)
+      max_length-= 9U;
   }
   const char *func_name() const { return "des_decrypt"; }
 };

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2010-12-16 18:18:20 +0000
+++ b/sql/item_timefunc.cc	2011-02-10 08:47:05 +0000
@@ -2205,8 +2205,6 @@ void Item_date_add_interval::fix_length_
   enum_field_types arg0_field_type;
 
   maybe_null=1;
-  fix_length_and_charset_datetime(MAX_DATETIME_FULL_WIDTH);
-  value.alloc(max_length);
 
   /*
     The field type for the result of an Item_date function is defined as
@@ -2231,6 +2229,21 @@ void Item_date_add_interval::fix_length_
     else
       cached_field_type= MYSQL_TYPE_DATETIME;
   }
+
+  if (cached_field_type == MYSQL_TYPE_STRING)
+  {
+    /* Behave as a usual string function when return type is VARCHAR. */
+    fix_length_and_charset(MAX_DATETIME_FULL_WIDTH, default_charset());
+  }
+  else
+  {
+    /*
+      Follow the "Number-to-string conversion" rules as in WorkLog 2649
+      when return type is DATE or DATETIME.
+    */
+    fix_length_and_charset_datetime(MAX_DATETIME_FULL_WIDTH);
+  }
+  value.alloc(max_length);
 }
 
 
@@ -2253,7 +2266,7 @@ bool Item_date_add_interval::get_date(MY
 }
 
 
-String *Item_date_add_interval::val_str(String *str)
+String *Item_date_add_interval::val_str_ascii(String *str)
 {
   DBUG_ASSERT(fixed == 1);
   MYSQL_TIME ltime;

=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h	2011-01-28 13:49:59 +0000
+++ b/sql/item_timefunc.h	2011-02-10 08:47:05 +0000
@@ -773,16 +773,32 @@ class Item_date_add_interval :public Ite
 {
   String value;
   enum_field_types cached_field_type;
-
+  String ascii_buf;
 public:
   const interval_type int_type; // keep it public
   const bool date_sub_interval; // keep it public
   Item_date_add_interval(Item *a,Item *b,interval_type type_arg,bool neg_arg)
     :Item_date_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
-  String *val_str(String *);
+  String *val_str_ascii(String *str);
+  String *val_str(String *str)
+  {
+    return val_str_from_val_str_ascii(str, &ascii_buf);
+  }
   const char *func_name() const { return "date_add_interval"; }
   void fix_length_and_dec();
   enum_field_types field_type() const { return cached_field_type; }
+  CHARSET_INFO *charset_for_protocol(void) const
+  {
+    /*
+      DATE_ADD() can return DATE, DATETIME or VARCHAR depending on arguments.
+      Send using "binary" when DATE or DATETIME,
+      or using collation.collation when VARCHAR
+      (which was fixed from @collation_connection in fix_length_and_dec).
+    */
+    DBUG_ASSERT(fixed == 1);
+    return cached_field_type == MYSQL_TYPE_STRING ?
+                                collation.collation : &my_charset_bin;
+  }
   longlong val_int();
   bool get_date(MYSQL_TIME *res, uint fuzzy_date);
   bool eq(const Item *item, bool binary_cmp) const;

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2011-01-07 19:54:11 +0000
+++ b/sql/log.cc	2011-02-09 07:31:17 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@
 #include "tztime.h"             // my_tz_OFFSET0, struct Time_zone
 #include "sql_acl.h"            // SUPER_ACL
 #include "sql_audit.h"
+#include "mysql/service_my_plugin_log.h"
 
 #include <my_dir.h>
 #include <stdarg.h>
@@ -1879,7 +1880,6 @@ const char *MYSQL_LOG::generate_name(con
 }
 
 
-
 int error_log_print(enum loglevel level, const char *format,
                     va_list args)
 {
@@ -2199,6 +2199,35 @@ void sql_print_information(const char *f
 }
 
 
+extern "C"
+int my_plugin_log_message(MYSQL_PLUGIN *plugin_ptr, plugin_log_level level,
+                          const char *format, ...)
+{
+  char format2[MYSQL_ERRMSG_SIZE];
+  int ret;
+  loglevel lvl;
+  struct st_plugin_int *plugin = (st_plugin_int *) plugin_ptr;
+  va_list args;
+
+  DBUG_ASSERT(level >= MY_ERROR_LEVEL || level <= MY_INFORMATION_LEVEL);
+
+  switch (level)
+  {
+  case MY_ERROR_LEVEL:       lvl= ERROR_LEVEL; break;
+  case MY_WARNING_LEVEL:     lvl= WARNING_LEVEL; break;
+  case MY_INFORMATION_LEVEL: lvl= INFORMATION_LEVEL; break;
+  default:                   return 1;
+  }
+
+  va_start(args, format);
+  snprintf(format2, sizeof (format2) - 1, "Plugin %.*s reported: '%s'", 
+           (int) plugin->name.length, plugin->name.str, format);
+  ret= error_log_print(lvl, format2, args);
+  va_end(args);
+  return ret;
+}
+
+
 /********* transaction coordinator log for 2pc - mmap() based solution *******/
 
 /*

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-02-02 22:02:29 +0000
+++ b/sql/mysqld.cc	2011-02-14 10:28:11 +0000
@@ -2886,6 +2886,19 @@ sizeof(load_default_groups)/sizeof(load_
 #endif
 
 
+#ifndef EMBEDDED_LIBRARY
+static
+int
+check_enough_stack_size()
+{
+  uchar stack_top;
+
+  return check_stack_overrun(current_thd, STACK_MIN_SIZE,
+                             &stack_top);
+}
+#endif
+
+
 /**
   Initialize one of the global date/time format variables.
 
@@ -3376,7 +3389,11 @@ static int init_common_variables()
   if (item_create_init())
     return 1;
   item_init();
-  my_regex_init(&my_charset_latin1);
+#ifndef EMBEDDED_LIBRARY
+  my_regex_init(&my_charset_latin1, check_enough_stack_size);
+#else
+  my_regex_init(&my_charset_latin1, NULL);
+#endif
   /*
     Process a comma-separated character set list and choose
     the first available character set. This is mostly for

=== modified file 'sql/net_serv.cc'
--- a/sql/net_serv.cc	2011-01-11 15:33:55 +0000
+++ b/sql/net_serv.cc	2011-02-08 15:54:12 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'sql/rpl_info_handler.h'
--- a/sql/rpl_info_handler.h	2010-10-25 10:39:01 +0000
+++ b/sql/rpl_info_handler.h	2011-02-04 11:55:17 +0000
@@ -55,13 +55,13 @@ public:
   /**
     Flushes and syncs in-memory information into a stable storage (i.e.
     repository). Usually, syncing after flushing depends on other options
-    such as @code relay-log-info-sync, master-info-sync. These options
+    such as @c relay-log-info-sync, @c master-info-sync. These options
     dictate after how many events or transactions the information
     should be synced. We can ignore them and always sync by setting the
-    parameter @code force, which is by default false, to @code true.
+    parameter @c force, which is by default @c false, to @c true.
 
     So if the number of events is below a threshold, the parameter
-    @code force is FALSE and we are using a file system as a storage
+    @c force is FALSE and we are using a file system as a storage
     system, it may happen that the changes will only end up in the
     operating system's cache and a crash may lead to inconsistencies.
 

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2011-01-24 03:58:22 +0000
+++ b/sql/rpl_slave.cc	2011-02-03 10:13:06 +0000
@@ -10,8 +10,8 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+   along with this program; if not, write to the Free Software Foundation,
+   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA */
 
 
 /**
@@ -6126,7 +6126,6 @@ err:
   thd_proc_info(thd, 0);
   if (ret == FALSE)
     my_ok(thd);
-  delete_dynamic(&lex_mi->repl_ignore_server_ids); //freeing of parser-time alloc
   DBUG_RETURN(ret);
 }
 

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2011-02-09 22:35:46 +0000
+++ b/sql/sql_base.cc	2011-02-14 10:28:11 +0000
@@ -6225,6 +6225,8 @@ find_field_in_natural_join(THD *thd, TAB
 /*
   Find field by name in a base table or a view with temp table algorithm.
 
+  The caller is expected to check column-level privileges.
+
   SYNOPSIS
     find_field_in_table()
     thd				thread handler
@@ -6332,6 +6334,8 @@ find_field_in_table(THD *thd, TABLE *tab
     This procedure detects the type of the table reference 'table_list'
     and calls the corresponding search routine.
 
+    The routine checks column-level privieleges for the found field.
+
   RETURN
     0			field is not found
     view_ref_found	found value in VIEW (real result is in *ref)
@@ -6607,8 +6611,16 @@ find_field_in_tables(THD *thd, Item_iden
       when table_ref->field_translation != NULL.
       */
     if (table_ref->table && !table_ref->view)
+    {
       found= find_field_in_table(thd, table_ref->table, name, length,
                                  TRUE, &(item->cached_field_index));
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+      /* Check if there are sufficient access rights to the found field. */
+      if (found && check_privileges &&
+          check_column_grant_in_table_ref(thd, table_ref, name, length))
+        found= WRONG_GRANT;
+#endif
+    }
     else
       found= find_field_in_table_ref(thd, table_ref, name, length, item->name,
                                      NULL, NULL, ref, check_privileges,

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-02-02 09:04:55 +0000
+++ b/sql/sql_class.cc	2011-02-03 10:13:06 +0000
@@ -11,7 +11,7 @@
 
    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 */
+   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
 
 
 /*****************************************************************************
@@ -1458,6 +1458,11 @@ void THD::cleanup_after_query()
   /* reset table map for multi-table update */
   table_map_for_update= 0;
   m_binlog_invoker= FALSE;
+  /* reset replication info structure */
+  if (lex && lex->mi.repl_ignore_server_ids.buffer) 
+  {
+    delete_dynamic(&lex->mi.repl_ignore_server_ids);
+  }
 }
 
 

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2011-02-02 22:02:29 +0000
+++ b/sql/sql_lex.cc	2011-02-14 10:28:11 +0000
@@ -10,8 +10,9 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
+   along with this program; if not, write to the Free Software 
+   Foundation, Inc.,  51 Franklin Street, Fifth Floor, Boston, 
+   MA 02110-1301 USA */
 
 
 /* A lexical scanner on a temporary buffer with a yacc interface */
@@ -2367,6 +2368,7 @@ LEX::LEX()
                          plugins_static_buffer,
                          INITIAL_LEX_PLUGIN_LIST_SIZE, 
                          INITIAL_LEX_PLUGIN_LIST_SIZE);
+  memset(&mi, 0, sizeof(LEX_MASTER_INFO));
   reset_query_tables_list(TRUE);
 }
 

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2010-12-10 16:55:50 +0000
+++ b/sql/sql_load.cc	2011-02-10 10:52:39 +0000
@@ -363,58 +363,58 @@ int mysql_load(THD *thd,sql_exchange *ex
       (void) fn_format(name, ex->file_name, mysql_real_data_home, "",
                        MY_RELATIVE_PATH | MY_UNPACK_FILENAME |
                        MY_RETURN_REAL_PATH);
-#if !defined(__WIN__)
-      MY_STAT stat_info;
-      if (!mysql_file_stat(key_file_load, name, &stat_info, MYF(MY_WME)))
-	DBUG_RETURN(TRUE);
-
-      // if we are not in slave thread, the file must be:
-      if (!thd->slave_thread &&
-	  !((stat_info.st_mode & S_IROTH) == S_IROTH &&  // readable by others
-	    (stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink
-	    ((stat_info.st_mode & S_IFREG) == S_IFREG ||
-	     (stat_info.st_mode & S_IFIFO) == S_IFIFO)))
-      {
-	my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name);
-	DBUG_RETURN(TRUE);
-      }
-      if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
-	is_fifo = 1;
-#endif
+    }
 
-      if (thd->slave_thread)
-      {
+    if (thd->slave_thread)
+    {
 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-        if (strncmp(active_mi->rli->slave_patternload_file, name,
-            active_mi->rli->slave_patternload_file_size))
-        {
-          /*
-            LOAD DATA INFILE in the slave SQL Thread can only read from
-            --slave-load-tmpdir". This should never happen. Please, report a bug.
-           */
-
-          sql_print_error("LOAD DATA INFILE in the slave SQL Thread can only read from --slave-load-tmpdir. " \
-                          "Please, report a bug.");
-          my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--slave-load-tmpdir");
-          DBUG_RETURN(TRUE);
-        }
-#else
+      if (strncmp(active_mi->rli->slave_patternload_file, name,
+                  active_mi->rli->slave_patternload_file_size))
+      {
         /*
-          This is impossible and should never happen.
+          LOAD DATA INFILE in the slave SQL Thread can only read from 
+          --slave-load-tmpdir". This should never happen. Please, report a bug.
         */
-        DBUG_ASSERT(FALSE); 
-#endif
-      }
-      else if (!is_secure_file_path(name))
-      {
-        /* Read only allowed from within dir specified by secure_file_priv */
-        my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
+
+        sql_print_error("LOAD DATA INFILE in the slave SQL Thread can only read from --slave-load-tmpdir. " \
+                        "Please, report a bug.");
+        my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--slave-load-tmpdir");
         DBUG_RETURN(TRUE);
       }
+#else
+      /*
+        This is impossible and should never happen.
+      */
+      DBUG_ASSERT(FALSE); 
+#endif
+    }
+    else if (!is_secure_file_path(name))
+    {
+      /* Read only allowed from within dir specified by secure_file_priv */
+      my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
+      DBUG_RETURN(TRUE);
+    }
 
+#if !defined(__WIN__) && ! defined(__NETWARE__)
+    MY_STAT stat_info;
+    if (!my_stat(name,&stat_info,MYF(MY_WME)))
+	    DBUG_RETURN(TRUE);
+
+    // if we are not in slave thread, the file must be:
+    if (!thd->slave_thread &&
+        !((stat_info.st_mode & S_IFLNK) != S_IFLNK &&   // symlink
+          ((stat_info.st_mode & S_IFREG) == S_IFREG ||  // regular file
+           (stat_info.st_mode & S_IFIFO) == S_IFIFO)))  // named pipe
+    {
+	    my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name);
+	    DBUG_RETURN(TRUE);
     }
+    if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
+            is_fifo = 1;
+#endif
     if ((file= mysql_file_open(key_file_load,
                                name, O_RDONLY, MYF(MY_WME))) < 0)
+
       DBUG_RETURN(TRUE);
   }
 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-02-02 22:02:29 +0000
+++ b/sql/sql_parse.cc	2011-02-14 10:28:11 +0000
@@ -1491,7 +1491,6 @@ void log_slow_statement(THD *thd)
   if (thd->enable_slow_log)
   {
     ulonglong end_utime_of_query= thd->current_utime();
-    thd_proc_info(thd, "logging slow query");
 
     if (((thd->server_status & SERVER_QUERY_WAS_SLOW) ||
          ((thd->server_status &

=== modified file 'sql/sql_plugin_services.h'
--- a/sql/sql_plugin_services.h	2010-09-01 13:05:01 +0000
+++ b/sql/sql_plugin_services.h	2011-02-08 17:48:20 +0000
@@ -46,6 +46,11 @@ static struct my_thread_scheduler_servic
   my_thread_scheduler_reset,
 };
 
+static struct my_plugin_log_service my_plugin_log_handler= {
+  my_plugin_log_message
+};
+
+
 
 static struct st_service_ref list_of_services[]=
 {
@@ -54,5 +59,6 @@ static struct st_service_ref list_of_ser
   { "thd_wait_service",    VERSION_thd_wait,    &thd_wait_handler },
   { "my_thread_scheduler_service",
     VERSION_my_thread_scheduler, &my_thread_scheduler_handler },
+  { "my_plugin_log_service", VERSION_my_plugin_log, &my_plugin_log_handler },
 };
 

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-02-02 13:23:58 +0000
+++ b/sql/sql_select.cc	2011-02-10 09:30:20 +0000
@@ -9236,7 +9236,7 @@ inline void add_cond_and_fix(Item **e1, 
       @code
       SELECT A.f2 FROM t1 LEFT JOIN t2 A ON A.f2 = f1
       WHERE A.f3=(SELECT MIN(f3) FROM  t2 C WHERE A.f4 = C.f4) OR A.f3 IS NULL;
-      @endocde
+      @endcode
       Here condition A.f3 IS NOT NULL is going to be added to the WHERE
       condition of the embedding query.
       Another example:
@@ -19897,11 +19897,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
 {
   int ref_key;
   uint ref_key_parts;
-  int order_direction;
+  int order_direction= 0;
   uint used_key_parts;
   TABLE *table=tab->table;
   SQL_SELECT *select=tab->select;
   QUICK_SELECT_I *save_quick= 0;
+  int best_key= -1;
   Item *orig_select_cond= 0;
   bool orig_select_cond_saved= false;
   bool changed_key= false;
@@ -20020,6 +20021,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
           key_map new_ref_key_map;  // Force the creation of quick select
           new_ref_key_map.set_bit(new_ref_key); // only for new_ref_key.
 
+          select->quick= 0;
           if (select->test_quick_select(tab->join->thd, new_ref_key_map, 0,
                                         (tab->join->select_options &
                                          OPTION_FOUND_ROWS) ?
@@ -20043,7 +20045,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
     uint best_key_parts= 0;
     uint saved_best_key_parts= 0;
     int best_key_direction= 0;
-    int best_key= -1;
     JOIN *join= tab->join;
     ha_rows table_records= table->file->stats.records;
 
@@ -20067,77 +20068,16 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
 
     if (best_key >= 0)
     {
-      bool quick_created= FALSE;
       if (table->quick_keys.is_set(best_key) && best_key != ref_key)
       {
         key_map map;           // Force the creation of quick select
         map.set_bit(best_key); // only best_key.
-        quick_created=         
-          select->test_quick_select(join->thd, map, 0,
-                                    join->select_options & OPTION_FOUND_ROWS ?
-                                    HA_POS_ERROR :
-                                    join->unit->select_limit_cnt,
-                                    TRUE, FALSE) > 0;
-      }
-      if (!no_changes)
-      {
-        /* 
-           If ref_key used index tree reading only ('Using index' in EXPLAIN),
-           and best_key doesn't, then revert the decision.
-        */
-        if (!table->covering_keys.is_set(best_key))
-          table->set_keyread(FALSE);
-        if (!quick_created)
-	{
-          tab->index= best_key;
-          tab->read_first_record= best_key_direction > 0 ?
-                                  join_read_first:join_read_last;
-          tab->type=JT_NEXT;           // Read with index_first(), index_next()
-          if (select && select->quick)
-          {
-            delete select->quick;
-            select->quick= 0;
-          }
-          if (table->covering_keys.is_set(best_key))
-            table->set_keyread(TRUE);
-          if (tab->pre_idx_push_select_cond)
-          {
-            tab->set_cond(tab->pre_idx_push_select_cond, __LINE__);
-            /*
-              orig_select_cond is a part of pre_idx_push_select_cond,
-              no need to restore it.
-            */
-            orig_select_cond= 0;
-            orig_select_cond_saved= false;
-          }
-          table->file->ha_index_or_rnd_end();
-          if (join->select_options & SELECT_DESCRIBE)
-          {
-            tab->ref.key= -1;
-            tab->ref.key_parts= 0;
-            if (select_limit < table_records) 
-              tab->limit= select_limit;
-          }
-        }
-        else if (tab->type != JT_ALL)
-        {
-          /*
-            We're about to use a quick access to the table.
-            We need to change the access method so as the quick access
-            method is actually used.
-          */
-          DBUG_ASSERT(tab->select->quick);
-          tab->type=JT_ALL;
-          tab->use_quick=QS_RANGE;
-          tab->ref.key= -1;
-          tab->ref.key_parts=0;		// Don't use ref key.
-          tab->read_first_record= join_init_read_record;
-          if (tab->is_using_loose_index_scan())
-            join->tmp_table_param.precomputed_group_by= TRUE;
-          /*
-            TODO: update the number of records in join->best_positions[tablenr]
-          */
-        }
+        select->quick= 0;
+        select->test_quick_select(join->thd, map, 0,
+                                  join->select_options & OPTION_FOUND_ROWS ?
+                                  HA_POS_ERROR :
+                                  join->unit->select_limit_cnt,
+                                  TRUE, FALSE);
       }
       order_direction= best_key_direction;
       /*
@@ -20155,6 +20095,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
   } 
 
 check_reverse_order:                  
+  DBUG_ASSERT(order_direction != 0);
+
   if (order_direction == -1)		// If ORDER BY ... DESC
   {
     if (select && select->quick)
@@ -20163,9 +20105,10 @@ check_reverse_order:                  
 	Don't reverse the sort order, if it's already done.
         (In some cases test_if_order_by_key() can be called multiple times
       */
-      if (!select->quick->reverse_sorted())
+      if (select->quick->reverse_sorted())
+        goto skipped_filesort;
+      else
       {
-        QUICK_SELECT_I *tmp;
         int quick_type= select->quick->get_type();
         if (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE ||
             quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT ||
@@ -20173,36 +20116,128 @@ check_reverse_order:                  
             quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)
         {
           tab->limit= 0;
-          select->quick= save_quick;
           goto use_filesort;                   // Use filesort
         }
-            
-        /* ORDER BY range_key DESC */
-	tmp= select->quick->make_reverse(used_key_parts);
-	if (!tmp)
-	{
-          select->quick= save_quick;
-          tab->limit= 0;
-	  goto use_filesort;		// Reverse sort not supported
-	}
-	select->set_quick(tmp);
       }
     }
-    else if (tab->type != JT_NEXT && tab->type != JT_REF_OR_NULL &&
-             tab->ref.key >= 0 && tab->ref.key_parts <= used_key_parts)
+  }
+
+  /*
+    Update query plan with access pattern for doing 
+    ordered access according to what we have decided
+    above.
+  */
+  if (!no_changes) // We are allowed to update QEP
+  {
+    if (best_key >= 0)
     {
-      /*
-	SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC
+      bool quick_created= 
+        (select && select->quick && select->quick!=save_quick);
 
-	Use a traversal function that starts by reading the last row
-	with key part (A) and then traverse the index backwards.
+      /* 
+         If ref_key used index tree reading only ('Using index' in EXPLAIN),
+         and best_key doesn't, then revert the decision.
       */
-      tab->read_first_record= join_read_last_key;
-      tab->read_record.read_record= join_read_prev_same;
+      if (!table->covering_keys.is_set(best_key))
+        table->set_keyread(FALSE);
+      if (!quick_created)
+      {
+        if (select)                  // Throw any existing quick select
+          select->quick= 0;          // Cleanup either reset to save_quick,
+                                     // or 'delete save_quick'
+        tab->index= best_key;
+        tab->read_first_record= order_direction > 0 ?
+                                join_read_first:join_read_last;
+        tab->type=JT_NEXT;           // Read with index_first(), index_next()
+
+        if (table->covering_keys.is_set(best_key))
+          table->set_keyread(TRUE);
+        if (tab->pre_idx_push_select_cond)
+        {
+          tab->set_cond(tab->pre_idx_push_select_cond, __LINE__);
+          /*
+            orig_select_cond is a part of pre_idx_push_select_cond,
+            no need to restore it.
+          */
+          orig_select_cond= 0;
+          orig_select_cond_saved= false;
+        }
+        table->file->ha_index_or_rnd_end();
+        if (tab->join->select_options & SELECT_DESCRIBE)
+        {
+          tab->ref.key= -1;
+          tab->ref.key_parts= 0;
+          if (select_limit < table->file->stats.records) 
+            tab->limit= select_limit;
+        }
+      }
+      else if (tab->type != JT_ALL)
+      {
+        /*
+          We're about to use a quick access to the table.
+          We need to change the access method so as the quick access
+          method is actually used.
+        */
+        DBUG_ASSERT(tab->select->quick);
+        tab->type=JT_ALL;
+        tab->use_quick=QS_RANGE;
+        tab->ref.key= -1;
+        tab->ref.key_parts=0;		// Don't use ref key.
+        tab->read_first_record= join_init_read_record;
+        if (tab->is_using_loose_index_scan())
+          tab->join->tmp_table_param.precomputed_group_by= TRUE;
+        /*
+          TODO: update the number of records in join->best_positions[tablenr]
+        */
+      }
+    } // best_key >= 0
+
+    if (order_direction == -1)		// If ORDER BY ... DESC
+    {
+      if (select && select->quick)
+      {
+        /* ORDER BY range_key DESC */
+        QUICK_SELECT_I *tmp= select->quick->make_reverse(used_key_parts);
+        if (!tmp)
+        {
+          tab->limit= 0;
+          goto use_filesort;            // Reverse sort failed -> filesort
+        }
+        if (select->quick == save_quick)
+          save_quick= 0;                // make_reverse() consumed it
+        select->set_quick(tmp);
+      }
+      else if (tab->type != JT_NEXT && tab->type != JT_REF_OR_NULL &&
+               tab->ref.key >= 0 && tab->ref.key_parts <= used_key_parts)
+      {
+        /*
+          SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC
+
+          Use a traversal function that starts by reading the last row
+          with key part (A) and then traverse the index backwards.
+        */
+        tab->read_first_record= join_read_last_key;
+        tab->read_record.read_record= join_read_prev_same;
+      }
     }
+    else if (select && select->quick)
+      select->quick->need_sorted_output();
+
+  } // QEP has been modified
+
+  /*
+    Cleanup:
+    We may have both a 'select->quick' and 'save_quick' (original)
+    at this point. Delete the one that we wan't use.
+  */
+
+skipped_filesort:
+  // Keep current (ordered) select->quick 
+  if (select && save_quick != select->quick)
+  {
+    delete save_quick;
+    save_quick= NULL;
   }
-  else if (select && select->quick)
-    select->quick->need_sorted_output();
   /*
     Restore condition only if we didn't chose index different to what we used
     for ICP.
@@ -20212,6 +20247,12 @@ check_reverse_order:                  
   DBUG_RETURN(1);
 
 use_filesort:
+  // Restore original save_quick
+  if (select && select->quick != save_quick)
+  {
+    delete select->quick;
+    select->quick= save_quick;
+  }
   if (orig_select_cond_saved)
     tab->set_cond(orig_select_cond, __LINE__);
   DBUG_RETURN(0);

=== modified file 'sql/sql_view.cc'
--- a/sql/sql_view.cc	2011-01-12 14:22:13 +0000
+++ b/sql/sql_view.cc	2011-02-08 15:54:12 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2011-02-02 22:02:29 +0000
+++ b/sql/sql_yacc.yy	2011-02-14 10:28:11 +0000
@@ -11,7 +11,8 @@
 
    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 */
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 
+   MA 02110-1301  USA */
 
 /* sql_yacc.yy */
 
@@ -1874,7 +1875,7 @@ change:
             /*
               Clear LEX_MASTER_INFO struct and allocate memory for
               repl_ignore_server_ids. repl_ignore_server_ids is freed
-              at the end of change_master. So it is guaranteed to be
+              in THD::cleanup_after_query.  So it is guaranteed to be
               uninitialized before here.
             */
             lex->mi.set_unspecified();

=== modified file 'storage/innobase/btr/btr0btr.c'
--- a/storage/innobase/btr/btr0btr.c	2011-01-25 09:24:38 +0000
+++ b/storage/innobase/btr/btr0btr.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2010, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/btr/btr0cur.c'
--- a/storage/innobase/btr/btr0cur.c	2011-01-28 09:15:39 +0000
+++ b/storage/innobase/btr/btr0cur.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by
@@ -197,7 +197,7 @@ static
 ulint
 btr_rec_get_externally_stored_len(
 /*==============================*/
-	rec_t*		rec,	/*!< in: record */
+	const rec_t*	rec,	/*!< in: record */
 	const ulint*	offsets);/*!< in: array returned by rec_get_offsets() */
 #endif /* !UNIV_HOTBACKUP */
 
@@ -1886,8 +1886,8 @@ btr_cur_update_in_place(
 		NOT call it if index is secondary */
 
 		if (!dict_index_is_clust(index)
-		    || row_upd_changes_ord_field_binary(NULL, NULL,
-							index, update)) {
+		    || row_upd_changes_ord_field_binary(index, update, thr,
+							NULL, NULL)) {
 
 			/* Remove possible hash index pointer to this record */
 			btr_search_update_hash_on_delete(cursor);
@@ -3765,34 +3765,62 @@ btr_estimate_number_of_different_key_val
 /*================== EXTERNAL STORAGE OF BIG FIELDS ===================*/
 
 /***********************************************************//**
+Gets the offset of the pointer to the externally stored part of a field.
+@return	offset of the pointer to the externally stored part */
+static
+ulint
+btr_rec_get_field_ref_offs(
+/*=======================*/
+	const ulint*	offsets,/*!< in: array returned by rec_get_offsets() */
+	ulint		n)	/*!< in: index of the external field */
+{
+	ulint	field_ref_offs;
+	ulint	local_len;
+
+	ut_a(rec_offs_nth_extern(offsets, n));
+	field_ref_offs = rec_get_nth_field_offs(offsets, n, &local_len);
+	ut_a(local_len != UNIV_SQL_NULL);
+	ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
+
+	return(field_ref_offs + local_len - BTR_EXTERN_FIELD_REF_SIZE);
+}
+
+/** Gets a pointer to the externally stored part of a field.
+@param rec	record
+@param offsets	rec_get_offsets(rec)
+@param n	index of the externally stored field
+@return pointer to the externally stored part */
+#define btr_rec_get_field_ref(rec, offsets, n)			\
+	((rec) + btr_rec_get_field_ref_offs(offsets, n))
+
+/***********************************************************//**
 Gets the externally stored size of a record, in units of a database page.
 @return	externally stored part, in units of a database page */
 static
 ulint
 btr_rec_get_externally_stored_len(
 /*==============================*/
-	rec_t*		rec,	/*!< in: record */
+	const rec_t*	rec,	/*!< in: record */
 	const ulint*	offsets)/*!< in: array returned by rec_get_offsets() */
 {
 	ulint	n_fields;
-	byte*	data;
-	ulint	local_len;
-	ulint	extern_len;
 	ulint	total_extern_len = 0;
 	ulint	i;
 
 	ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec));
+
+	if (!rec_offs_any_extern(offsets)) {
+		return(0);
+	}
+
 	n_fields = rec_offs_n_fields(offsets);
 
 	for (i = 0; i < n_fields; i++) {
 		if (rec_offs_nth_extern(offsets, i)) {
 
-			data = rec_get_nth_field(rec, offsets, i, &local_len);
-
-			local_len -= BTR_EXTERN_FIELD_REF_SIZE;
-
-			extern_len = mach_read_from_4(data + local_len
-						      + BTR_EXTERN_LEN + 4);
+			ulint	extern_len = mach_read_from_4(
+				btr_rec_get_field_ref(rec, offsets, i)
+				+ BTR_EXTERN_LEN + 4);
 
 			total_extern_len += ut_calc_align(extern_len,
 							  UNIV_PAGE_SIZE);
@@ -3822,7 +3850,7 @@ btr_cur_set_ownership_of_extern_field(
 	ulint	byte_val;
 
 	data = rec_get_nth_field(rec, offsets, i, &local_len);
-
+	ut_ad(rec_offs_nth_extern(offsets, i));
 	ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
 
 	local_len -= BTR_EXTERN_FIELD_REF_SIZE;
@@ -3832,6 +3860,9 @@ btr_cur_set_ownership_of_extern_field(
 	if (val) {
 		byte_val = byte_val & (~BTR_EXTERN_OWNER_FLAG);
 	} else {
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+		ut_a(!(byte_val & BTR_EXTERN_OWNER_FLAG));
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
 		byte_val = byte_val | BTR_EXTERN_OWNER_FLAG;
 	}
 
@@ -4068,8 +4099,8 @@ file segment of the index tree.
 @return	DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
 UNIV_INTERN
 ulint
-btr_store_big_rec_extern_fields(
-/*============================*/
+btr_store_big_rec_extern_fields_func(
+/*=================================*/
 	dict_index_t*	index,		/*!< in: index of rec; the index tree
 					MUST be X-latched */
 	buf_block_t*	rec_block,	/*!< in/out: block containing rec */
@@ -4078,11 +4109,17 @@ btr_store_big_rec_extern_fields(
 					the "external storage" flags in offsets
 					will not correspond to rec when
 					this function returns */
-	big_rec_t*	big_rec_vec,	/*!< in: vector containing fields
+#ifdef UNIV_DEBUG
+	mtr_t*		local_mtr,	/*!< in: mtr containing the
+					latch to rec and to the tree */
+#endif /* UNIV_DEBUG */
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+	ibool		update_in_place,/*! in: TRUE if the record is updated
+					in place (not delete+insert) */
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
+	const big_rec_t*big_rec_vec)	/*!< in: vector containing fields
 					to be stored externally */
-	mtr_t*		local_mtr __attribute__((unused))) /*!< in: mtr
-					containing the latch to rec and to the
-					tree */
+
 {
 	ulint	rec_page_no;
 	byte*	field_ref;
@@ -4100,6 +4137,7 @@ btr_store_big_rec_extern_fields(
 	z_stream c_stream;
 
 	ut_ad(rec_offs_validate(rec, index, offsets));
+	ut_ad(rec_offs_any_extern(offsets));
 	ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
 				MTR_MEMO_X_LOCK));
 	ut_ad(mtr_memo_contains(local_mtr, rec_block, MTR_MEMO_PAGE_X_FIX));
@@ -4131,21 +4169,37 @@ btr_store_big_rec_extern_fields(
 		ut_a(err == Z_OK);
 	}
 
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+	/* All pointers to externally stored columns in the record
+	must either be zero or they must be pointers to inherited
+	columns, owned by this record or an earlier record version. */
+	for (i = 0; i < rec_offs_n_fields(offsets); i++) {
+		if (!rec_offs_nth_extern(offsets, i)) {
+			continue;
+		}
+		field_ref = btr_rec_get_field_ref(rec, offsets, i);
+
+		ut_a(!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG));
+		/* Either this must be an update in place,
+		or the BLOB must be inherited, or the BLOB pointer
+		must be zero (will be written in this function). */
+		ut_a(update_in_place
+		     || (field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_INHERITED_FLAG)
+		     || !memcmp(field_ref, field_ref_zero,
+				BTR_EXTERN_FIELD_REF_SIZE));
+	}
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
 	/* We have to create a file segment to the tablespace
 	for each field and put the pointer to the field in rec */
 
 	for (i = 0; i < big_rec_vec->n_fields; i++) {
-		ut_ad(rec_offs_nth_extern(offsets,
-					  big_rec_vec->fields[i].field_no));
-		{
-			ulint	local_len;
-			field_ref = rec_get_nth_field(
-				rec, offsets, big_rec_vec->fields[i].field_no,
-				&local_len);
-			ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
-			local_len -= BTR_EXTERN_FIELD_REF_SIZE;
-			field_ref += local_len;
-		}
+		field_ref = btr_rec_get_field_ref(
+			rec, offsets, big_rec_vec->fields[i].field_no);
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+		/* A zero BLOB pointer should have been initially inserted. */
+		ut_a(!memcmp(field_ref, field_ref_zero,
+			     BTR_EXTERN_FIELD_REF_SIZE));
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
 		extern_len = big_rec_vec->fields[i].len;
 		UNIV_MEM_ASSERT_RW(big_rec_vec->fields[i].data,
 				   extern_len);
@@ -4427,6 +4481,23 @@ next_zip_page:
 		mem_heap_free(heap);
 	}
 
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+	/* All pointers to externally stored columns in the record
+	must be valid. */
+	for (i = 0; i < rec_offs_n_fields(offsets); i++) {
+		if (!rec_offs_nth_extern(offsets, i)) {
+			continue;
+		}
+
+		field_ref = btr_rec_get_field_ref(rec, offsets, i);
+
+		/* The pointer must not be zero. */
+		ut_a(0 != memcmp(field_ref, field_ref_zero,
+				 BTR_EXTERN_FIELD_REF_SIZE));
+		/* The column must not be disowned by this record. */
+		ut_a(!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG));
+	}
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
 	return(DB_SUCCESS);
 }
 
@@ -4449,6 +4520,7 @@ btr_check_blob_fil_page_type(
 	if (UNIV_UNLIKELY(type != FIL_PAGE_TYPE_BLOB)) {
 		ulint	flags = fil_space_get_flags(space_id);
 
+#ifndef UNIV_DEBUG /* Improve debug test coverage */
 		if (UNIV_LIKELY
 		    ((flags & DICT_TF_FORMAT_MASK) == DICT_TF_FORMAT_51)) {
 			/* Old versions of InnoDB did not initialize
@@ -4457,6 +4529,7 @@ btr_check_blob_fil_page_type(
 			a BLOB page that is in Antelope format.*/
 			return;
 		}
+#endif /* !UNIV_DEBUG */
 
 		ut_print_timestamp(stderr);
 		fprintf(stderr,
@@ -4506,23 +4579,13 @@ btr_free_externally_stored_field(
 	ulint		page_no;
 	ulint		next_page_no;
 	mtr_t		mtr;
-#ifdef UNIV_DEBUG
+
 	ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
 				MTR_MEMO_X_LOCK));
 	ut_ad(mtr_memo_contains_page(local_mtr, field_ref,
 				     MTR_MEMO_PAGE_X_FIX));
 	ut_ad(!rec || rec_offs_validate(rec, index, offsets));
-
-	if (rec) {
-		ulint	local_len;
-		const byte*	f = rec_get_nth_field(rec, offsets,
-						      i, &local_len);
-		ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
-		local_len -= BTR_EXTERN_FIELD_REF_SIZE;
-		f += local_len;
-		ut_ad(f == field_ref);
-	}
-#endif /* UNIV_DEBUG */
+	ut_ad(!rec || field_ref == btr_rec_get_field_ref(rec, offsets, i));
 
 	if (UNIV_UNLIKELY(!memcmp(field_ref, field_ref_zero,
 				  BTR_EXTERN_FIELD_REF_SIZE))) {
@@ -4685,13 +4748,8 @@ btr_rec_free_externally_stored_fields(
 
 	for (i = 0; i < n_fields; i++) {
 		if (rec_offs_nth_extern(offsets, i)) {
-			ulint	len;
-			byte*	data
-				= rec_get_nth_field(rec, offsets, i, &len);
-			ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
-
 			btr_free_externally_stored_field(
-				index, data + len - BTR_EXTERN_FIELD_REF_SIZE,
+				index, btr_rec_get_field_ref(rec, offsets, i),
 				rec, offsets, page_zip, i, rb_ctx, mtr);
 		}
 	}

=== modified file 'storage/innobase/btr/btr0sea.c'
--- a/storage/innobase/btr/btr0sea.c	2011-01-25 09:24:38 +0000
+++ b/storage/innobase/btr/btr0sea.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by

=== modified file 'storage/innobase/buf/buf0buddy.c'
--- a/storage/innobase/buf/buf0buddy.c	2011-01-25 09:24:38 +0000
+++ b/storage/innobase/buf/buf0buddy.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 2006, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 2006, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/buf/buf0buf.c'
--- a/storage/innobase/buf/buf0buf.c	2011-01-25 09:24:38 +0000
+++ b/storage/innobase/buf/buf0buf.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by
@@ -873,9 +873,9 @@ buf_block_init(
 
 	block->modify_clock = 0;
 
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	block->page.file_page_was_freed = FALSE;
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 
 	block->check_index_page_at_flush = FALSE;
 	block->index = NULL;
@@ -2344,7 +2344,7 @@ buf_page_peek_if_search_hashed(
 	return(is_hashed);
 }
 
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 /********************************************************************//**
 Sets file_page_was_freed TRUE if the page is found in the buffer pool.
 This function should be called when we free a file page and want the
@@ -2367,6 +2367,8 @@ buf_page_set_file_page_was_freed(
 
 	if (bpage) {
 		ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage));
+		/* bpage->file_page_was_freed can already hold
+		when this code is invoked from dict_drop_index_tree() */
 		bpage->file_page_was_freed = TRUE;
 		rw_lock_s_unlock(hash_lock);
 	}
@@ -2401,7 +2403,7 @@ buf_page_reset_file_page_was_freed(
 
 	return(bpage);
 }
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 
 /********************************************************************//**
 Attempts to discard the uncompressed frame of a compressed page. The
@@ -2539,7 +2541,7 @@ got_block:
 
 	buf_page_set_accessed_make_young(bpage, access_time);
 
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	ut_a(!bpage->file_page_was_freed);
 #endif
 
@@ -3273,7 +3275,7 @@ wait_until_unfixed:
 
 	buf_page_set_accessed_make_young(&block->page, access_time);
 
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	ut_a(!block->page.file_page_was_freed);
 #endif
 
@@ -3436,7 +3438,7 @@ buf_page_optimistic_get(
 	ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
 #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
 
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	ut_a(block->page.file_page_was_freed == FALSE);
 #endif
 	if (UNIV_UNLIKELY(!access_time)) {
@@ -3548,7 +3550,7 @@ buf_page_get_known_nowait(
 	ut_a(block->page.buf_fix_count > 0);
 	ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
 #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	ut_a(block->page.file_page_was_freed == FALSE);
 #endif
 
@@ -3637,9 +3639,9 @@ buf_page_try_get_func(
 	ut_a(block->page.buf_fix_count > 0);
 	ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
 #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	ut_a(block->page.file_page_was_freed == FALSE);
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 	buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
 
 	buf_pool->stat.n_page_gets++;
@@ -3668,9 +3670,9 @@ buf_page_init_low(
 	bpage->newest_modification = 0;
 	bpage->oldest_modification = 0;
 	HASH_INVALIDATE(bpage, hash);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	bpage->file_page_was_freed = FALSE;
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 }
 
 /********************************************************************//**
@@ -4057,9 +4059,9 @@ buf_page_create(
 #ifdef UNIV_IBUF_COUNT_DEBUG
 		ut_a(ibuf_count_get(space, offset) == 0);
 #endif
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 		block->page.file_page_was_freed = FALSE;
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 
 		/* Page can be found in buf_pool */
 		buf_pool_mutex_exit(buf_pool);

=== modified file 'storage/innobase/buf/buf0lru.c'
--- a/storage/innobase/buf/buf0lru.c	2011-01-25 09:24:38 +0000
+++ b/storage/innobase/buf/buf0lru.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/dict/dict0dict.c'
--- a/storage/innobase/dict/dict0dict.c	2011-01-15 08:31:58 +0000
+++ b/storage/innobase/dict/dict0dict.c	2011-02-08 17:33:31 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2010, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -1281,7 +1281,7 @@ dict_table_rename_in_cache(
 	dict_foreign_t*	foreign;
 	dict_index_t*	index;
 	ulint		fold;
-	char		old_name[MAX_TABLE_NAME_LEN + 1];
+	char		old_name[MAX_FULL_NAME_LEN + 1];
 
 	ut_ad(table);
 	ut_ad(mutex_own(&(dict_sys->mutex)));
@@ -1293,7 +1293,7 @@ dict_table_rename_in_cache(
 		ut_print_timestamp(stderr);
 		fprintf(stderr, "InnoDB: too long table name: '%s', "
 			"max length is %d\n", table->name,
-			MAX_TABLE_NAME_LEN);
+			MAX_FULL_NAME_LEN);
 		ut_error;
 	}
 
@@ -1343,11 +1343,11 @@ dict_table_rename_in_cache(
 		    ut_fold_string(old_name), table);
 
 	if (strlen(new_name) > strlen(table->name)) {
-		/* We allocate MAX_TABLE_NAME_LEN+1 bytes here to avoid
+		/* We allocate MAX_FULL_NAME_LEN + 1 bytes here to avoid
 		memory fragmentation, we assume a repeated calls of
 		ut_realloc() with the same size do not cause fragmentation */
-		ut_a(strlen(new_name) <= MAX_TABLE_NAME_LEN);
-		table->name = ut_realloc(table->name, MAX_TABLE_NAME_LEN + 1);
+		ut_a(strlen(new_name) <= MAX_FULL_NAME_LEN);
+		table->name = ut_realloc(table->name, MAX_FULL_NAME_LEN + 1);
 	}
 	memcpy(table->name, new_name, strlen(new_name) + 1);
 

=== modified file 'storage/innobase/dict/dict0load.c'
--- a/storage/innobase/dict/dict0load.c	2011-01-17 12:20:52 +0000
+++ b/storage/innobase/dict/dict0load.c	2011-02-04 15:04:19 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -1550,7 +1550,7 @@ err_len:
 				"InnoDB: in InnoDB data dictionary"
 				" has unknown type %lx.\n",
 				(ulong) flags);
-			return(NULL);
+			return("incorrect flags in SYS_TABLES");
 		}
 	} else {
 		flags = 0;

=== modified file 'storage/innobase/dict/dict0stats.c'
--- a/storage/innobase/dict/dict0stats.c	2011-01-15 08:31:58 +0000
+++ b/storage/innobase/dict/dict0stats.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 2009, 2010, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2009, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/fsp/fsp0fsp.c'
--- a/storage/innobase/fsp/fsp0fsp.c	2011-01-06 07:21:08 +0000
+++ b/storage/innobase/fsp/fsp0fsp.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -3419,9 +3419,9 @@ fseg_free_page(
 
 	fseg_free_page_low(seg_inode, space, zip_size, page, mtr);
 
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	buf_page_set_file_page_was_freed(space, page);
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 }
 
 /**********************************************************************//**
@@ -3487,13 +3487,13 @@ fseg_free_extent(
 
 	fsp_free_extent(space, zip_size, page, mtr);
 
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	for (i = 0; i < FSP_EXTENT_SIZE; i++) {
 
 		buf_page_set_file_page_was_freed(space,
 						 first_page_in_extent + i);
 	}
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 }
 
 /**********************************************************************//**

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2011-01-30 16:56:39 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2011-02-08 17:33:31 +0000
@@ -2266,9 +2266,14 @@ ha_innobase::reset_template(void)
 
 	prebuilt->keep_other_fields_on_keyread = 0;
 	prebuilt->read_just_key = 0;
-	/* Reset index condition pushdown state */
-	prebuilt->idx_cond = NULL;
-	prebuilt->idx_cond_n_cols = 0;
+	/* Reset index condition pushdown state. */
+	if (prebuilt->idx_cond) {
+		prebuilt->idx_cond = NULL;
+		prebuilt->idx_cond_n_cols = 0;
+		/* Invalidate prebuilt->mysql_template
+		in ha_innobase::write_row(). */
+		prebuilt->template_type = ROW_MYSQL_NO_TEMPLATE;
+	}
 }
 
 /*****************************************************************//**
@@ -6659,6 +6664,17 @@ create_table_def(
 		DBUG_RETURN(HA_ERR_GENERIC);
 	}
 
+	/* MySQL does the name length check. But we do additional check
+	on the name length here */
+	if (strlen(table_name) > MAX_FULL_NAME_LEN) {
+		push_warning_printf(
+			(THD*) trx->mysql_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+			ER_TABLE_NAME,
+			"InnoDB: Table Name or Database Name is too long");
+
+		DBUG_RETURN(ER_TABLE_NAME);
+	}
+
 	n_cols = form->s->fields;
 
 	/* We pass 0 as the space id, and determine at a lower level the space

=== modified file 'storage/innobase/handler/handler0alter.cc'
--- a/storage/innobase/handler/handler0alter.cc	2011-01-26 13:57:04 +0000
+++ b/storage/innobase/handler/handler0alter.cc	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 2005, 2010, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2005, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/handler/i_s.cc'
--- a/storage/innobase/handler/i_s.cc	2011-01-07 04:06:36 +0000
+++ b/storage/innobase/handler/i_s.cc	2011-02-08 17:33:31 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 2007, 2010, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2007, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -857,16 +857,7 @@ fill_innodb_locks_from_cache(
 	for (i = 0; i < rows_num; i++) {
 
 		i_s_locks_row_t*	row;
-
-		/* note that the decoded database or table name is
-		never expected to be longer than NAME_LEN;
-		NAME_LEN for database name
-		2 for surrounding quotes around database name
-		NAME_LEN for table name
-		2 for surrounding quotes around table name
-		1 for the separating dot (.)
-		9 for the #mysql50# prefix */
-		char			buf[2 * NAME_LEN + 14];
+		char			buf[MAX_FULL_NAME_LEN + 1];
 		const char*		bufend;
 
 		char			lock_trx_id[TRX_ID_MAX_LEN + 1];
@@ -3283,19 +3274,6 @@ i_s_innodb_buffer_page_get_info(
 		page_type = fil_page_get_type(frame);
 
 		i_s_innodb_set_page_type(page_info, page_type, frame);
-
-	} else if (page_info->page_state == BUF_BLOCK_MEMORY) {
-		const byte*	frame;
-		const buf_block_t*block;
-		ulint		page_type;
-
-		block = reinterpret_cast<const buf_block_t*>(bpage);
-
-		frame = block->frame;
-
-		page_type = fil_page_get_type(frame);
-
-		i_s_innodb_set_page_type(page_info, page_type, frame);
 	} else {
 		page_info->page_type = I_S_PAGE_TYPE_UNKNOWN;
 	}
@@ -4066,7 +4044,7 @@ static ST_FIELD_INFO	innodb_sys_tables_f
 
 #define SYS_TABLE_NAME		1
 	{STRUCT_FLD(field_name,		"NAME"),
-	 STRUCT_FLD(field_length,	NAME_LEN + 1),
+	 STRUCT_FLD(field_length,	MAX_FULL_NAME_LEN + 1),
 	 STRUCT_FLD(field_type,		MYSQL_TYPE_STRING),
 	 STRUCT_FLD(value,		0),
 	 STRUCT_FLD(field_flags,	0),

=== modified file 'storage/innobase/ibuf/ibuf0ibuf.c'
--- a/storage/innobase/ibuf/ibuf0ibuf.c	2011-01-27 08:19:06 +0000
+++ b/storage/innobase/ibuf/ibuf0ibuf.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1997, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -2276,9 +2276,9 @@ ibuf_remove_free_page(void)
 	fseg_free_page(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
 		       IBUF_SPACE_ID, page_no, &mtr);
 
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	buf_page_reset_file_page_was_freed(IBUF_SPACE_ID, page_no);
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 
 	ibuf_enter();
 
@@ -2322,9 +2322,9 @@ ibuf_remove_free_page(void)
 	ibuf_bitmap_page_set_bits(
 		bitmap_page, page_no, zip_size, IBUF_BITMAP_IBUF, FALSE, &mtr);
 
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	buf_page_set_file_page_was_freed(IBUF_SPACE_ID, page_no);
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 	mtr_commit(&mtr);
 
 	ibuf_exit();

=== modified file 'storage/innobase/include/btr0cur.h'
--- a/storage/innobase/include/btr0cur.h	2011-01-15 08:31:58 +0000
+++ b/storage/innobase/include/btr0cur.h	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -501,8 +501,8 @@ file segment of the index tree.
 @return	DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
 UNIV_INTERN
 ulint
-btr_store_big_rec_extern_fields(
-/*============================*/
+btr_store_big_rec_extern_fields_func(
+/*=================================*/
 	dict_index_t*	index,		/*!< in: index of rec; the index tree
 					MUST be X-latched */
 	buf_block_t*	rec_block,	/*!< in/out: block containing rec */
@@ -511,10 +511,42 @@ btr_store_big_rec_extern_fields(
 					the "external storage" flags in offsets
 					will not correspond to rec when
 					this function returns */
-	big_rec_t*	big_rec_vec,	/*!< in: vector containing fields
+#ifdef UNIV_DEBUG
+	mtr_t*		local_mtr,	/*!< in: mtr containing the
+					latch to rec and to the tree */
+#endif /* UNIV_DEBUG */
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+	ibool		update_in_place,/*! in: TRUE if the record is updated
+					in place (not delete+insert) */
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
+	const big_rec_t*big_rec_vec)	/*!< in: vector containing fields
 					to be stored externally */
-	mtr_t*		local_mtr);	/*!< in: mtr containing the latch to
-					rec and to the tree */
+	__attribute__((nonnull));
+
+/** Stores the fields in big_rec_vec to the tablespace and puts pointers to
+them in rec.  The extern flags in rec will have to be set beforehand.
+The fields are stored on pages allocated from leaf node
+file segment of the index tree.
+@param index	in: clustered index; MUST be X-latched by mtr
+@param b	in/out: block containing rec; MUST be X-latched by mtr
+@param rec	in/out: clustered index record
+@param offsets	in: rec_get_offsets(rec, index);
+		the "external storage" flags in offsets will not be adjusted
+@param mtr	in: mini-transaction that holds x-latch on index and b
+@param upd	in: TRUE if the record is updated in place (not delete+insert)
+@param big	in: vector containing fields to be stored externally
+@return	DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
+#ifdef UNIV_DEBUG
+# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
+	btr_store_big_rec_extern_fields_func(index,b,rec,offsets,mtr,upd,big)
+#elif defined UNIV_BLOB_LIGHT_DEBUG
+# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
+	btr_store_big_rec_extern_fields_func(index,b,rec,offsets,upd,big)
+#else
+# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
+	btr_store_big_rec_extern_fields_func(index,b,rec,offsets,big)
+#endif
+
 /*******************************************************************//**
 Frees the space in an externally stored field to the file space
 management if the field in data is owned the externally stored field,

=== modified file 'storage/innobase/include/buf0buf.h'
--- a/storage/innobase/include/buf0buf.h	2011-01-25 09:24:38 +0000
+++ b/storage/innobase/include/buf0buf.h	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -485,7 +485,7 @@ buf_reset_check_index_page_at_flush(
 /*================================*/
 	ulint	space,	/*!< in: space id */
 	ulint	offset);/*!< in: page number */
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 /********************************************************************//**
 Sets file_page_was_freed TRUE if the page is found in the buffer pool.
 This function should be called when we free a file page and want the
@@ -510,7 +510,7 @@ buf_page_reset_file_page_was_freed(
 /*===============================*/
 	ulint	space,	/*!< in: space id */
 	ulint	offset);	/*!< in: page number */
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 /********************************************************************//**
 Reads the freed_page_clock of a buffer block.
 @return	freed_page_clock */
@@ -1491,11 +1491,11 @@ struct buf_page_struct{
 					0 if the block was never accessed
 					in the buffer pool */
 	/* @} */
-# ifdef UNIV_DEBUG_FILE_ACCESSES
+# if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	ibool		file_page_was_freed;
 					/*!< this is set to TRUE when fsp
 					frees a page in buffer pool */
-# endif /* UNIV_DEBUG_FILE_ACCESSES */
+# endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 #endif /* !UNIV_HOTBACKUP */
 };
 

=== modified file 'storage/innobase/include/buf0lru.h'
--- a/storage/innobase/include/buf0lru.h	2011-01-25 09:24:38 +0000
+++ b/storage/innobase/include/buf0lru.h	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/include/dict0types.h'
--- a/storage/innobase/include/dict0types.h	2011-01-17 12:15:40 +0000
+++ b/storage/innobase/include/dict0types.h	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/include/os0sync.h'
--- a/storage/innobase/include/os0sync.h	2011-01-21 04:22:26 +0000
+++ b/storage/innobase/include/os0sync.h	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by

=== modified file 'storage/innobase/include/os0sync.ic'
--- a/storage/innobase/include/os0sync.ic	2011-01-21 04:22:26 +0000
+++ b/storage/innobase/include/os0sync.ic	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/include/rem0cmp.h'
--- a/storage/innobase/include/rem0cmp.h	2011-01-15 08:31:58 +0000
+++ b/storage/innobase/include/rem0cmp.h	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/include/rem0cmp.ic'
--- a/storage/innobase/include/rem0cmp.ic	2011-01-15 08:31:58 +0000
+++ b/storage/innobase/include/rem0cmp.ic	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/include/row0upd.h'
--- a/storage/innobase/include/row0upd.h	2010-12-21 12:49:41 +0000
+++ b/storage/innobase/include/row0upd.h	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -280,19 +280,29 @@ NOTE: we compare the fields as binary st
 @return TRUE if update vector changes an ordering field in the index record */
 UNIV_INTERN
 ibool
-row_upd_changes_ord_field_binary(
-/*=============================*/
+row_upd_changes_ord_field_binary_func(
+/*==================================*/
+	dict_index_t*	index,	/*!< in: index of the record */
+	const upd_t*	update,	/*!< in: update vector for the row; NOTE: the
+				field numbers in this MUST be clustered index
+				positions! */
+#ifdef UNIV_DEBUG
+	const que_thr_t*thr,	/*!< in: query thread */
+#endif /* UNIV_DEBUG */
 	const dtuple_t*	row,	/*!< in: old value of row, or NULL if the
 				row and the data values in update are not
 				known when this function is called, e.g., at
 				compile time */
-	const row_ext_t*ext,	/*!< NULL, or prefixes of the externally
+	const row_ext_t*ext)	/*!< NULL, or prefixes of the externally
 				stored columns in the old row */
-	dict_index_t*	index,	/*!< in: index of the record */
-	const upd_t*	update)	/*!< in: update vector for the row; NOTE: the
-				field numbers in this MUST be clustered index
-				positions! */
-	__attribute__((nonnull(3,4), warn_unused_result));
+	__attribute__((nonnull(1,2), warn_unused_result));
+#ifdef UNIV_DEBUG
+# define row_upd_changes_ord_field_binary(index,update,thr,row,ext)	\
+	row_upd_changes_ord_field_binary_func(index,update,thr,row,ext)
+#else /* UNIV_DEBUG */
+# define row_upd_changes_ord_field_binary(index,update,thr,row,ext)	\
+	row_upd_changes_ord_field_binary_func(index,update,row,ext)
+#endif /* UNIV_DEBUG */
 /***********************************************************//**
 Checks if an update vector changes an ordering field of an index record.
 This function is fast if the update vector is short or the number of ordering

=== modified file 'storage/innobase/include/srv0srv.h'
--- a/storage/innobase/include/srv0srv.h	2011-01-27 09:48:41 +0000
+++ b/storage/innobase/include/srv0srv.h	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2010, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, 2009, Google Inc.
 Copyright (c) 2009, Percona Inc.
 

=== modified file 'storage/innobase/include/trx0trx.h'
--- a/storage/innobase/include/trx0trx.h	2011-01-27 11:45:15 +0000
+++ b/storage/innobase/include/trx0trx.h	2011-01-30 21:11:14 +0000
@@ -319,13 +319,17 @@ trx_set_dict_operation(
 Determines if a transaction is in the given state.
 The caller must hold trx_sys->lock, or it must be the thread
 that is serving a running transaction.
+A running transaction must be in trx_sys->trx_list.
 @return	TRUE if trx->state == state */
 UNIV_INLINE
 ibool
 trx_state_eq(
 /*=========*/
 	const trx_t*	trx,	/*!< in: transaction */
-	trx_state_t	state)	/*!< in: state */
+	trx_state_t	state)	/*!< in: state;
+				if state != TRX_STATE_NOT_STARTED
+				asserts that
+				trx->state != TRX_STATE_NOT_STARTED */
 	__attribute__((nonnull, warn_unused_result));
 # ifdef UNIV_DEBUG
 /**********************************************************************//**

=== modified file 'storage/innobase/include/trx0trx.ic'
--- a/storage/innobase/include/trx0trx.ic	2011-01-24 10:28:28 +0000
+++ b/storage/innobase/include/trx0trx.ic	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -27,13 +27,17 @@ Created 3/26/1996 Heikki Tuuri
 Determines if a transaction is in the given state.
 The caller must hold trx_sys->lock, or it must be the thread
 that is serving a running transaction.
+A running transaction must be in trx_sys->trx_list.
 @return	TRUE if trx->state == state */
 UNIV_INLINE
 ibool
 trx_state_eq(
 /*=========*/
 	const trx_t*	trx,	/*!< in: transaction */
-	trx_state_t	state)	/*!< in: state */
+	trx_state_t	state)	/*!< in: state;
+				if state != TRX_STATE_NOT_STARTED
+				asserts that
+				trx->state != TRX_STATE_NOT_STARTED */
 {
 #ifdef UNIV_DEBUG
 	switch (trx->state) {

=== modified file 'storage/innobase/include/univ.i'
--- a/storage/innobase/include/univ.i	2011-01-21 16:14:47 +0000
+++ b/storage/innobase/include/univ.i	2011-02-08 17:34:42 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 Copyright (c) 2009, Sun Microsystems, Inc.
 
@@ -179,14 +179,15 @@ command. Not tested on Windows. */
 						debugging without UNIV_DEBUG */
 #define UNIV_BUF_DEBUG				/* Enable buffer pool
 						debugging without UNIV_DEBUG */
+#define UNIV_BLOB_LIGHT_DEBUG			/* Enable off-page column
+						debugging without UNIV_DEBUG */
 #define UNIV_DEBUG				/* Enable ut_ad() assertions
 						and disable UNIV_INLINE */
 #define UNIV_DEBUG_LOCK_VALIDATE		/* Enable
 						ut_ad(lock_rec_validate_page())
 						assertions. */
-#define UNIV_DEBUG_FILE_ACCESSES		/* Debug .ibd file access
-						(field file_page_was_freed
-						in buf_page_t) */
+#define UNIV_DEBUG_FILE_ACCESSES		/* Enable freed block access
+						debugging without UNIV_DEBUG */
 #define UNIV_LRU_DEBUG				/* debug the buffer pool LRU */
 #define UNIV_HASH_DEBUG				/* debug HASH_ macros */
 #define UNIV_LIST_DEBUG				/* debug UT_LIST_ macros */
@@ -313,6 +314,14 @@ longer names internally */
 the MySQL's NAME_LEN, see check_and_convert_db_name(). */
 #define MAX_DATABASE_NAME_LEN	MAX_TABLE_NAME_LEN
 
+/* MAX_FULL_NAME_LEN defines the full name path including the
+database name and table name. In addition, 14 bytes is added for:
+	2 for surrounding quotes around table name
+	1 for the separating dot (.)
+	9 for the #mysql50# prefix */
+#define MAX_FULL_NAME_LEN				\
+	(MAX_TABLE_NAME_LEN + MAX_DATABASE_NAME_LEN + 14)
+
 /*
 			UNIVERSAL TYPE DEFINITIONS
 			==========================

=== modified file 'storage/innobase/include/ut0vec.h'
--- a/storage/innobase/include/ut0vec.h	2010-07-16 21:00:50 +0000
+++ b/storage/innobase/include/ut0vec.h	2010-11-30 11:03:30 +0000
@@ -94,6 +94,25 @@ ib_vector_get(
 	ulint		n);	/*!< in: element index to get */
 
 /****************************************************************//**
+Get last element. The vector must not be empty.
+@return	last element */
+UNIV_INLINE
+void*
+ib_vector_get_last(
+/*===============*/
+	ib_vector_t*	vec);	/*!< in: vector */
+
+/****************************************************************//**
+Set the n'th element. */
+UNIV_INLINE
+void
+ib_vector_set(
+/*==========*/
+	ib_vector_t*	vec,	/*!< in/out: vector */
+	ulint		n,	/*!< in: element index to set */
+	void*		elem);	/*!< in: data element */
+
+/****************************************************************//**
 Remove the last element from the vector. */
 UNIV_INLINE
 void*

=== modified file 'storage/innobase/include/ut0vec.ic'
--- a/storage/innobase/include/ut0vec.ic	2010-07-16 21:00:50 +0000
+++ b/storage/innobase/include/ut0vec.ic	2010-11-30 11:03:30 +0000
@@ -51,6 +51,35 @@ ib_vector_get(
 }
 
 /****************************************************************//**
+Get last element. The vector must not be empty.
+@return	last element */
+UNIV_INLINE
+void*
+ib_vector_get_last(
+/*===============*/
+	ib_vector_t*	vec)	/*!< in: vector */
+{
+	ut_a(vec->used > 0);
+
+	return(vec->data[vec->used - 1]);
+}
+
+/****************************************************************//**
+Set the n'th element. */
+UNIV_INLINE
+void
+ib_vector_set(
+/*==========*/
+	ib_vector_t*	vec,	/*!< in/out: vector */
+	ulint		n,	/*!< in: element index to set */
+	void*		elem)	/*!< in: data element */
+{
+	ut_a(n < vec->used);
+
+	vec->data[n] = elem;
+}
+
+/****************************************************************//**
 Remove the last element from the vector.
 @return	last vector element */
 UNIV_INLINE

=== modified file 'storage/innobase/lock/lock0lock.c'
--- a/storage/innobase/lock/lock0lock.c	2011-01-27 08:15:24 +0000
+++ b/storage/innobase/lock/lock0lock.c	2011-02-08 17:33:31 +0000
@@ -2261,14 +2261,13 @@ lock_grant(
 {
 	ut_ad(lock_mutex_own());
 
-	trx_mutex_enter(lock->trx);
-
 	lock_reset_lock_and_trx_wait(lock);
+	trx_mutex_enter(lock->trx);
 
 	if (lock_get_mode(lock) == LOCK_AUTO_INC) {
 		dict_table_t*	table = lock->un_member.tab_lock.table;
 
-		if (table->autoinc_trx == lock->trx) {
+		if (UNIV_UNLIKELY(table->autoinc_trx == lock->trx)) {
 			fprintf(stderr,
 				"InnoDB: Error: trx already had"
 				" an AUTO-INC lock!\n");
@@ -2319,8 +2318,6 @@ lock_rec_cancel(
 	ut_ad(lock_mutex_own());
 	ut_ad(lock_get_type_low(lock) == LOCK_REC);
 
-	trx_mutex_enter(lock->trx);
-
 	/* Reset the bit (there can be only one set bit) in the lock bitmap */
 	lock_rec_reset_nth_bit(lock, lock_rec_find_set_bit(lock));
 
@@ -2330,6 +2327,8 @@ lock_rec_cancel(
 
 	/* The following function releases the trx from lock wait */
 
+	trx_mutex_enter(lock->trx);
+
 	thr = que_thr_end_lock_wait(lock->trx);
 
 	if (thr != NULL) {
@@ -3488,7 +3487,6 @@ lock_deadlock_occurs(
 	trx_t*	trx)	/*!< in/out: transaction */
 {
 	trx_t*		mark_trx;
-	ulint		ret;
 	ulint		cost	= 0;
 
 	ut_ad(trx);
@@ -3520,15 +3518,22 @@ retry:
 
 	trx_mutex_enter(trx);
 
-	ret = lock_deadlock_recursive(trx, trx, lock, &cost, 0);
-
-	switch (ret) {
+	switch (lock_deadlock_recursive(trx, trx, lock, &cost, 0)) {
 	case LOCK_VICTIM_IS_OTHER:
 		/* We chose some other trx as a victim: retry if there still
 		is a deadlock */
 		goto retry;
 
 	case LOCK_VICTIM_EXCEED_MAX_DEPTH:
+		/* Release the mutex to obey the latching order.
+		This is safe, because lock_deadlock_occurs() is invoked
+		when a lock wait is enqueued for the currently running
+		transaction. Because trx is a running transaction
+		(it is not currently suspended because of a lock wait),
+		its state can only be changed by this thread, which is
+		currently associated with the transaction. */
+		trx_mutex_exit(trx);
+
 		/* If the lock search exceeds the max step
 		or the max depth, the current trx will be
 		the victim. Print its information. */
@@ -3540,32 +3545,31 @@ retry:
 			" FOLLOWING TRANSACTION \n\n"
 			"*** TRANSACTION:\n");
 
-		/* To obey the latching order */
-		trx_mutex_exit(trx);
-
 		lock_deadlock_trx_print(trx, 3000);
 
-		trx_mutex_enter(trx);
-
 		lock_deadlock_fputs(
 			"*** WAITING FOR THIS LOCK TO BE GRANTED:\n");
 
 		lock_deadlock_lock_print(lock);
 
+		trx_mutex_enter(trx);
 		break;
 
 	case LOCK_VICTIM_IS_START:
 		lock_deadlock_fputs("*** WE ROLL BACK TRANSACTION (2)\n");
 		break;
 
-	default:
-		/* No deadlock detected*/
+	case LOCK_VICTIM_NONE:
+		/* No deadlock detected */
+		ut_ad(trx_mutex_own(trx));
+		ut_ad(lock_mutex_own());
 		return(FALSE);
 	}
 
 	lock_deadlock_found = TRUE;
 
 	ut_ad(trx_mutex_own(trx));
+	ut_ad(lock_mutex_own());
 
 	return(TRUE);
 }
@@ -3658,7 +3662,6 @@ lock_deadlock_recursive(
 
 			if (lock_trx == start) {
 
-				/* To obey the latching order */
 				trx_mutex_exit(start);
 
 				/* We came back to the recursion starting
@@ -3843,6 +3846,80 @@ lock_table_create(
 }
 
 /*************************************************************//**
+Pops autoinc lock requests from the transaction's autoinc_locks. We
+handle the case where there are gaps in the array and they need to
+be popped off the stack. */
+UNIV_INLINE
+void
+lock_table_pop_autoinc_locks(
+/*=========================*/
+	trx_t*	trx)	/*!< in/out: transaction that owns the AUTOINC locks */
+{
+	ut_ad(lock_mutex_own());
+	ut_ad(!ib_vector_is_empty(trx->autoinc_locks));
+
+	/* Skip any gaps, gaps are NULL lock entries in the
+	trx->autoinc_locks vector. */
+
+	do {
+		ib_vector_pop(trx->autoinc_locks);
+
+		if (ib_vector_is_empty(trx->autoinc_locks)) {
+			return;
+		}
+
+	} while (ib_vector_get_last(trx->autoinc_locks) == NULL);
+}
+
+/*************************************************************//**
+Removes an autoinc lock request from the transaction's autoinc_locks. */
+UNIV_INLINE
+void
+lock_table_remove_autoinc_lock(
+/*===========================*/
+	lock_t*	lock,	/*!< in: table lock */
+	trx_t*	trx)	/*!< in/out: transaction that owns the lock */
+{
+	lock_t*	autoinc_lock;
+	lint	i = ib_vector_size(trx->autoinc_locks) - 1;
+
+	ut_ad(lock_mutex_own());
+	ut_ad(lock_get_mode(lock) == LOCK_AUTO_INC);
+	ut_ad(lock_get_type_low(lock) & LOCK_TABLE);
+	ut_ad(!ib_vector_is_empty(trx->autoinc_locks));
+
+	/* With stored functions and procedures the user may drop
+	a table within the same "statement". This special case has
+	to be handled by deleting only those AUTOINC locks that were
+	held by the table being dropped. */
+
+	autoinc_lock = ib_vector_get(trx->autoinc_locks, i);
+
+	/* This is the default fast case. */
+
+	if (autoinc_lock == lock) {
+		lock_table_pop_autoinc_locks(trx);
+	} else {
+		/* The last element should never be NULL */
+		ut_a(autoinc_lock != NULL);
+
+		/* Handle freeing the locks from within the stack. */
+
+		while (--i >= 0) {
+			autoinc_lock = ib_vector_get(trx->autoinc_locks, i);
+
+			if (UNIV_LIKELY(autoinc_lock == lock)) {
+				ib_vector_set(trx->autoinc_locks, i, NULL);
+				return;
+			}
+		}
+
+		/* Must find the autoinc lock. */
+		ut_error;
+	}
+}
+
+/*************************************************************//**
 Removes a table lock request from the queue and the trx list of locks;
 this is a low-level function which does NOT check if waiting requests
 can now be granted. */
@@ -3881,10 +3958,8 @@ lock_table_remove_low(
 
 		if (!lock_get_wait(lock)
 		    && !ib_vector_is_empty(trx->autoinc_locks)) {
-			lock_t*	autoinc_lock;
 
-			autoinc_lock = ib_vector_pop(trx->autoinc_locks);
-			ut_a(autoinc_lock == lock);
+			lock_table_remove_autoinc_lock(lock, trx);
 		}
 
 		ut_a(table->n_waiting_or_granted_auto_inc_locks > 0);
@@ -4771,9 +4846,8 @@ loop:
 
 	if (trx == NULL) {
 
-		rw_lock_s_unlock(&trx_sys->lock);
-
 		lock_mutex_exit();
+		rw_lock_s_unlock(&trx_sys->lock);
 
 		ut_ad(lock_validate());
 
@@ -4858,9 +4932,8 @@ loop:
 				goto print_rec;
 			}
 
-			rw_lock_s_unlock(&trx_sys->lock);
-
 			lock_mutex_exit();
+			rw_lock_s_unlock(&trx_sys->lock);
 
 			mtr_start(&mtr);
 
@@ -4897,8 +4970,6 @@ print_rec:
 
 		nth_trx++;
 		nth_lock = 0;
-
-		goto loop;
 	}
 
 	goto loop;
@@ -5257,10 +5328,10 @@ lock_validate(void)
 		}
 	}
 
-	rw_lock_s_unlock(&trx_sys->lock);
-
 	lock_mutex_exit();
 
+	rw_lock_s_unlock(&trx_sys->lock);
+
 	return(TRUE);
 }
 #endif /* UNIV_DEBUG */
@@ -5307,8 +5378,9 @@ lock_rec_insert_check_and_lock(
 	next_rec_heap_no = page_rec_get_heap_no(next_rec);
 
 	lock_mutex_enter();
-
-	trx_mutex_enter(trx);
+	/* Because this code is invoked for a running transaction by
+	the thread that is serving the transaction, it is not necessary
+	to hold trx->mutex here. */
 
 	/* When inserting a record into an index, the table must be at
 	least IX-locked or we must be building an index, in which case
@@ -5322,8 +5394,6 @@ lock_rec_insert_check_and_lock(
 	if (UNIV_LIKELY(lock == NULL)) {
 		/* We optimize CPU time usage in the simplest case */
 
-		trx_mutex_exit(trx);
-
 		lock_mutex_exit();
 
 		if (!dict_index_is_clust(index)) {
@@ -5355,16 +5425,16 @@ lock_rec_insert_check_and_lock(
 		    block, next_rec_heap_no, trx)) {
 
 		/* Note that we may get DB_SUCCESS also here! */
+		trx_mutex_enter(trx);
 		err = lock_rec_enqueue_waiting(LOCK_X | LOCK_GAP
 					       | LOCK_INSERT_INTENTION,
 					       block, next_rec_heap_no,
 					       index, thr);
+		trx_mutex_exit(trx);
 	} else {
 		err = DB_SUCCESS;
 	}
 
-	trx_mutex_exit(trx);
-
 	lock_mutex_exit();
 
 	switch (err) {
@@ -6222,9 +6292,8 @@ lock_trx_handle_wait(
 		err = DB_SUCCESS;
 	}
 
-	trx_mutex_exit(trx);
-
 	lock_mutex_exit();
+	trx_mutex_exit(trx);
 
 	return(err);
 }

=== modified file 'storage/innobase/lock/lock0wait.c'
--- a/storage/innobase/lock/lock0wait.c	2011-01-27 09:48:41 +0000
+++ b/storage/innobase/lock/lock0wait.c	2011-02-07 21:12:43 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -150,59 +150,49 @@ lock_wait_table_reserve_slot(
 
 	slot = lock_sys->waiting_threads;
 
-	for (i = 0; i < OS_THREAD_MAX_N; ++i, ++slot) {
+	for (i = OS_THREAD_MAX_N; i--; ++slot) {
 		if (!slot->in_use) {
-			break;
-		}
-	}
-
-	/* Check if we have run out of slots. */
-	if (slot == lock_sys->waiting_threads+ OS_THREAD_MAX_N) {
-
-		ut_print_timestamp(stderr);
-
-		fprintf(stderr,
-			"  InnoDB: There appear to be %lu user"
-			" threads currently waiting\n"
-			"InnoDB: inside InnoDB, which is the"
-			" upper limit. Cannot continue operation.\n"
-			"InnoDB: We intentionally generate"
-			" a seg fault to print a stack trace\n"
-			"InnoDB: on Linux. But first we print"
-			" a list of waiting threads.\n", (ulong) i);
+			slot->in_use = TRUE;
+			slot->thr = thr;
+			slot->thr->slot = slot;
+			slot->id = os_thread_get_curr_id();
+			slot->handle = os_thread_get_curr();
+
+			if (slot->event == NULL) {
+				slot->event = os_event_create(NULL);
+				ut_a(slot->event);
+			}
 
-		lock_wait_table_print();
+			os_event_reset(slot->event);
+			slot->suspended = TRUE;
+			slot->suspend_time = ut_time();
+			slot->wait_timeout = wait_timeout;
 
-		ut_error;
-	} else {
+			if (slot == lock_sys->last_slot) {
+				++lock_sys->last_slot;
+			}
 
-		ut_a(slot->in_use == FALSE);
+			ut_ad(lock_sys->last_slot
+			      <= lock_sys->waiting_threads + OS_THREAD_MAX_N);
 
-		slot->in_use = TRUE;
-		slot->thr = thr;
-		slot->thr->slot = slot;
-		slot->id = os_thread_get_curr_id();
-		slot->handle = os_thread_get_curr();
-
-		if (slot->event == NULL) {
-			slot->event = os_event_create(NULL);
-			ut_a(slot->event);
+			return(slot);
 		}
-
-		os_event_reset(slot->event);
-		slot->suspended = TRUE;
-		slot->suspend_time = ut_time();
-		slot->wait_timeout = wait_timeout;
 	}
 
-	if (slot == lock_sys->last_slot) {
-		++lock_sys->last_slot;
-	}
+	ut_print_timestamp(stderr);
 
-	ut_ad(lock_sys->last_slot
-	      <= lock_sys->waiting_threads+ OS_THREAD_MAX_N);
+	fprintf(stderr,
+		"  InnoDB: There appear to be %lu user"
+		" threads currently waiting\n"
+		"InnoDB: inside InnoDB, which is the"
+		" upper limit. Cannot continue operation.\n"
+		"InnoDB: As a last thing, we print"
+		" a list of waiting threads.\n", (ulong) OS_THREAD_MAX_N);
 
-	return(slot);
+	lock_wait_table_print();
+
+	ut_error;
+	return(NULL);
 }
 
 /***************************************************************//**
@@ -245,7 +235,7 @@ lock_wait_suspend_thread(
 
 	if (thr->state == QUE_THR_RUNNING) {
 
-		ut_ad(thr->is_active == TRUE);
+		ut_ad(thr->is_active);
 
 		/* The lock has already been released or this transaction
 		was chosen as a deadlock victim: no need to suspend */
@@ -256,13 +246,12 @@ lock_wait_suspend_thread(
 			trx->lock.was_chosen_as_deadlock_victim = FALSE;
 		}
 
-		trx_mutex_exit(trx);
-
 		lock_wait_mutex_exit();
+		trx_mutex_exit(trx);
 		return;
 	}
 
-	ut_ad(thr->is_active == FALSE);
+	ut_ad(!thr->is_active);
 
 	slot = lock_wait_table_reserve_slot(thr, lock_wait_timeout);
 
@@ -283,8 +272,8 @@ lock_wait_suspend_thread(
 
 	os_event_set(srv_timeout_event);
 
-	trx_mutex_exit(trx);
 	lock_wait_mutex_exit();
+	trx_mutex_exit(trx);
 
 	if (trx->declared_to_be_inside_innodb) {
 
@@ -395,7 +384,7 @@ lock_wait_release_thread_if_suspended(
 
 	/* We own both the lock mutex and the trx_t::mutex but not the
 	lock wait mutex. This is OK because other threads will see the state
-	of this mutex as being in use and no other thread can change the state
+	of this slot as being in use and no other thread can change the state
 	of the slot to free unless that thread also owns the lock mutex. */
 
 	if (thr->slot != NULL && thr->slot->in_use && thr->slot->thr == thr) {

=== modified file 'storage/innobase/mem/mem0mem.c'
--- a/storage/innobase/mem/mem0mem.c	2011-01-25 09:24:38 +0000
+++ b/storage/innobase/mem/mem0mem.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/page/page0zip.c'
--- a/storage/innobase/page/page0zip.c	2011-01-25 09:24:38 +0000
+++ b/storage/innobase/page/page0zip.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 2005, 2010, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2005, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/que/que0que.c'
--- a/storage/innobase/que/que0que.c	2010-11-03 03:18:47 +0000
+++ b/storage/innobase/que/que0que.c	2011-02-07 11:23:17 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -206,6 +206,7 @@ que_thr_end_lock_wait(
 	ibool		was_active;
 
 	ut_ad(lock_mutex_own());
+	ut_ad(trx_mutex_own(trx));
 
 	thr = trx->lock.wait_thr;
 
@@ -215,8 +216,6 @@ que_thr_end_lock_wait(
 	/* In MySQL this is the only possible state here */
 	ut_a(thr->state == QUE_THR_LOCK_WAIT);
 
-	ut_ad(thr->state == QUE_THR_LOCK_WAIT);
-
 	was_active = thr->is_active;
 
 	que_thr_move_to_run_state(thr);
@@ -704,7 +703,6 @@ que_thr_stop(
 	que_thr_t*	thr)	/*!< in: query thread */
 {
 	que_t*		graph;
-	ibool		ret	= TRUE;
 	trx_t*		trx = thr_get_trx(thr);;
 
 	graph = thr->graph;
@@ -732,10 +730,10 @@ que_thr_stop(
 	} else {
 		ut_ad(graph->state == QUE_FORK_ACTIVE);
 
-		ret = FALSE;
+		return(FALSE);
 	}
 
-	return(ret);
+	return(TRUE);
 }
 
 /**********************************************************************//**

=== modified file 'storage/innobase/rem/rem0cmp.c'
--- a/storage/innobase/rem/rem0cmp.c	2011-01-15 08:31:58 +0000
+++ b/storage/innobase/rem/rem0cmp.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software

=== modified file 'storage/innobase/row/row0ins.c'
--- a/storage/innobase/row/row0ins.c	2011-01-18 10:55:35 +0000
+++ b/storage/innobase/row/row0ins.c	2011-02-02 14:08:30 +0000
@@ -2146,7 +2146,7 @@ function_exit:
 
 		err = btr_store_big_rec_extern_fields(
 			index, btr_cur_get_block(&cursor),
-			rec, offsets, big_rec, &mtr);
+			rec, offsets, &mtr, FALSE, big_rec);
 
 		if (modify) {
 			dtuple_big_rec_free(big_rec);

=== modified file 'storage/innobase/row/row0merge.c'
--- a/storage/innobase/row/row0merge.c	2011-01-28 09:42:04 +0000
+++ b/storage/innobase/row/row0merge.c	2011-02-08 17:33:31 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 2005, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 2005, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -2160,7 +2160,7 @@ row_merge_drop_temp_indexes(void)
 }
 
 /*********************************************************************//**
-Creates temperary merge files, and if UNIV_PFS_IO defined, register
+Creates temporary merge files, and if UNIV_PFS_IO defined, register
 the file descriptor with Performance Schema.
 @return File descriptor */
 UNIV_INLINE
@@ -2400,7 +2400,7 @@ row_merge_rename_tables(
 {
 	ulint		err	= DB_ERROR;
 	pars_info_t*	info;
-	char		old_name[MAX_TABLE_NAME_LEN + 1];
+	char		old_name[MAX_FULL_NAME_LEN + 1];
 
 	ut_ad(trx->mysql_thd == NULL
 	      || trx->mysql_thread_id == os_thread_get_curr_id());
@@ -2416,7 +2416,7 @@ row_merge_rename_tables(
 		ut_print_timestamp(stderr);
 		fprintf(stderr, "InnoDB: too long table name: '%s', "
 			"max length is %d\n", old_table->name,
-			MAX_TABLE_NAME_LEN);
+			MAX_FULL_NAME_LEN);
 		ut_error;
 	}
 

=== modified file 'storage/innobase/row/row0mysql.c'
--- a/storage/innobase/row/row0mysql.c	2011-01-06 07:21:08 +0000
+++ b/storage/innobase/row/row0mysql.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 2000, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 2000, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -1938,15 +1938,13 @@ err_exit:
 
 	err = trx->error_state;
 
-	if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
+	switch (err) {
+	case DB_SUCCESS:
+		break;
+	case DB_OUT_OF_FILE_SPACE:
 		trx->error_state = DB_SUCCESS;
 		trx_general_rollback_for_mysql(trx, NULL);
-		/* TO DO: free table?  The code below will dereference
-		table->name, though. */
-	}
 
-	switch (err) {
-	case DB_OUT_OF_FILE_SPACE:
 		ut_print_timestamp(stderr);
 		fputs("  InnoDB: Warning: cannot create table ",
 		      stderr);
@@ -1969,9 +1967,13 @@ err_exit:
 		break;
 
 	case DB_DUPLICATE_KEY:
+	default:
 		/* We may also get err == DB_ERROR if the .ibd file for the
 		table already exists */
 
+		trx->error_state = DB_SUCCESS;
+		trx_general_rollback_for_mysql(trx, NULL);
+		dict_mem_table_free(table);
 		break;
 	}
 

=== modified file 'storage/innobase/row/row0purge.c'
--- a/storage/innobase/row/row0purge.c	2010-12-21 12:49:41 +0000
+++ b/storage/innobase/row/row0purge.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1997, 2010, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -489,8 +489,11 @@ Purges an update of an existing record. 
 marked record if that record contained an externally stored field. */
 static
 void
-row_purge_upd_exist_or_extern(
-/*==========================*/
+row_purge_upd_exist_or_extern_func(
+/*===============================*/
+#ifdef UNIV_DEBUG
+	const que_thr_t*thr,		/*!< in: query thread */
+#endif /* UNIV_DEBUG */
 	purge_node_t*	node,		/*!< in: row purge node */
 	trx_undo_rec_t*	undo_rec)	/*!< in: record to purge */
 {
@@ -516,8 +519,8 @@ row_purge_upd_exist_or_extern(
 	while (node->index != NULL) {
 		index = node->index;
 
-		if (row_upd_changes_ord_field_binary(NULL, NULL, node->index,
-						     node->update)) {
+		if (row_upd_changes_ord_field_binary(node->index, node->update,
+						     thr, NULL, NULL)) {
 			/* Build the older version of the index entry */
 			entry = row_build_index_entry(node->row, NULL,
 						      index, heap);
@@ -599,6 +602,14 @@ skip_secondaries:
 	}
 }
 
+#ifdef UNIV_DEBUG
+# define row_purge_upd_exist_or_extern(thr,node,undo_rec)	\
+	row_purge_upd_exist_or_extern_func(thr,node,undo_rec)
+#else /* UNIV_DEBUG */
+# define row_purge_upd_exist_or_extern(thr,node,undo_rec)	\
+	row_purge_upd_exist_or_extern_func(node,undo_rec)
+#endif /* UNIV_DEBUG */
+
 /***********************************************************//**
 Parses the row reference and other info in a modify undo log record.
 @return TRUE if purge operation required */
@@ -708,10 +719,13 @@ err_exit:
 Purges the parsed record. */
 static
 void
-row_purge_record(
-/*=============*/
+row_purge_record_func(
+/*==================*/
 	purge_node_t*	node,		/*!< in: row purge node */
 	trx_undo_rec_t*	undo_rec,	/*!< in: record to purge */
+#ifdef UNIV_DEBUG
+	const que_thr_t*thr,		/*!< in: query thread */
+#endif /* UNIV_DEBUG */
 	ibool		updated_extern)	/*!< in: TRUE if external columns
 					were updated */
 {
@@ -727,7 +741,7 @@ row_purge_record(
 	} else if (updated_extern
 		   || node->rec_type == TRX_UNDO_UPD_EXIST_REC) {
 
-		row_purge_upd_exist_or_extern(node, undo_rec);
+		row_purge_upd_exist_or_extern(thr, node, undo_rec);
 	}
 
 	MONITOR_INC(MONITOR_NUM_ROW_PURGE);
@@ -743,11 +757,19 @@ row_purge_record(
 
 }
 
+#ifdef UNIV_DEBUG
+# define row_purge_record(node,undo_rec,thr,updated_extern)	\
+	row_purge_record_func(node,undo_rec,thr,updated_extern)
+#else /* UNIV_DEBUG */
+# define row_purge_record(node,undo_rec,thr,updated_extern)	\
+	row_purge_record_func(node,undo_rec,updated_extern)
+#endif /* UNIV_DEBUG */
+
 /***********************************************************//**
 Fetches an undo log record and does the purge for the recorded operation.
 If none left, or the current purge completed, returns the control to the
 parent node, which is always a query thread node. */
-static
+static __attribute__((nonnull))
 void
 row_purge(
 /*======*/
@@ -755,7 +777,8 @@ row_purge(
 	trx_undo_rec_t*	undo_rec,	/*!< in: record to purge */
 	que_thr_t*	thr)		/*!< in: query thread */
 {
-	ut_ad(node && thr);
+	ut_ad(node);
+	ut_ad(thr);
 
 	if (undo_rec != &trx_purge_dummy_rec) {
 		ibool	updated_extern;
@@ -763,7 +786,7 @@ row_purge(
 		if (row_purge_parse_undo_rec(
 			node, undo_rec, &updated_extern, thr)) {
 
-			row_purge_record(node, undo_rec, updated_extern);
+			row_purge_record(node, undo_rec, thr, updated_extern);
 
 			rw_lock_s_unlock_gen(&dict_operation_lock, 0);
 		}

=== modified file 'storage/innobase/row/row0sel.c'
--- a/storage/innobase/row/row0sel.c	2011-01-18 21:14:22 +0000
+++ b/storage/innobase/row/row0sel.c	2011-02-07 11:23:17 +0000
@@ -4366,7 +4366,8 @@ no_gap_lock:
 
 			err = lock_trx_handle_wait(trx);
 
-			if (err == DB_SUCCESS) {
+			switch (err) {
+			case DB_SUCCESS:
 				/* The lock was granted while we were
 				searching for the last committed version.
 				Do a normal locking read. */
@@ -4374,12 +4375,14 @@ no_gap_lock:
 				offsets = rec_get_offsets(
 					rec, index, offsets, ULINT_UNDEFINED,
 					&heap);
-				break;
-			} else if (err == DB_DEADLOCK) {
+				goto locks_ok;
+			case DB_DEADLOCK:
 				goto lock_wait_or_error;
- 			} else {
-				ut_a(err == DB_LOCK_WAIT);
+			case DB_LOCK_WAIT:
 				err = DB_SUCCESS;
+				break;
+			default:
+				ut_error;
 			}
 
 			if (old_vers == NULL) {
@@ -4469,6 +4472,7 @@ no_gap_lock:
 		}
 	}
 
+locks_ok:
 	/* NOTE that at this point rec can be an old version of a clustered
 	index record built for a consistent read. We cannot assume after this
 	point that rec is on a buffer pool page. Functions like

=== modified file 'storage/innobase/row/row0umod.c'
--- a/storage/innobase/row/row0umod.c	2011-01-18 10:55:35 +0000
+++ b/storage/innobase/row/row0umod.c	2011-02-02 14:08:30 +0000
@@ -173,40 +173,26 @@ row_undo_mod_remove_clust_low(
 	mtr_t*		mtr,	/*!< in: mtr */
 	ulint		mode)	/*!< in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE */
 {
-	btr_pcur_t*	pcur;
 	btr_cur_t*	btr_cur;
 	ulint		err;
-	ibool		success;
 
 	ut_ad(node->rec_type == TRX_UNDO_UPD_DEL_REC);
-	pcur = &(node->pcur);
-	btr_cur = btr_pcur_get_btr_cur(pcur);
 
-	success = btr_pcur_restore_position(mode, pcur, mtr);
+	/* Find out if the record has been purged already
+	or if we can remove it. */
 
-	if (!success) {
+	if (!btr_pcur_restore_position(mode, &node->pcur, mtr)
+	    || row_vers_must_preserve_del_marked(node->new_trx_id, mtr)) {
 
 		return(DB_SUCCESS);
 	}
 
-	/* Find out if we can remove the whole clustered index record */
-
-	if (node->rec_type == TRX_UNDO_UPD_DEL_REC
-	    && !row_vers_must_preserve_del_marked(node->new_trx_id, mtr)) {
-
-		/* Ok, we can remove */
-	} else {
-		return(DB_SUCCESS);
-	}
+	btr_cur = btr_pcur_get_btr_cur(&node->pcur);
 
 	if (mode == BTR_MODIFY_LEAF) {
-		success = btr_cur_optimistic_delete(btr_cur, mtr);
-
-		if (success) {
-			err = DB_SUCCESS;
-		} else {
-			err = DB_FAIL;
-		}
+		err = btr_cur_optimistic_delete(btr_cur, mtr)
+			? DB_SUCCESS
+			: DB_FAIL;
 	} else {
 		ut_ad(mode == BTR_MODIFY_TREE);
 
@@ -693,8 +679,9 @@ row_undo_mod_upd_exist_sec(
 	while (node->index != NULL) {
 		index = node->index;
 
-		if (row_upd_changes_ord_field_binary(
-			    node->row, node->ext, node->index, node->update)) {
+		if (row_upd_changes_ord_field_binary(node->index, node->update,
+						     thr,
+						     node->row, node->ext)) {
 
 			/* Build the newest version of the index entry */
 			entry = row_build_index_entry(node->row, node->ext,

=== modified file 'storage/innobase/row/row0upd.c'
--- a/storage/innobase/row/row0upd.c	2011-01-26 08:10:28 +0000
+++ b/storage/innobase/row/row0upd.c	2011-02-02 14:08:30 +0000
@@ -1190,25 +1190,31 @@ NOTE: we compare the fields as binary st
 @return TRUE if update vector changes an ordering field in the index record */
 UNIV_INTERN
 ibool
-row_upd_changes_ord_field_binary(
-/*=============================*/
+row_upd_changes_ord_field_binary_func(
+/*==================================*/
+	dict_index_t*	index,	/*!< in: index of the record */
+	const upd_t*	update,	/*!< in: update vector for the row; NOTE: the
+				field numbers in this MUST be clustered index
+				positions! */
+#ifdef UNIV_DEBUG
+	const que_thr_t*thr,	/*!< in: query thread */
+#endif /* UNIV_DEBUG */
 	const dtuple_t*	row,	/*!< in: old value of row, or NULL if the
 				row and the data values in update are not
 				known when this function is called, e.g., at
 				compile time */
-	const row_ext_t*ext,	/*!< NULL, or prefixes of the externally
+	const row_ext_t*ext)	/*!< NULL, or prefixes of the externally
 				stored columns in the old row */
-	dict_index_t*	index,	/*!< in: index of the record */
-	const upd_t*	update)	/*!< in: update vector for the row; NOTE: the
-				field numbers in this MUST be clustered index
-				positions! */
 {
 	ulint			n_unique;
 	ulint			i;
 	const dict_index_t*	clust_index;
 
-	ut_ad(update);
 	ut_ad(index);
+	ut_ad(update);
+	ut_ad(thr);
+	ut_ad(thr->graph);
+	ut_ad(thr->graph->trx);
 
 	n_unique = dict_index_get_n_unique(index);
 
@@ -1261,9 +1267,14 @@ row_upd_changes_ord_field_binary(
 
 			if (UNIV_LIKELY_NULL(buf)) {
 				if (UNIV_UNLIKELY(buf == field_ref_zero)) {
-					/* This should never happen, but
-					we try to fail safe here. */
-					ut_ad(0);
+					/* The externally stored field
+					was not written yet. This
+					record should only be seen by
+					recv_recovery_rollback_active(),
+					when the server had crashed before
+					storing the field. */
+					ut_ad(thr->graph->trx->is_recovered);
+					ut_ad(trx_is_recv(thr->graph->trx));
 					return(TRUE);
 				}
 
@@ -1636,8 +1647,8 @@ row_upd_sec_step(
 	ut_ad(!dict_index_is_clust(node->index));
 
 	if (node->state == UPD_NODE_UPDATE_ALL_SEC
-	    || row_upd_changes_ord_field_binary(node->row, node->ext,
-						node->index, node->update)) {
+	    || row_upd_changes_ord_field_binary(node->index, node->update,
+						thr, node->row, node->ext)) {
 		return(row_upd_sec_index_entry(node, thr));
 	}
 
@@ -1967,7 +1978,7 @@ row_upd_clust_rec(
 			index, btr_cur_get_block(btr_cur), rec,
 			rec_get_offsets(rec, index, offsets_,
 					ULINT_UNDEFINED, &heap),
-			big_rec, mtr);
+			mtr, TRUE, big_rec);
 		mtr_commit(mtr);
 	}
 
@@ -2165,8 +2176,8 @@ exit_func:
 
 	row_upd_store_row(node);
 
-	if (row_upd_changes_ord_field_binary(node->row, node->ext, index,
-					     node->update)) {
+	if (row_upd_changes_ord_field_binary(index, node->update, thr,
+					     node->row, node->ext)) {
 
 		/* Update causes an ordering field (ordering fields within
 		the B-tree) of the clustered index record to change: perform

=== modified file 'storage/innobase/srv/srv0start.c'
--- a/storage/innobase/srv/srv0start.c	2011-01-06 11:42:30 +0000
+++ b/storage/innobase/srv/srv0start.c	2011-02-07 23:51:55 +0000
@@ -1327,13 +1327,16 @@ innobase_start_or_create_for_mysql(void)
 
 	ut_a(srv_n_file_io_threads <= SRV_MAX_N_IO_THREADS);
 
-	/* TODO: Investigate if SRV_N_PENDING_IOS_PER_THREAD (32) limit
-	still applies to windows. */
-	if (!srv_use_native_aio) {
-		io_limit = 8 * SRV_N_PENDING_IOS_PER_THREAD;
-	} else {
+	io_limit = 8 * SRV_N_PENDING_IOS_PER_THREAD;
+
+	/* On Windows when using native aio the number of aio requests
+	that a thread can handle at a given time is limited to 32
+	i.e.: SRV_N_PENDING_IOS_PER_THREAD */
+# ifdef __WIN__
+	if (srv_use_native_aio) {
 		io_limit = SRV_N_PENDING_IOS_PER_THREAD;
 	}
+# endif /* __WIN__ */
 
 	os_aio_init(io_limit,
 		    srv_n_read_io_threads,

=== modified file 'storage/innobase/sync/sync0sync.c'
--- a/storage/innobase/sync/sync0sync.c	2011-01-25 22:49:40 +0000
+++ b/storage/innobase/sync/sync0sync.c	2011-02-03 22:18:48 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by

=== modified file 'storage/innobase/trx/trx0purge.c'
--- a/storage/innobase/trx/trx0purge.c	2011-01-19 10:37:10 +0000
+++ b/storage/innobase/trx/trx0purge.c	2011-02-07 11:23:17 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -160,8 +160,6 @@ trx_purge_sys_create(
 
 	ut_a(purge_sys->trx->sess == purge_sys->sess);
 
-	trx_mutex_enter(purge_sys->trx);
-
 	/* A purge transaction is not a real transaction, we use a transaction
 	here only because the query threads code requires it. It is otherwise
 	quite unnecessary. We should get rid of it eventually. */
@@ -169,8 +167,6 @@ trx_purge_sys_create(
 	purge_sys->trx->start_time = ut_time();
 	purge_sys->trx->state = TRX_STATE_ACTIVE;
 
-	trx_mutex_exit(purge_sys->trx);
-
 	purge_sys->query = trx_purge_graph_build(
 		purge_sys->trx, n_purge_threads);
 
@@ -187,8 +183,9 @@ trx_purge_sys_close(void)
 	que_graph_free(purge_sys->query);
 
 	ut_a(purge_sys->trx->id == 0);
+	ut_a(purge_sys->sess->trx == purge_sys->trx);
 
-	purge_sys->sess->trx->state = TRX_STATE_NOT_STARTED;
+	purge_sys->trx->state = TRX_STATE_NOT_STARTED;
 
 	sess_close(purge_sys->sess);
 

=== modified file 'storage/innobase/trx/trx0roll.c'
--- a/storage/innobase/trx/trx0roll.c	2011-01-24 10:28:28 +0000
+++ b/storage/innobase/trx/trx0roll.c	2011-02-07 21:12:43 +0000
@@ -50,8 +50,8 @@ Created 3/26/1996 Heikki Tuuri
 rollback */
 #define TRX_ROLL_TRUNC_THRESHOLD	1
 
-/** In crash recovery, the current trx to be rolled back */
-static trx_t*		trx_roll_crash_recv_trx	= NULL;
+/** In crash recovery, the current trx to be rolled back; NULL otherwise */
+static const trx_t*	trx_roll_crash_recv_trx	= NULL;
 
 /** In crash recovery we set this to the undo n:o of the current trx to be
 rolled back. Then we can print how many % the rollback has progressed. */
@@ -244,6 +244,7 @@ trx_rollback_last_sql_stat_for_mysql(
 	}
 
 	ut_error;
+	return(DB_CORRUPTION);
 }
 
 /*******************************************************************//**
@@ -743,7 +744,7 @@ trx_rollback_or_clean_recovered(
 			ut_ad(trx->in_trx_list);
 
 			/* If this function does a cleanup or rollback
-			then it will release the trx sys mutex, therefore
+			then it will release the trx_sys->lock, therefore
 			we need to reacquire it before retrying the loop. */
 
 			if (trx_rollback_resurrected(trx, all)) {

=== modified file 'storage/innobase/trx/trx0trx.c'
--- a/storage/innobase/trx/trx0trx.c	2011-01-27 11:45:15 +0000
+++ b/storage/innobase/trx/trx0trx.c	2011-02-07 11:23:17 +0000
@@ -1445,18 +1445,19 @@ static
 void
 trx_prepare(
 /*========*/
-	trx_t*	trx)	/*!< in: transaction */
+	trx_t*	trx)	/*!< in/out: transaction */
 {
 	trx_rseg_t*	rseg;
-	ib_uint64_t	lsn		= 0;
+	ib_uint64_t	lsn;
 	mtr_t		mtr;
 
 	rseg = trx->rseg;
+	/* Only fresh user transactions can be prepared.
+	Recovered transactions cannot. */
+	ut_a(!trx->is_recovered);
 
 	if (trx->insert_undo != NULL || trx->update_undo != NULL) {
 
-		trx_mutex_exit(trx);
-
 		mtr_start(&mtr);
 
 		/* Change the undo log segment states from TRX_UNDO_ACTIVE
@@ -1489,16 +1490,13 @@ trx_prepare(
 					world */
 		/*--------------*/
 		lsn = mtr.end_lsn;
-
-		trx_mutex_enter(trx);
+		ut_ad(lsn);
+	} else {
+		lsn = 0;
 	}
 
-	ut_ad(trx_mutex_own(trx));
-
-	/* Note: This state change is only covered by the trx_t::mutex and
-	not the trx_sys_t::lock. */
-
 	/*--------------------------------------*/
+	ut_a(trx->state == TRX_STATE_ACTIVE);
 	trx->state = TRX_STATE_PREPARED;
 	/*--------------------------------------*/
 
@@ -1520,8 +1518,6 @@ trx_prepare(
 		TODO: find out if MySQL holds some mutex when calling this.
 		That would spoil our group prepare algorithm. */
 
-		trx_mutex_exit(trx);
-
 		if (srv_flush_log_at_trx_commit == 0) {
 			/* Do nothing */
 		} else if (srv_flush_log_at_trx_commit == 1) {
@@ -1544,8 +1540,6 @@ trx_prepare(
 		} else {
 			ut_error;
 		}
-
-		trx_mutex_enter(trx);
 	}
 }
 
@@ -1559,15 +1553,11 @@ trx_prepare_for_mysql(
 {
 	trx_start_if_not_started_xa(trx);
 
-	trx_mutex_enter(trx);
-
 	trx->op_info = "preparing";
 
 	trx_prepare(trx);
 
 	trx->op_info = "";
-
-	trx_mutex_exit(trx);
 }
 
 /**********************************************************************//**
@@ -1685,8 +1675,6 @@ trx_get_trx_by_xid(
 			trx->xid.formatID = -1;
 			break;
 		}
-
-		trx = UT_LIST_GET_NEXT(trx_list, trx);
 	}
 
 	rw_lock_s_unlock(&trx_sys->lock);

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2010-12-09 16:17:13 +0000
+++ b/storage/perfschema/pfs.cc	2011-02-04 11:55:17 +0000
@@ -899,19 +899,30 @@ static inline int mysql_mutex_lock(...)
   @ingroup Performance_schema_implementation
 */
 
+/** TIMED bit in the state flags bitfield. */
 #define STATE_FLAG_TIMED (1<<0)
+/** THREAD bit in the state flags bitfield. */
 #define STATE_FLAG_THREAD (1<<1)
+/** EVENT bit in the state flags bitfield. */
 #define STATE_FLAG_WAIT (1<<2)
 
 pthread_key(PFS_thread*, THR_PFS);
 bool THR_PFS_initialized= false;
 
+/**
+  Conversion map from PSI_mutex_operation to enum_operation_type.
+  Indexed by enum PSI_mutex_operation.
+*/
 static enum_operation_type mutex_operation_map[]=
 {
   OPERATION_TYPE_LOCK,
   OPERATION_TYPE_TRYLOCK
 };
 
+/**
+  Conversion map from PSI_rwlock_operation to enum_operation_type.
+  Indexed by enum PSI_rwlock_operation.
+*/
 static enum_operation_type rwlock_operation_map[]=
 {
   OPERATION_TYPE_READLOCK,
@@ -920,6 +931,10 @@ static enum_operation_type rwlock_operat
   OPERATION_TYPE_TRYWRITELOCK
 };
 
+/**
+  Conversion map from PSI_cond_operation to enum_operation_type.
+  Indexed by enum PSI_cond_operation.
+*/
 static enum_operation_type cond_operation_map[]=
 {
   OPERATION_TYPE_WAIT,
@@ -1072,6 +1087,10 @@ static int build_prefix(const LEX_STRING
 
 C_MODE_START
 
+/**
+  Implementation of the mutex instrumentation interface.
+  @sa PSI_v1::register_mutex.
+*/
 static void register_mutex_v1(const char *category,
                               PSI_mutex_info_v1 *info,
                               int count)
@@ -1081,6 +1100,10 @@ static void register_mutex_v1(const char
                    register_mutex_class)
 }
 
+/**
+  Implementation of the rwlock instrumentation interface.
+  @sa PSI_v1::register_rwlock.
+*/
 static void register_rwlock_v1(const char *category,
                                PSI_rwlock_info_v1 *info,
                                int count)
@@ -1090,6 +1113,10 @@ static void register_rwlock_v1(const cha
                    register_rwlock_class)
 }
 
+/**
+  Implementation of the cond instrumentation interface.
+  @sa PSI_v1::register_cond.
+*/
 static void register_cond_v1(const char *category,
                              PSI_cond_info_v1 *info,
                              int count)
@@ -1099,6 +1126,10 @@ static void register_cond_v1(const char 
                    register_cond_class)
 }
 
+/**
+  Implementation of the thread instrumentation interface.
+  @sa PSI_v1::register_thread.
+*/
 static void register_thread_v1(const char *category,
                                PSI_thread_info_v1 *info,
                                int count)
@@ -1108,6 +1139,10 @@ static void register_thread_v1(const cha
                    register_thread_class)
 }
 
+/**
+  Implementation of the file instrumentation interface.
+  @sa PSI_v1::register_file.
+*/
 static void register_file_v1(const char *category,
                              PSI_file_info_v1 *info,
                              int count)
@@ -1304,6 +1339,11 @@ static void create_file_v1(PSI_file_key 
   file_handle_array[index]= pfs_file;
 }
 
+/**
+  Arguments given from a parent to a child thread, packaged in one structure.
+  This data is used when spawning a new instrumented thread.
+  @sa pfs_spawn_thread.
+*/
 struct PFS_spawn_thread_arg
 {
   PFS_thread *m_parent_thread;
@@ -1619,12 +1659,20 @@ static void set_thread_info_v1(const cha
   }
 }
 
+/**
+  Implementation of the thread instrumentation interface.
+  @sa PSI_v1::set_thread.
+*/
 static void set_thread_v1(PSI_thread* thread)
 {
   PFS_thread *pfs= reinterpret_cast<PFS_thread*> (thread);
   my_pthread_setspecific_ptr(THR_PFS, pfs);
 }
 
+/**
+  Implementation of the thread instrumentation interface.
+  @sa PSI_v1::delete_current_thread.
+*/
 static void delete_current_thread_v1(void)
 {
   PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
@@ -1636,6 +1684,10 @@ static void delete_current_thread_v1(voi
   }
 }
 
+/**
+  Implementation of the thread instrumentation interface.
+  @sa PSI_v1::delete_thread.
+*/
 static void delete_thread_v1(PSI_thread *thread)
 {
   PFS_thread *pfs= reinterpret_cast<PFS_thread*> (thread);
@@ -2471,6 +2523,10 @@ get_thread_file_descriptor_locker_v1(PSI
   return reinterpret_cast<PSI_file_locker*> (state);
 }
 
+/**
+  Implementation of the mutex instrumentation interface.
+  @sa PSI_v1::unlock_mutex.
+*/
 static void unlock_mutex_v1(PSI_mutex *mutex)
 {
   PFS_mutex *pfs_mutex= reinterpret_cast<PFS_mutex*> (mutex);
@@ -2510,6 +2566,10 @@ static void unlock_mutex_v1(PSI_mutex *m
 #endif
 }
 
+/**
+  Implementation of the rwlock instrumentation interface.
+  @sa PSI_v1::unlock_rwlock.
+*/
 static void unlock_rwlock_v1(PSI_rwlock *rwlock)
 {
   PFS_rwlock *pfs_rwlock= reinterpret_cast<PFS_rwlock*> (rwlock);
@@ -2586,6 +2646,10 @@ static void unlock_rwlock_v1(PSI_rwlock 
 #endif
 }
 
+/**
+  Implementation of the cond instrumentation interface.
+  @sa PSI_v1::signal_cond.
+*/
 static void signal_cond_v1(PSI_cond* cond)
 {
   PFS_cond *pfs_cond= reinterpret_cast<PFS_cond*> (cond);
@@ -2594,6 +2658,10 @@ static void signal_cond_v1(PSI_cond* con
   pfs_cond->m_cond_stat.m_signal_count++;
 }
 
+/**
+  Implementation of the cond instrumentation interface.
+  @sa PSI_v1::broadcast_cond.
+*/
 static void broadcast_cond_v1(PSI_cond* cond)
 {
   PFS_cond *pfs_cond= reinterpret_cast<PFS_cond*> (cond);

=== modified file 'storage/perfschema/pfs_engine_table.cc'
--- a/storage/perfschema/pfs_engine_table.cc	2011-01-03 13:39:18 +0000
+++ b/storage/perfschema/pfs_engine_table.cc	2011-02-04 11:55:17 +0000
@@ -100,6 +100,7 @@ void PFS_engine_table_share::check_all_t
     (*current)->check_one_table(thd);
 }
 
+/** Error reporting for schema integrity checks. */
 class PFS_check_intact : public Table_check_intact
 {
 protected:
@@ -465,6 +466,7 @@ int PFS_engine_table::update_row_values(
   return HA_ERR_WRONG_COMMAND;
 }
 
+/** Implementation of internal ACL checks, for the performance schema. */
 class PFS_internal_schema_access : public ACL_internal_schema_access
 {
 public:

=== modified file 'storage/perfschema/pfs_engine_table.h'
--- a/storage/perfschema/pfs_engine_table.h	2010-07-30 09:02:32 +0000
+++ b/storage/perfschema/pfs_engine_table.h	2011-02-04 11:55:17 +0000
@@ -140,7 +140,9 @@ struct PFS_engine_table_share
   void check_one_table(THD *thd);
   static void init_all_locks(void);
   static void delete_all_locks(void);
+  /** Get the row count. */
   ha_rows get_row_count(void) const;
+  /** Write a row. */
   int write_row(TABLE *table, unsigned char *buf, Field **fields) const;
 
   /** Table name. */
@@ -172,6 +174,10 @@ struct PFS_engine_table_share
   bool m_checked;
 };
 
+/**
+  Privileges for read only tables.
+  The only operation allowed is SELECT.
+*/
 class PFS_readonly_acl : public ACL_internal_table_access
 {
 public:
@@ -184,8 +190,13 @@ public:
   ACL_internal_access_result check(ulong want_access, ulong *save_priv) const;
 };
 
+/** Singleton instance of PFS_readonly_acl. */
 extern PFS_readonly_acl pfs_readonly_acl;
 
+/**
+  Privileges for truncatable tables.
+  Operations allowed are SELECT and TRUNCATE.
+*/
 class PFS_truncatable_acl : public ACL_internal_table_access
 {
 public:
@@ -198,8 +209,13 @@ public:
   ACL_internal_access_result check(ulong want_access, ulong *save_priv) const;
 };
 
+/** Singleton instance of PFS_truncatable_acl. */
 extern PFS_truncatable_acl pfs_truncatable_acl;
 
+/**
+  Privileges for updatable tables.
+  Operations allowed are SELECT and UPDATE.
+*/
 class PFS_updatable_acl : public ACL_internal_table_access
 {
 public:
@@ -212,8 +228,13 @@ public:
   ACL_internal_access_result check(ulong want_access, ulong *save_priv) const;
 };
 
+/** Singleton instance of PFS_updatable_acl. */
 extern PFS_updatable_acl pfs_updatable_acl;
 
+/**
+  Privileges for editable tables.
+  Operations allowed are SELECT, INSERT, UPDATE, DELETE and TRUNCATE.
+*/
 class PFS_editable_acl : public ACL_internal_table_access
 {
 public:
@@ -226,8 +247,12 @@ public:
   ACL_internal_access_result check(ulong want_access, ulong *save_priv) const;
 };
 
+/** Singleton instance of PFS_editable_acl. */
 extern PFS_editable_acl pfs_editable_acl;
 
+/**
+  Privileges for unknown tables.
+*/
 class PFS_unknown_acl : public ACL_internal_table_access
 {
 public:
@@ -240,6 +265,7 @@ public:
   ACL_internal_access_result check(ulong want_access, ulong *save_priv) const;
 };
 
+/** Singleton instance of PFS_unknown_acl. */
 extern PFS_unknown_acl pfs_unknown_acl;
 
 /** Position of a cursor, for simple iterations. */
@@ -262,6 +288,7 @@ struct PFS_simple_index
   { m_index++; }
 };
 
+/** Position of a double cursor, for iterations using 2 nested loops. */
 struct PFS_double_index
 {
   /** Outer index. */
@@ -286,6 +313,7 @@ struct PFS_double_index
   }
 };
 
+/** Position of a triple cursor, for iterations using 3 nested loops. */
 struct PFS_triple_index
 {
   /** Outer index. */

=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h	2010-12-09 16:17:13 +0000
+++ b/storage/perfschema/pfs_instr.h	2011-02-04 11:55:17 +0000
@@ -42,6 +42,7 @@ struct PFS_thread_class;
 
 struct PFS_thread;
 
+/** Base structure for wait instruments. */
 struct PFS_instr
 {
   /** Internal lock. */

=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc	2010-12-09 16:17:13 +0000
+++ b/storage/perfschema/pfs_instr_class.cc	2011-02-04 11:55:17 +0000
@@ -335,7 +335,7 @@ void cleanup_table_share_hash(void)
 }
 
 /**
-  Get the hash pins for @table_share_hash.
+  Get the hash pins for @sa table_share_hash.
   @param thread The running thread.
   @returns The LF_HASH pins for the thread.
 */
@@ -1004,7 +1004,7 @@ void purge_table_share(PFS_thread *threa
   @param schema_name The table schema name
   @param schema_name_length The table schema name length
   @param table_name The table name
-  @parem table_name_length The table name length
+  @param table_name_length The table name length
 */
 void drop_table_share(PFS_thread *thread,
                       bool temporary,

=== modified file 'storage/perfschema/pfs_setup_actor.h'
--- a/storage/perfschema/pfs_setup_actor.h	2010-07-10 03:31:35 +0000
+++ b/storage/perfschema/pfs_setup_actor.h	2011-02-04 11:55:17 +0000
@@ -35,6 +35,7 @@ struct PFS_global_param;
   @{
 */
 
+/** Hash key for @sa PFS_setup_actor. */
 struct PFS_setup_actor_key
 {
   /**
@@ -47,6 +48,7 @@ struct PFS_setup_actor_key
   uint m_key_length;
 };
 
+/** A setup_actor record. */
 struct PFS_setup_actor
 {
   /** Internal lock. */

=== modified file 'storage/perfschema/pfs_setup_object.h'
--- a/storage/perfschema/pfs_setup_object.h	2010-09-23 16:08:54 +0000
+++ b/storage/perfschema/pfs_setup_object.h	2011-02-04 11:55:17 +0000
@@ -32,6 +32,7 @@ struct PFS_global_param;
   @{
 */
 
+/** Hash key for @sa PFS_setup_object. */
 struct PFS_setup_object_key
 {
   /**
@@ -43,6 +44,7 @@ struct PFS_setup_object_key
   uint m_key_length;
 };
 
+/** A setup_object record. */
 struct PFS_setup_object
 {
   enum_object_type get_object_type()

=== modified file 'storage/perfschema/pfs_stat.h'
--- a/storage/perfschema/pfs_stat.h	2010-12-09 16:17:13 +0000
+++ b/storage/perfschema/pfs_stat.h	2011-02-04 11:55:17 +0000
@@ -199,6 +199,7 @@ enum PFS_TL_LOCK_TYPE
 
 #define COUNT_PFS_TL_LOCK_TYPE 11
 
+/** Statistics for table locks. */
 struct PFS_table_lock_stat
 {
   PFS_single_stat m_stat[COUNT_PFS_TL_LOCK_TYPE];

=== modified file 'storage/perfschema/pfs_timer.h'
--- a/storage/perfschema/pfs_timer.h	2010-09-23 16:08:54 +0000
+++ b/storage/perfschema/pfs_timer.h	2011-02-04 11:55:17 +0000
@@ -23,6 +23,12 @@
 #include <my_rdtsc.h>
 #include "pfs_column_types.h"
 
+/**
+  A time normalizer.
+  A time normalizer consist of a transformation that
+  converts raw timer values (expressed in the timer unit)
+  to normalized values, expressed in picoseconds.
+*/
 struct time_normalizer
 {
   static time_normalizer* get(enum_timer_name timer_name);

=== modified file 'storage/perfschema/table_helper.h'
--- a/storage/perfschema/table_helper.h	2011-01-07 16:20:19 +0000
+++ b/storage/perfschema/table_helper.h	2011-02-04 11:55:17 +0000
@@ -32,6 +32,7 @@
   @{
 */
 
+/** Namespace, internal views used within table setup_instruments. */
 struct PFS_instrument_view_constants
 {
   static const uint FIRST_VIEW= 1;
@@ -43,6 +44,7 @@ struct PFS_instrument_view_constants
   static const uint LAST_VIEW= 5;
 };
 
+/** Namespace, internal views used within object summaries. */
 struct PFS_object_view_constants
 {
   static const uint FIRST_VIEW= 1;

=== removed file 'storage/perfschema/unittest/stub_server_misc.h.moved'
--- a/storage/perfschema/unittest/stub_server_misc.h.moved	2010-12-02 15:05:07 +0000
+++ b/storage/perfschema/unittest/stub_server_misc.h.moved	1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-/* 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, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-/*
-  Minimal code to be able to link a unit test.
-*/
-
-volatile bool ready_to_exit= false;
-

=== modified file 'support-files/mysql.spec.sh'
--- a/support-files/mysql.spec.sh	2010-12-29 00:38:59 +0000
+++ b/support-files/mysql.spec.sh	2011-02-09 13:34:44 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -523,10 +523,27 @@ rm -f $RBR%{_mandir}/man1/make_win_bin_d
 ##############################################################################
 
 %pre -n MySQL-server%{product_suffix}
+# This is the code running at the beginning of a RPM upgrade action,
+# before replacing the old files with the new ones.
 
 # ATTENTION: Parts of this are duplicated in the "triggerpostun" !
 
-mysql_datadir=%{mysqldatadir}
+# There are users who deviate from the default file system layout.
+# Check local settings to support them.
+if [ -x %{_bindir}/my_print_defaults ]
+then
+  mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`
+  PID_FILE_PATT=`%{_bindir}/my_print_defaults server mysqld | grep '^--pid-file=' | sed -n 's/--pid-file=//p'`
+fi
+if [ -z "$mysql_datadir" ]
+then
+  mysql_datadir=%{mysqldatadir}
+fi
+if [ -z "$PID_FILE_PATT" ]
+then
+  PID_FILE_PATT="$mysql_datadir/*.pid"
+fi
+
 # Check if we can safely upgrade.  An upgrade is only safe if it's from one
 # of our RPMs in the same version family.
 
@@ -601,7 +618,7 @@ fi
 
 # We assume that if there is exactly one ".pid" file,
 # it contains the valid PID of a running MySQL server.
-NR_PID_FILES=`ls $mysql_datadir/*.pid 2>/dev/null | wc -l`
+NR_PID_FILES=`ls $PID_FILE_PATT 2>/dev/null | wc -l`
 case $NR_PID_FILES in
 	0 ) SERVER_TO_START=''  ;;  # No "*.pid" file == no running server
 	1 ) SERVER_TO_START='true' ;;
@@ -623,8 +640,8 @@ if [ -f $STATUS_FILE ]; then
 	echo "before repeating the MySQL upgrade."
 	exit 1
 elif [ -n "$SEVERAL_PID_FILES" ] ; then
-	echo "Your MySQL directory '$mysql_datadir' has more than one PID file:"
-	ls -ld $mysql_datadir/*.pid
+	echo "You have more than one PID file:"
+	ls -ld $PID_FILE_PATT
 	echo "Please check which one (if any) corresponds to a running server"
 	echo "and delete all others before repeating the MySQL upgrade."
 	exit 1
@@ -649,17 +666,17 @@ if [ -d $mysql_datadir ] ; then
 	if [ -n "$SERVER_TO_START" ] ; then
 		# There is only one PID file, race possibility ignored
 		echo "PID file:"                           >> $STATUS_FILE
-		ls -l   $mysql_datadir/*.pid               >> $STATUS_FILE
-		cat     $mysql_datadir/*.pid               >> $STATUS_FILE
+		ls -l   $PID_FILE_PATT                     >> $STATUS_FILE
+		cat     $PID_FILE_PATT                     >> $STATUS_FILE
 		echo                                       >> $STATUS_FILE
 		echo "Server process:"                     >> $STATUS_FILE
-		ps -fp `cat $mysql_datadir/*.pid`          >> $STATUS_FILE
+		ps -fp `cat $PID_FILE_PATT`                >> $STATUS_FILE
 		echo                                       >> $STATUS_FILE
 		echo "SERVER_TO_START=$SERVER_TO_START"    >> $STATUS_FILE
 	else
 		# Take a note we checked it ...
 		echo "PID file:"                           >> $STATUS_FILE
-		ls -l   $mysql_datadir/*.pid               >> $STATUS_FILE 2>&1
+		ls -l   $PID_FILE_PATT                     >> $STATUS_FILE 2>&1
 	fi
 fi
 
@@ -674,10 +691,22 @@ if [ -x %{_sysconfdir}/init.d/mysql ] ; 
 fi
 
 %post -n MySQL-server%{product_suffix}
+# This is the code running at the end of a RPM install or upgrade action,
+# after the (new) files have been written.
 
 # ATTENTION: Parts of this are duplicated in the "triggerpostun" !
 
-mysql_datadir=%{mysqldatadir}
+# There are users who deviate from the default file system layout.
+# Check local settings to support them.
+if [ -x %{_bindir}/my_print_defaults ]
+then
+  mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`
+fi
+if [ -z "$mysql_datadir" ]
+then
+  mysql_datadir=%{mysqldatadir}
+fi
+
 NEW_VERSION=%{mysql_version}-%{release}
 STATUS_FILE=$mysql_datadir/RPM_UPGRADE_MARKER
 
@@ -855,7 +884,17 @@ fi
 #   http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch10s02.html
 # For all details of this code, see the "pre" and "post" sections.
 
-mysql_datadir=%{mysqldatadir}
+# There are users who deviate from the default file system layout.
+# Check local settings to support them.
+if [ -x %{_bindir}/my_print_defaults ]
+then
+  mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`
+fi
+if [ -z "$mysql_datadir" ]
+then
+  mysql_datadir=%{mysqldatadir}
+fi
+
 NEW_VERSION=%{mysql_version}-%{release}
 STATUS_FILE=$mysql_datadir/RPM_UPGRADE_MARKER-LAST  # Note the difference!
 STATUS_HISTORY=$mysql_datadir/RPM_UPGRADE_HISTORY
@@ -1085,6 +1124,14 @@ echo "====="                            
 # merging BK trees)
 ##############################################################################
 %changelog
+
+* Thu Feb 09 2011 Joerg Bruehe <joerg.bruehe@stripped>
+
+- Fix bug#56581: If an installation deviates from the default file locations
+  ("datadir" and "pid-file"), the mechanism to detect a running server (on upgrade)
+  should still work, and use these locations.
+  The problem was that the fix for bug#27072 did not check for local settings.
+
 * Tue Nov 23 2010 Jonathan Perkin <jonathan.perkin@stripped>
 
 - EXCEPTIONS-CLIENT has been deleted, remove it from here too

=== modified file 'unittest/gunit/CMakeLists.txt'
--- a/unittest/gunit/CMakeLists.txt	2011-02-01 07:52:46 +0000
+++ b/unittest/gunit/CMakeLists.txt	2011-02-07 13:03:47 +0000
@@ -239,7 +239,7 @@ FOREACH(test ${SERVER_TESTS})
     ADD_EXECUTABLE(${test}-t ${test}-t.cc)
   ENDIF()
   TARGET_LINK_LIBRARIES(${test}-t sql binlog rpl master slave sql)
-  TARGET_LINK_LIBRARIES(${test}-t gunit sqlgunitlib strings dbug regex)
+  TARGET_LINK_LIBRARIES(${test}-t gunit sqlgunitlib strings dbug regex mysys)
   IF (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
     SET_TARGET_PROPERTIES(${test}-t  PROPERTIES LINK_FLAGS "-library=stlport4")
   ENDIF()

=== modified file 'unittest/gunit/item-t.cc'
--- a/unittest/gunit/item-t.cc	2011-02-01 07:52:46 +0000
+++ b/unittest/gunit/item-t.cc	2011-02-07 13:03:47 +0000
@@ -53,7 +53,8 @@ protected:
   virtual void SetUp()
   {
     m_thd= new THD(false);
-    m_thd->thread_stack= (char*) &m_thd;
+    THD *stack_thd= m_thd;
+    m_thd->thread_stack= (char*) &stack_thd;
     m_thd->store_globals();
   }
 
@@ -63,7 +64,6 @@ protected:
     delete m_thd;
   }
 
-private:
   THD      *m_thd;
 };
 
@@ -167,4 +167,20 @@ TEST_F(ItemTest, ItemInt)
   */
 }
 
+
+TEST_F(ItemTest, ItemFuncDesDecrypt)
+{
+  // Bug #59632 Assertion failed: arg_length > length
+  const uint length= 1U;
+  Item_int *item_one= new Item_int(1, length);
+  Item_int *item_two= new Item_int(2, length);
+  Item_func_des_decrypt *item_decrypt=
+    new Item_func_des_decrypt(item_two, item_one);
+  
+  EXPECT_FALSE(item_decrypt->fix_fields(m_thd, NULL));
+  EXPECT_EQ(length, item_one->max_length);
+  EXPECT_EQ(length, item_two->max_length);
+  EXPECT_LE(item_decrypt->max_length, length);
+}
+
 }

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (mattias.jonsson:3641 to 3642) Bug#60114Mattias Jonsson14 Feb