List:Commits« Previous MessageNext Message »
From:Bjorn Munch Date:April 15 2011 2:26pm
Subject:bzr commit into mysql-trunk-mtr branch (bjorn.munch:3064)
View as plain text  
#At file:///home/bm136801/my/mtr-tr/ based on revid:bjorn.munch@stripped

 3064 Bjorn Munch	2011-04-15 [merge]
      merge from trunk

    removed:
      mysql-test/suite/bugs/
      mysql-test/suite/bugs/combinations
      mysql-test/suite/bugs/data/
      mysql-test/suite/bugs/data/rpl_bug12691.dat
      mysql-test/suite/bugs/r/
      mysql-test/suite/bugs/r/bug57108.result
      mysql-test/suite/bugs/r/rpl_bug12691.result
      mysql-test/suite/bugs/r/rpl_bug31582.result
      mysql-test/suite/bugs/r/rpl_bug31583.result
      mysql-test/suite/bugs/r/rpl_bug33029.result
      mysql-test/suite/bugs/r/rpl_bug38205.result
      mysql-test/suite/bugs/t/
      mysql-test/suite/bugs/t/bug57108-master.opt
      mysql-test/suite/bugs/t/bug57108.test
      mysql-test/suite/bugs/t/rpl_bug12691.test
      mysql-test/suite/bugs/t/rpl_bug31582.test
      mysql-test/suite/bugs/t/rpl_bug31583.test
      mysql-test/suite/bugs/t/rpl_bug33029.test
      mysql-test/suite/bugs/t/rpl_bug38205.test
      mysql-test/suite/sys_vars/r/max_long_data_size_basic.result
      mysql-test/suite/sys_vars/t/max_long_data_size_basic.test
    added:
      sql/item_inetfunc.cc
      sql/item_inetfunc.h
      unittest/gunit/sql_plist-t.cc
    renamed:
      mysql-test/suite/bugs/r/rpl_bug23533.result => mysql-test/suite/binlog/r/binlog_bug23533.result
      mysql-test/suite/bugs/r/rpl_bug36391.result => mysql-test/suite/binlog/r/binlog_bug36391.result
      mysql-test/suite/bugs/r/rpl_bug37426.result => mysql-test/suite/rpl/r/rpl_bug37426.result
      mysql-test/suite/bugs/t/rpl_bug23533.test => mysql-test/suite/binlog/t/binlog_bug23533.test
      mysql-test/suite/bugs/t/rpl_bug36391-master.opt => mysql-test/suite/binlog/t/binlog_bug36391-master.opt
      mysql-test/suite/bugs/t/rpl_bug36391.test => mysql-test/suite/binlog/t/binlog_bug36391.test
      mysql-test/suite/bugs/t/rpl_bug37426.test => mysql-test/suite/rpl/t/rpl_bug37426.test
    modified:
      client/client_priv.h
      client/mysqlslap.c
      cmake/os/Windows.cmake
      cmake/os/WindowsCache.cmake
      config.h.cmake
      configure.cmake
      include/my_global.h
      include/my_net.h
      include/violite.h
      libmysql/libmysql.c
      libmysqld/libmysqld.c
      mysql-test/collections/default.experimental
      mysql-test/collections/default.weekly
      mysql-test/include/ctype_numconv.inc
      mysql-test/include/func_in.inc
      mysql-test/include/subquery.inc
      mysql-test/include/subquery_mat.inc
      mysql-test/r/alter_table.result
      mysql-test/r/ctype_binary.result
      mysql-test/r/ctype_cp1251.result
      mysql-test/r/ctype_latin1.result
      mysql-test/r/ctype_ucs.result
      mysql-test/r/ctype_utf8.result
      mysql-test/r/func_analyse.result
      mysql-test/r/func_group.result
      mysql-test/r/func_in_icp.result
      mysql-test/r/func_in_icp_mrr.result
      mysql-test/r/func_in_mrr.result
      mysql-test/r/func_in_mrr_cost.result
      mysql-test/r/func_in_none.result
      mysql-test/r/innodb_icp_all.result
      mysql-test/r/loaddata.result
      mysql-test/r/myisam_icp_all.result
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/r/mysqlslap.result
      mysql-test/r/subquery_all.result
      mysql-test/r/subquery_all_jcl6.result
      mysql-test/r/subquery_mat.result
      mysql-test/r/subquery_mat_all.result
      mysql-test/r/subquery_mat_none.result
      mysql-test/r/subquery_nomat_nosj.result
      mysql-test/r/subquery_nomat_nosj_jcl6.result
      mysql-test/r/subquery_none.result
      mysql-test/r/variables.result
      mysql-test/r/view.result
      mysql-test/r/warnings.result
      mysql-test/r/xa.result
      mysql-test/t/alter_table.test
      mysql-test/t/func_analyse.test
      mysql-test/t/func_group.test
      mysql-test/t/loaddata.test
      mysql-test/t/mysqlslap.test
      mysql-test/t/variables.test
      mysql-test/t/view.test
      mysql-test/t/warnings.test
      mysql-test/t/xa.test
      mysys/charset.c
      mysys/my_init.c
      mysys/my_thr_init.c
      mysys/mysys_priv.h
      sql-common/client.c
      sql/CMakeLists.txt
      sql/field.cc
      sql/hostname.cc
      sql/item.cc
      sql/item.h
      sql/item_cmpfunc.cc
      sql/item_create.cc
      sql/item_func.cc
      sql/item_func.h
      sql/item_strfunc.cc
      sql/item_strfunc.h
      sql/item_sum.cc
      sql/mdl.h
      sql/mysqld.cc
      sql/opt_range.cc
      sql/opt_sum.cc
      sql/rpl_info_factory.h
      sql/sp_head.cc
      sql/sql_admin.cc
      sql/sql_base.h
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_connect.cc
      sql/sql_error.cc
      sql/sql_error.h
      sql/sql_join_cache.cc
      sql/sql_load.cc
      sql/sql_parse.cc
      sql/sql_plist.h
      sql/sql_prepare.cc
      sql/sql_select.cc
      sql/sql_select.h
      sql/sql_show.cc
      sql/sql_table.cc
      sql/sql_trigger.cc
      sql/sql_update.cc
      sql/sys_vars.cc
      sql/transaction.cc
      storage/myisam/myisamdef.h
      unittest/gunit/CMakeLists.txt
      vio/vio_priv.h
      vio/viosocket.c
      mysql-test/suite/binlog/r/binlog_bug23533.result
      mysql-test/suite/binlog/r/binlog_bug36391.result
      mysql-test/suite/rpl/r/rpl_bug37426.result
      mysql-test/suite/binlog/t/binlog_bug23533.test
      mysql-test/suite/binlog/t/binlog_bug36391.test
      mysql-test/suite/rpl/t/rpl_bug37426.test
=== modified file 'client/client_priv.h'
--- a/client/client_priv.h	2011-02-21 11:33:20 +0000
+++ b/client/client_priv.h	2011-04-08 07:07:57 +0000
@@ -75,6 +75,7 @@ enum options_client
   OPT_SLAP_POST_SYSTEM,
   OPT_SLAP_COMMIT,
   OPT_SLAP_DETACH,
+  OPT_SLAP_NO_DROP,
   OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID,
   OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
   OPT_AUTO_VERTICAL_OUTPUT,

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

=== modified file 'cmake/os/Windows.cmake'
--- a/cmake/os/Windows.cmake	2010-11-19 23:41:00 +0000
+++ b/cmake/os/Windows.cmake	2011-04-14 08:09:49 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Sun Microsystems, Inc
+# Copyright (C) 2010, 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
@@ -191,3 +191,4 @@ IF(NOT HAVE_SIZE_OF_SSIZE_T)
 ENDIF()
 
 SET(FN_NO_CASE_SENSE 1)
+SET(USE_SYMDIR 1)

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

=== modified file 'config.h.cmake'
--- a/config.h.cmake	2011-04-04 08:47:25 +0000
+++ b/config.h.cmake	2011-04-14 08:09:49 +0000
@@ -156,7 +156,6 @@
 #cmakedefine HAVE_GETADDRINFO 1
 #cmakedefine HAVE_GETCWD 1
 #cmakedefine HAVE_GETHOSTBYADDR_R 1
-#cmakedefine HAVE_GETHOSTBYNAME_R 1
 #cmakedefine HAVE_GETHRTIME 1
 #cmakedefine HAVE_GETLINE 1
 #cmakedefine HAVE_GETNAMEINFO 1
@@ -447,8 +446,6 @@
 
 
 #cmakedefine HAVE_SOLARIS_STYLE_GETHOST 1
-#cmakedefine HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE 1
-#cmakedefine HAVE_GETHOSTBYNAME_R_RETURN_INT 1
 
 #cmakedefine MY_ATOMIC_MODE_DUMMY 1
 #cmakedefine MY_ATOMIC_MODE_RWLOCKS 1
@@ -512,6 +509,7 @@
 #cmakedefine EXTRA_DEBUG 1
 #cmakedefine BACKUP_TEST 1
 #cmakedefine CYBOZU 1
+#cmakedefine USE_SYMDIR 1
 
 /* Character sets and collations */
 #cmakedefine MYSQL_DEFAULT_CHARSET_NAME "@MYSQL_DEFAULT_CHARSET_NAME@"

=== modified file 'configure.cmake'
--- a/configure.cmake	2011-04-04 08:47:25 +0000
+++ b/configure.cmake	2011-04-13 19:16:45 +0000
@@ -341,7 +341,6 @@ CHECK_FUNCTION_EXISTS (fseeko HAVE_FSEEK
 CHECK_FUNCTION_EXISTS (fsync HAVE_FSYNC)
 CHECK_FUNCTION_EXISTS (getcwd HAVE_GETCWD)
 CHECK_FUNCTION_EXISTS (gethostbyaddr_r HAVE_GETHOSTBYADDR_R)
-CHECK_FUNCTION_EXISTS (gethostbyname_r HAVE_GETHOSTBYNAME_R)
 CHECK_FUNCTION_EXISTS (gethrtime HAVE_GETHRTIME)
 CHECK_FUNCTION_EXISTS (getnameinfo HAVE_GETNAMEINFO)
 CHECK_FUNCTION_EXISTS (getpass HAVE_GETPASS)
@@ -912,44 +911,6 @@ CHECK_CXX_SOURCE_COMPILES("
   "
   HAVE_SOLARIS_STYLE_GETHOST)
 
-CHECK_CXX_SOURCE_COMPILES("
-    #undef inline
-    #if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
-    #define _REENTRANT
-    #endif
-    #include <pthread.h>
-    #include <sys/types.h>
-    #include <sys/socket.h>
-    #include <netinet/in.h>
-    #include <arpa/inet.h>
-    #include <netdb.h>
-    int main()
-    {
-       int ret = gethostbyname_r((const char *) 0,
-	(struct hostent*) 0, (char*) 0, 0, (struct hostent **) 0, (int *) 0);
-      return 0;
-    }"
-    HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
-
-CHECK_CXX_SOURCE_COMPILES("
-    #undef inline
-    #if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
-    #define _REENTRANT
-    #endif
-    #include <pthread.h>
-    #include <sys/types.h>
-    #include <sys/socket.h>
-    #include <netinet/in.h>
-    #include <arpa/inet.h>
-    #include <netdb.h>
-    int main()
-    {
-      int ret = gethostbyname_r((const char *) 0, (struct hostent*) 0, (struct hostent_data*) 0);
-      return 0;
-    }"
-    HAVE_GETHOSTBYNAME_R_RETURN_INT)
-
-
 # Use of ALARMs to wakeup on timeout on sockets
 #
 # This feature makes use of a mutex and is a scalability hog we

=== modified file 'include/my_global.h'
--- a/include/my_global.h	2011-04-04 13:49:51 +0000
+++ b/include/my_global.h	2011-04-13 19:16:45 +0000
@@ -297,9 +297,6 @@ C_MODE_END
 #undef HAVE_PWRITE
 #endif
 
-#ifdef UNDEF_HAVE_GETHOSTBYNAME_R		/* For OSF4.x */
-#undef HAVE_GETHOSTBYNAME_R
-#endif
 #ifdef UNDEF_HAVE_INITGROUPS			/* For AIX 4.3 */
 #undef HAVE_INITGROUPS
 #endif

=== modified file 'include/my_net.h'
--- a/include/my_net.h	2011-03-29 12:43:49 +0000
+++ b/include/my_net.h	2011-04-15 09:33:58 +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, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
 
 /*
   This file is also used to make handling of sockets and ioctl()
@@ -27,18 +27,23 @@
 C_MODE_START
 
 #include <errno.h>
+
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
+
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
+
 #ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
 #endif
+
 #ifdef HAVE_POLL
 #include <sys/poll.h>
 #endif
+
 #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
 #endif
@@ -47,9 +52,9 @@ C_MODE_START
 #include <netinet/in_systm.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
-#if !defined(alpha_linux_port)
-#include <netinet/tcp.h>
-#endif
+# if !defined(alpha_linux_port)
+#   include <netinet/tcp.h>
+# endif
 #endif
 
 #if defined(__WIN__)
@@ -61,7 +66,8 @@ C_MODE_START
   #define SD_BOTH 0x02
 */
 #define SHUT_RDWR 0x02
-
+#else
+#include <netdb.h>     /* getaddrinfo() & co */
 #endif
 
 /*

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

=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c	2011-03-08 19:14:42 +0000
+++ b/libmysql/libmysql.c	2011-04-15 09:33:58 +0000
@@ -1,11 +1,8 @@
-/* Copyright (C) 2000-2004 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation.
-
-   There are special exceptions to the terms and conditions of the GPL as it
-   is applied to this software.
+   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
@@ -14,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, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
 
 #include <my_global.h>
 #include <my_sys.h>
@@ -34,10 +31,6 @@
 #include <pwd.h>
 #endif
 #if !defined(__WIN__)
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
 #ifdef HAVE_SELECT_H
 #include <select.h>
 #endif

=== modified file 'libmysqld/libmysqld.c'
--- a/libmysqld/libmysqld.c	2010-08-09 08:32:50 +0000
+++ b/libmysqld/libmysqld.c	2011-04-15 09:33:58 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -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, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
 
 #include <my_global.h>
 #include <mysql.h>
@@ -33,10 +33,6 @@
 #include <pwd.h>
 #endif
 #if !defined(__WIN__)
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
 #ifdef HAVE_SELECT_H
 #  include <select.h>
 #endif

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

=== modified file 'mysql-test/collections/default.weekly'
--- a/mysql-test/collections/default.weekly	2011-04-06 04:31:38 +0000
+++ b/mysql-test/collections/default.weekly	2011-04-14 05:33:57 +0000
@@ -11,17 +11,17 @@ perl mysql-test-run.pl --timer --force -
 
 # Non debug runs of all the tests run in the daily and weekly collections
 
-perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=normal               --vardir=var-normal                                                                  --report-features --skip-test-list=collections/disabled-daily.list --unit-tests
+perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60  --parallel=auto --experimental=collections/default.experimental --comment=normal   --vardir=var-normal   --report-features --skip-test-list=collections/disabled-daily.list --unit-tests
 perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=n_mix                --vardir=var-n_mix                                  --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-daily.list
 perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=row                --vardir=var-row                                  --mysqld=--binlog-format=row --skip-test-list=collections/disabled-daily.list
 perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=ps_row               --vardir=var-ps_row                                 --mysqld=--binlog-format=row     --ps-protocol --skip-test-list=collections/disabled-daily.list
 perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=embedded             --vardir=var-embedded                                                                --embedded
 perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=ps                   --vardir=var-ps                                                                --ps-protocol --skip-test-list=collections/disabled-daily.list
-perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=funcs2               --vardir=var-funcs2              --suite=funcs_2
-perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=partitions           --vardir=var-parts               --suite=parts
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=stress               --vardir=var-stress              --suite=stress
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=jp                   --vardir=var-jp                  --suite=jp
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=nist                 --vardir=var-nist                --suite=nist
+perl mysql-test-run.pl --force --timer   --big-test --testcase-timeout=60  --parallel=auto --experimental=collections/default.experimental --comment=funcs2               --vardir=var-funcs2              --suite=funcs_2
+perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60  --parallel=auto --experimental=collections/default.experimental --comment=partitions           --vardir=var-parts               --suite=parts
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60  --parallel=auto --experimental=collections/default.experimental --comment=stress               --vardir=var-stress              --suite=stress
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60  --parallel=auto --experimental=collections/default.experimental --comment=jp                   --vardir=var-jp                  --suite=jp
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60  --parallel=auto --experimental=collections/default.experimental --comment=nist                 --vardir=var-nist                --suite=nist
 perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=nist+ps              --vardir=var-ps_nist             --suite=nist                                        --ps-protocol
 perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_checksum  --vardir=var-rpl_binlog_checksum --suite=rpl,binlog --mysqld=--binlog-checksum=CRC32 --skip-test-list=collections/disabled-daily.list
 perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_relay --vardir=var-rpl_crash_safe_relay --suite=rpl --mysqld=--relay-log-info-repository=TABLE --skip-test-list=collections/disabled-daily.list

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

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

=== modified file 'mysql-test/include/subquery.inc'
--- a/mysql-test/include/subquery.inc	2011-02-02 09:04:55 +0000
+++ b/mysql-test/include/subquery.inc	2011-04-15 08:11:49 +0000
@@ -5064,6 +5064,28 @@ DROP TABLE t1;
 
 
 --echo #
+--echo # Bug #11765713 58705:
+--echo # OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
+--echo # CREATED BY OPT_SUM_QUERY
+--echo #
+
+CREATE TABLE t1(a INT NOT NULL, KEY (a));
+INSERT INTO t1 VALUES (0), (1);
+
+--error ER_SUBQUERY_NO_1_ROW
+SELECT 1 as foo FROM t1 WHERE a < SOME
+  (SELECT a FROM t1 WHERE a <=>
+    (SELECT a FROM t1)
+  );
+
+SELECT 1 as foo FROM t1 WHERE a < SOME
+  (SELECT a FROM t1 WHERE a <=>
+    (SELECT a FROM t1 where a is null)
+  ); 
+
+DROP TABLE t1;
+
+--echo #
 --echo # Bug #57704: Cleanup code dies with void TABLE::set_keyread(bool): 
 --echo #             Assertion `file' failed.
 --echo #

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

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

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

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

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

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

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

=== modified file 'mysql-test/r/func_analyse.result'
--- a/mysql-test/r/func_analyse.result	2011-03-14 18:11:41 +0000
+++ b/mysql-test/r/func_analyse.result	2011-04-14 09:32:17 +0000
@@ -135,6 +135,19 @@ SELECT * FROM t1 PROCEDURE ANALYSE();
 Field_name	Min_value	Max_value	Min_length	Max_length	Empties_or_zeros	Nulls	Avg_value_or_avg_length	Std	Optimal_fieldtype
 test.t1.a	e	e-	1	2	0	0	1.3333	NULL	ENUM('e','e-') NOT NULL
 DROP TABLE t1;
+#
+# Bug#11756242  48137: PROCEDURE ANALYSE() LEAKS MEMORY WHEN RETURNING NULL
+#
+CREATE TABLE t1(f1 INT) ENGINE=MYISAM;
+CREATE TABLE t2(f2 INT) ENGINE=INNODB;
+INSERT INTO t2 VALUES (1);
+SELECT DISTINCTROW f1 FROM t1 NATURAL RIGHT OUTER JOIN t2 PROCEDURE ANALYSE();
+Field_name	Min_value	Max_value	Min_length	Max_length	Empties_or_zeros	Nulls	Avg_value_or_avg_length	Std	Optimal_fieldtype
+test.t1.f1	NULL	NULL	0	0	0	1	0.0	0.0	CHAR(0)
+SELECT * FROM t2 LIMIT 1 PROCEDURE ANALYSE();
+Field_name	Min_value	Max_value	Min_length	Max_length	Empties_or_zeros	Nulls	Avg_value_or_avg_length	Std	Optimal_fieldtype
+test.t2.f2	1	1	1	1	0	0	1.0000	0.0000	ENUM('1') NOT NULL
+DROP TABLE t1, t2;
 End of 5.1 tests
 #
 # Bug #47338 assertion in handler::ha_external_lock

=== modified file 'mysql-test/r/func_group.result'
--- a/mysql-test/r/func_group.result	2011-04-02 19:42:50 +0000
+++ b/mysql-test/r/func_group.result	2011-04-12 10:31:30 +0000
@@ -1746,6 +1746,17 @@ MAX(LENGTH(a))	LENGTH(MAX(a))	MIN(a)	MAX
 20	20	18446668621106209655	18446668621106209655	18446668621106209655	18446668621106209655
 DROP TABLE t1;
 #
+# Bug #11766270  59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+#
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def				MAX(f1)	MAX(f1)	13	4	4	Y	32864	0	63
+MAX(f1)
+2001
+DROP TABLE t1;
+#
 End of 5.1 tests
 #
 # Bug#52123 Assertion failed: aggregator == aggr->Aggrtype(),

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

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

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

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

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

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

=== modified file 'mysql-test/r/loaddata.result'
--- a/mysql-test/r/loaddata.result	2010-07-14 12:05:20 +0000
+++ b/mysql-test/r/loaddata.result	2011-04-15 08:55:21 +0000
@@ -532,4 +532,11 @@ a
 0
 1
 DROP TABLE t1;
+#
+# Bug#11765139  58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U
+#
+CREATE TABLE t1(f1 INT);
+SELECT 0xE1BB30 INTO OUTFILE 't1.dat';
+LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8;
+DROP TABLE t1;
 End of 5.1 tests

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

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

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

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

=== modified file 'mysql-test/r/subquery_all.result'
--- a/mysql-test/r/subquery_all.result	2011-02-14 11:21:26 +0000
+++ b/mysql-test/r/subquery_all.result	2011-04-15 08:11:49 +0000
@@ -4923,7 +4923,7 @@ WHERE t3.name='xxx' AND t2.id=t3.id);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	4	Using where
 2	DEPENDENT SUBQUERY	t2	eq_ref	PRIMARY	PRIMARY	4	func	1	Using where; Using index; Full scan on NULL key
-2	DEPENDENT SUBQUERY	t3	eq_ref	PRIMARY	PRIMARY	4	func	1	Using index condition; Using where; Full scan on NULL key
+2	DEPENDENT SUBQUERY	t3	eq_ref	PRIMARY	PRIMARY	4	func	1	Using where; Full scan on NULL key
 SELECT * FROM t1
 WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3 
 WHERE t3.name='xxx' AND t2.id=t3.id);
@@ -6213,6 +6213,24 @@ id	select_type	table	type	possible_keys
 DROP TABLE t2;
 DROP TABLE t1;
 #
+# Bug #11765713 58705:
+# OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
+# CREATED BY OPT_SUM_QUERY
+#
+CREATE TABLE t1(a INT NOT NULL, KEY (a));
+INSERT INTO t1 VALUES (0), (1);
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1)
+);
+ERROR 21000: Subquery returns more than 1 row
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1 where a is null)
+);
+foo
+DROP TABLE t1;
+#
 # Bug #57704: Cleanup code dies with void TABLE::set_keyread(bool): 
 #             Assertion `file' failed.
 #

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

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

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

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

=== modified file 'mysql-test/r/subquery_nomat_nosj.result'
--- a/mysql-test/r/subquery_nomat_nosj.result	2011-03-24 13:16:36 +0000
+++ b/mysql-test/r/subquery_nomat_nosj.result	2011-04-15 08:11:49 +0000
@@ -6213,6 +6213,24 @@ id	select_type	table	type	possible_keys
 DROP TABLE t2;
 DROP TABLE t1;
 #
+# Bug #11765713 58705:
+# OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
+# CREATED BY OPT_SUM_QUERY
+#
+CREATE TABLE t1(a INT NOT NULL, KEY (a));
+INSERT INTO t1 VALUES (0), (1);
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1)
+);
+ERROR 21000: Subquery returns more than 1 row
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1 where a is null)
+);
+foo
+DROP TABLE t1;
+#
 # Bug #57704: Cleanup code dies with void TABLE::set_keyread(bool): 
 #             Assertion `file' failed.
 #

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

=== modified file 'mysql-test/r/subquery_none.result'
--- a/mysql-test/r/subquery_none.result	2011-02-14 11:21:26 +0000
+++ b/mysql-test/r/subquery_none.result	2011-04-15 08:11:49 +0000
@@ -6212,6 +6212,24 @@ id	select_type	table	type	possible_keys
 DROP TABLE t2;
 DROP TABLE t1;
 #
+# Bug #11765713 58705:
+# OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
+# CREATED BY OPT_SUM_QUERY
+#
+CREATE TABLE t1(a INT NOT NULL, KEY (a));
+INSERT INTO t1 VALUES (0), (1);
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1)
+);
+ERROR 21000: Subquery returns more than 1 row
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1 where a is null)
+);
+foo
+DROP TABLE t1;
+#
 # Bug #57704: Cleanup code dies with void TABLE::set_keyread(bool): 
 #             Assertion `file' failed.
 #

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

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

=== modified file 'mysql-test/r/warnings.result'
--- a/mysql-test/r/warnings.result	2010-08-30 06:38:09 +0000
+++ b/mysql-test/r/warnings.result	2011-04-15 12:14:35 +0000
@@ -316,3 +316,25 @@ SHOW ERRORS;
 Level	Code	Message
 Error	1051	Unknown table 'test.t1'
 End of 5.0 tests
+
+-- Bug#55847
+
+DROP TABLE IF EXISTS t1;
+DROP FUNCTION IF EXISTS f1;
+CREATE TABLE t1(a INT UNIQUE);
+CREATE FUNCTION f1(x INT) RETURNS INT
+BEGIN
+INSERT INTO t1 VALUES(x);
+INSERT INTO t1 VALUES(x);
+RETURN x;
+END|
+
+SHOW TABLES WHERE f1(11) = 11;
+ERROR 23000: Duplicate entry '11' for key 'a'
+
+SHOW WARNINGS;
+Level	Code	Message
+Error	1062	Duplicate entry '11' for key 'a'
+
+DROP TABLE t1;
+DROP FUNCTION f1;

=== modified file 'mysql-test/r/xa.result'
--- a/mysql-test/r/xa.result	2011-03-25 15:13:41 +0000
+++ b/mysql-test/r/xa.result	2011-04-14 08:47:14 +0000
@@ -193,8 +193,39 @@ SAVEPOINT savep;
 ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the  PREPARED state
 SET @a=(SELECT * FROM t1);
 ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the  PREPARED state
+UPDATE t1 SET a=1 WHERE a=2;
+ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the  PREPARED state
 XA COMMIT 'a';
 SELECT * FROM t1;
 a
 1
 DROP TABLE t1;
+#
+# Bug#12352846 - TRANS_XA_START(THD*):
+#                ASSERTION THD->TRANSACTION.XID_STATE.XID.IS_NULL()
+#                FAILED 
+#
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+# Connection con2
+XA START 'xid1';
+# Sending:
+INSERT INTO t2 SELECT a FROM t1;
+# Connection default
+# Waiting until INSERT ... is blocked
+DELETE FROM t1;
+COMMIT;
+# Connection con2
+# Reaping: INSERT INTO t2 SELECT a FROM t1
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+XA COMMIT 'xid1';
+ERROR XA102: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected
+XA START 'xid1';
+XA END 'xid1';
+XA PREPARE 'xid1';
+XA ROLLBACK 'xid1';
+# Connection default
+DROP TABLE t1, t2;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

=== modified file 'mysql-test/t/func_analyse.test'
--- a/mysql-test/t/func_analyse.test	2011-03-14 18:11:41 +0000
+++ b/mysql-test/t/func_analyse.test	2011-04-14 09:32:17 +0000
@@ -1,6 +1,7 @@
 #
 # Test of procedure analyse
 #
+-- source include/have_innodb.inc
 
 --disable_warnings
 drop table if exists t1,t2;
@@ -144,6 +145,17 @@ INSERT INTO t1 VALUES ('e'),('e'),('e-')
 SELECT * FROM t1 PROCEDURE ANALYSE();
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#11756242  48137: PROCEDURE ANALYSE() LEAKS MEMORY WHEN RETURNING NULL
+--echo #
+
+CREATE TABLE t1(f1 INT) ENGINE=MYISAM;
+CREATE TABLE t2(f2 INT) ENGINE=INNODB;
+INSERT INTO t2 VALUES (1);
+SELECT DISTINCTROW f1 FROM t1 NATURAL RIGHT OUTER JOIN t2 PROCEDURE ANALYSE();
+SELECT * FROM t2 LIMIT 1 PROCEDURE ANALYSE();
+DROP TABLE t1, t2;
+
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'mysql-test/t/func_group.test'
--- a/mysql-test/t/func_group.test	2011-04-02 19:42:50 +0000
+++ b/mysql-test/t/func_group.test	2011-04-12 10:31:30 +0000
@@ -1129,6 +1129,18 @@ SELECT MAX(LENGTH(a)), LENGTH(MAX(a)), M
 DROP TABLE t1;
 
 --echo #
+--echo # Bug #11766270  59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+--echo #
+
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+--enable_metadata
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+--disable_metadata
+DROP TABLE t1;
+
+
+--echo #
 --echo End of 5.1 tests
 
 ###

=== modified file 'mysql-test/t/loaddata.test'
--- a/mysql-test/t/loaddata.test	2010-07-14 12:05:20 +0000
+++ b/mysql-test/t/loaddata.test	2011-04-15 08:55:21 +0000
@@ -601,5 +601,18 @@ DROP TABLE t1;
 let $MYSQLD_DATADIR= `select @@datadir`;
 remove_file $MYSQLD_DATADIR/test/tmpp2.txt;
 
+--echo #
+--echo # Bug#11765139  58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U
+--echo #
+
+CREATE TABLE t1(f1 INT);
+EVAL SELECT 0xE1BB30 INTO OUTFILE 't1.dat';
+--disable_warnings
+LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8;
+--enable_warnings
+
+DROP TABLE t1;
+let $MYSQLD_DATADIR= `select @@datadir`;
+remove_file $MYSQLD_DATADIR/test/t1.dat;
 
 --echo End of 5.1 tests

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

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

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

=== modified file 'mysql-test/t/warnings.test'
--- a/mysql-test/t/warnings.test	2009-11-13 10:17:53 +0000
+++ b/mysql-test/t/warnings.test	2011-04-15 12:02:22 +0000
@@ -228,3 +228,43 @@ DROP TABLE t1;
 SHOW ERRORS;
 
 --echo End of 5.0 tests
+
+#
+# Bug#55847: SHOW WARNINGS returns empty result set when SQLEXCEPTION is active
+#
+
+--echo
+--echo -- Bug#55847
+--echo
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+CREATE TABLE t1(a INT UNIQUE);
+
+delimiter |;
+
+CREATE FUNCTION f1(x INT) RETURNS INT
+BEGIN
+  INSERT INTO t1 VALUES(x);
+  INSERT INTO t1 VALUES(x);
+  RETURN x;
+END|
+
+delimiter ;|
+
+--echo
+
+--error ER_DUP_ENTRY
+SHOW TABLES WHERE f1(11) = 11;
+
+--echo
+
+SHOW WARNINGS;
+
+--echo
+
+DROP TABLE t1;
+DROP FUNCTION f1;

=== modified file 'mysql-test/t/xa.test'
--- a/mysql-test/t/xa.test	2011-03-25 15:13:41 +0000
+++ b/mysql-test/t/xa.test	2011-04-14 08:47:14 +0000
@@ -3,6 +3,8 @@
 #
 -- source include/have_innodb.inc
 
+--source include/not_embedded.inc
+
 # Save the initial number of concurrent sessions
 --source include/count_sessions.inc
 
@@ -318,12 +320,67 @@ INSERT INTO t1 VALUES (2); # used to cau
 SAVEPOINT savep;
 --error ER_XAER_RMFAIL
 SET @a=(SELECT * FROM t1); # used to cause InnoDB assert
+--error ER_XAER_RMFAIL
+UPDATE t1 SET a=1 WHERE a=2;
 
 XA COMMIT 'a';
 SELECT * FROM t1;
 DROP TABLE t1;
 
 
+--echo #
+--echo # Bug#12352846 - TRANS_XA_START(THD*):
+--echo #                ASSERTION THD->TRANSACTION.XID_STATE.XID.IS_NULL()
+--echo #                FAILED 
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+
+--echo # Connection con2
+--connect (con2,localhost,root)
+XA START 'xid1';
+--echo # Sending:
+--send INSERT INTO t2 SELECT a FROM t1
+
+--echo # Connection default
+--connection default
+let $wait_condition=
+  SELECT COUNT(*) = 1 FROM information_schema.processlist
+  WHERE state = "Sending data"
+  AND info = "INSERT INTO t2 SELECT a FROM t1";
+--echo # Waiting until INSERT ... is blocked
+--source include/wait_condition.inc
+DELETE FROM t1;
+COMMIT;
+
+--echo # Connection con2
+--connection con2
+--echo # Reaping: INSERT INTO t2 SELECT a FROM t1
+--error ER_LOCK_DEADLOCK
+--reap
+--error ER_XA_RBDEADLOCK
+XA COMMIT 'xid1';
+# This caused the assert to be triggered
+XA START 'xid1';
+
+XA END 'xid1';
+XA PREPARE 'xid1';
+XA ROLLBACK 'xid1';
+
+--echo # Connection default
+connection default;
+DROP TABLE t1, t2;
+disconnect con2;
+
+
 # Wait till all disconnects are completed
 --source include/wait_until_count_sessions.inc
 

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

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

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

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

=== modified file 'sql-common/client.c'
--- a/sql-common/client.c	2011-03-17 09:43:28 +0000
+++ b/sql-common/client.c	2011-04-15 09:33:58 +0000
@@ -37,10 +37,6 @@
 
 #include "mysql.h"
 
-#ifndef __WIN__
-#include <netdb.h>
-#endif
-
 /* Remove client convenience wrappers */
 #undef max_allowed_packet
 #undef net_buffer_length
@@ -61,6 +57,7 @@ my_bool	net_flush(NET *net);
 #else  /*EMBEDDED_LIBRARY*/
 #define CLI_MYSQL_REAL_CONNECT STDCALL mysql_real_connect
 #endif /*EMBEDDED_LIBRARY*/
+
 #include <my_sys.h>
 #include <mysys_err.h>
 #include <m_string.h>
@@ -69,6 +66,7 @@ my_bool	net_flush(NET *net);
 #include "mysqld_error.h"
 #include "errmsg.h"
 #include <violite.h>
+
 #if !defined(__WIN__)
 #include <my_pthread.h>				/* because of signal()	*/
 #endif /* !defined(__WIN__) */
@@ -76,21 +74,20 @@ my_bool	net_flush(NET *net);
 #include <sys/stat.h>
 #include <signal.h>
 #include <time.h>
+
 #ifdef	 HAVE_PWD_H
 #include <pwd.h>
 #endif
+
 #if !defined(__WIN__)
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
 #ifdef HAVE_SELECT_H
 #  include <select.h>
 #endif
 #ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
+#  include <sys/select.h>
 #endif
 #endif /* !defined(__WIN__) */
+
 #ifdef HAVE_SYS_UN_H
 #  include <sys/un.h>
 #endif
@@ -111,6 +108,7 @@ my_bool	net_flush(NET *net);
 #include "client_settings.h"
 #include <sql_common.h>
 #include <mysql/client_plugin.h>
+
 #define native_password_plugin_name "mysql_native_password"
 #define old_password_plugin_name    "mysql_old_password"
 

=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt	2011-02-02 08:30:13 +0000
+++ b/sql/CMakeLists.txt	2011-04-15 09:04:21 +0000
@@ -64,6 +64,7 @@ SET(SQL_SHARED_SOURCES
   item_sum.cc
   item_timefunc.cc 
   item_xmlfunc.cc 
+  item_inetfunc.cc
   key.cc
   keycaches.cc
   lock.cc

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2011-04-04 08:47:25 +0000
+++ b/sql/field.cc	2011-04-12 10:31:30 +0000
@@ -5380,6 +5380,7 @@ double Field_year::val_real(void)
 longlong Field_year::val_int(void)
 {
   ASSERT_COLUMN_MARKED_FOR_READ;
+  DBUG_ASSERT(field_length == 2 || field_length == 4);
   int tmp= (int) ptr[0];
   if (field_length != 4)
     tmp%=100;					// Return last 2 char
@@ -5392,6 +5393,7 @@ longlong Field_year::val_int(void)
 String *Field_year::val_str(String *val_buffer,
 			    String *val_ptr __attribute__((unused)))
 {
+  DBUG_ASSERT(field_length < 5);
   val_buffer->alloc(5);
   val_buffer->length(field_length);
   char *to=(char*) val_buffer->ptr();

=== modified file 'sql/hostname.cc'
--- a/sql/hostname.cc	2010-07-23 20:59:42 +0000
+++ b/sql/hostname.cc	2011-04-15 09:33:58 +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
@@ -26,10 +26,6 @@
 
 #include "sql_priv.h"
 #include "hostname.h"
-#include "my_global.h"
-#ifndef __WIN__
-#include <netdb.h>        // getservbyname, servent
-#endif
 #include "hash_filo.h"
 #include <m_ctype.h>
 #include "log.h"                                // sql_print_warning,
@@ -366,41 +362,35 @@ bool ip_to_hostname(struct sockaddr_stor
   err_code= vio_getnameinfo(ip, hostname_buffer, NI_MAXHOST, NULL, 0,
                             NI_NAMEREQD);
 
-  if (err_code == EAI_NONAME)
+  if (err_code)
   {
-    /*
-      There is no reverse address mapping for the IP address. A host name
-      can not be resolved.
-    */
-
-    DBUG_PRINT("error", ("IP address '%s' could not be resolved: "
-                         "no reverse address mapping.",
-                         (const char *) ip_key));
+    // NOTE: gai_strerror() returns a string ending by a dot.
 
-    sql_print_warning("IP address '%s' could not be resolved: "
-                      "no reverse address mapping.",
-                      (const char *) ip_key);
+    DBUG_PRINT("error", ("IP address '%s' could not be resolved: %s",
+                         (const char *) ip_key,
+                         (const char *) gai_strerror(err_code)));
 
-    err_status= add_hostname(ip_key, NULL);
+    sql_print_warning("IP address '%s' could not be resolved: %s",
+                      (const char *) ip_key,
+                      (const char *) gai_strerror(err_code));
 
-    *hostname= NULL;
-    *connect_errors= 0; /* New IP added to the cache. */
+    if (vio_is_no_name_error(err_code))
+    {
+      /*
+        The no-name error means that there is no reverse address mapping
+        for the IP address. A host name can not be resolved.
+
+        If it is not the no-name error, we should not cache the hostname
+        (or rather its absence), because the failure might be transient.
+      */
 
-    DBUG_RETURN(err_status);
-  }
-  else if (err_code)
-  {
-    DBUG_PRINT("error", ("IP address '%s' could not be resolved: "
-                         "getnameinfo() returned %d.",
-                         (const char *) ip_key,
-                         (int) err_code));
+      add_hostname(ip_key, NULL);
 
-    sql_print_warning("IP address '%s' could not be resolved: "
-                      "getnameinfo() returned error (code: %d).",
-                      (const char *) ip_key,
-                      (int) err_code);
+      *hostname= NULL;
+      *connect_errors= 0; /* New IP added to the cache. */
+    }
 
-    DBUG_RETURN(TRUE);
+    DBUG_RETURN(FALSE);
   }
 
   DBUG_PRINT("info", ("IP '%s' resolved to '%s'.",

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2011-04-04 08:47:25 +0000
+++ b/sql/item.cc	2011-04-11 10:28:36 +0000
@@ -1765,7 +1765,8 @@ bool agg_item_collations(DTCollation &c,
   }
   
   /* If all arguments where numbers, reset to @@collation_connection */
-  if (c.derivation == DERIVATION_NUMERIC)
+  if (flags & MY_COLL_ALLOW_NUMERIC_CONV &&
+      c.derivation == DERIVATION_NUMERIC)
     c.set(Item::default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_NUMERIC);
 
   return FALSE;
@@ -2979,12 +2980,12 @@ bool Item_param::set_longdata(const char
     (here), and first have to concatenate all pieces together,
     write query to the binary log and only then perform conversion.
   */
-  if (str_value.length() + length > max_long_data_size)
+  if (str_value.length() + length > current_thd->variables.max_allowed_packet)
   {
     my_message(ER_UNKNOWN_ERROR,
                "Parameter of prepared statement which is set through "
                "mysql_send_long_data() is longer than "
-               "'max_long_data_size' bytes",
+               "'max_allowed_packet' bytes",
                MYF(0));
     DBUG_RETURN(true);
   }
@@ -6576,7 +6577,7 @@ void Item_ref::print(String *str, enum_q
     {
       THD *thd= current_thd;
       append_identifier(thd, str, (*ref)->real_item()->name,
-                        (*ref)->real_item()->name_length);
+                        strlen((*ref)->real_item()->name));
     }
     else
       (*ref)->print(str, query_type);
@@ -6742,7 +6743,19 @@ my_decimal *Item_ref::val_decimal(my_dec
 int Item_ref::save_in_field(Field *to, bool no_conversions)
 {
   int res;
-  DBUG_ASSERT(!result_field);
+  if (result_field)
+  {
+    if (result_field->is_null())
+    {
+      null_value= 1;
+      res= set_field_to_null_with_conversions(to, no_conversions);
+      return res;
+    }
+    to->set_notnull();
+    res= field_conv(to, result_field);
+    null_value= 0;
+    return res;
+  }
   res= (*ref)->save_in_field(to, no_conversions);
   null_value= (*ref)->null_value;
   return res;

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

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

=== modified file 'sql/item_create.cc'
--- a/sql/item_create.cc	2011-03-09 20:54:55 +0000
+++ b/sql/item_create.cc	2011-04-15 09:04:21 +0000
@@ -30,6 +30,7 @@
 #include "set_var.h"
 #include "sp_head.h"
 #include "sp.h"
+#include "item_inetfunc.h"
 
 /*
 =============================================================================

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2011-03-28 13:38:03 +0000
+++ b/sql/item_func.cc	2011-04-15 09:04:21 +0000
@@ -2550,7 +2550,8 @@ void Item_func_min_max::fix_length_and_d
   }
   if (cmp_type == STRING_RESULT)
   {
-    agg_arg_charsets_for_comparison(collation, args, arg_count);
+    agg_arg_charsets_for_string_result_with_comparison(collation,
+                                                       args, arg_count);
     if (datetime_found)
     {
       thd= current_thd;
@@ -5710,61 +5711,6 @@ void Item_func_get_system_var::cleanup()
 }
 
 
-longlong Item_func_inet_aton::val_int()
-{
-  DBUG_ASSERT(fixed == 1);
-  uint byte_result = 0;
-  ulonglong result = 0;			// We are ready for 64 bit addresses
-  const char *p,* end;
-  char c = '.'; // we mark c to indicate invalid IP in case length is 0
-  char buff[36];
-  int dot_count= 0;
-
-  String *s, tmp(buff, sizeof(buff), &my_charset_latin1);
-  if (!(s = args[0]->val_str_ascii(&tmp)))       // If null value
-    goto err;
-  null_value=0;
-
-  end= (p = s->ptr()) + s->length();
-  while (p < end)
-  {
-    c = *p++;
-    int digit = (int) (c - '0');
-    if (digit >= 0 && digit <= 9)
-    {
-      if ((byte_result = byte_result * 10 + digit) > 255)
-	goto err;				// Wrong address
-    }
-    else if (c == '.')
-    {
-      dot_count++;
-      result= (result << 8) + (ulonglong) byte_result;
-      byte_result = 0;
-    }
-    else
-      goto err;					// Invalid character
-  }
-  if (c != '.')					// IP number can't end on '.'
-  {
-    /*
-      Handle short-forms addresses according to standard. Examples:
-      127		-> 0.0.0.127
-      127.1		-> 127.0.0.1
-      127.2.1		-> 127.2.0.1
-    */
-    switch (dot_count) {
-    case 1: result<<= 8; /* Fall through */
-    case 2: result<<= 8; /* Fall through */
-    }
-    return (result << 8) + (ulonglong) byte_result;
-  }
-
-err:
-  null_value=1;
-  return 0;
-}
-
-
 void Item_func_match::init_search(bool no_order)
 {
   DBUG_ENTER("Item_func_match::init_search");

=== modified file 'sql/item_func.h'
--- a/sql/item_func.h	2011-03-22 11:44:40 +0000
+++ b/sql/item_func.h	2011-04-15 09:04:21 +0000
@@ -164,6 +164,11 @@ public:
   {
     return agg_item_charsets(c, func_name(), items, nitems, flags, item_sep);
   }
+  /*
+    Aggregate arguments for string result, e.g: CONCAT(a,b)
+    - convert to @@character_set_connection if all arguments are numbers
+    - allow DERIVATION_NONE
+  */
   bool agg_arg_charsets_for_string_result(DTCollation &c,
                                           Item **items, uint nitems,
                                           int item_sep= 1)
@@ -171,6 +176,11 @@ public:
     return agg_item_charsets_for_string_result(c, func_name(),
                                                items, nitems, item_sep);
   }
+  /*
+    Aggregate arguments for comparison, e.g: a=b, a LIKE b, a RLIKE b
+    - don't convert to @@character_set_connection if all arguments are numbers
+    - don't allow DERIVATION_NONE
+  */
   bool agg_arg_charsets_for_comparison(DTCollation &c,
                                        Item **items, uint nitems,
                                        int item_sep= 1)
@@ -178,6 +188,21 @@ public:
     return agg_item_charsets_for_comparison(c, func_name(),
                                             items, nitems, item_sep);
   }
+  /*
+    Aggregate arguments for string result, when some comparison
+    is involved internally, e.g: REPLACE(a,b,c)
+    - convert to @@character_set_connection if all arguments are numbers
+    - disallow DERIVATION_NONE
+  */
+  bool agg_arg_charsets_for_string_result_with_comparison(DTCollation &c,
+                                                          Item **items,
+                                                          uint nitems,
+                                                          int item_sep= 1)
+  {
+    return agg_item_charsets_for_string_result_with_comparison(c, func_name(),
+                                                               items, nitems,
+                                                               item_sep);
+  }
   bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
   Item *transform(Item_transformer transformer, uchar *arg);
   Item* compile(Item_analyzer analyzer, uchar **arg_p,
@@ -1610,17 +1635,6 @@ public:
 };
 
 
-class Item_func_inet_aton : public Item_int_func
-{
-public:
-  Item_func_inet_aton(Item *a) :Item_int_func(a) {}
-  longlong val_int();
-  const char *func_name() const { return "inet_aton"; }
-  void fix_length_and_dec()
-    { decimals= 0; max_length= 21; maybe_null= 1; unsigned_flag= 1;}
-};
-
-
 /* for fulltext search */
 #include <ft_global.h>
 

=== added file 'sql/item_inetfunc.cc'
--- a/sql/item_inetfunc.cc	1970-01-01 00:00:00 +0000
+++ b/sql/item_inetfunc.cc	2011-04-15 09:42:59 +0000
@@ -0,0 +1,133 @@
+/* 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 "item_inetfunc.h"
+
+#include "violite.h"  // vio_getnameinfo()
+
+///////////////////////////////////////////////////////////////////////////
+
+longlong Item_func_inet_aton::val_int()
+{
+  DBUG_ASSERT(fixed);
+
+  uint byte_result= 0;
+  ulonglong result= 0;
+  const char *p,* end;
+  char c= '.'; // we mark c to indicate invalid IP in case length is 0
+  char buff[36];
+  int dot_count= 0;
+
+  String tmp(buff, sizeof (buff), &my_charset_latin1);
+  String *s= args[0]->val_str_ascii(&tmp);
+
+  if (!s)       // If null value
+    goto err;
+
+  null_value= 0;
+
+  p= s->ptr();
+  end= p + s->length();
+  while (p < end)
+  {
+    c= *p++;
+    int digit= (int) (c - '0');
+    if (digit >= 0 && digit <= 9)
+    {
+      byte_result= byte_result * 10 + digit;
+      if (byte_result > 255)
+        goto err;                               // Wrong address
+    }
+    else if (c == '.')
+    {
+      dot_count++;
+      result= (result << 8) + (ulonglong) byte_result;
+      byte_result= 0;
+    }
+    else
+      goto err;                                 // Invalid character
+  }
+  if (c != '.')                                 // IP number can't end on '.'
+  {
+    /*
+      Attempt to support short-form addresses (i.e. classful addresses).
+      The current code does not support full range of classful addresses.
+      Examples:
+        127     -> 0.0.0.127
+        127.255 -> 127.0.0.255
+        127.256 -> NULL (should have been 127.0.1.0)
+        127.2.1 -> 127.2.0.1
+    */
+    switch (dot_count) {
+    case 1: result<<= 8; /* Fall through */
+    case 2: result<<= 8; /* Fall through */
+    }
+    return (result << 8) + (ulonglong) byte_result;
+  }
+
+err:
+  null_value=1;
+  return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+String* Item_func_inet_ntoa::val_str(String* str)
+{
+  DBUG_ASSERT(fixed);
+
+  ulonglong n= (ulonglong) args[0]->val_int();
+
+  /*
+    We do not know if args[0] is NULL until we have called
+    some val function on it if args[0] is not a constant!
+
+    Also return null if n > 255.255.255.255
+  */
+  null_value= args[0]->null_value || n > (ulonglong) LL(4294967295);
+
+  if (null_value)
+    return 0;                                   // Null value
+
+  str->set_charset(collation.collation);
+  str->length(0);
+
+  uchar buf[8];
+  int4store(buf, n);
+
+  /* Now we can assume little endian. */
+
+  char num[4];
+  num[3]= '.';
+
+  for (uchar *p= buf + 4; p-- > buf;)
+  {
+    uint c= *p;
+    uint n1, n2;                                // Try to avoid divisions
+    n1= c / 100;                                // 100 digits
+    c -= n1 * 100;
+    n2= c / 10;                                 // 10 digits
+    c -= n2 * 10;                               // last digit
+    num[0]= (char) n1 + '0';
+    num[1]= (char) n2 + '0';
+    num[2]= (char) c + '0';
+    uint length= (n1 ? 4 : n2 ? 3 : 2);         // Remove pre-zero
+    uint dot_length= (p <= buf) ? 1 : 0;
+
+    str->append(num + 4 - length, length - dot_length, &my_charset_latin1);
+  }
+
+  return str;
+}

=== added file 'sql/item_inetfunc.h'
--- a/sql/item_inetfunc.h	1970-01-01 00:00:00 +0000
+++ b/sql/item_inetfunc.h	2011-04-15 09:39:46 +0000
@@ -0,0 +1,74 @@
+#ifndef ITEM_INETFUNC_INCLUDED
+#define ITEM_INETFUNC_INCLUDED
+
+/* 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 "item.h"
+
+/*************************************************************************
+  Item_func_inet_aton implements INET_ATON() SQL-function.
+*************************************************************************/
+
+class Item_func_inet_aton : public Item_int_func
+{
+public:
+  inline Item_func_inet_aton(Item *arg)
+    : Item_int_func(arg)
+  {}
+
+public:
+  virtual longlong val_int();
+
+  virtual const char *func_name() const
+  { return "inet_aton"; }
+
+  virtual void fix_length_and_dec()
+  {
+    decimals= 0;
+    max_length= 21;
+    maybe_null= 1;
+    unsigned_flag= 1;
+  }
+};
+
+
+/*************************************************************************
+  Item_func_inet_ntoa implements INET_NTOA() SQL-function.
+*************************************************************************/
+
+class Item_func_inet_ntoa : public Item_str_func
+{
+public:
+  inline Item_func_inet_ntoa(Item *arg)
+    : Item_str_func(arg)
+  { }
+
+public:
+  virtual String* val_str(String* str);
+
+  virtual const char *func_name() const
+  { return "inet_ntoa"; }
+
+  virtual void fix_length_and_dec()
+  {
+    decimals= 0;
+    fix_length_and_charset(3 * 8 + 7, default_charset());
+    maybe_null= 1;
+  }
+};
+
+#endif // ITEM_INETFUNC_INCLUDED

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2011-03-24 10:37:16 +0000
+++ b/sql/item_strfunc.cc	2011-04-15 09:04:21 +0000
@@ -1261,7 +1261,7 @@ void Item_func_replace::fix_length_and_d
     char_length+= max_substrs * (uint) diff;
   }
 
-  if (agg_arg_charsets_for_comparison(collation, args, 3))
+  if (agg_arg_charsets_for_string_result_with_comparison(collation, args, 3))
     return;
   fix_char_length_ulonglong(char_length);
 }
@@ -1551,7 +1551,7 @@ void Item_func_substr::fix_length_and_de
 
 void Item_func_substr_index::fix_length_and_dec()
 { 
-  if (agg_arg_charsets_for_comparison(collation, args, 2))
+  if (agg_arg_charsets_for_string_result_with_comparison(collation, args, 2))
     return;
   fix_char_length(args[0]->max_char_length());
 }
@@ -1890,7 +1890,8 @@ void Item_func_trim::fix_length_and_dec(
   {
     // Handle character set for args[1] and args[0].
     // Note that we pass args[1] as the first item, and args[0] as the second.
-    if (agg_arg_charsets_for_comparison(collation, &args[1], 2, -1))
+    if (agg_arg_charsets_for_string_result_with_comparison(collation,
+                                                           &args[1], 2, -1))
       return;
   }
   fix_char_length(args[0]->max_char_length());
@@ -3512,48 +3513,6 @@ void Item_func_export_set::fix_length_an
   fix_char_length(length * 64 + sep_length * 63);
 }
 
-String* Item_func_inet_ntoa::val_str(String* str)
-{
-  DBUG_ASSERT(fixed == 1);
-  uchar buf[8], *p;
-  ulonglong n = (ulonglong) args[0]->val_int();
-  char num[4];
-
-  /*
-    We do not know if args[0] is NULL until we have called
-    some val function on it if args[0] is not a constant!
-
-    Also return null if n > 255.255.255.255
-  */
-  if ((null_value= (args[0]->null_value || n > (ulonglong) LL(4294967295))))
-    return 0;					// Null value
-
-  str->set_charset(collation.collation);
-  str->length(0);
-  int4store(buf,n);
-
-  /* Now we can assume little endian. */
-
-  num[3]='.';
-  for (p=buf+4 ; p-- > buf ; )
-  {
-    uint c = *p;
-    uint n1,n2;					// Try to avoid divisions
-    n1= c / 100;				// 100 digits
-    c-= n1*100;
-    n2= c / 10;					// 10 digits
-    c-=n2*10;					// last digit
-    num[0]=(char) n1+'0';
-    num[1]=(char) n2+'0';
-    num[2]=(char) c+'0';
-    uint length= (n1 ? 4 : n2 ? 3 : 2);         // Remove pre-zero
-    uint dot_length= (p <= buf) ? 1 : 0;
-    (void) str->append(num + 4 - length, length - dot_length,
-                       &my_charset_latin1);
-  }
-  return str;
-}
-
 
 #define get_esc_bit(mask, num) (1 & (*((mask) + ((num) >> 3))) >> ((num) & 7))
 

=== modified file 'sql/item_strfunc.h'
--- a/sql/item_strfunc.h	2011-03-22 11:44:40 +0000
+++ b/sql/item_strfunc.h	2011-04-15 09:04:21 +0000
@@ -780,22 +780,6 @@ class Item_func_export_set: public Item_
   const char *func_name() const { return "export_set"; }
 };
 
-class Item_func_inet_ntoa : public Item_str_func
-{
-public:
-  Item_func_inet_ntoa(Item *a) :Item_str_func(a)
-    {
-    }
-  String* val_str(String* str);
-  const char *func_name() const { return "inet_ntoa"; }
-  void fix_length_and_dec() 
-  { 
-    decimals= 0; 
-    fix_length_and_charset(3 * 8 + 7, default_charset()); 
-    maybe_null= 1;
-  }
-};
-
 class Item_func_quote :public Item_str_func
 {
   String tmp_value;

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

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

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-04-04 08:47:25 +0000
+++ b/sql/mysqld.cc	2011-04-15 09:33:58 +0000
@@ -17,9 +17,6 @@
 #include "sql_priv.h"
 #include "unireg.h"
 #include <signal.h>
-#ifndef __WIN__
-#include <netdb.h>        // getservbyname, servent
-#endif
 #include "sql_parse.h"    // test_if_data_home_dir
 #include "sql_cache.h"    // query_cache, query_cache_*
 #include "sql_locale.h"   // MY_LOCALES, my_locales, my_locale_by_name
@@ -244,11 +241,7 @@ inline void setup_fpu()
 
 #define MYSQL_KILL_SIGNAL SIGTERM
 
-#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
-#include <sys/types.h>
-#else
 #include <my_pthread.h>			// For thr_setconcurency()
-#endif
 
 #ifdef SOLARIS
 extern "C" int gethostname(char *name, int namelen);
@@ -323,7 +316,6 @@ static PSI_rwlock_key key_rwlock_openssl
 
 /* the default log output is log tables */
 static bool lower_case_table_names_used= 0;
-static bool max_long_data_size_used= false;
 static bool volatile select_thread_in_use, signal_thread_in_use;
 /* See Bug#56666 and Bug#56760 */;
 volatile bool ready_to_exit;
@@ -482,11 +474,6 @@ ulong specialflag=0;
 ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
 ulong binlog_stmt_cache_use= 0, binlog_stmt_cache_disk_use= 0;
 ulong max_connections, max_connect_errors;
-/*
-  Maximum length of parameter value which can be set through
-  mysql_send_long_data() call.
-*/
-ulong max_long_data_size;
 /**
   Limit of the total number of prepared statements in the server.
   Is necessary to protect the server against out-of-memory attacks.
@@ -7592,10 +7579,6 @@ mysqld_get_one_option(int optid,
     if (argument == NULL) /* no argument */
       log_error_file_ptr= const_cast<char*>("");
     break;
-  case OPT_MAX_LONG_DATA_SIZE:
-    max_long_data_size_used= true;
-    WARN_DEPRECATED(NULL, "--max_long_data_size", "'--max_allowed_packet'");
-    break;
   }
   return 0;
 }
@@ -7830,13 +7813,6 @@ static int get_options(int *argc_ptr, ch
 
   opt_readonly= read_only;
 
-  /*
-    If max_long_data_size is not specified explicitly use
-    value of max_allowed_packet.
-  */
-  if (!max_long_data_size_used)
-    max_long_data_size= global_system_variables.max_allowed_packet;
-
   return 0;
 }
 

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2011-04-04 08:47:25 +0000
+++ b/sql/opt_range.cc	2011-04-07 14:24:47 +0000
@@ -1154,8 +1154,7 @@ SQL_SELECT::SQL_SELECT() :quick(0),cond(
 
 void SQL_SELECT::cleanup()
 {
-  delete quick;
-  quick= 0;
+  set_quick(NULL);
   if (free_cond)
   {
     free_cond=0;
@@ -2216,8 +2215,7 @@ int SQL_SELECT::test_quick_select(THD *t
 		      (ulong) keys_to_use.to_ulonglong(), (ulong) prev_tables,
 		      (ulong) const_tables));
   DBUG_PRINT("info", ("records: %lu", (ulong) head->file->stats.records));
-  delete quick;
-  quick=0;
+  set_quick(NULL);
   needed_reg.clear_all();
   quick_keys.clear_all();
   if (keys_to_use.is_clear_all())
@@ -2458,10 +2456,7 @@ int SQL_SELECT::test_quick_select(THD *t
     {
       records= best_trp->records;
       if (!(quick= best_trp->make_quick(&param, TRUE)) || quick->init())
-      {
-        delete quick;
-        quick= NULL;
-      }
+        set_quick(NULL);
     }
 
   free_mem:

=== modified file 'sql/opt_sum.cc'
--- a/sql/opt_sum.cc	2010-12-08 12:55:40 +0000
+++ b/sql/opt_sum.cc	2011-04-15 08:11:49 +0000
@@ -212,6 +212,7 @@ static int get_index_max_value(TABLE *ta
 /**
   Substitutes constants for some COUNT(), MIN() and MAX() functions.
 
+  @param thd                   thread handler
   @param tables                list of leaves of join table tree
   @param all_fields            All fields to be returned
   @param conds                 WHERE clause
@@ -229,9 +230,12 @@ static int get_index_max_value(TABLE *ta
     HA_ERR_KEY_NOT_FOUND on impossible conditions
   @retval
     HA_ERR_... if a deadlock or a lock wait timeout happens, for example
+  @retval
+    ER_...     e.g. ER_SUBQUERY_NO_1_ROW
 */
 
-int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,Item *conds)
+int opt_sum_query(THD *thd,
+                  TABLE_LIST *tables, List<Item> &all_fields, Item *conds)
 {
   List_iterator_fast<Item> it(all_fields);
   int const_result= 1;
@@ -243,6 +247,8 @@ int opt_sum_query(TABLE_LIST *tables, Li
   Item *item;
   int error;
 
+  DBUG_ENTER("opt_sum_query");
+
   if (conds)
     where_tables= conds->used_tables();
 
@@ -270,7 +276,7 @@ int opt_sum_query(TABLE_LIST *tables, Li
           WHERE t2.field IS NULL;
       */
       if (tl->table->map & where_tables)
-        return 0;
+        DBUG_RETURN(0);
     }
     else
       used_tables|= tl->table->map;
@@ -297,7 +303,7 @@ int opt_sum_query(TABLE_LIST *tables, Li
       if(error)
       {
         tl->table->file->print_error(error, MYF(ME_FATALERROR));
-        return error;
+        DBUG_RETURN(error);
       }
       count*= tl->table->file->stats.records;
     }
@@ -390,10 +396,10 @@ int opt_sum_query(TABLE_LIST *tables, Li
           if (error)
 	  {
 	    if (error == HA_ERR_KEY_NOT_FOUND || error == HA_ERR_END_OF_FILE)
-	      return HA_ERR_KEY_NOT_FOUND;	      // No rows matching WHERE
+	      DBUG_RETURN(HA_ERR_KEY_NOT_FOUND); // No rows matching WHERE
 	    /* HA_ERR_LOCK_DEADLOCK or some other error */
  	    table->file->print_error(error, MYF(0));
-            return(error);
+            DBUG_RETURN(error);
 	  }
           removed_tables|= table->map;
         }
@@ -442,6 +448,10 @@ int opt_sum_query(TABLE_LIST *tables, Li
         const_result= 0;
     }
   }
+
+  if (thd->is_error())
+    DBUG_RETURN(thd->stmt_da->sql_errno());
+
   /*
     If we have a where clause, we can only ignore searching in the
     tables if MIN/MAX optimisation replaced all used tables
@@ -451,7 +461,7 @@ int opt_sum_query(TABLE_LIST *tables, Li
   */
   if (removed_tables && used_tables != removed_tables)
     const_result= 0;                            // We didn't remove all tables
-  return const_result;
+  DBUG_RETURN(const_result);
 }
 
 
@@ -737,6 +747,12 @@ static bool matching_cond(bool max_fl, T
 
     if (is_null || (is_null_safe_eq && args[1]->is_null()))
     {
+      /*
+        If we have a non-nullable index, we cannot use it,
+        since set_null will be ignored, and we will compare uninitialized data.
+      */
+      if (!part->field->real_maybe_null())
+        DBUG_RETURN(false);
       part->field->set_null();
       *key_ptr= (uchar) 1;
     }
@@ -807,8 +823,9 @@ static bool matching_cond(bool max_fl, T
   @param[out]    prefix_len  Length of prefix for the search range
 
   @note
-    This function may set table->key_read to 1, which must be reset after
-    index is used! (This can only happen when function returns 1)
+    This function may set field->table->key_read to true,
+    which must be reset after index is used!
+    (This can only happen when function returns 1)
 
   @retval
     0   Index can not be used to optimize MIN(field)/MAX(field)
@@ -823,7 +840,9 @@ static bool find_key_for_maxmin(bool max
                                 uint *range_fl, uint *prefix_len)
 {
   if (!(field->flags & PART_KEY_FLAG))
-    return 0;                                        // Not key field
+    return false;                               // Not key field
+
+  DBUG_ENTER("find_key_for_maxmin");
 
   TABLE *table= field->table;
   uint idx= 0;
@@ -848,7 +867,7 @@ static bool find_key_for_maxmin(bool max
          part++, jdx++, key_part_to_use= (key_part_to_use << 1) | 1)
     {
       if (!(table->file->index_flags(idx, jdx, 0) & HA_READ_ORDER))
-        return 0;
+        DBUG_RETURN(false);
 
       /* Check whether the index component is partial */
       Field *part_field= table->field[part->fieldnr-1];
@@ -897,12 +916,12 @@ static bool find_key_for_maxmin(bool max
           */
           if (field->part_of_key.is_set(idx))
             table->set_keyread(TRUE);
-          return 1;
+          DBUG_RETURN(true);
         }
       }
     }
   }
-  return 0;
+  DBUG_RETURN(false);
 }
 
 

=== modified file 'sql/rpl_info_factory.h'
--- a/sql/rpl_info_factory.h	2011-03-23 23:28:49 +0000
+++ b/sql/rpl_info_factory.h	2011-04-14 12:25:14 +0000
@@ -36,10 +36,10 @@ public:
   static bool create(uint mi_option, Master_info **mi,
                      uint rli_option, Relay_log_info **rli);
   static Master_info *create_mi(uint rli_option);
-  static bool change_mi_repository(Master_info *mi, uint mi_option,
+  static bool change_mi_repository(Master_info *mi, const uint mi_option,
                                    const char **msg);
   static Relay_log_info *create_rli(uint rli_option, bool is_slave_recovery);
-  static bool change_rli_repository(Relay_log_info *mi, uint mi_option,
+  static bool change_rli_repository(Relay_log_info *mi, const uint mi_option,
                                     const char **msg);
 private:
   static bool decide_repository(Rpl_info *info,

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2011-03-22 11:44:40 +0000
+++ b/sql/sp_head.cc	2011-04-15 12:14:35 +0000
@@ -1214,7 +1214,8 @@ sp_head::execute(THD *thd, bool merge_da
   String old_packet;
   Reprepare_observer *save_reprepare_observer= thd->m_reprepare_observer;
   Object_creation_ctx *saved_creation_ctx;
-  Warning_info *saved_warning_info, warning_info(thd->warning_info->warn_id());
+  Warning_info *saved_warning_info;
+  Warning_info warning_info(thd->warning_info->warn_id(), false);
 
   /*
     Just reporting a stack overrun error

=== modified file 'sql/sql_admin.cc'
--- a/sql/sql_admin.cc	2011-03-08 09:21:39 +0000
+++ b/sql/sql_admin.cc	2011-04-15 12:14:35 +0000
@@ -263,7 +263,7 @@ static bool mysql_admin_table(THD* thd,
                               const char *operator_name,
                               thr_lock_type lock_type,
                               bool open_for_modify,
-                              bool no_warnings_for_error,
+                              bool repair_table_use_frm,
                               uint extra_open_options,
                               int (*prepare_func)(THD *, TABLE_LIST *,
                                                   HA_CHECK_OPT *),
@@ -331,18 +331,43 @@ static bool mysql_admin_table(THD* thd,
       lex->query_tables= table;
       lex->query_tables_last= &table->next_global;
       lex->query_tables_own_last= 0;
-      /*
-        Under locked tables, we know that the table can be opened,
-        so any errors opening the table are logical errors.
-        In these cases it makes sense to report them.
-      */
-      if (!thd->locked_tables_mode)
-        thd->no_warnings_for_error= no_warnings_for_error;
+
       if (view_operator_func == NULL)
         table->required_type=FRMTYPE_TABLE;
 
-      open_error= open_and_lock_tables(thd, table, TRUE, 0);
-      thd->no_warnings_for_error= 0;
+      if (!thd->locked_tables_mode && repair_table_use_frm)
+      {
+        /*
+          If we're not under LOCK TABLES and we're executing REPAIR TABLE
+          USE_FRM, we need to ignore errors from open_and_lock_tables().
+          REPAIR TABLE USE_FRM is a heavy weapon used when a table is
+          critically damaged, so open_and_lock_tables() will most likely
+          report errors. Those errors are not interesting for the user
+          because it's already known that the table is badly damaged.
+        */
+
+        Warning_info wi(thd->query_id, false);
+        Warning_info *wi_saved= thd->warning_info;
+
+        thd->warning_info= &wi;
+
+        open_error= open_and_lock_tables(thd, table, TRUE, 0);
+
+        thd->warning_info= wi_saved;
+      }
+      else
+      {
+        /*
+          It's assumed that even if it is REPAIR TABLE USE_FRM, the table
+          can be opened if we're under LOCK TABLES (otherwise LOCK TABLES
+          would fail). Thus, the only errors we could have from
+          open_and_lock_tables() are logical ones, like incorrect locking
+          mode. It does make sense for the user to see such errors.
+        */
+
+        open_error= open_and_lock_tables(thd, table, TRUE, 0);
+      }
+
       table->next_global= save_next_global;
       table->next_local= save_next_local;
       thd->open_options&= ~extra_open_options;

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

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-04-04 08:47:25 +0000
+++ b/sql/sql_class.cc	2011-04-15 12:14:35 +0000
@@ -13,7 +13,6 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
 
-
 /*****************************************************************************
 **
 ** This file implements classes defined in sql_class.h
@@ -510,7 +509,7 @@ THD::THD(bool enable_plugins)
    debug_sync_control(0),
 #endif /* defined(ENABLED_DEBUG_SYNC) */
    m_enable_plugins(enable_plugins),
-   main_warning_info(0)
+   main_warning_info(0, false)
 {
   ulong tmp;
 
@@ -569,7 +568,7 @@ THD::THD(bool enable_plugins)
   client_capabilities= 0;                       // minimalistic client
   ull=0;
   system_thread= NON_SYSTEM_THREAD;
-  cleanup_done= abort_on_warning= no_warnings_for_error= 0;
+  cleanup_done= abort_on_warning= 0;
   peer_port= 0;					// For SHOW PROCESSLIST
   transaction.m_pending_rows_event= 0;
   transaction.on= 1;
@@ -842,10 +841,6 @@ MYSQL_ERROR* THD::raise_condition(uint s
 
   query_cache_abort(&query_cache_tls);
 
-  /* FIXME: broken special case */
-  if (no_warnings_for_error && (level == MYSQL_ERROR::WARN_LEVEL_ERROR))
-    DBUG_RETURN(NULL);
-
   /* When simulating OOM, skip writing to error log to avoid mtr errors */
   DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_RETURN(NULL););
 

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-04-04 10:06:13 +0000
+++ b/sql/sql_class.h	2011-04-15 12:14:35 +0000
@@ -2180,7 +2180,6 @@ public:
   bool       enable_slow_log;   /* enable slow log for current statement */
   bool	     abort_on_warning;
   bool 	     got_warning;       /* Set on call to push_warning() */
-  bool	     no_warnings_for_error; /* no warnings on call to my_error() */
   /* set during loop of derived table processing */
   bool       derived_tables_processing;
   my_bool    tablespace_op;	/* This is TRUE in DISCARD/IMPORT TABLESPACE */
@@ -2974,6 +2973,7 @@ private:
 
   /** The current internal error handler for this thread, or NULL. */
   Internal_error_handler *m_internal_handler;
+
   /**
     The lex to hold the parsed tree of conventional (non-prepared) queries.
     Whereas for prepared and stored procedure statements we use an own lex

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2011-03-15 15:49:50 +0000
+++ b/sql/sql_connect.cc	2011-04-15 09:33:58 +0000
@@ -1,4 +1,4 @@
-/* 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
@@ -20,9 +20,6 @@
 
 #include "my_global.h"
 #include "sql_priv.h"
-#ifndef __WIN__
-#include <netdb.h>        // getservbyname, servent
-#endif
 #include "sql_audit.h"
 #include "sql_connect.h"
 #include "my_global.h"

=== modified file 'sql/sql_error.cc'
--- a/sql/sql_error.cc	2011-03-09 20:54:55 +0000
+++ b/sql/sql_error.cc	2011-04-15 12:14:35 +0000
@@ -457,10 +457,11 @@ Diagnostics_area::disable_status()
   m_status= DA_DISABLED;
 }
 
-Warning_info::Warning_info(ulonglong warn_id_arg)
+Warning_info::Warning_info(ulonglong warn_id_arg, bool allow_unlimited_warnings)
   :m_statement_warn_count(0),
   m_current_row_for_warning(1),
   m_warn_id(warn_id_arg),
+  m_allow_unlimited_warnings(allow_unlimited_warnings),
   m_read_only(FALSE)
 {
   /* Initialize sub structures */
@@ -542,7 +543,8 @@ MYSQL_ERROR *Warning_info::push_warning(
 
   if (! m_read_only)
   {
-    if (m_warn_list.elements < thd->variables.max_error_count)
+    if (m_allow_unlimited_warnings ||
+        m_warn_list.elements < thd->variables.max_error_count)
     {
       cond= new (& m_warn_root) MYSQL_ERROR(& m_warn_root);
       if (cond)
@@ -558,6 +560,20 @@ MYSQL_ERROR *Warning_info::push_warning(
   return cond;
 }
 
+MYSQL_ERROR *Warning_info::push_warning(THD *thd, const MYSQL_ERROR *sql_condition)
+{
+  MYSQL_ERROR *new_condition= push_warning(thd,
+                                           sql_condition->get_sql_errno(),
+                                           sql_condition->get_sqlstate(),
+                                           sql_condition->get_level(),
+                                           sql_condition->get_message_text());
+
+  if (new_condition)
+    new_condition->copy_opt_attributes(sql_condition);
+
+  return new_condition;
+}
+
 /*
   Push the warning to error list if there is still room in the list
 

=== modified file 'sql/sql_error.h'
--- a/sql/sql_error.h	2011-03-09 20:54:55 +0000
+++ b/sql/sql_error.h	2011-04-15 12:14:35 +0000
@@ -322,10 +322,13 @@ class Warning_info
 {
   /** A memory root to allocate warnings and errors */
   MEM_ROOT           m_warn_root;
+
   /** List of warnings of all severities (levels). */
   List <MYSQL_ERROR> m_warn_list;
+
   /** A break down of the number of warnings per severity (level). */
   uint	             m_warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_END];
+
   /**
     The number of warnings of the current statement. Warning_info
     life cycle differs from statement life cycle -- it may span
@@ -333,20 +336,25 @@ class Warning_info
     m_statement_warn_count 0, whereas m_warn_list is not empty.
   */
   uint	             m_statement_warn_count;
+
   /*
     Row counter, to print in errors and warnings. Not increased in
     create_sort_index(); may differ from examined_row_count.
   */
   ulong              m_current_row_for_warning;
-  /** Used to optionally clear warnings only once per statement.  */
+
+  /** Used to optionally clear warnings only once per statement. */
   ulonglong          m_warn_id;
 
+  /** Indicates if push_warning() allows unlimited number of warnings. */
+  bool               m_allow_unlimited_warnings;
+
 private:
   Warning_info(const Warning_info &rhs); /* Not implemented */
   Warning_info& operator=(const Warning_info &rhs); /* Not implemented */
 public:
 
-  Warning_info(ulonglong warn_id_arg);
+  Warning_info(ulonglong warn_id_arg, bool allow_unlimited_warnings);
   ~Warning_info();
 
   /**
@@ -383,19 +391,13 @@ public:
   void append_warnings(THD *thd, List<MYSQL_ERROR> *src)
   {
     MYSQL_ERROR *err;
-    MYSQL_ERROR *copy;
     List_iterator_fast<MYSQL_ERROR> it(*src);
     /*
       Don't use ::push_warning() to avoid invocation of condition
       handlers or escalation of warnings to errors.
     */
     while ((err= it++))
-    {
-      copy= Warning_info::push_warning(thd, err->get_sql_errno(), err->get_sqlstate(),
-                                       err->get_level(), err->get_message_text());
-      if (copy)
-        copy->copy_opt_attributes(err);
-    }
+      Warning_info::push_warning(thd, err);
   }
 
   /**
@@ -461,6 +463,9 @@ public:
                             MYSQL_ERROR::enum_warning_level level,
                             const char* msg);
 
+  /** Add a new condition to the current list. */
+  MYSQL_ERROR *push_warning(THD *thd, const MYSQL_ERROR *sql_condition);
+
   /**
     Set the read only status for this statement area.
     This is a privileged operation, reserved for the implementation of

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

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2011-03-09 20:54:55 +0000
+++ b/sql/sql_load.cc	2011-04-15 09:02:16 +0000
@@ -1337,7 +1337,7 @@ READ_INFO::READ_INFO(File file_par, uint
 
 
   /* Set of a stack for unget if long terminators */
-  uint length=max(field_term_length,line_term_length)+1;
+  uint length= max(cs->mbmaxlen, max(field_term_length, line_term_length)) + 1;
   set_if_bigger(length,line_start.length());
   stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-04-01 14:04:52 +0000
+++ b/sql/sql_parse.cc	2011-04-15 12:14:35 +0000
@@ -7335,10 +7335,20 @@ bool parse_sql(THD *thd,
 
   bool mysql_parse_status= MYSQLparse(thd) != 0;
 
-  /* Check that if MYSQLparse() failed, thd->is_error() is set. */
+  /*
+    Check that if MYSQLparse() failed either thd->is_error() is set, or an
+    internal error handler is set.
+
+    The assert will not catch a situation where parsing fails without an
+    error reported if an error handler exists. The problem is that the
+    error handler might have intercepted the error, so thd->is_error() is
+    not set. However, there is no way to be 100% sure here (the error
+    handler might be for other errors than parsing one).
+  */
 
   DBUG_ASSERT(!mysql_parse_status ||
-              (mysql_parse_status && thd->is_error()));
+              (mysql_parse_status && thd->is_error()) ||
+              (mysql_parse_status && thd->get_internal_handler()));
 
   /* Reset parser state. */
 

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

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2011-03-17 17:39:31 +0000
+++ b/sql/sql_prepare.cc	2011-04-15 12:14:35 +0000
@@ -2843,7 +2843,8 @@ void mysql_stmt_get_longdata(THD *thd, c
   param= stmt->param_array[param_number];
 
   Diagnostics_area new_stmt_da, *save_stmt_da= thd->stmt_da;
-  Warning_info new_warnning_info(thd->query_id), *save_warinig_info= thd->warning_info;
+  Warning_info new_warnning_info(thd->query_id, false);
+  Warning_info *save_warinig_info= thd->warning_info;
 
   thd->stmt_da= &new_stmt_da;
   thd->warning_info= &new_warnning_info;
@@ -3909,7 +3910,7 @@ Ed_result_set::Ed_result_set(List<Ed_row
 */
 
 Ed_connection::Ed_connection(THD *thd)
-  :m_warning_info(thd->query_id),
+  :m_warning_info(thd->query_id, false),
   m_thd(thd),
   m_rsets(0),
   m_current_rset(0)

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-04-04 08:47:25 +0000
+++ b/sql/sql_select.cc	2011-04-15 08:11:49 +0000
@@ -1893,7 +1893,7 @@ JOIN::optimize()
       If all items were resolved by opt_sum_query, there is no need to
       open any tables.
     */
-    if ((res=opt_sum_query(select_lex->leaf_tables, all_fields, conds)))
+    if ((res=opt_sum_query(thd, select_lex->leaf_tables, all_fields, conds)))
     {
       if (res == HA_ERR_KEY_NOT_FOUND)
       {
@@ -2936,7 +2936,11 @@ JOIN::exec()
         curr_join->best_positions[curr_join->const_tables].sj_strategy 
           != SJ_OPT_LOOSE_SCAN)
       disable_sorted_access(&curr_join->join_tab[curr_join->const_tables]);
-    if ((tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table, 0)))
+
+    Procedure *save_proc= curr_join->procedure;
+    tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table, 0);
+    curr_join->procedure= save_proc;
+    if (tmp_error)
     {
       error= tmp_error;
       DBUG_VOID_RETURN;
@@ -11253,10 +11257,7 @@ make_join_readinfo(JOIN *join, ulonglong
     case JT_REF_OR_NULL:
     case JT_REF:
       if (tab->select)
-      {
-	delete tab->select->quick;
-	tab->select->quick=0;
-      }
+        tab->select->set_quick(NULL);
       delete tab->quick;
       tab->quick=0;
       /* fall through */
@@ -18421,8 +18422,7 @@ int read_first_record_seq(JOIN_TAB *tab)
 static int
 test_if_quick_select(JOIN_TAB *tab)
 {
-  delete tab->select->quick;
-  tab->select->quick=0;
+  tab->select->set_quick(NULL);
   return tab->select->test_quick_select(tab->join->thd, 
                                         tab->keys,
                                         0,          // empty table map
@@ -18629,10 +18629,14 @@ end_send(JOIN *join, JOIN_TAB *join_tab
     }
     if (join->having && join->having->val_int() == 0)
       DBUG_RETURN(NESTED_LOOP_OK);               // Didn't match having
-    error=0;
     if (join->procedure)
-      error=join->procedure->send_row(join->procedure_fields_list);
-    else if (join->do_send_rows)
+    {
+      if (join->procedure->send_row(join->procedure_fields_list))
+        DBUG_RETURN(NESTED_LOOP_ERROR);
+      DBUG_RETURN(NESTED_LOOP_OK);
+    }
+    error=0;
+    if (join->do_send_rows)
       error=join->result->send_data(*join->fields);
     if (error)
       DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */
@@ -20341,10 +20345,8 @@ skipped_filesort:
 use_filesort:
   // Restore original save_quick
   if (select && select->quick != save_quick)
-  {
-    delete select->quick;
-    select->quick= save_quick;
-  }
+    select->set_quick(save_quick);
+
   if (orig_select_cond_saved)
     tab->set_cond(orig_select_cond, __LINE__);
   DBUG_RETURN(0);

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2011-03-29 07:20:17 +0000
+++ b/sql/sql_select.h	2011-04-15 08:11:49 +0000
@@ -2062,7 +2062,8 @@ bool is_indexed_agg_distinct(JOIN *join,
 
 /* functions from opt_sum.cc */
 bool simple_pred(Item_func *func_item, Item **args, bool *inv_order);
-int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,Item *conds);
+int opt_sum_query(THD* thd,
+                  TABLE_LIST *tables, List<Item> &all_fields, Item *conds);
 
 /* from sql_delete.cc, used by opt_range.cc */
 extern "C" int refpos_order_cmp(const void* arg, const void *a,const void *b);

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-04-06 15:21:05 +0000
+++ b/sql/sql_show.cc	2011-04-15 12:14:35 +0000
@@ -3417,6 +3417,45 @@ end:
 
 
 /**
+  Trigger_error_handler is intended to intercept and silence SQL conditions
+  that might happen during trigger loading for SHOW statements.
+  The potential SQL conditions are:
+
+    - ER_PARSE_ERROR -- this error is thrown if a trigger definition file
+      is damaged or contains invalid CREATE TRIGGER statement. That should
+      not happen in normal life.
+
+    - ER_TRG_NO_DEFINER -- this warning is thrown when we're loading a
+      trigger created/imported in/from the version of MySQL, which does not
+      support trigger definers.
+
+    - ER_TRG_NO_CREATION_CTX -- this warning is thrown when we're loading a
+      trigger created/imported in/from the version of MySQL, which does not
+      support trigger creation contexts.
+*/
+
+class Trigger_error_handler : public Internal_error_handler
+{
+public:
+  bool handle_condition(THD *thd,
+                        uint sql_errno,
+                        const char* sqlstate,
+                        MYSQL_ERROR::enum_warning_level level,
+                        const char* msg,
+                        MYSQL_ERROR ** cond_hdl)
+  {
+    if (sql_errno == ER_PARSE_ERROR ||
+        sql_errno == ER_TRG_NO_DEFINER ||
+        sql_errno == ER_TRG_NO_CREATION_CTX)
+      return true;
+
+    return false;
+  }
+};
+
+
+
+/**
   @brief          Fill I_S tables whose data are retrieved
                   from frm files and storage engine
 
@@ -3571,7 +3610,6 @@ int get_all_tables(THD *thd, TABLE_LIST
         acl_get(sctx->host, sctx->ip, sctx->priv_user, db_name->str, 0))
 #endif
     {
-      thd->no_warnings_for_error= 1;
       List<LEX_STRING> table_names;
       int res= make_table_name_list(thd, &table_names, lex,
                                     &lookup_field_vals,
@@ -3620,9 +3658,24 @@ int get_all_tables(THD *thd, TABLE_LIST
             if (!(table_open_method & ~OPEN_FRM_ONLY) &&
                 !with_i_schema)
             {
-              if (!fill_schema_table_from_frm(thd, tables, schema_table, db_name,
-                                              table_name, schema_table_idx,
-                                              can_deadlock))
+              /*
+                Here we need to filter out warnings, which can happen
+                during loading of triggers in fill_schema_table_from_frm(),
+                because we don't need those warnings to pollute output of
+                SELECT from I_S / SHOW-statements.
+              */
+
+              Trigger_error_handler err_handler;
+              thd->push_internal_handler(&err_handler);
+
+              int res= fill_schema_table_from_frm(thd, tables, schema_table,
+                                                  db_name, table_name,
+                                                  schema_table_idx,
+                                                  can_deadlock);
+
+              thd->pop_internal_handler();
+
+              if (!res)
                 continue;
             }
 
@@ -3632,7 +3685,6 @@ int get_all_tables(THD *thd, TABLE_LIST
               Set the parent lex of 'sel' because it is needed by
               sel.init_query() which is called inside make_table_list.
             */
-            thd->no_warnings_for_error= 1;
             sel.parent_lex= lex;
             if (make_table_list(thd, &sel, db_name, table_name))
               goto err;
@@ -6667,6 +6719,92 @@ int make_schema_select(THD *thd, SELECT_
 }
 
 
+/**
+  Fill INFORMATION_SCHEMA-table, leave correct Diagnostics_area /
+  Warning_info state after itself.
+
+  This function is a wrapper around ST_SCHEMA_TABLE::fill_table(), which
+  may "partially silence" some errors. The thing is that during
+  fill_table() many errors might be emitted. These errors stem from the
+  nature of fill_table().
+
+  For example, SELECT ... FROM INFORMATION_SCHEMA.xxx WHERE TABLE_NAME = 'xxx'
+  results in a number of 'Table <db name>.xxx does not exist' errors,
+  because fill_table() tries to open the 'xxx' table in every possible
+  database.
+
+  Those errors are cleared (the error status is cleared from
+  Diagnostics_area) inside fill_table(), but they remain in Warning_info
+  (Warning_info is not cleared because it may contain useful warnings).
+
+  This function is responsible for making sure that Warning_info does not
+  contain warnings corresponding to the cleared errors.
+
+  @note: THD::no_warnings_for_error used to be set before calling
+  fill_table(), thus those errors didn't go to Warning_info. This is not
+  the case now (THD::no_warnings_for_error was eliminated as a hack), so we
+  need to take care of those warnings here.
+
+  @param thd            Thread context.
+  @param table_list     I_S table.
+  @param join_table     JOIN/SELECT table.
+
+  @return Error status.
+  @retval TRUE Error.
+  @retval FALSE Success.
+*/
+static bool do_fill_table(THD *thd,
+                          TABLE_LIST *table_list,
+                          JOIN_TAB *join_table)
+{
+  // NOTE: fill_table() may generate many "useless" warnings, which will be
+  // ignored afterwards. On the other hand, there might be "useful"
+  // warnings, which should be presented to the user. Warning_info usually
+  // stores no more than THD::variables.max_error_count warnings.
+  // The problem is that "useless warnings" may occupy all the slots in the
+  // Warning_info, so "useful warnings" get rejected. In order to avoid
+  // that problem we create a Warning_info instance, which is capable of
+  // storing "unlimited" number of warnings.
+  Warning_info wi(thd->query_id, true);
+  Warning_info *wi_saved= thd->warning_info;
+
+  thd->warning_info= &wi;
+
+  bool res= table_list->schema_table->fill_table(
+    thd, table_list, join_table->select_cond);
+
+  thd->warning_info= wi_saved;
+
+  // Pass an error if any.
+
+  if (thd->stmt_da->is_error())
+  {
+    thd->warning_info->push_warning(thd,
+                                    thd->stmt_da->sql_errno(),
+                                    thd->stmt_da->get_sqlstate(),
+                                    MYSQL_ERROR::WARN_LEVEL_ERROR,
+                                    thd->stmt_da->message());
+  }
+
+  // Pass warnings (if any).
+  //
+  // Filter out warnings with WARN_LEVEL_ERROR level, because they
+  // correspond to the errors which were filtered out in fill_table().
+
+
+  List_iterator_fast<MYSQL_ERROR> it(wi.warn_list());
+  MYSQL_ERROR *err;
+
+  while ((err= it++))
+  {
+    if (err->get_level() != MYSQL_ERROR::WARN_LEVEL_ERROR)
+      thd->warning_info->push_warning(thd, err);
+  }
+
+  return res;
+}
+
+
 /*
   Fill temporary schema tables before SELECT
 
@@ -6689,7 +6827,6 @@ bool get_schema_tables_result(JOIN *join
   bool result= 0;
   DBUG_ENTER("get_schema_tables_result");
 
-  thd->no_warnings_for_error= 1;
   for (JOIN_TAB *tab= join->join_tab; tab < tmp_join_tab; tab++)
   {  
     if (!tab->table || !tab->table->pos_in_table_list)
@@ -6740,8 +6877,7 @@ bool get_schema_tables_result(JOIN *join
       else
         table_list->table->file->stats.records= 0;
 
-      if (table_list->schema_table->fill_table(thd, table_list,
-                                               tab->select_cond))
+      if (do_fill_table(thd, table_list, tab))
       {
         result= 1;
         join->error= 1;
@@ -6753,7 +6889,6 @@ bool get_schema_tables_result(JOIN *join
       table_list->schema_table_state= executed_place;
     }
   }
-  thd->no_warnings_for_error= 0;
   DBUG_RETURN(result);
 }
 

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

=== modified file 'sql/sql_trigger.cc'
--- a/sql/sql_trigger.cc	2011-03-10 08:33:54 +0000
+++ b/sql/sql_trigger.cc	2011-04-15 12:14:35 +0000
@@ -1225,13 +1225,12 @@ bool Table_triggers_list::check_n_load(T
 
           DBUG_RETURN(1); // EOM
         }
-        
-        if (!thd->no_warnings_for_error)
-          push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                              ER_TRG_NO_CREATION_CTX,
-                              ER(ER_TRG_NO_CREATION_CTX),
-                              (const char*) db,
-                              (const char*) table_name);
+
+        push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                            ER_TRG_NO_CREATION_CTX,
+                            ER(ER_TRG_NO_CREATION_CTX),
+                            (const char*) db,
+                            (const char*) table_name);
 
         if (!(trg_client_cs_name= alloc_lex_string(&table->mem_root)) ||
             !(trg_connection_cl_name= alloc_lex_string(&table->mem_root)) ||
@@ -1362,12 +1361,12 @@ bool Table_triggers_list::check_n_load(T
             MySQL, which does not support triggers definers. We should emit
             warning here.
           */
-          if (!thd->no_warnings_for_error)
-            push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                                ER_TRG_NO_DEFINER, ER(ER_TRG_NO_DEFINER),
-                                (const char*) db,
-                                (const char*) sp->m_name.str);
-          
+
+          push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                              ER_TRG_NO_DEFINER, ER(ER_TRG_NO_DEFINER),
+                              (const char*) db,
+                              (const char*) sp->m_name.str);
+
           /*
             Set definer to the '' to correct displaying in the information
             schema.

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

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2011-04-04 10:06:13 +0000
+++ b/sql/sys_vars.cc	2011-04-11 10:28:36 +0000
@@ -1420,16 +1420,6 @@ static Sys_var_ulong Sys_max_length_for_
        SESSION_VAR(max_length_for_sort_data), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(4, 8192*1024L), DEFAULT(1024), BLOCK_SIZE(1));
 
-static Sys_var_ulong Sys_max_long_data_size(
-       "max_long_data_size",
-       "The maximum BLOB length to send to server from "
-       "mysql_send_long_data API. Deprecated option; "
-       "use max_allowed_packet instead.",
-       READ_ONLY GLOBAL_VAR(max_long_data_size),
-       CMD_LINE(REQUIRED_ARG, OPT_MAX_LONG_DATA_SIZE),
-       VALID_RANGE(1024, UINT_MAX32), DEFAULT(1024*1024),
-       BLOCK_SIZE(1));
-
 static PolyLock_mutex PLock_prepared_stmt_count(&LOCK_prepared_stmt_count);
 static Sys_var_ulong Sys_max_prepared_stmt_count(
        "max_prepared_stmt_count",

=== modified file 'sql/transaction.cc'
--- a/sql/transaction.cc	2011-03-25 15:13:41 +0000
+++ b/sql/transaction.cc	2011-04-14 08:47:14 +0000
@@ -75,6 +75,33 @@ static bool xa_trans_rolled_back(XID_STA
 
 
 /**
+  Rollback the active XA transaction.
+
+  @note Resets rm_error before calling ha_rollback(), so
+        the thd->transaction.xid structure gets reset
+        by ha_rollback() / THD::transaction::cleanup().
+
+  @return TRUE if the rollback failed, FALSE otherwise.
+*/
+
+static bool xa_trans_force_rollback(THD *thd)
+{
+  /*
+    We must reset rm_error before calling ha_rollback(),
+    so thd->transaction.xid structure gets reset
+    by ha_rollback()/THD::transaction::cleanup().
+  */
+  thd->transaction.xid_state.rm_error= 0;
+  if (ha_rollback_trans(thd, true))
+  {
+    my_error(ER_XAER_RMERR, MYF(0));
+    return true;
+  }
+  return false;
+}
+
+
+/**
   Begin a new transaction.
 
   @note Beginning a transaction implicitly commits any current
@@ -645,8 +672,7 @@ bool trans_xa_commit(THD *thd)
 
   if (xa_trans_rolled_back(&thd->transaction.xid_state))
   {
-    if (ha_rollback_trans(thd, TRUE))
-      my_error(ER_XAER_RMERR, MYF(0));
+    xa_trans_force_rollback(thd);
     res= thd->is_error();
   }
   else if (xa_state == XA_IDLE && thd->lex->xa_opt == XA_ONE_PHASE)
@@ -735,15 +761,7 @@ bool trans_xa_rollback(THD *thd)
     DBUG_RETURN(TRUE);
   }
 
-  /*
-    Resource Manager error is meaningless at this point, as we perform
-    explicit rollback request by user. We must reset rm_error before
-    calling ha_rollback(), so thd->transaction.xid structure gets reset
-    by ha_rollback()/THD::transaction::cleanup().
-  */
-  thd->transaction.xid_state.rm_error= 0;
-  if ((res= test(ha_rollback_trans(thd, TRUE))))
-    my_error(ER_XAER_RMERR, MYF(0));
+  res= xa_trans_force_rollback(thd);
 
   thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
   thd->transaction.all.modified_non_trans_table= FALSE;

=== modified file 'storage/myisam/myisamdef.h'
--- a/storage/myisam/myisamdef.h	2011-03-28 08:51:35 +0000
+++ b/storage/myisam/myisamdef.h	2011-04-14 12:04:53 +0000
@@ -226,8 +226,9 @@ typedef struct st_mi_bit_buff {		/* Used
   uint error;
 } MI_BIT_BUFF;
 
-
+C_MODE_START
 typedef ICP_RESULT (*index_cond_func_t)(void *param);
+C_MODE_END
 
 struct st_myisam_info {
   MYISAM_SHARE *s;			/* Shared between open:s */

=== modified file 'unittest/gunit/CMakeLists.txt'
--- a/unittest/gunit/CMakeLists.txt	2011-04-04 08:47:25 +0000
+++ b/unittest/gunit/CMakeLists.txt	2011-04-13 11:31:44 +0000
@@ -212,6 +212,7 @@ SET(TESTS
   my_decimal
   my_regex
   sql_list
+  sql_plist
   thread_utils
   )
 

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

=== modified file 'vio/vio_priv.h'
--- a/vio/vio_priv.h	2010-06-07 14:01:39 +0000
+++ b/vio/vio_priv.h	2011-04-15 09:33:58 +0000
@@ -1,7 +1,7 @@
 #ifndef VIO_PRIV_INCLUDED
 #define VIO_PRIV_INCLUDED
 
-/* Copyright (C) 2003 MySQL AB
+/* Copyright (c) 2003, 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,7 +14,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, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
 
 /* Structures and functions private to the vio package */
 
@@ -25,11 +25,6 @@
 #include <m_string.h>
 #include <violite.h>
 
-#ifndef __WIN__
-#include <sys/socket.h>
-#include <netdb.h>
-#endif
-
 #ifdef _WIN32
 void	vio_win32_timeout(Vio *vio, uint which, uint timeout);
 #endif

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

No bundle (reason: revision is a merge).
Thread
bzr commit into mysql-trunk-mtr branch (bjorn.munch:3064) Bjorn Munch15 Apr