List:Commits« Previous MessageNext Message »
From:Bjorn Munch Date:January 17 2011 10:04am
Subject:bzr commit into mysql-trunk-mtr branch (bjorn.munch:3007)
View as plain text  
#At file:///home/bm136801/my/mtr-tr/ based on revid:bjorn.munch@stripped

 3007 Bjorn Munch	2011-01-17 [merge]
      merge from trunk

    added:
      mysql-test/extra/rpl_tests/rpl_show_binlog_events.inc
      mysql-test/extra/rpl_tests/rpl_show_log_events_with_varying_options.inc
      mysql-test/suite/sys_vars/r/autocommit_func4.result
      mysql-test/suite/sys_vars/r/autocommit_func5.result
      mysql-test/suite/sys_vars/t/autocommit_func4-master.opt
      mysql-test/suite/sys_vars/t/autocommit_func4.test
      mysql-test/suite/sys_vars/t/autocommit_func5-master.opt
      mysql-test/suite/sys_vars/t/autocommit_func5.test
      unittest/gunit/my_decimal-t.cc
    modified:
      client/client_priv.h
      client/mysql.cc
      client/mysql_upgrade.c
      client/mysqladmin.cc
      client/mysqlbinlog.cc
      client/mysqlcheck.c
      client/mysqldump.c
      client/mysqlimport.c
      client/mysqlshow.c
      client/mysqlslap.c
      mysql-test/collections/default.experimental
      mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc
      mysql-test/include/func_in.inc
      mysql-test/include/icp_tests.inc
      mysql-test/include/select.inc
      mysql-test/include/setup_fake_relay_log.inc
      mysql-test/include/wait_for_status_var.inc
      mysql-test/r/client_xml.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/func_math.result
      mysql-test/r/func_str.result
      mysql-test/r/gis-precise.result
      mysql-test/r/gis.result
      mysql-test/r/innodb_icp.result
      mysql-test/r/innodb_icp_all.result
      mysql-test/r/innodb_icp_none.result
      mysql-test/r/join_outer.result
      mysql-test/r/myisam_icp.result
      mysql-test/r/myisam_icp_all.result
      mysql-test/r/myisam_icp_none.result
      mysql-test/r/mysqladmin.result
      mysql-test/r/mysqlbinlog_row_big.result
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/r/mysqldump.result
      mysql-test/r/plugin_auth.result
      mysql-test/r/select_all.result
      mysql-test/r/select_icp_mrr.result
      mysql-test/r/select_none.result
      mysql-test/r/show_check.result
      mysql-test/r/subquery_sj_none.result
      mysql-test/r/type_timestamp.result
      mysql-test/r/update.result
      mysql-test/suite/perfschema/r/server_init.result
      mysql-test/suite/perfschema/t/server_init.test
      mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
      mysql-test/suite/rpl/r/rpl_row_show_relaylog_events.result
      mysql-test/suite/rpl/r/rpl_stm_mix_show_relaylog_events.result
      mysql-test/suite/rpl/t/rpl_heartbeat_basic.test
      mysql-test/t/func_math.test
      mysql-test/t/func_str.test
      mysql-test/t/gis-precise.test
      mysql-test/t/gis.test
      mysql-test/t/join_outer.test
      mysql-test/t/mysqladmin.test
      mysql-test/t/mysqlbinlog_row_big.test
      mysql-test/t/mysqldump.test
      mysql-test/t/plugin_auth.test
      mysql-test/t/show_check.test
      mysql-test/t/type_timestamp.test
      mysys/my_getopt.c
      mysys/my_getsystime.c
      mysys/my_init.c
      mysys/my_thr_init.c
      mysys/mysys_priv.h
      sql/handler.cc
      sql/item.cc
      sql/item_cmpfunc.cc
      sql/item_func.cc
      sql/item_geofunc.h
      sql/item_strfunc.cc
      sql/item_strfunc.h
      sql/my_decimal.h
      sql/mysqld.cc
      sql/mysqld.h
      sql/sql_analyse.cc
      sql/sql_select.cc
      sql/sql_select.h
      sql/sql_string.cc
      sql/sql_string.h
      storage/innobase/handler/ha_innodb.cc
      storage/myisam/ha_myisam.cc
      strings/decimal.c
      unittest/gunit/CMakeLists.txt
=== modified file 'client/client_priv.h'
--- a/client/client_priv.h	2010-11-24 13:09:52 +0000
+++ b/client/client_priv.h	2011-01-16 04:02:29 +0000
@@ -82,6 +82,7 @@ enum options_client
   OPT_WRITE_BINLOG, OPT_DUMP_DATE,
   OPT_INIT_COMMAND,
   OPT_PLUGIN_DIR,
+  OPT_DEFAULT_AUTH,
   OPT_DEFAULT_PLUGIN,
   OPT_RAW_OUTPUT, OPT_WAIT_SERVER_ID, OPT_STOP_NEVER,
   OPT_BINLOG_ROWS_EVENT_MAX_SIZE,

=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2010-11-26 14:37:59 +0000
+++ b/client/mysql.cc	2011-01-16 04:02:29 +0000
@@ -163,7 +163,7 @@ static int wait_time = 5;
 static STATUS status;
 static ulong select_limit,max_join_size,opt_connect_timeout=0;
 static char mysql_charsets_dir[FN_REFLEN+1];
-static char *opt_plugin_dir= 0, *opt_default_auth;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
 static const char *xmlmeta[] = {
   "&", "&",
   "<", "&lt;",
@@ -1568,7 +1568,7 @@ static struct my_option my_long_options[
   {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
    (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"default_auth", OPT_PLUGIN_DIR,
+  {"default_auth", OPT_DEFAULT_AUTH,
     "Default authentication client-side plugin to use.",
    (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},

=== modified file 'client/mysql_upgrade.c'
--- a/client/mysql_upgrade.c	2010-10-06 15:08:00 +0000
+++ b/client/mysql_upgrade.c	2011-01-16 04:02:29 +0000
@@ -45,6 +45,8 @@ static DYNAMIC_STRING ds_args;
 static DYNAMIC_STRING conn_args;
 
 static char *opt_password= 0;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
+
 static my_bool tty_password= 0;
 
 static char opt_tmpdir[FN_REFLEN] = "";
@@ -88,6 +90,10 @@ static struct my_option my_long_options[
   {"default-character-set", OPT_DEFAULT_CHARSET,
    "Set the default character set.", 0,
    0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"default_auth", OPT_DEFAULT_AUTH,
+   "Default authentication client-side plugin to use.",
+   (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade "
    "has already been executed for the current version of MySQL.",
    &opt_force, &opt_force, 0,
@@ -102,6 +108,9 @@ static struct my_option my_long_options[
   {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0,
    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif
+  {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+   (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"port", 'P', "Port number to use for connection or 0 for default to, in "
    "order of preference, my.cnf, $MYSQL_TCP_PORT, "
 #if MYSQL_PORT_DEFAULT == 0
@@ -283,6 +292,8 @@ get_one_option(int optid, const struct m
   case 'S': /* --socket */
   case OPT_MYSQL_PROTOCOL: /* --protocol */
   case OPT_SHARED_MEMORY_BASE_NAME: /* --shared-memory-base-name */
+  case OPT_PLUGIN_DIR:                          /* --plugin-dir */
+  case OPT_DEFAULT_AUTH:                        /* --default-auth */
     add_one_option(&conn_args, opt, argument);
     break;
   }

=== modified file 'client/mysqladmin.cc'
--- a/client/mysqladmin.cc	2011-01-11 09:09:21 +0000
+++ b/client/mysqladmin.cc	2011-01-16 04:02:29 +0000
@@ -43,7 +43,7 @@ static uint opt_count_iterations= 0, my_
 static char *opt_bind_addr = NULL;
 static ulong opt_connect_timeout, opt_shutdown_timeout;
 static char * unix_port=0;
-static char *opt_plugin_dir= 0, *opt_default_auth;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
 
 #ifdef HAVE_SMEM
 static char *shared_memory_base_name=0;
@@ -212,7 +212,7 @@ static struct my_option my_long_options[
   {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
    (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"default_auth", OPT_PLUGIN_DIR,
+  {"default_auth", OPT_DEFAULT_AUTH,
    "Default authentication client-side plugin to use.",
    (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -419,6 +419,9 @@ int main(int argc,char *argv[])
 
       if (interval)                             /* --sleep=interval given */
       {
+        if (opt_count_iterations && --nr_iterations == 0)
+          break;
+
         /*
           If connection was dropped (unintentionally, or due to SHUTDOWN),
           re-establish it if --wait ("retry-connect") was given and user

=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2010-12-06 13:12:51 +0000
+++ b/client/mysqlbinlog.cc	2011-01-16 04:02:29 +0000
@@ -87,6 +87,8 @@ static char* host = 0;
 static int port= 0;
 static uint my_end_arg;
 static const char* sock= 0;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
+
 #ifdef HAVE_SMEM
 static char *shared_memory_base_name= 0;
 #endif
@@ -1024,6 +1026,10 @@ static struct my_option my_long_options[
   {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
    &debug_info_flag, &debug_info_flag,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"default_auth", OPT_DEFAULT_AUTH,
+   "Default authentication client-side plugin to use.",
+   (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"disable-log-bin", 'D', "Disable binary log. This is useful, if you "
     "enabled --to-last-log and are sending the output to the same MySQL server. "
     "This way you could avoid an endless loop. You would also like to use it "
@@ -1049,6 +1055,9 @@ static struct my_option my_long_options[
    0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"password", 'p', "Password to connect to remote server.",
    0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+  {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+   (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"port", 'P', "Port number to use for connection or 0 for default to, in "
    "order of preference, my.cnf, $MYSQL_TCP_PORT, "
 #if MYSQL_PORT_DEFAULT == 0
@@ -1390,6 +1399,12 @@ static Exit_status safe_connect()
     return ERROR_STOP;
   }
 
+  if (opt_plugin_dir && *opt_plugin_dir)
+    mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+  if (opt_default_auth && *opt_default_auth)
+    mysql_options(mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
   if (opt_protocol)
     mysql_options(mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);
   if (opt_bind_addr)

=== modified file 'client/mysqlcheck.c'
--- a/client/mysqlcheck.c	2010-11-05 22:14:29 +0000
+++ b/client/mysqlcheck.c	2011-01-16 04:02:29 +0000
@@ -40,6 +40,7 @@ static int my_end_arg;
 static char * opt_mysql_unix_port = 0;
 static char *opt_password = 0, *current_user = 0, 
 	    *default_charset= 0, *current_host= 0;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
 static int first_error = 0;
 DYNAMIC_ARRAY tables4repair;
 #ifdef HAVE_SMEM
@@ -103,6 +104,10 @@ static struct my_option my_long_options[
   {"default-character-set", OPT_DEFAULT_CHARSET,
    "Set the default character set.", &default_charset,
    &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"default_auth", OPT_DEFAULT_AUTH,
+   "Default authentication client-side plugin to use.",
+   (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"fast",'F', "Check only tables that haven't been closed properly.",
    &opt_fast, &opt_fast, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
    0},
@@ -140,6 +145,9 @@ static struct my_option my_long_options[
   {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
    NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif
+  {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+   (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"port", 'P', "Port number to use for connection or 0 for default to, in "
    "order of preference, my.cnf, $MYSQL_TCP_PORT, "
 #if MYSQL_PORT_DEFAULT == 0
@@ -802,6 +810,13 @@ static int dbConnect(char *host, char *u
   if (shared_memory_base_name)
     mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
 #endif
+
+  if (opt_plugin_dir && *opt_plugin_dir)
+    mysql_options(&mysql_connection, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+  if (opt_default_auth && *opt_default_auth)
+    mysql_options(&mysql_connection, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
   mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
   if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd,
          NULL, opt_mysql_port, opt_mysql_unix_port, 0)))

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2010-12-07 12:11:26 +0000
+++ b/client/mysqldump.c	2011-01-16 04:02:29 +0000
@@ -138,7 +138,7 @@ FILE *stderror_file=0;
 static char *shared_memory_base_name=0;
 #endif
 static uint opt_protocol= 0;
-static char *opt_plugin_dir= 0, *opt_default_auth;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
 
 /*
 Dynamic_string wrapper functions. In this file use these
@@ -510,7 +510,7 @@ static struct my_option my_long_options[
   {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
    (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"default_auth", OPT_PLUGIN_DIR,
+  {"default_auth", OPT_DEFAULT_AUTH,
    "Default authentication client-side plugin to use.",
    (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -2250,6 +2250,15 @@ static uint get_table_structure(char *ta
   const char *insert_option;
   char	     name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
   char       table_buff2[NAME_LEN*2+3], query_buff[QUERY_LENGTH];
+  const char *show_fields_stmt= "SELECT `COLUMN_NAME` AS `Field`, "
+                                "`COLUMN_TYPE` AS `Type`, "
+                                "`IS_NULLABLE` AS `Null`, "
+                                "`COLUMN_KEY` AS `Key`, "
+                                "`COLUMN_DEFAULT` AS `Default`, "
+                                "`EXTRA` AS `Extra`, "
+                                "`COLUMN_COMMENT` AS `Comment` "
+                                "FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE "
+                                "TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'";
   FILE       *sql_file= md_result_file;
   int        len;
   MYSQL_RES  *result;
@@ -2517,8 +2526,8 @@ static uint get_table_structure(char *ta
     verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n",
                 my_progname, mysql_error(mysql));
 
-    my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
-                result_table);
+    my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt, db, table);
+
     if (mysql_query_with_error_report(mysql, &result, query_buff))
       DBUG_RETURN(0);
 

=== modified file 'client/mysqlimport.c'
--- a/client/mysqlimport.c	2010-10-25 13:49:55 +0000
+++ b/client/mysqlimport.c	2011-01-16 04:02:29 +0000
@@ -61,6 +61,7 @@ static char	*opt_password=0, *current_us
 static uint     opt_mysql_port= 0, opt_protocol= 0;
 static char *opt_bind_addr = NULL;
 static char * opt_mysql_unix_port=0;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
 static longlong opt_ignore_lines= -1;
 #include <sslopt-vars.h>
 
@@ -94,6 +95,10 @@ static struct my_option my_long_options[
   {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
    &debug_info_flag, &debug_info_flag,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"default_auth", OPT_DEFAULT_AUTH,
+   "Default authentication client-side plugin to use.",
+   (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"delete", 'd', "First delete all rows from table.", &opt_delete,
    &opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"fields-terminated-by", OPT_FTB,
@@ -143,6 +148,9 @@ static struct my_option my_long_options[
   {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
    NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif
+  {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+   (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"port", 'P', "Port number to use for connection or 0 for default to, in "
    "order of preference, my.cnf, $MYSQL_TCP_PORT, "
 #if MYSQL_PORT_DEFAULT == 0
@@ -435,6 +443,13 @@ static MYSQL *db_connect(char *host, cha
   if (shared_memory_base_name)
     mysql_options(mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
 #endif
+
+  if (opt_plugin_dir && *opt_plugin_dir)
+    mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+  if (opt_default_auth && *opt_default_auth)
+    mysql_options(mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
   mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset);
   if (!(mysql_real_connect(mysql,host,user,passwd,
                            database,opt_mysql_port,opt_mysql_unix_port,

=== modified file 'client/mysqlshow.c'
--- a/client/mysqlshow.c	2010-10-25 13:49:55 +0000
+++ b/client/mysqlshow.c	2011-01-16 04:02:29 +0000
@@ -34,6 +34,7 @@ static my_bool debug_info_flag= 0, debug
 static uint my_end_arg= 0;
 static uint opt_verbose=0;
 static char *default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
 
 #ifdef HAVE_SMEM 
 static char *shared_memory_base_name=0;
@@ -127,6 +128,12 @@ int main(int argc, char **argv)
 #endif
   mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
 
+  if (opt_plugin_dir && *opt_plugin_dir)
+    mysql_options(&mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+  if (opt_default_auth && *opt_default_auth)
+    mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
   if (!(mysql_real_connect(&mysql,host,user,opt_password,
 			   (first_argument_uses_wildcards) ? "" :
                            argv[0],opt_mysql_port,opt_mysql_unix_port,
@@ -188,6 +195,10 @@ static struct my_option my_long_options[
   {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
    &debug_info_flag, &debug_info_flag,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"default_auth", OPT_DEFAULT_AUTH,
+   "Default authentication client-side plugin to use.",
+   (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG,
    0, 0, 0, 0, 0, 0},
   {"host", 'h', "Connect to host.", &host, &host, 0, GET_STR,
@@ -201,6 +212,9 @@ static struct my_option my_long_options[
    "Password to use when connecting to server. If password is not given, it's "
    "solicited on the tty.",
    0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+  {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+   (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"port", 'P', "Port number to use for connection or 0 for default to, in "
    "order of preference, my.cnf, $MYSQL_TCP_PORT, "
 #if MYSQL_PORT_DEFAULT == 0

=== modified file 'client/mysqlslap.c'
--- a/client/mysqlslap.c	2010-10-06 15:08:00 +0000
+++ b/client/mysqlslap.c	2011-01-16 04:02:29 +0000
@@ -122,6 +122,7 @@ static char *host= NULL, *opt_password=
             *pre_system= NULL,
             *post_system= NULL,
             *opt_mysql_unix_port= NULL;
+static char *opt_plugin_dir= 0, *opt_default_auth= 0;
 
 const char *delimiter= "\n";
 
@@ -340,6 +341,12 @@ int main(int argc, char **argv)
 #endif
   mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
 
+  if (opt_plugin_dir && *opt_plugin_dir)
+    mysql_options(&mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
+
+  if (opt_default_auth && *opt_default_auth)
+    mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
+
   if (!opt_only_print) 
   {
     if (!(mysql_real_connect(&mysql, host, user, opt_password,
@@ -583,6 +590,10 @@ static struct my_option my_long_options[
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"debug-info", 'T', "Print some debug info at exit.", &debug_info_flag,
    &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"default_auth", OPT_DEFAULT_AUTH,
+   "Default authentication client-side plugin to use.",
+   (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"delimiter", 'F',
     "Delimiter to use in SQL statements supplied in file or command line.",
     &delimiter, &delimiter, 0, GET_STR, REQUIRED_ARG,
@@ -622,6 +633,9 @@ static struct my_option my_long_options[
   {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
     NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif
+  {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
+   (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"port", 'P', "Port number to use for connection.", &opt_mysql_port,
     &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
     0},
@@ -1509,7 +1523,12 @@ generate_primary_key_list(MYSQL *mysql,
       exit(1);
     }
 
-    result= mysql_store_result(mysql);
+    if (!(result= mysql_store_result(mysql)))
+    {
+      fprintf(stderr, "%s: Error when storing result: %d %s\n",
+              my_progname, mysql_errno(mysql), mysql_error(mysql));
+      exit(1);
+    }
     primary_keys_number_of= mysql_num_rows(result);
 
     /* So why check this? Blackhole :) */
@@ -1881,10 +1900,15 @@ limit_not_met:
       {
         if (mysql_field_count(mysql))
         {
-          result= mysql_store_result(mysql);
-          while ((row = mysql_fetch_row(result)))
-            counter++;
-          mysql_free_result(result);
+          if (!(result= mysql_store_result(mysql)))
+            fprintf(stderr, "%s: Error when storing result: %d %s\n",
+                    my_progname, mysql_errno(mysql), mysql_error(mysql));
+          else
+          {
+            while ((row= mysql_fetch_row(result)))
+              counter++;
+            mysql_free_result(result);
+          }
         }
       } while(mysql_next_result(mysql) == 0);
       queries++;

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2011-01-12 15:13:48 +0000
+++ b/mysql-test/collections/default.experimental	2011-01-14 13:06:00 +0000
@@ -12,7 +12,6 @@ main.gis
 main.gis-rtree @freebsd                  # Bug#38965 2010-05-04 alik test cases gis-rtree, type_float, type_newdecimal fail in embedded server
 main.information_schema                  # Bug#47449 2009-09-19 alik main.information_schema and innodb.innodb_information_schema fail sporadically
 main.lock_multi_bug38499                 # Bug#47448 2009-09-19 alik main.lock_multi_bug38499 times out sporadically
-main.lowercase_table2 @darwin            # Bug#55509 2010-07-26 alik main.lowercase_table2 fails on Mac OSX (again)
 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

=== added file 'mysql-test/extra/rpl_tests/rpl_show_binlog_events.inc'
--- a/mysql-test/extra/rpl_tests/rpl_show_binlog_events.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_show_binlog_events.inc	2011-01-13 12:21:57 +0000
@@ -0,0 +1,17 @@
+# Include file for rpl_show_relaylog_events.inc
+
+--let $log_type= BINLOG
+if ($is_relay_log) {
+  --let $log_type= RELAYLOG
+}
+--let $args=
+if ($binlog_file != '') {
+  --let $args= IN <FILE>
+}
+if ($binlog_limit) {
+  --let $args= $args LIMIT $binlog_limit
+}
+--echo ******** [$CURRENT_CONNECTION] SHOW $log_type EVENTS $args ********
+--source include/show_events.inc
+
+

=== added file 'mysql-test/extra/rpl_tests/rpl_show_log_events_with_varying_options.inc'
--- a/mysql-test/extra/rpl_tests/rpl_show_log_events_with_varying_options.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_show_log_events_with_varying_options.inc	2011-01-13 12:21:57 +0000
@@ -0,0 +1,11 @@
+# Include file for rpl_show_log_events.inc 
+
+--let $binlog_limit=
+--source extra/rpl_tests/rpl_show_binlog_events.inc
+--let $binlog_limit= 1
+--source extra/rpl_tests/rpl_show_binlog_events.inc
+--let $binlog_limit= 1,3
+--source extra/rpl_tests/rpl_show_binlog_events.inc
+--let $binlog_limit=
+--let $binlog_file=
+--source extra/rpl_tests/rpl_show_binlog_events.inc 

=== modified file 'mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc'
--- a/mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc	2010-06-19 09:24:34 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc	2011-01-14 11:15:25 +0000
@@ -1,103 +1,62 @@
 -- connection master
+-- source include/rpl_reset.inc
+
+-- connection master
 
 CREATE TABLE t1 (a INT);
 INSERT INTO t1 VALUES (1);
 INSERT INTO t1 VALUES (2);
 INSERT INTO t1 VALUES (3);
-INSERT INTO t1 VALUES (4);
-INSERT INTO t1 VALUES (5);
-INSERT INTO t1 VALUES (6);
-
--- echo [MASTER] ********* SOW BINLOG EVENTS IN ...  *********
--- source include/show_binlog_events.inc
-
--- echo [MASTER] ********* SOW BINLOG EVENTS         *********
-let $binlog_file= ;
--- source include/show_binlog_events.inc
-
--- echo [MASTER] ********* SOW BINLOG EVENTS ... LIMIT rows  *********
-let $binlog_limit= 3;
--- source include/show_binlog_events.inc
-
--- echo [MASTER] ********* SOW BINLOG EVENTS ... LIMIT offset,rows  *********
-let $binlog_limit= 1,4;
--- source include/show_binlog_events.inc
-
-# clear show_binlog_event/show_relaylog_events parameters
-let $binlog_limit= ;
-
--- sync_slave_with_master
-
--- echo [SLAVE] ********* SOW BINLOG EVENTS IN ...   *********
--- source include/show_binlog_events.inc
-
--- echo [SLAVE] ********* SOW BINLOG EVENTS          *********
-let $binlog_file= ;
--- source include/show_binlog_events.inc
-
--- echo [SLAVE] ********* SOW BINLOG EVENTS ... LIMIT rows  *********
-let $binlog_limit= 3;
--- source include/show_binlog_events.inc
-
--- echo [SLAVE] ********* SOW BINLOG EVENTS ... LIMIT offset,rows  *********
-let $binlog_limit= 1,4;
--- source include/show_binlog_events.inc
-
-# clear show_binlog_event/show_relaylog_events parameters
-let $binlog_limit= ;
 
--- echo [SLAVE] ********* SOW RELAYLOG EVENTS IN ... *********
-let $binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
--- source include/show_relaylog_events.inc
-
--- echo [SLAVE] ********* SOW RELAYLOG EVENTS        *********
-let $binlog_file= ;
--- source include/show_relaylog_events.inc
-
--- echo [MASTER] ********* SOW RELAYLOG EVENTS ... LIMIT rows  *********
-let $binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
-let $binlog_limit= 3;
--- source include/show_relaylog_events.inc
-
--- echo [MASTER] ********* SOW RELAYLOG EVENTS ... LIMIT offset,rows  *********
-let $binlog_limit= 1,3;
--- source include/show_relaylog_events.inc
+# PART I
+#
+# SHOWs contents of binary logs on the master and both, binary and
+# relay logs, on the slave.
+#
+
+--let $is_relay_log= 0
+--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+--source extra/rpl_tests/rpl_show_log_events_with_varying_options.inc
+
+--sync_slave_with_master
+--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+--source extra/rpl_tests/rpl_show_log_events_with_varying_options.inc
+
+--let $is_relay_log= 1
+--let $binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
+--source extra/rpl_tests/rpl_show_log_events_with_varying_options.inc
+
+#
+# PART II
+#
+# Although this second part of the test may seem redudant it is
+# actually needed to assert that SHOW RELAYLOG EVENTS works properly
+# with respect to the ordering of the relay log in relay-log.index. 
+#
+# If no file is specified with "IN" then first relay log file in
+# relay-log.index (ie, the oldest one) should be picked and its
+# contents displayed. The same happens for SHOW BINLOG EVENTS, so we
+# show them both. All in all, this is the reason for re-assert after
+# MASTER and SLAVE's FLUSH LOGS operations.
+#
 
 FLUSH LOGS;
-let $binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
-
 -- connection master
 FLUSH LOGS;
 DROP TABLE t1;
 
-# clear show_binlog_event/show_relaylog_events parameters
-let $binlog_file= ;
-let $binlog_limit= ;
+--let $is_relay_log= 0
+--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+--source extra/rpl_tests/rpl_show_log_events_with_varying_options.inc
+
+--sync_slave_with_master
+--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+--source extra/rpl_tests/rpl_show_log_events_with_varying_options.inc
+
+--let $is_relay_log= 1
+--let $binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
+--source extra/rpl_tests/rpl_show_log_events_with_varying_options.inc
 
--- echo [MASTER] ********* SOW BINLOG EVENTS IN ...  *********
-let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
--- source include/show_binlog_events.inc
-
--- echo [MASTER] ********* SOW BINLOG EVENTS         *********
-let $binlog_file= ;
--- source include/show_binlog_events.inc
-
--- sync_slave_with_master
-
--- echo [SLAVE] ********* SOW BINLOG EVENTS IN ...   *********
-let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
--- source include/show_binlog_events.inc
-
--- echo [SLAVE] ********* SOW BINLOG EVENTS          *********
-let $binlog_file= ;
--- source include/show_binlog_events.inc
-
--- echo [SLAVE] ********* SOW RELAYLOG EVENTS IN ... *********
--- source include/show_relaylog_events.inc
-
--- echo [SLAVE] ********* SOW RELAYLOG EVENTS        *********
-let $binlog_file= ;
--- source include/show_relaylog_events.inc
 
 # clear show_binlog_event/show_relaylog_events parameters
 let $binlog_file= ;

=== modified file 'mysql-test/include/func_in.inc'
--- a/mysql-test/include/func_in.inc	2010-07-23 17:51:11 +0000
+++ b/mysql-test/include/func_in.inc	2011-01-14 08:20:08 +0000
@@ -555,5 +555,47 @@ SELECT CASE a WHEN a THEN a END FROM t1
 DROP TABLE t1;
 
 --echo #
+--echo # Bug#58628: Incorrect result for 'WHERE NULL NOT IN (<subquery>)
+--echo #
+
+CREATE TABLE t1 (pk INT NOT NULL, i INT);
+INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL);
+
+CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk));
+INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3);
+
+## Baseline queries: t1.i contains only NULL and should effectively
+## be evaluated as 'WHERE NULL IN'
+## .. These return correct resultset !
+
+--sorted_result
+SELECT * FROM t1
+  WHERE t1.i NOT IN
+    (SELECT i FROM subq WHERE subq.pk = t1.pk);
+
+--sorted_result
+SELECT * FROM t1
+  WHERE t1.i IN
+    (SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+
+## Replaced 't1.i' with some constant expression which 
+## also evaluates to NULL. Expected to return same result as above:
+
+--sorted_result
+SELECT * FROM t1
+  WHERE NULL NOT IN
+    (SELECT i FROM subq WHERE subq.pk = t1.pk);
+
+--sorted_result
+SELECT * FROM t1
+  WHERE NULL IN
+    (SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+
+--sorted_result
+SELECT * FROM t1
+  WHERE 1+NULL NOT IN
+    (SELECT i FROM subq WHERE subq.pk = t1.pk);
+
+DROP TABLE t1,subq;
 
 --echo End of 5.1 tests

=== modified file 'mysql-test/include/icp_tests.inc'
--- a/mysql-test/include/icp_tests.inc	2011-01-10 09:04:20 +0000
+++ b/mysql-test/include/icp_tests.inc	2011-01-13 07:33:03 +0000
@@ -655,6 +655,27 @@ select 1 from t1 where b <= 1 and a <> '
 drop table t1;
 
 --echo #
+--echo # Bug #58816 "Extra temporary duplicate rows in result set when 
+--echo #             switching ICP off"
+--echo #
+
+CREATE TABLE t1 (
+  pk INT NOT NULL,
+  c1 INT NOT NULL,
+  PRIMARY KEY (pk)
+);
+
+INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
+
+EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
+
+SET SESSION optimizer_switch='index_condition_pushdown=off';
+
+SELECT pk, c1 FROM t1 WHERE pk <> 3;
+
+DROP TABLE t1;
+
+--echo #
 --echo # Bug#58837: ICP crash or valgrind error due to uninitialized 
 --echo #            value in innobase_index_cond
 --echo #

=== modified file 'mysql-test/include/select.inc'
--- a/mysql-test/include/select.inc	2010-12-17 09:41:21 +0000
+++ b/mysql-test/include/select.inc	2011-01-13 10:48:28 +0000
@@ -4137,6 +4137,76 @@ SELECT 1 FROM t1 ORDER BY a COLLATE lati
 DROP TABLE t1;
 
 
+
+--echo #
+--echo # Bug #58422: Incorrect result when OUTER JOIN'ing 
+--echo # with an empty table
+--echo #
+
+CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+CREATE TABLE t1(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
+
+EXPLAIN
+SELECT *
+  FROM 
+    t1
+  LEFT OUTER JOIN
+    (t2 INNER JOIN t_empty ON TRUE)
+  ON t1.pk=t2.pk
+  WHERE t2.pk <> 2;
+
+SELECT *
+  FROM 
+    t1
+  LEFT OUTER JOIN
+    (t2 INNER JOIN t_empty ON TRUE)
+  ON t1.pk=t2.pk
+  WHERE t2.pk <> 2;
+
+
+EXPLAIN
+SELECT *
+  FROM 
+    t1
+  LEFT OUTER JOIN
+    (t2 CROSS JOIN t_empty)
+  ON t1.pk=t2.pk
+  WHERE t2.pk <> 2;
+
+SELECT *
+  FROM 
+    t1
+  LEFT OUTER JOIN
+    (t2 CROSS JOIN t_empty)
+  ON t1.pk=t2.pk
+  WHERE t2.pk <> 2;
+
+
+EXPLAIN
+SELECT *
+  FROM 
+    t1
+  LEFT OUTER JOIN
+    (t2 INNER JOIN t_empty ON t_empty.i=t2.i)
+  ON t1.pk=t2.pk
+  WHERE t2.pk <> 2;
+
+SELECT *
+  FROM 
+    t1
+  LEFT OUTER JOIN
+    (t2 INNER JOIN t_empty ON t_empty.i=t2.i)
+  ON t1.pk=t2.pk
+  WHERE t2.pk <> 2;
+
+
+
+DROP TABLE t1,t2,t_empty;
+
+
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'mysql-test/include/setup_fake_relay_log.inc'
--- a/mysql-test/include/setup_fake_relay_log.inc	2010-12-19 17:22:30 +0000
+++ b/mysql-test/include/setup_fake_relay_log.inc	2011-01-14 11:15:25 +0000
@@ -74,6 +74,7 @@ let $_fake_relay_index= $_fake_datadir/$
 let $_fake_relay_log_purge= `SELECT @@global.relay_log_purge`;
 
 RESET SLAVE;
+let $_orphan_relay_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
 
 # Create relay log file.
 --copy_file $fake_relay_log $_fake_relay_log
@@ -102,6 +103,8 @@ RESET SLAVE;
 # Setup replication from existing relay log.
 eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_filename-fake.000001', RELAY_LOG_POS=4;
 
+# remove the orphan log file (became spurious)
+-- remove_file $_fake_datadir/$_orphan_relay_file
 
 --let $include_filename= setup_fake_relay_log.inc
 --source include/end_include_file.inc

=== modified file 'mysql-test/include/wait_for_status_var.inc'
--- a/mysql-test/include/wait_for_status_var.inc	2010-10-21 13:24:31 +0000
+++ b/mysql-test/include/wait_for_status_var.inc	2011-01-13 21:18:17 +0000
@@ -50,8 +50,23 @@ if (!$_status_var_comparsion)
   let $_status_var_comparsion= =;
 }
 
+# Get type of variable
+let $_is_number= 0;
+if (`SELECT '$status_var_value' REGEXP '^[\+\-]*[0-9]+(\.[0-9]+)*\$'`)
+{
+  let $_is_number= 1;
+}
+
 let $_show_status_value= query_get_value("SHOW $status_type STATUS LIKE '$status_var'", Value, 1);
-while (`SELECT NOT('$_show_status_value' $_status_var_comparsion '$status_var_value')`)
+
+# Set way of comparing
+let $_query= SELECT NOT('$_show_status_value' $_status_var_comparsion '$status_var_value');
+if ($is_number)
+{
+  let $_query= SELECT NOT($_show_status_value $_status_var_comparsion $status_var_value);
+}
+
+while (`$_query`)
 {
   if (!$_status_timeout_counter)
   {
@@ -65,4 +80,9 @@ while (`SELECT NOT('$_show_status_value'
   dec $_status_timeout_counter;
   sleep 0.1;
   let $_show_status_value= query_get_value("SHOW $status_type STATUS LIKE '$status_var'", Value, 1);
+  let $_query= SELECT NOT('$_show_status_value' $_status_var_comparsion '$status_var_value');
+  if ($is_number)
+  {
+    let $_query= SELECT NOT($_show_status_value $_status_var_comparsion $status_var_value);
+  }
 }

=== modified file 'mysql-test/r/client_xml.result'
--- a/mysql-test/r/client_xml.result	2008-07-18 12:00:45 +0000
+++ b/mysql-test/r/client_xml.result	2011-01-14 14:20:34 +0000
@@ -21,9 +21,9 @@ insert into t1 values (1, 2, 'a&b a<b a>
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="test">
 	<table_structure name="t1">
-		<field Field="a&amp;b" Type="int(11)" Null="YES" Key="" Extra="" />
-		<field Field="a&lt;b" Type="int(11)" Null="YES" Key="" Extra="" />
-		<field Field="a&gt;b" Type="text" Null="YES" Key="" Extra="" />
+		<field Field="a&amp;b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
+		<field Field="a&lt;b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
+		<field Field="a&gt;b" Type="text" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_data name="t1">
 	<row>

=== modified file 'mysql-test/r/func_in_icp.result'
--- a/mysql-test/r/func_in_icp.result	2010-07-23 17:51:11 +0000
+++ b/mysql-test/r/func_in_icp.result	2011-01-14 08:20:08 +0000
@@ -771,5 +771,40 @@ CASE a WHEN a THEN a END
 NULL
 DROP TABLE t1;
 #
+# Bug#58628: Incorrect result for 'WHERE NULL NOT IN (<subquery>)
+#
+CREATE TABLE t1 (pk INT NOT NULL, i INT);
+INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL);
+CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk));
+INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3);
+SELECT * FROM t1
+WHERE t1.i NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+SELECT * FROM t1
+WHERE t1.i IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+pk	i
+0	NULL
+1	NULL
+2	NULL
+3	NULL
+SELECT * FROM t1
+WHERE NULL NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+SELECT * FROM t1
+WHERE NULL IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+pk	i
+0	NULL
+1	NULL
+2	NULL
+3	NULL
+SELECT * FROM t1
+WHERE 1+NULL NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+DROP TABLE t1,subq;
 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	2010-11-30 13:55:22 +0000
+++ b/mysql-test/r/func_in_icp_mrr.result	2011-01-14 08:20:08 +0000
@@ -771,5 +771,40 @@ CASE a WHEN a THEN a END
 NULL
 DROP TABLE t1;
 #
+# Bug#58628: Incorrect result for 'WHERE NULL NOT IN (<subquery>)
+#
+CREATE TABLE t1 (pk INT NOT NULL, i INT);
+INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL);
+CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk));
+INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3);
+SELECT * FROM t1
+WHERE t1.i NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+SELECT * FROM t1
+WHERE t1.i IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+pk	i
+0	NULL
+1	NULL
+2	NULL
+3	NULL
+SELECT * FROM t1
+WHERE NULL NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+SELECT * FROM t1
+WHERE NULL IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+pk	i
+0	NULL
+1	NULL
+2	NULL
+3	NULL
+SELECT * FROM t1
+WHERE 1+NULL NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+DROP TABLE t1,subq;
 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	2010-11-30 13:55:22 +0000
+++ b/mysql-test/r/func_in_mrr.result	2011-01-14 08:20:08 +0000
@@ -771,5 +771,40 @@ CASE a WHEN a THEN a END
 NULL
 DROP TABLE t1;
 #
+# Bug#58628: Incorrect result for 'WHERE NULL NOT IN (<subquery>)
+#
+CREATE TABLE t1 (pk INT NOT NULL, i INT);
+INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL);
+CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk));
+INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3);
+SELECT * FROM t1
+WHERE t1.i NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+SELECT * FROM t1
+WHERE t1.i IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+pk	i
+0	NULL
+1	NULL
+2	NULL
+3	NULL
+SELECT * FROM t1
+WHERE NULL NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+SELECT * FROM t1
+WHERE NULL IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+pk	i
+0	NULL
+1	NULL
+2	NULL
+3	NULL
+SELECT * FROM t1
+WHERE 1+NULL NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+DROP TABLE t1,subq;
 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	2010-11-30 13:55:22 +0000
+++ b/mysql-test/r/func_in_mrr_cost.result	2011-01-14 08:20:08 +0000
@@ -771,5 +771,40 @@ CASE a WHEN a THEN a END
 NULL
 DROP TABLE t1;
 #
+# Bug#58628: Incorrect result for 'WHERE NULL NOT IN (<subquery>)
+#
+CREATE TABLE t1 (pk INT NOT NULL, i INT);
+INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL);
+CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk));
+INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3);
+SELECT * FROM t1
+WHERE t1.i NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+SELECT * FROM t1
+WHERE t1.i IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+pk	i
+0	NULL
+1	NULL
+2	NULL
+3	NULL
+SELECT * FROM t1
+WHERE NULL NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+SELECT * FROM t1
+WHERE NULL IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+pk	i
+0	NULL
+1	NULL
+2	NULL
+3	NULL
+SELECT * FROM t1
+WHERE 1+NULL NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+DROP TABLE t1,subq;
 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	2010-07-23 17:51:11 +0000
+++ b/mysql-test/r/func_in_none.result	2011-01-14 08:20:08 +0000
@@ -770,5 +770,40 @@ CASE a WHEN a THEN a END
 NULL
 DROP TABLE t1;
 #
+# Bug#58628: Incorrect result for 'WHERE NULL NOT IN (<subquery>)
+#
+CREATE TABLE t1 (pk INT NOT NULL, i INT);
+INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL);
+CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk));
+INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3);
+SELECT * FROM t1
+WHERE t1.i NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+SELECT * FROM t1
+WHERE t1.i IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+pk	i
+0	NULL
+1	NULL
+2	NULL
+3	NULL
+SELECT * FROM t1
+WHERE NULL NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+SELECT * FROM t1
+WHERE NULL IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN;
+pk	i
+0	NULL
+1	NULL
+2	NULL
+3	NULL
+SELECT * FROM t1
+WHERE 1+NULL NOT IN
+(SELECT i FROM subq WHERE subq.pk = t1.pk);
+pk	i
+DROP TABLE t1,subq;
 End of 5.1 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/func_math.result'
--- a/mysql-test/r/func_math.result	2010-12-24 11:30:28 +0000
+++ b/mysql-test/r/func_math.result	2011-01-14 15:36:19 +0000
@@ -641,3 +641,18 @@ INSERT INTO t1 (SELECT -pi());
 Warnings:
 Warning	1265	Data truncated for column 'a' at row 1
 DROP TABLE t1;
+#
+# Bug #59241 invalid memory read
+#            in do_div_mod with doubly assigned variables
+#
+SELECT ((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa')));
+((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa')))
+NULL
+Warnings:
+Warning	1366	Incorrect decimal value: '' for column '' at row -1
+#
+# Bug #59498 div function broken in mysql-trunk
+#
+SELECT 1 div null;
+1 div null
+NULL

=== modified file 'mysql-test/r/func_str.result'
--- a/mysql-test/r/func_str.result	2010-12-14 16:29:15 +0000
+++ b/mysql-test/r/func_str.result	2011-01-13 08:19:52 +0000
@@ -2615,6 +2615,22 @@ CONVERT(('' IN (REVERSE(CAST(('') AS DEC
 1
 Warnings:
 Warning	1292	Truncated incorrect DECIMAL value: ''
+# 
+# Bug#58165: "my_empty_string" gets modified and causes LOAD DATA to fail
+# and other crashes
+#
+CREATE TABLE t1 ( a TEXT );
+SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE 'bug58165.txt';
+SELECT insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' );
+insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' )
+x
+Warnings:
+Warning	1292	Truncated incorrect INTEGER value: 'b'
+LOAD DATA INFILE 'bug58165.txt' INTO TABLE t1;
+SELECT * FROM t1;
+a
+aaaaaaaaaaaaaa
+DROP TABLE t1;
 End of 5.1 tests
 Start of 5.4 tests
 SELECT format(12345678901234567890.123, 3);

=== modified file 'mysql-test/r/gis-precise.result'
--- a/mysql-test/r/gis-precise.result	2010-10-14 05:33:13 +0000
+++ b/mysql-test/r/gis-precise.result	2011-01-14 21:08:28 +0000
@@ -160,15 +160,16 @@ select astext(geom), area(geom),area(ST_
 astext(geom)	area(geom)	area(ST_buffer(geom,2))
 POLYGON((0 0,10 10,0 8,0 0))	40	101.67150840374886
 POLYGON((1 1,10 10,0 8,1 1))	36	108.55539589266459
-select astext(ST_buffer(geom,2)) from t1;
-astext(ST_buffer(geom,2))
-POLYGON((1.414213562373095 -1.414213562373095,-1.414213562373095 1.414213562373095,0 2.82842712474619,0 6.000050261222183,-0.09604577729856129 6.0023075290067505,-0.19395220952652842 6.009426579997669,-0.2913913938935395 6.021341096711012,-0.38812859086978896 6.03802237603243,-0.4839307520745837 6.059430231298929,-0.578567081710303 6.085513089112066,-0.6718095925696909 6.116208113582781,-0.7634336552770082 6.151441357708556,-0.8532185394398725 6.191127941518226,-0.940947945408108 6.235172256555257,-1.0264105253585494 6.283468196206902,-1.1094003924504583 6.335899411324313,-1.189717616824956 6.39233959051784,-1.2671687072535667 6.45265276445223,-1.341567077275533 6.516693633408666,-1.4127334947009451 6.584307917324514,-1.480496513396783 6.655332727467508,-1.5446928863156684 6.729596958848976,-1.6051679587723025 6.806921702430742,-1.661776041020146 6.8871206761326675,-1.7143807592307814 6.970000673602507,-1.7628553840304106 7.055362029666924,-1.8070831358020145 7.142999101342386,-1.8469574660176828 7.232700763247128,-1.8823823139233473 7.3242509162206835,-1.913272337957552 7.417429007925692,-1.9395531213467532 7.512010564177801,-1.9611613513818404 7.607767729723632,-1.9780449719440023 7.704469817164048,-1.990163308912474 7.8018838627003015,-1.9974871681520578 7.899775187364235,-1.9999989058443504 7.997907962380466,-1.9976924709932495 8.096045777298562,-1.9905734200023315 8.193952209526529,-1.978658903288988 8.291391393893539,-1.9619776239675701 8.388128590869789,-1.940569768701071 8.483930752074583,-1.9144869108879337 8.578567081710304,-1.8837918864172196 8.67180959256969,-1.848558642291444 8.763433655277009,-1.8088720584817741 8.853218539439872,-1.7648277434447421 8.940947945408109,-1.716531803793098 9.02641052535855,-1.6641005886756872 9.109400392450459,-1.6076604094821603 9.189717616824955,-1.5473472355477698 9.267168707253568,-1.483306366591334 9.341567077275533,-1.415692082675486 9.412733494700944,-1.3446672725324915 9.480496513396783,-1.2704030411510234 9.54469288631567,-1.1930782975692584 9.605167958772302,-1.1128793238673322 9.661776041020147,-1.0299993263974934 9.714380759230782,-0.9446379703330767 9.762855384030411,-0.8570008986576141 9.807083135802014,-0.7672992367528719 9.846957466017683,-0.6757490837793165 9.882382313923348,-0.5825709920743072 9.913272337957553,-0.4879894358221987 9.939553121346753,-0.3922322702763681 9.96116135138184,-0.2955301828359524 9.978044971944003,-0.3922322702763681 9.96116135138184,9.607767729723632 11.96116135138184,9.609819355967744 11.96157056080646,9.706539051089276 11.978353019929562,9.803965719340878 11.990369453344393,9.901864651345164 11.997590912410345,10 12,10.098135348654836 11.997590912410345,10.196034280659122 11.990369453344393,10.293460948910724 11.978353019929562,10.390180644032256 11.96157056080646,10.485960359806528 11.940062506389088,10.580569354508924 11.913880671464417,10.67377970678444 11.88308813036604,10.76536686473018 11.847759065022574,10.855110186860564 11.807978586246886,10.942793473651996 11.76384252869671,11.028205488386444 11.715457220000545,11.111140466039204 11.66293922460509,11.191398608984866 11.60641506296129,11.268786568327291 11.546020906725474,11.343117909694037 11.481902250709918,11.414213562373096 11.414213562373096,11.481902250709918 11.343117909694037,11.546020906725474 11.268786568327291,11.60641506296129 11.191398608984866,11.66293922460509 11.111140466039204,11.715457220000545 11.028205488386444,11.76384252869671 10.942793473651996,11.807978586246886 10.855110186860564,11.847759065022574 10.76536686473018,11.88308813036604 10.67377970678444,11.913880671464417 10.580569354508924,11.940062506389088 10.485960359806528,11.96157056080646 10.390180644032256,11.978353019929562 10.293460948910724,11.990369453344393 10.196034280659122,11.997590912410345 10.098135348654836,12 10,11.997590912410345 9.901864651345164,11.990369453344393 9.803965719340878,11.978353019929562 9.706539051089276,11.96157056080646 9.609819355967744,11.940062506389088 9.514039640193472,11.913880671464417 9.419430645491076,11.88308813036604 9.32622029321556,11.847759065022574 9.23463313526982,11.807978586246886 9.144889813139436,11.76384252869671 9.057206526348004,11.715457220000545 8.971794511613556,11.66293922460509 8.888859533960796,11.60641506296129 8.808601391015134,11.546020906725474 8.731213431672709,11.481902250709918 8.656882090305963,11.414213562373096 8.585786437626904,1.414213562373095 -1.414213562373095))
-POLYGON((0.9892698494111194 -0.9999712157599518,0.8911488380683092 -0.9970356593075951,0.7932900587088283 -0.9892890690323013,0.6959292617035704 -0.9767501071485654,0.5993009977403192 -0.959448981113848,0.5036380527705995 -0.9374273708561667,0.40917088720792716 -0.9107383283634973,0.3161270807284893 -0.8794461498768888,0.2247307840117696 -0.843626220995187,0.13520217874192864 -0.8033648350645226,0.04775694717084156 -0.7587589852900836,-0.03739424747933939 -0.7099161310709878,-0.12004626852233802 -0.6569539391211774,-0.19999999999999996 -0.5999999999999999,-0.27706282637007584 -0.5391915207353741,-0.35104909653393324 -0.47467499428004234,-0.42178057108631606 -0.40660584659721555,-0.4890868517096818 -0.3351480622258147,-0.5528057916786753 -0.26047378922735365,-0.6127838864857904 -0.18276292446617926,-0.6688766436471771 -0.10220268022216916,-0.7209489307976877 -0.018987133179951154,-0.7688753012365837 0.06668324311882912,-0.8125402961396226 0.15460206123382925,-0.8518387227094812 0.2445575170314307,-0.8866759075944177 0.33633289993945015,-0.9169679249646674 0.4297071150218881,-0.9426417986971172 0.5244552156159955,-0.9636356781811806 0.6203489452484875,-0.9798989873223332 0.717157287525381,-1.9798989873223332 7.717157287525381,-1.990163308912474 7.8018838627003015,-1.9974871681520578 7.899775187364235,-1.9999989058443504 7.997907962380466,-1.9976924709932495 8.096045777298562,-1.9905734200023315 8.193952209526529,-1.978658903288988 8.291391393893539,-1.9619776239675701 8.388128590869789,-1.940569768701071 8.483930752074583,-1.9144869108879337 8.578567081710304,-1.8837918864172196 8.67180959256969,-1.848558642291444 8.763433655277009,-1.8088720584817741 8.853218539439872,-1.7648277434447421 8.940947945408109,-1.716531803793098 9.02641052535855,-1.6641005886756872 9.109400392450459,-1.6076604094821603 9.189717616824955,-1.5473472355477698 9.267168707253568,-1.483306366591334 9.341567077275533,-1.415692082675486 9.412733494700944,-1.3446672725324915 9.480496513396783,-1.2704030411510234 9.54469288631567,-1.1930782975692584 9.605167958772302,-1.1128793238673322 9.661776041020147,-1.0299993263974934 9.714380759230782,-0.9446379703330767 9.762855384030411,-0.8570008986576141 9.807083135802014,-0.7672992367528719 9.846957466017683,-0.6757490837793165 9.882382313923348,-0.5825709920743072 9.913272337957553,-0.4879894358221987 9.939553121346753,-0.3922322702763681 9.96116135138184,9.607767729723632 11.96116135138184,9.609819355967744 11.96157056080646,9.706539051089276 11.978353019929562,9.803965719340878 11.990369453344393,9.901864651345164 11.997590912410345,10 12,10.098135348654836 11.997590912410345,10.196034280659122 11.990369453344393,10.293460948910724 11.978353019929562,10.390180644032256 11.96157056080646,10.485960359806528 11.940062506389088,10.580569354508924 11.913880671464417,10.67377970678444 11.88308813036604,10.76536686473018 11.847759065022574,10.855110186860564 11.807978586246886,10.942793473651996 11.76384252869671,11.028205488386444 11.715457220000545,11.111140466039204 11.66293922460509,11.191398608984866 11.60641506296129,11.268786568327291 11.546020906725474,11.343117909694037 11.481902250709918,11.414213562373096 11.414213562373096,11.481902250709918 11.343117909694037,11.546020906725474 11.268786568327291,11.60641506296129 11.191398608984866,11.66293922460509 11.111140466039204,11.715457220000545 11.028205488386444,11.76384252869671 10.942793473651996,11.807978586246886 10.855110186860564,11.847759065022574 10.76536686473018,11.88308813036604 10.67377970678444,11.913880671464417 10.580569354508924,11.940062506389088 10.485960359806528,11.96157056080646 10.390180644032256,11.978353019929562 10.293460948910724,11.990369453344393 10.196034280659122,11.997590912410345 10.098135348654836,12 10,11.997590912410345 9.901864651345164,11.990369453344393 9.803965719340878,11.978353019929562 9.706539051089276,11.96157056080646 9.609819355967744,11.940062506389088 9.514039640193472,11.913880671464417 9.419430645491076,11.88308813036604 9.32622029321556,11.847759065022574 9.23463313526982,11.807978586246886 9.144889813139436,11.76384252869671 9.057206526348004,11.715457220000545 8.971794511613556,11.66293922460509 8.888859533960796,11.60641506296129 8.808601391015134,11.546020906725474 8.731213431672709,11.481902250709918 8.656882090305963,11.414213562373096 8.585786437626904,2.414213562373095 -0.4142135623730949,2.4066058465972153 -0.42178057108631606,2.335148062225815 -0.4890868517096818,2.260473789227354 -0.5528057916786753,2.1827629244661795 -0.6127838864857904,2.1022026802221694 -0.6688766436471771,2.018987133179951 -0.7209489307976877,1.9333167568811709 -0.7688753012365837,1.8453979387661708 -0.8125402961396226,1.7554424829685693 -0.8518387227094812,1.6636671000605499 -0.8866759075944177,1.570292884978112 -0.9169679249646674,1.4755447843840046 -0.9426417986971172,1.3796510547515126 -0.9636356781811806,1.282842712474619 -0.9798989873223332,1.1853529773292786 -0.9913925463843567,1.0874167106265484 -0.9980886663767536,0.9892698494111194 -0.9999712157599518))
+select NUMPOINTS(EXTERIORRING(ST_buffer(geom,2))) from t1;
+NUMPOINTS(EXTERIORRING(ST_buffer(geom,2)))
+121
+134
 set @geom=geomfromtext('LINESTRING(2 1, 4 2, 2 3, 2 5)');
 set @buff=ST_buffer(@geom,1);
-select astext(@buff);
-astext(@buff)
-POLYGON((2.0218594008566466 0.00023894525032219782,1.9727771204112932 0.00037061126290494073,1.9237604222673113 0.002910472030148492,1.8749273919438858 0.0078524088049996,1.8263956724883341 0.015184516028905026,1.7782821810637013 0.024889130013345362,1.7307028272850733 0.03694287149320841,1.683772233983162 0.05131670194948634,1.6376034610678665 0.06797599356561079,1.592307733157046 0.08688061264889702,1.5479941716266756 0.10798501631612445,1.504769531727891 0.13123836221033125,1.46273794540424 0.1565846309845056,1.4220006704287085 0.18396276125709976,1.382655846464876 0.21330679671424568,1.3447982586398712 0.24454604500429356,1.3085191091986976 0.2776052480418776,1.2739057977900368 0.3124047633112361,1.241041710912841 0.34886075573200737,1.2100060210309511 0.38688539962528223,1.1808734958396978 0.4263870902933562,1.1537143181439746 0.46727066470347056,1.1285939167817136 0.5094376307438929,1.1055728090000843 0.5527864045000421,1.0847064546641425 0.5972125549790352,1.0660451226491614 0.6426090556930975,1.0496337697385036 0.6888665424957445,1.0355119323187965 0.7358735770495916,1.0237136311333106 0.7835169152910685,1.0142672893230111 0.8316817802452878,1.0071956639527206 0.8802521385338314,1.0025157911873577 0.9291109799093207,1.0002389452503222 0.9781405991433534,1.000370611262905 1.0272228795887068,1.0029104720301485 1.0762395777326887,1.0078524088049996 1.1250726080561142,1.015184516028905 1.1736043275116659,1.0248891300133454 1.2217178189362987,1.0369428714932085 1.2692971727149267,1.0513167019494865 1.316227766016838,1.0679759935656108 1.3623965389321335,1.086880612648897 1.407692266842954,1.1079850163161244 1.4520058283733244,1.1312383622103312 1.495230468272109,1.1565846309845056 1.53726205459576,1.1839627612570998 1.5779993295712915,1.2133067967142457 1.617344153535124,1.2445460450042936 1.6552017413601288,1.2776052480418776 1.6914808908013024,1.3124047633112361 1.7260942022099632,1.3488607557320074 1.758958289087159,1.3868853996252821 1.7899939789690489,1.4263870902933562 1.8191265041603022,1.4672706647034706 1.8462856818560254,1.5094376307438928 1.8714060832182864,1.5527864045000421 1.8944271909999157,1.7639320225002106 2,1.5527864045000421 2.1055728090000843,1.5286032631740025 2.118078735651645,1.4858972558067784 2.1422713899997277,1.4444297669803978 2.1685303876974547,1.4043006955075668 2.196792468519355,1.3656067158363545 2.226989546637263,1.3284410451529816 2.259048874645041,1.2928932188134525 2.2928932188134525,1.2590488746450408 2.3284410451529816,1.2269895466372631 2.3656067158363543,1.1967924685193552 2.4043006955075668,1.1685303876974547 2.444429766980398,1.1422713899997279 2.4858972558067784,1.118078735651645 2.5286032631740025,1.0960107068765566 2.572444906569718,1.0761204674887133 2.6173165676349104,1.0584559348169793 2.66311014660778,1.043059664267791 2.709715322745538,1.029968746805456 2.757019820096736,1.0192147195967696 2.8049096779838716,1.0108234900352189 2.853269525544638,1.0048152733278033 2.9019828596704396,1.0012045437948276 2.950932325672582,1 3,1 5,1.0048152733278033 5.098017140329561,1.0108234900352189 5.146730474455362,1.0192147195967696 5.195090322016128,1.029968746805456 5.242980179903264,1.043059664267791 5.290284677254462,1.0584559348169793 5.33688985339222,1.0761204674887133 5.38268343236509,1.0960107068765566 5.427555093430282,1.118078735651645 5.471396736825998,1.1422713899997279 5.514102744193222,1.1685303876974547 5.555570233019602,1.1967924685193552 5.595699304492434,1.2269895466372631 5.634393284163646,1.2590488746450408 5.671558954847018,1.2928932188134525 5.707106781186548,1.3284410451529816 5.740951125354959,1.3656067158363545 5.773010453362737,1.4043006955075668 5.803207531480645,1.4444297669803978 5.831469612302545,1.4858972558067784 5.857728610000272,1.5286032631740025 5.881921264348355,1.572444906569718 5.903989293123443,1.6173165676349102 5.923879532511287,1.6631101466077798 5.941544065183021,1.7097153227455377 5.956940335732209,1.7570198200967362 5.970031253194544,1.8049096779838716 5.98078528040323,1.853269525544638 5.989176509964781,1.9019828596704393 5.995184726672197,1.950932325672582 5.998795456205173,2 6,2.049067674327418 5.998795456205173,2.0980171403295604 5.995184726672197,2.146730474455362 5.989176509964781,2.1950903220161284 5.98078528040323,2.242980179903264 5.970031253194544,2.290284677254462 5.956940335732209,2.33688985339222 5.941544065183021,2.3826834323650896 5.923879532511287,2.427555093430282 5.903989293123443,2.4713967368259975 5.881921264348355,2.5141027441932216 5.857728610000272,2.555570233019602 5.831469612302545,2.5956993044924332 5.803207531480645,2.6343932841636457 5.773010453362737,2.6715589548470184 5.740951125354959,2.7071067811865475 5.707106781186548,2.740951125354959 5.671558954847018,2.773010453362737 5.634393284163646,2.803207531480645 5.595699304492434,2.8314696123025453 5.555570233019602,2.8577286100002723 5.514102744193222,2.881921264348355 5.471396736825998,2.9039892931234434 5.427555093430282,2.923879532511287 5.38268343236509,2.9415440651830207 5.33688985339222,2.956940335732209 5.290284677254462,2.970031253194544 5.242980179903264,2.9807852804032304 5.195090322016128,2.989176509964781 5.146730474455362,2.9951847266721967 5.098017140329561,2.9987954562051726 5.049067674327418,3 5,3 3.618033988749895,4.447213595499958 2.8944271909999157,4.452005828373324 2.8920149836838753,4.4952304682721085 2.8687616377896688,4.53726205459576 2.8434153690154944,4.577999329571291 2.8160372387429002,4.617344153535124 2.786693203285754,4.655201741360129 2.7554539549957067,4.691480890801302 2.7223947519581224,4.726094202209963 2.6875952366887637,4.758958289087159 2.6511392442679926,4.789993978969049 2.613114600374718,4.819126504160303 2.573612909706644,4.846285681856025 2.5327293352965294,4.871406083218286 2.490562369256107,4.894427190999916 2.447213595499958,4.9152935453358575 2.402787445020965,4.933954877350839 2.3573909443069025,4.950366230261497 2.3111334575042557,4.964488067681204 2.2641264229504086,4.976286368866689 2.2164830847089316,4.985732710676989 2.1683182197547124,4.992804336047279 2.1197478614661684,4.997484208812643 2.070889020090679,4.999761054749678 2.0218594008566466,4.999629388737095 1.9727771204112932,4.997089527969852 1.9237604222673113,4.992147591195001 1.8749273919438858,4.984815483971095 1.8263956724883341,4.975110869986654 1.7782821810637013,4.963057128506792 1.7307028272850733,4.948683298050514 1.683772233983162,4.932024006434389 1.6376034610678665,4.913119387351103 1.592307733157046,4.892014983683875 1.5479941716266756,4.868761637789669 1.504769531727891,4.843415369015494 1.46273794540424,4.816037238742901 1.4220006704287085,4.786693203285754 1.382655846464876,4.755453954995707 1.3447982586398712,4.722394751958122 1.3085191091986976,4.687595236688764 1.2739057977900368,4.651139244267993 1.241041710912841,4.613114600374717 1.2100060210309511,4.573612909706644 1.1808734958396978,4.53272933529653 1.1537143181439746,4.490562369256107 1.1285939167817136,4.447213595499958 1.1055728090000843,2.447213595499958 0.10557280900008414,2.3573909443069025 0.06604512264916129,2.3111334575042557 0.04963376973850353,2.2641264229504086 0.03551193231879646,2.2164830847089316 0.023713631133310598,2.1683182197547124 0.014267289323011023,2.1197478614661684 0.007195663952720532,2.070889020090679 0.0025157911873575634,2.0218594008566466 0.00023894525032219782))
+select NUMPOINTS(EXTERIORRING(@buff)) from t1;
+NUMPOINTS(EXTERIORRING(@buff))
+202
+202
 DROP TABLE t1;
 select st_touches(geomfromtext('point(0 0)'), geomfromtext('point(1 1)'));
 st_touches(geomfromtext('point(0 0)'), geomfromtext('point(1 1)'))

=== modified file 'mysql-test/r/gis.result'
--- a/mysql-test/r/gis.result	2010-11-29 13:30:18 +0000
+++ b/mysql-test/r/gis.result	2011-01-12 17:24:53 +0000
@@ -1014,6 +1014,14 @@ SET @a=0x0000000003000000010000000000000
 SET @a=POLYFROMWKB(@a);
 SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440;
 SET @a=POLYFROMWKB(@a);
+create table t1(a polygon NOT NULL)engine=myisam;
+insert into t1 values (geomfromtext("point(0 1)"));
+insert into t1 values (geomfromtext("point(1 0)"));
+select * from (select polygon(t1.a) as p from t1 order by t1.a) d;
+p
+NULL
+NULL
+drop table t1;
 End of 5.1 tests
 CREATE TABLE t1(
 col0 BINARY NOT NULL,

=== modified file 'mysql-test/r/innodb_icp.result'
--- a/mysql-test/r/innodb_icp.result	2011-01-10 09:04:20 +0000
+++ b/mysql-test/r/innodb_icp.result	2011-01-13 07:33:03 +0000
@@ -599,6 +599,27 @@ select 1 from t1 where b <= 1 and a <> '
 1
 drop table t1;
 #
+# Bug #58816 "Extra temporary duplicate rows in result set when 
+#             switching ICP off"
+#
+CREATE TABLE t1 (
+pk INT NOT NULL,
+c1 INT NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
+EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	4	Using index condition
+SET SESSION optimizer_switch='index_condition_pushdown=off';
+SELECT pk, c1 FROM t1 WHERE pk <> 3;
+pk	c1
+1	9
+2	7
+4	3
+5	1
+DROP TABLE t1;
+#
 # Bug#58837: ICP crash or valgrind error due to uninitialized 
 #            value in innobase_index_cond
 #

=== modified file 'mysql-test/r/innodb_icp_all.result'
--- a/mysql-test/r/innodb_icp_all.result	2010-12-13 15:22:45 +0000
+++ b/mysql-test/r/innodb_icp_all.result	2011-01-13 07:33:03 +0000
@@ -598,5 +598,26 @@ insert into t1 values ('',1);
 select 1 from t1 where b <= 1 and a <> '';
 1
 drop table t1;
+#
+# Bug #58816 "Extra temporary duplicate rows in result set when 
+#             switching ICP off"
+#
+CREATE TABLE t1 (
+pk INT NOT NULL,
+c1 INT NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
+EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	4	Using index condition
+SET SESSION optimizer_switch='index_condition_pushdown=off';
+SELECT pk, c1 FROM t1 WHERE pk <> 3;
+pk	c1
+1	9
+2	7
+4	3
+5	1
+DROP TABLE t1;
 set default_storage_engine= @save_storage_engine;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/innodb_icp_none.result'
--- a/mysql-test/r/innodb_icp_none.result	2011-01-10 09:04:20 +0000
+++ b/mysql-test/r/innodb_icp_none.result	2011-01-13 07:33:03 +0000
@@ -598,6 +598,27 @@ select 1 from t1 where b <= 1 and a <> '
 1
 drop table t1;
 #
+# Bug #58816 "Extra temporary duplicate rows in result set when 
+#             switching ICP off"
+#
+CREATE TABLE t1 (
+pk INT NOT NULL,
+c1 INT NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
+EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	4	Using where
+SET SESSION optimizer_switch='index_condition_pushdown=off';
+SELECT pk, c1 FROM t1 WHERE pk <> 3;
+pk	c1
+1	9
+2	7
+4	3
+5	1
+DROP TABLE t1;
+#
 # Bug#58837: ICP crash or valgrind error due to uninitialized 
 #            value in innobase_index_cond
 #

=== modified file 'mysql-test/r/join_outer.result'
--- a/mysql-test/r/join_outer.result	2010-12-17 11:28:59 +0000
+++ b/mysql-test/r/join_outer.result	2011-01-13 09:08:47 +0000
@@ -1432,6 +1432,76 @@ WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AN
 GROUP BY t2.f1, t2.f2;
 f1	f1	f2
 DROP TABLE t1,t2;
+#
+# Bug#57034 incorrect OUTER JOIN result when joined on unique key
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY, 
+col_int INT, 
+col_int_unique INT UNIQUE KEY);
+INSERT INTO t1 VALUES (1,NULL,2), (2,0,0);
+CREATE TABLE t2 (pk INT PRIMARY KEY,
+col_int INT,
+col_int_unique INT UNIQUE KEY);
+INSERT INTO t2 VALUES (1,0,1), (2,0,2);
+EXPLAIN
+SELECT * FROM t1 LEFT JOIN t2
+ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int 
+WHERE t1.pk=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	const	PRIMARY	PRIMARY	4	const	1	
+1	SIMPLE	t2	const	col_int_unique	col_int_unique	5	const	1	
+SELECT * FROM t1 LEFT JOIN t2
+ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int 
+WHERE t1.pk=1;
+pk	col_int	col_int_unique	pk	col_int	col_int_unique
+1	NULL	2	NULL	NULL	NULL
+DROP TABLE t1,t2;
+#
+# Bug#48046 Server incorrectly processing JOINs on NULL values
+#
+CREATE TABLE `BB` (
+`pk` int(11) NOT NULL AUTO_INCREMENT,
+`time_key` time DEFAULT NULL,
+`varchar_key` varchar(1) DEFAULT NULL,
+`varchar_nokey` varchar(1) DEFAULT NULL,
+PRIMARY KEY (`pk`),
+KEY `time_key` (`time_key`),
+KEY `varchar_key` (`varchar_key`)
+) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
+INSERT INTO `BB` VALUES (10,'18:27:58',NULL,NULL);
+SELECT table1.time_key AS field1, table2.pk 
+FROM BB table1  LEFT JOIN BB table2 
+ON table2.varchar_nokey = table1.varchar_key
+HAVING field1;
+field1	pk
+18:27:58	NULL
+DROP TABLE BB;
+#
+# Bug#49600 Server incorrectly processing RIGHT JOIN with 
+#           constant WHERE clause and no index
+#
+CREATE TABLE `BB` (
+`col_datetime_key` datetime DEFAULT NULL,
+`col_varchar_key` varchar(1) DEFAULT NULL,
+`col_varchar_nokey` varchar(1) DEFAULT NULL,
+KEY `col_datetime_key` (`col_datetime_key`),
+KEY `col_varchar_key` (`col_varchar_key`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO `BB` VALUES ('1900-01-01 00:00:00',NULL,NULL);
+SELECT table1.col_datetime_key  
+FROM BB table1 RIGHT JOIN BB table2 
+ON table2 .col_varchar_nokey = table1.col_varchar_key
+WHERE 7;
+col_datetime_key
+NULL
+ALTER TABLE BB DISABLE KEYS;
+SELECT table1.col_datetime_key  
+FROM BB table1 RIGHT JOIN BB table2
+ON table2 .col_varchar_nokey = table1.col_varchar_key
+WHERE 7;
+col_datetime_key
+NULL
+DROP TABLE BB;
 End of 5.1 tests
 #
 # Bug#54235 Extra rows with join_cache_level=4,6,8 and two LEFT JOIN

=== modified file 'mysql-test/r/myisam_icp.result'
--- a/mysql-test/r/myisam_icp.result	2011-01-10 09:04:20 +0000
+++ b/mysql-test/r/myisam_icp.result	2011-01-13 07:33:03 +0000
@@ -597,6 +597,27 @@ select 1 from t1 where b <= 1 and a <> '
 1
 drop table t1;
 #
+# Bug #58816 "Extra temporary duplicate rows in result set when 
+#             switching ICP off"
+#
+CREATE TABLE t1 (
+pk INT NOT NULL,
+c1 INT NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
+EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	5	Using where
+SET SESSION optimizer_switch='index_condition_pushdown=off';
+SELECT pk, c1 FROM t1 WHERE pk <> 3;
+pk	c1
+1	9
+2	7
+4	3
+5	1
+DROP TABLE t1;
+#
 # Bug#58837: ICP crash or valgrind error due to uninitialized 
 #            value in innobase_index_cond
 #

=== modified file 'mysql-test/r/myisam_icp_all.result'
--- a/mysql-test/r/myisam_icp_all.result	2010-12-13 15:22:45 +0000
+++ b/mysql-test/r/myisam_icp_all.result	2011-01-13 07:33:03 +0000
@@ -596,4 +596,25 @@ insert into t1 values ('',1);
 select 1 from t1 where b <= 1 and a <> '';
 1
 drop table t1;
+#
+# Bug #58816 "Extra temporary duplicate rows in result set when 
+#             switching ICP off"
+#
+CREATE TABLE t1 (
+pk INT NOT NULL,
+c1 INT NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
+EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	5	Using where
+SET SESSION optimizer_switch='index_condition_pushdown=off';
+SELECT pk, c1 FROM t1 WHERE pk <> 3;
+pk	c1
+1	9
+2	7
+4	3
+5	1
+DROP TABLE t1;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/myisam_icp_none.result'
--- a/mysql-test/r/myisam_icp_none.result	2011-01-10 09:04:20 +0000
+++ b/mysql-test/r/myisam_icp_none.result	2011-01-13 07:33:03 +0000
@@ -596,6 +596,27 @@ select 1 from t1 where b <= 1 and a <> '
 1
 drop table t1;
 #
+# Bug #58816 "Extra temporary duplicate rows in result set when 
+#             switching ICP off"
+#
+CREATE TABLE t1 (
+pk INT NOT NULL,
+c1 INT NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
+EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	5	Using where
+SET SESSION optimizer_switch='index_condition_pushdown=off';
+SELECT pk, c1 FROM t1 WHERE pk <> 3;
+pk	c1
+1	9
+2	7
+4	3
+5	1
+DROP TABLE t1;
+#
 # Bug#58837: ICP crash or valgrind error due to uninitialized 
 #            value in innobase_index_cond
 #

=== modified file 'mysql-test/r/mysqladmin.result'
--- a/mysql-test/r/mysqladmin.result	2010-09-30 10:28:49 +0000
+++ b/mysql-test/r/mysqladmin.result	2011-01-16 03:25:30 +0000
@@ -3,3 +3,11 @@ mysqladmin: unknown variable 'database=d
 Warning: mysqladmin: unknown variable 'loose-database=db2'
 mysqld is alive
 mysqld is alive
+#
+# Bug#58221 : mysqladmin --sleep=x --count=x keeps looping
+#
+# Executing mysqladmin with --sleep=1 and --count=2.
+# Done.
+# Displaying the output :
+mysqld is alive
+mysqld is alive

=== modified file 'mysql-test/r/mysqlbinlog_row_big.result'
--- a/mysql-test/r/mysqlbinlog_row_big.result	2009-04-02 22:34:18 +0000
+++ b/mysql-test/r/mysqlbinlog_row_big.result	2011-01-12 19:32:45 +0000
@@ -36,8 +36,8 @@ c1 LONGTEXT
 #
 # Insert some big rows.
 #
-256MB
-INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 16777216));
+64MB
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 4194304));
 affected rows: 1
 32MB
 INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 2097152));
@@ -53,7 +53,7 @@ affected rows: 1
 # Do not display the column value itself, just its length.
 #
 SELECT LENGTH(c1) FROM t1;
-LENGTH(c1)	268435456
+LENGTH(c1)	67108864
 LENGTH(c1)	33554432
 LENGTH(c1)	4194304
 LENGTH(c1)	524288
@@ -69,7 +69,7 @@ info: Rows matched: 4  Changed: 4  Warni
 # Do not display the column value itself, just its length.
 #
 SELECT LENGTH(c1) FROM t1;
-LENGTH(c1)	536870912
+LENGTH(c1)	134217728
 LENGTH(c1)	1048576
 LENGTH(c1)	67108864
 LENGTH(c1)	8388608

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2011-01-03 14:50:58 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2011-01-14 13:42:41 +0000
@@ -20,6 +20,7 @@ The following options may be given as th
  Offset added to Auto-increment columns. Used when
  auto-increment-increment != 1
  --autocommit        Set default value for autocommit (0 or 1)
+ (Defaults to on; use --skip-autocommit to disable.)
  --automatic-sp-privileges 
  Creating and dropping stored procedures alters ACLs
  (Defaults to on; use --skip-automatic-sp-privileges to disable.)
@@ -749,6 +750,7 @@ abort-slave-event-count 0
 allow-suspicious-udfs FALSE
 auto-increment-increment 1
 auto-increment-offset 1
+autocommit TRUE
 automatic-sp-privileges TRUE
 back-log 50
 big-tables FALSE

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	2011-01-03 14:50:58 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2011-01-14 13:42:41 +0000
@@ -20,6 +20,7 @@ The following options may be given as th
  Offset added to Auto-increment columns. Used when
  auto-increment-increment != 1
  --autocommit        Set default value for autocommit (0 or 1)
+ (Defaults to on; use --skip-autocommit to disable.)
  --automatic-sp-privileges 
  Creating and dropping stored procedures alters ACLs
  (Defaults to on; use --skip-automatic-sp-privileges to disable.)
@@ -753,6 +754,7 @@ abort-slave-event-count 0
 allow-suspicious-udfs FALSE
 auto-increment-increment 1
 auto-increment-offset 1
+autocommit TRUE
 automatic-sp-privileges TRUE
 back-log 50
 big-tables FALSE

=== modified file 'mysql-test/r/mysqldump.result'
--- a/mysql-test/r/mysqldump.result	2010-10-18 12:18:18 +0000
+++ b/mysql-test/r/mysqldump.result	2011-01-14 14:49:16 +0000
@@ -14,7 +14,7 @@ INSERT INTO t1 VALUES (1), (2);
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="test">
 	<table_structure name="t1">
-		<field Field="a" Type="int(11)" Null="YES" Key="MUL" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="MUL" Extra="" Comment="" />
 		<key Table="t1" Non_unique="1" Key_name="a" Seq_in_index="1" Column_name="a" Collation="A" Null="YES" Index_type="BTREE" Comment="" Index_comment="" />
 	</table_structure>
 	<table_data name="t1">
@@ -150,9 +150,9 @@ INSERT INTO t1 VALUES (1, "test", "tes")
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="test">
 	<table_structure name="t1">
-		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
-		<field Field="b" Type="text" Null="YES" Key="" Extra="" />
-		<field Field="c" Type="varchar(3)" Null="YES" Key="" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
+		<field Field="b" Type="text" Null="YES" Key="" Extra="" Comment="" />
+		<field Field="c" Type="varchar(3)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_data name="t1">
 	<row>
@@ -178,7 +178,7 @@ INSERT INTO t1 VALUES ("1\""), ("\"2");
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="test">
 	<table_structure name="t1">
-		<field Field="a&quot;b&quot;" Type="char(2)" Null="YES" Key="" Extra="" />
+		<field Field="a&quot;b&quot;" Type="char(2)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_data name="t1">
 	<row>
@@ -1612,10 +1612,10 @@ CREATE TABLE `t2` (
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="mysqldump_test_db">
 	<table_structure name="t1">
-		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_structure name="t2">
-		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 </database>
 </mysqldump>
@@ -1623,10 +1623,10 @@ CREATE TABLE `t2` (
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="mysqldump_test_db">
 	<table_structure name="t1">
-		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_structure name="t2">
-		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+		<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 </database>
 </mysqldump>
@@ -3644,8 +3644,8 @@ INSERT INTO t1 VALUES(1,0xff00fef0);
 <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <database name="test">
 	<table_structure name="t1">
-		<field Field="f1" Type="int(10)" Null="YES" Key="" Extra="" />
-		<field Field="data" Type="mediumblob" Null="YES" Key="" Extra="" />
+		<field Field="f1" Type="int(10)" Null="YES" Key="" Extra="" Comment="" />
+		<field Field="data" Type="mediumblob" Null="YES" Key="" Extra="" Comment="" />
 	</table_structure>
 	<table_data name="t1">
 	<row>
@@ -4581,6 +4581,21 @@ truncate table t1;
 test.t1: Records: 1  Deleted: 0  Skipped: 0  Warnings: 0
 drop table t1;
 #
+# Bug #13618 : mysqldump --xml ommit comment on table field
+#
+CREATE TABLE `comment_table` (i INT COMMENT 'FIELD COMMENT') COMMENT = 'TABLE COMMENT';
+<?xml version="1.0"?>
+<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<database name="test">
+	<table_structure name="comment_table">
+		<field Field="i" Type="int(11)" Null="YES" Key="" Extra="" Comment="FIELD COMMENT" />
+	</table_structure>
+	<table_data name="comment_table">
+	</table_data>
+</database>
+</mysqldump>
+DROP TABLE `comment_table`;
+#
 # End of 5.1 tests
 #
 #

=== modified file 'mysql-test/r/plugin_auth.result'
--- a/mysql-test/r/plugin_auth.result	2010-12-17 11:28:59 +0000
+++ b/mysql-test/r/plugin_auth.result	2011-01-16 04:02:29 +0000
@@ -321,7 +321,7 @@ Proxied_user
 With_grant	1
 FLUSH PRIVILEGES;
 #
-# Bug#58139 : default-auth option not recognized in MySQL standardi
+# Bug#58139 : default-auth option not recognized in MySQL standard
 #             command line clients
 #
 # Executing 'mysql'
@@ -330,4 +330,6 @@ FLUSH PRIVILEGES;
 # Executing 'mysqladmin'
 mysqld is alive
 # Executing 'mysqldump'
+# Executing 'mysql_upgrade'
+The --upgrade-system-tables option was used, databases won't be touched.
 End of 5.5 tests

=== modified file 'mysql-test/r/select_all.result'
--- a/mysql-test/r/select_all.result	2010-12-20 14:21:44 +0000
+++ b/mysql-test/r/select_all.result	2011-01-13 10:48:28 +0000
@@ -4874,6 +4874,70 @@ SELECT 1 FROM t1 ORDER BY a COLLATE lati
 1
 1
 DROP TABLE t1;
+#
+# Bug #58422: Incorrect result when OUTER JOIN'ing 
+# with an empty table
+#
+CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+CREATE TABLE t1(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
+EXPLAIN
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON TRUE)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON TRUE)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+pk	i	pk	i	pk	i
+EXPLAIN
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 CROSS JOIN t_empty)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 CROSS JOIN t_empty)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+pk	i	pk	i	pk	i
+EXPLAIN
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON t_empty.i=t2.i)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON t_empty.i=t2.i)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+pk	i	pk	i	pk	i
+DROP TABLE t1,t2,t_empty;
 End of 5.1 tests
 #
 # Bug#45227: Lost HAVING clause led to a wrong result.

=== modified file 'mysql-test/r/select_icp_mrr.result'
--- a/mysql-test/r/select_icp_mrr.result	2010-12-17 09:41:21 +0000
+++ b/mysql-test/r/select_icp_mrr.result	2011-01-13 10:48:28 +0000
@@ -4874,6 +4874,70 @@ SELECT 1 FROM t1 ORDER BY a COLLATE lati
 1
 1
 DROP TABLE t1;
+#
+# Bug #58422: Incorrect result when OUTER JOIN'ing 
+# with an empty table
+#
+CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+CREATE TABLE t1(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
+EXPLAIN
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON TRUE)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON TRUE)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+pk	i	pk	i	pk	i
+EXPLAIN
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 CROSS JOIN t_empty)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 CROSS JOIN t_empty)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+pk	i	pk	i	pk	i
+EXPLAIN
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON t_empty.i=t2.i)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON t_empty.i=t2.i)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+pk	i	pk	i	pk	i
+DROP TABLE t1,t2,t_empty;
 End of 5.1 tests
 #
 # Bug#45227: Lost HAVING clause led to a wrong result.

=== modified file 'mysql-test/r/select_none.result'
--- a/mysql-test/r/select_none.result	2010-12-17 09:41:21 +0000
+++ b/mysql-test/r/select_none.result	2011-01-13 10:48:28 +0000
@@ -4873,6 +4873,70 @@ SELECT 1 FROM t1 ORDER BY a COLLATE lati
 1
 1
 DROP TABLE t1;
+#
+# Bug #58422: Incorrect result when OUTER JOIN'ing 
+# with an empty table
+#
+CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+CREATE TABLE t1(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
+EXPLAIN
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON TRUE)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON TRUE)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+pk	i	pk	i	pk	i
+EXPLAIN
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 CROSS JOIN t_empty)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 CROSS JOIN t_empty)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+pk	i	pk	i	pk	i
+EXPLAIN
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON t_empty.i=t2.i)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+SELECT *
+FROM 
+t1
+LEFT OUTER JOIN
+(t2 INNER JOIN t_empty ON t_empty.i=t2.i)
+ON t1.pk=t2.pk
+WHERE t2.pk <> 2;
+pk	i	pk	i	pk	i
+DROP TABLE t1,t2,t_empty;
 End of 5.1 tests
 #
 # Bug#45227: Lost HAVING clause led to a wrong result.

=== modified file 'mysql-test/r/show_check.result'
--- a/mysql-test/r/show_check.result	2011-01-05 14:43:28 +0000
+++ b/mysql-test/r/show_check.result	2011-01-17 07:14:27 +0000
@@ -1325,6 +1325,17 @@ Tables_in_test	Table_type
 ��t��	BASE TABLE
 drop table `��t��`;
 set names latin1;
+#
+# Bug#4374 SHOW TABLE STATUS FROM ignores collation_connection
+# Character set: Latin-1 (ISO-8859-1)
+#
+SET NAMES latin1;
+CREATE DATABASE `�`;
+CREATE TABLE `�`.`�` (a int) ENGINE=Memory;
+SHOW TABLE STATUS FROM `�` LIKE '�';
+Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
+�	MEMORY	10	Fixed	0	8	#	#	#	0	NULL	NULL	NULL	NULL	latin1_swedish_ci	NULL		
+DROP DATABASE `�`;
 show columns from `#mysql50#????????`;
 Got one of the listed errors
 DROP TABLE IF EXISTS t1;

=== modified file 'mysql-test/r/subquery_sj_none.result'
--- a/mysql-test/r/subquery_sj_none.result	2010-11-29 13:30:18 +0000
+++ b/mysql-test/r/subquery_sj_none.result	2011-01-13 10:48:28 +0000
@@ -702,8 +702,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
-2	DEPENDENT SUBQUERY	t3	system	NULL	NULL	NULL	NULL	0	const row not found
-2	DEPENDENT SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1098,7 +1097,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
-2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1122,7 +1121,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
-2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1130,7 +1129,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
-2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1300,8 +1299,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
-2	DEPENDENT SUBQUERY	t3	system	NULL	NULL	NULL	NULL	0	const row not found
-2	DEPENDENT SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1326,7 +1324,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
-2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1334,7 +1332,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
-2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1728,7 +1726,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
-2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1908,8 +1906,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-2	DEPENDENT SUBQUERY	t3	system	NULL	NULL	NULL	NULL	0	const row not found
-2	DEPENDENT SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1934,7 +1931,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
-2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i

=== modified file 'mysql-test/r/type_timestamp.result'
--- a/mysql-test/r/type_timestamp.result	2010-09-13 07:35:53 +0000
+++ b/mysql-test/r/type_timestamp.result	2011-01-12 17:24:53 +0000
@@ -540,3 +540,32 @@ a
 2010-03-05 11:08:02
 DROP TABLE t1;
 End of Bug#50888
+#
+# Bug59330: Incorrect result when comparing an aggregate
+#           function with TIMESTAMP
+#
+CREATE TABLE t1 (dt DATETIME, ts TIMESTAMP);
+INSERT INTO t1 VALUES('2011-01-06 12:34:30', '2011-01-06 12:34:30');
+SELECT MAX(dt), MAX(ts) FROM t1;
+MAX(dt)	MAX(ts)
+2011-01-06 12:34:30	2011-01-06 12:34:30
+SELECT MAX(ts) < '2010-01-01 00:00:00' FROM t1;
+MAX(ts) < '2010-01-01 00:00:00'
+0
+SELECT MAX(dt) < '2010-01-01 00:00:00' FROM t1;
+MAX(dt) < '2010-01-01 00:00:00'
+0
+SELECT MAX(ts) > '2010-01-01 00:00:00' FROM t1;
+MAX(ts) > '2010-01-01 00:00:00'
+1
+SELECT MAX(dt) > '2010-01-01 00:00:00' FROM t1;
+MAX(dt) > '2010-01-01 00:00:00'
+1
+SELECT MAX(ts) = '2011-01-06 12:34:30' FROM t1;
+MAX(ts) = '2011-01-06 12:34:30'
+1
+SELECT MAX(dt) = '2011-01-06 12:34:30' FROM t1;
+MAX(dt) = '2011-01-06 12:34:30'
+1
+DROP TABLE t1;
+End of 5.5 tests

=== modified file 'mysql-test/r/update.result'
--- a/mysql-test/r/update.result	2010-08-25 19:00:38 +0000
+++ b/mysql-test/r/update.result	2011-01-14 08:20:08 +0000
@@ -410,7 +410,7 @@ user_id
 show status like '%Handler_read%';
 Variable_name	Value
 Handler_read_first	0
-Handler_read_key	1
+Handler_read_key	0
 Handler_read_last	0
 Handler_read_next	0
 Handler_read_prev	0
@@ -421,7 +421,7 @@ user_id
 show status like '%Handler_read%';
 Variable_name	Value
 Handler_read_first	0
-Handler_read_key	2
+Handler_read_key	0
 Handler_read_last	0
 Handler_read_next	0
 Handler_read_prev	0
@@ -431,7 +431,7 @@ UPDATE t1 SET user_id=null WHERE request
 show status like '%Handler_read%';
 Variable_name	Value
 Handler_read_first	0
-Handler_read_key	3
+Handler_read_key	1
 Handler_read_last	0
 Handler_read_next	0
 Handler_read_prev	0
@@ -441,7 +441,7 @@ UPDATE t1 SET user_id=null WHERE request
 show status like '%Handler_read%';
 Variable_name	Value
 Handler_read_first	0
-Handler_read_key	3
+Handler_read_key	1
 Handler_read_last	0
 Handler_read_next	0
 Handler_read_prev	0

=== modified file 'mysql-test/suite/perfschema/r/server_init.result'
--- a/mysql-test/suite/perfschema/r/server_init.result	2010-11-18 16:34:56 +0000
+++ b/mysql-test/suite/perfschema/r/server_init.result	2011-01-13 11:31:20 +0000
@@ -31,10 +31,6 @@ select count(name) from mutex_instances
 where name like "wait/synch/mutex/mysys/THR_LOCK_charset";
 count(name)
 1
-select count(name) from mutex_instances
-where name like "wait/synch/mutex/mysys/THR_LOCK_time";
-count(name)
-1
 select count(name) from cond_instances
 where name like "wait/synch/cond/mysys/THR_COND_threads";
 count(name)

=== modified file 'mysql-test/suite/perfschema/t/server_init.test'
--- a/mysql-test/suite/perfschema/t/server_init.test	2010-11-18 16:34:56 +0000
+++ b/mysql-test/suite/perfschema/t/server_init.test	2011-01-13 11:31:20 +0000
@@ -52,9 +52,6 @@ select count(name) from mutex_instances
 select count(name) from mutex_instances
  where name like "wait/synch/mutex/mysys/THR_LOCK_charset";
 
-select count(name) from mutex_instances
- where name like "wait/synch/mutex/mysys/THR_LOCK_time";
-
 # There are no global rwlock in mysys
 
 # Verify that these global conditions have been properly initilized in mysys

=== modified file 'mysql-test/suite/rpl/r/rpl_heartbeat_basic.result'
--- a/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result	2011-01-13 21:36:21 +0000
@@ -17,7 +17,7 @@ RESET SLAVE;
 
 *** Reset slave affect ***
 SET @@global.slave_net_timeout=30;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=5;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=5;
 RESET SLAVE;
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 Variable_name	Value
@@ -25,7 +25,7 @@ Slave_heartbeat_period	15.000
 
 *** Default value if slave_net_timeout changed ***
 SET @@global.slave_net_timeout=50;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root';
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20;
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 Variable_name	Value
 Slave_heartbeat_period	25.000
@@ -40,14 +40,14 @@ SET @@global.slave_net_timeout=@restore_
 RESET SLAVE;
 
 *** Warning if updated slave_heartbeat_timeout > slave_net_timeout ***
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=SLAVE_NET_TIMEOUT;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=SLAVE_NET_TIMEOUT;
 Warnings:
 Warning	1717	The requested value for the heartbeat period exceeds the value of `slave_net_timeout' seconds. A sensible value for the period should be less than the timeout.
 RESET SLAVE;
 
 *** CHANGE MASTER statement only updates slave_heartbeat_period ***
 SET @@global.slave_net_timeout=20;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=5;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=5;
 SHOW VARIABLES LIKE 'slave_net_timeout';
 Variable_name	Value
 slave_net_timeout	20
@@ -68,7 +68,7 @@ RESET SLAVE;
 SET @@global.slave_net_timeout=500;
 SET @@global.slave_net_timeout=200;
 RESET SLAVE;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root';
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20;
 include/start_slave.inc
 SHOW VARIABLES LIKE 'slave_net_timeout';
 Variable_name	Value
@@ -83,7 +83,7 @@ SET @@global.slave_net_timeout=@restore_
 
 *** Start/stop slave ***
 SET @@global.slave_net_timeout=100;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=20;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=20;
 include/start_slave.inc
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 Variable_name	Value
@@ -95,7 +95,7 @@ Slave_heartbeat_period	20.000
 
 *** Reload slave ***
 SET @@global.slave_net_timeout=50;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=30;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=30;
 include/rpl_restart_server.inc [server_number=2]
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 Variable_name	Value
@@ -103,7 +103,7 @@ Slave_heartbeat_period	30.000
 SET @restore_slave_net_timeout=@@global.slave_net_timeout;
 
 *** Disable heartbeat ***
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=0;
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 Variable_name	Value
 Slave_heartbeat_period	0.000
@@ -130,12 +130,12 @@ Result
 0
 
 *** Min slave_heartbeat_timeout ***
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.001;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=0.001;
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 Variable_name	Value
 Slave_heartbeat_period	0.001
 RESET SLAVE;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.0009;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=0.0009;
 Warnings:
 Warning	1716	The requested value for the heartbeat period is less than 1 millisecond. The value is reset to 0, meaning that heartbeating will effectively be disabled.
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
@@ -144,36 +144,36 @@ Slave_heartbeat_period	0.000
 RESET SLAVE;
 
 *** Max slave_heartbeat_timeout ***
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294967;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=4294967;
 Warnings:
 Warning	1717	The requested value for the heartbeat period exceeds the value of `slave_net_timeout' seconds. A sensible value for the period should be less than the timeout.
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 Variable_name	Value
 Slave_heartbeat_period	4294967.000
 RESET SLAVE;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294968;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=4294968;
 ERROR HY000: The requested value for the heartbeat period is either negative or exceeds the maximum allowed (4294967 seconds).
 RESET SLAVE;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=8589935;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=8589935;
 ERROR HY000: The requested value for the heartbeat period is either negative or exceeds the maximum allowed (4294967 seconds).
 RESET SLAVE;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294967296;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=4294967296;
 ERROR HY000: The requested value for the heartbeat period is either negative or exceeds the maximum allowed (4294967 seconds).
 RESET SLAVE;
 
 *** Misc incorrect values ***
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD='-1';
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD='-1';
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''-1'' at line 1
 RESET SLAVE;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD='123abc';
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD='123abc';
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''123abc'' at line 1
 RESET SLAVE;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD='';
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD='';
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''' at line 1
 RESET SLAVE;
 
 *** Running slave ***
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=0.1;
 include/start_slave.inc
 Heartbeat event received
 
@@ -219,7 +219,7 @@ BEGIN
 UPDATE test.t1 SET a = a + 1 WHERE a < 10;
 END|
 RESET SLAVE;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=5;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=5;
 include/start_slave.inc
 SET @@global.event_scheduler=1;
 Number of received heartbeat events: 0
@@ -232,7 +232,7 @@ RESET SLAVE;
 DROP TABLE t1;
 DROP TABLE t1;
 RESET MASTER;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.5;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=0.5;
 include/start_slave.inc
 Heartbeat events are received while rotation of relay logs (1 means 'yes'): 1
 
@@ -241,7 +241,7 @@ SET @@global.slave_compressed_protocol=1
 include/stop_slave.inc
 RESET SLAVE;
 SET @@global.slave_compressed_protocol=1;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=0.1;
 include/start_slave.inc
 Heartbeat event received
 SET @@global.slave_compressed_protocol=0;
@@ -250,7 +250,7 @@ SET @@global.slave_compressed_protocol=0
 *** Reset master ***
 STOP SLAVE;
 RESET SLAVE;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=0.1;
 include/start_slave.inc
 RESET MASTER;
 Heartbeat events are received after reset of master (1 means 'yes'): 1
@@ -258,7 +258,7 @@ Heartbeat events are received after rese
 *** Reload master ***
 STOP SLAVE;
 RESET SLAVE;
-CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1, MASTER_CONNECT_RETRY = 5;
+CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=0.1;
 include/start_slave.inc
 Heartbeat event received
 include/rpl_restart_server.inc [server_number=1]

=== modified file 'mysql-test/suite/rpl/r/rpl_row_show_relaylog_events.result'
--- a/mysql-test/suite/rpl/r/rpl_row_show_relaylog_events.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_show_relaylog_events.result	2011-01-14 11:15:25 +0000
@@ -1,14 +1,12 @@
 include/master-slave.inc
 [connection master]
+include/rpl_reset.inc
 CREATE TABLE t1 (a INT);
 INSERT INTO t1 VALUES (1);
 INSERT INTO t1 VALUES (2);
 INSERT INTO t1 VALUES (3);
-INSERT INTO t1 VALUES (4);
-INSERT INTO t1 VALUES (5);
-INSERT INTO t1 VALUES (6);
-[MASTER] ********* SOW BINLOG EVENTS IN ...  *********
-show binlog events from <binlog_start>;
+******** [master] SHOW BINLOG EVENTS IN <FILE> ********
+show binlog events in 'master-bin.000001' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
 master-bin.000001	#	Query	#	#	BEGIN
@@ -23,19 +21,17 @@ master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	COMMIT
+******** [master] SHOW BINLOG EVENTS IN <FILE> LIMIT 1 ********
+show binlog events in 'master-bin.000001' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
+******** [master] SHOW BINLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show binlog events in 'master-bin.000001' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	COMMIT
-[MASTER] ********* SOW BINLOG EVENTS         *********
+******** [master] SHOW BINLOG EVENTS  ********
 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 (a INT)
@@ -51,33 +47,8 @@ master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	COMMIT
-[MASTER] ********* SOW BINLOG EVENTS ... LIMIT rows  *********
-show binlog events from <binlog_start> limit 3;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-[MASTER] ********* SOW BINLOG EVENTS ... LIMIT offset,rows  *********
-show binlog events from <binlog_start> limit 1,4;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	COMMIT
-[SLAVE] ********* SOW BINLOG EVENTS IN ...   *********
-show binlog events from <binlog_start>;
+******** [slave] SHOW BINLOG EVENTS IN <FILE> ********
+show binlog events in 'slave-bin.000001' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
 slave-bin.000001	#	Query	#	#	BEGIN
@@ -92,19 +63,17 @@ slave-bin.000001	#	Query	#	#	BEGIN
 slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 slave-bin.000001	#	Query	#	#	COMMIT
+******** [slave] SHOW BINLOG EVENTS IN <FILE> LIMIT 1 ********
+show binlog events in 'slave-bin.000001' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
+******** [slave] SHOW BINLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show binlog events in 'slave-bin.000001' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000001	#	Query	#	#	BEGIN
 slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-bin.000001	#	Query	#	#	COMMIT
-[SLAVE] ********* SOW BINLOG EVENTS          *********
+******** [slave] SHOW BINLOG EVENTS  ********
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
@@ -120,85 +89,53 @@ slave-bin.000001	#	Query	#	#	BEGIN
 slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-bin.000001	#	Query	#	#	COMMIT
-[SLAVE] ********* SOW BINLOG EVENTS ... LIMIT rows  *********
-show binlog events from <binlog_start> limit 3;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-[SLAVE] ********* SOW BINLOG EVENTS ... LIMIT offset,rows  *********
-show binlog events from <binlog_start> limit 1,4;
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> ********
+show relaylog events in 'slave-relay-bin.000003' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-bin.000001	#	Query	#	#	COMMIT
-[SLAVE] ********* SOW RELAYLOG EVENTS IN ... *********
-show relaylog events in 'slave-relay-bin.000002' from <binlog_start>;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000002	#	Rotate	#	#	master-bin.000001;pos=4
-slave-relay-bin.000002	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
-slave-relay-bin.000002	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
-slave-relay-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
-slave-relay-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
-slave-relay-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
-slave-relay-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
-slave-relay-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
-slave-relay-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-[SLAVE] ********* SOW RELAYLOG EVENTS        *********
+slave-relay-bin.000003	#	Rotate	#	#	master-bin.000001;pos=4
+slave-relay-bin.000003	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
+slave-relay-bin.000003	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
+slave-relay-bin.000003	#	Query	#	#	BEGIN
+slave-relay-bin.000003	#	Table_map	#	#	table_id: # (test.t1)
+slave-relay-bin.000003	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-relay-bin.000003	#	Query	#	#	COMMIT
+slave-relay-bin.000003	#	Query	#	#	BEGIN
+slave-relay-bin.000003	#	Table_map	#	#	table_id: # (test.t1)
+slave-relay-bin.000003	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-relay-bin.000003	#	Query	#	#	COMMIT
+slave-relay-bin.000003	#	Query	#	#	BEGIN
+slave-relay-bin.000003	#	Table_map	#	#	table_id: # (test.t1)
+slave-relay-bin.000003	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-relay-bin.000003	#	Query	#	#	COMMIT
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> LIMIT 1 ********
+show relaylog events in 'slave-relay-bin.000003' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-relay-bin.000003	#	Rotate	#	#	master-bin.000001;pos=4
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show relaylog events in 'slave-relay-bin.000003' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-relay-bin.000003	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
+slave-relay-bin.000003	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
+slave-relay-bin.000003	#	Query	#	#	BEGIN
+******** [slave] SHOW RELAYLOG EVENTS  ********
 show relaylog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000001	#	Rotate	#	#	slave-relay-bin.000002;pos=4
-[MASTER] ********* SOW RELAYLOG EVENTS ... LIMIT rows  *********
-show relaylog events in 'slave-relay-bin.000002' from <binlog_start> limit 3;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000002	#	Rotate	#	#	master-bin.000001;pos=4
-slave-relay-bin.000002	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
-slave-relay-bin.000002	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
-[MASTER] ********* SOW RELAYLOG EVENTS ... LIMIT offset,rows  *********
-show relaylog events in 'slave-relay-bin.000002' from <binlog_start> limit 1,3;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000002	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
-slave-relay-bin.000002	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
-slave-relay-bin.000002	#	Query	#	#	BEGIN
+slave-relay-bin.000002	#	Rotate	#	#	slave-relay-bin.000003;pos=4
 FLUSH LOGS;
 FLUSH LOGS;
 DROP TABLE t1;
-[MASTER] ********* SOW BINLOG EVENTS IN ...  *********
+******** [master] SHOW BINLOG EVENTS IN <FILE> ********
 show binlog events in 'master-bin.000002' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000002	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
-[MASTER] ********* SOW BINLOG EVENTS         *********
+******** [master] SHOW BINLOG EVENTS IN <FILE> LIMIT 1 ********
+show binlog events in 'master-bin.000002' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000002	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
+******** [master] SHOW BINLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show binlog events in 'master-bin.000002' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+******** [master] SHOW BINLOG EVENTS  ********
 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 (a INT)
@@ -214,24 +151,19 @@ master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Rotate	#	#	master-bin.000002;pos=4
-[SLAVE] ********* SOW BINLOG EVENTS IN ...   *********
+******** [slave] SHOW BINLOG EVENTS IN <FILE> ********
 show binlog events in 'slave-bin.000002' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000002	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
-[SLAVE] ********* SOW BINLOG EVENTS          *********
+******** [slave] SHOW BINLOG EVENTS IN <FILE> LIMIT 1 ********
+show binlog events in 'slave-bin.000002' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-bin.000002	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
+******** [slave] SHOW BINLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show binlog events in 'slave-bin.000002' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+******** [slave] SHOW BINLOG EVENTS  ********
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
@@ -247,27 +179,25 @@ slave-bin.000001	#	Query	#	#	BEGIN
 slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-slave-bin.000001	#	Query	#	#	COMMIT
 slave-bin.000001	#	Rotate	#	#	slave-bin.000002;pos=4
-[SLAVE] ********* SOW RELAYLOG EVENTS IN ... *********
-show relaylog events from <binlog_start>;
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> ********
+show relaylog events in 'slave-relay-bin.000006' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000004	#	Rotate	#	#	master-bin.000002;pos=4
-slave-relay-bin.000004	#	Rotate	#	#	slave-relay-bin.000005;pos=4
-[SLAVE] ********* SOW RELAYLOG EVENTS        *********
+slave-relay-bin.000006	#	Rotate	#	#	master-bin.000002;pos=4
+slave-relay-bin.000006	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
+slave-relay-bin.000006	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> LIMIT 1 ********
+show relaylog events in 'slave-relay-bin.000006' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-relay-bin.000006	#	Rotate	#	#	master-bin.000002;pos=4
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show relaylog events in 'slave-relay-bin.000006' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-relay-bin.000006	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
+slave-relay-bin.000006	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
+******** [slave] SHOW RELAYLOG EVENTS  ********
 show relaylog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000004	#	Rotate	#	#	master-bin.000002;pos=4
-slave-relay-bin.000004	#	Rotate	#	#	slave-relay-bin.000005;pos=4
+slave-relay-bin.000005	#	Rotate	#	#	master-bin.000002;pos=4
+slave-relay-bin.000005	#	Rotate	#	#	slave-relay-bin.000006;pos=4
 include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_mix_show_relaylog_events.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_mix_show_relaylog_events.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_mix_show_relaylog_events.result	2011-01-14 11:15:25 +0000
@@ -1,14 +1,12 @@
 include/master-slave.inc
 [connection master]
+include/rpl_reset.inc
 CREATE TABLE t1 (a INT);
 INSERT INTO t1 VALUES (1);
 INSERT INTO t1 VALUES (2);
 INSERT INTO t1 VALUES (3);
-INSERT INTO t1 VALUES (4);
-INSERT INTO t1 VALUES (5);
-INSERT INTO t1 VALUES (6);
-[MASTER] ********* SOW BINLOG EVENTS IN ...  *********
-show binlog events from <binlog_start>;
+******** [master] SHOW BINLOG EVENTS IN <FILE> ********
+show binlog events in 'master-bin.000001' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
 master-bin.000001	#	Query	#	#	BEGIN
@@ -20,16 +18,17 @@ master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
 master-bin.000001	#	Query	#	#	COMMIT
+******** [master] SHOW BINLOG EVENTS IN <FILE> LIMIT 1 ********
+show binlog events in 'master-bin.000001' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
+******** [master] SHOW BINLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show binlog events in 'master-bin.000001' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (4)
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (5)
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (6)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
 master-bin.000001	#	Query	#	#	COMMIT
-[MASTER] ********* SOW BINLOG EVENTS         *********
+******** [master] SHOW BINLOG EVENTS  ********
 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 (a INT)
@@ -42,30 +41,8 @@ master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
 master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (4)
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (5)
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (6)
-master-bin.000001	#	Query	#	#	COMMIT
-[MASTER] ********* SOW BINLOG EVENTS ... LIMIT rows  *********
-show binlog events from <binlog_start> limit 3;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
-[MASTER] ********* SOW BINLOG EVENTS ... LIMIT offset,rows  *********
-show binlog events from <binlog_start> limit 1,4;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-[SLAVE] ********* SOW BINLOG EVENTS IN ...   *********
-show binlog events from <binlog_start>;
+******** [slave] SHOW BINLOG EVENTS IN <FILE> ********
+show binlog events in 'slave-bin.000001' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
 slave-bin.000001	#	Query	#	#	BEGIN
@@ -77,16 +54,17 @@ slave-bin.000001	#	Query	#	#	COMMIT
 slave-bin.000001	#	Query	#	#	BEGIN
 slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
 slave-bin.000001	#	Query	#	#	COMMIT
+******** [slave] SHOW BINLOG EVENTS IN <FILE> LIMIT 1 ********
+show binlog events in 'slave-bin.000001' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
+******** [slave] SHOW BINLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show binlog events in 'slave-bin.000001' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (4)
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (5)
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (6)
+slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
 slave-bin.000001	#	Query	#	#	COMMIT
-[SLAVE] ********* SOW BINLOG EVENTS          *********
+******** [slave] SHOW BINLOG EVENTS  ********
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
@@ -99,76 +77,50 @@ slave-bin.000001	#	Query	#	#	COMMIT
 slave-bin.000001	#	Query	#	#	BEGIN
 slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
 slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (4)
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (5)
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (6)
-slave-bin.000001	#	Query	#	#	COMMIT
-[SLAVE] ********* SOW BINLOG EVENTS ... LIMIT rows  *********
-show binlog events from <binlog_start> limit 3;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
-[SLAVE] ********* SOW BINLOG EVENTS ... LIMIT offset,rows  *********
-show binlog events from <binlog_start> limit 1,4;
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> ********
+show relaylog events in 'slave-relay-bin.000003' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-[SLAVE] ********* SOW RELAYLOG EVENTS IN ... *********
-show relaylog events in 'slave-relay-bin.000002' from <binlog_start>;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000002	#	Rotate	#	#	master-bin.000001;pos=4
-slave-relay-bin.000002	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
-slave-relay-bin.000002	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (2)
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (4)
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (5)
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-slave-relay-bin.000002	#	Query	#	#	BEGIN
-slave-relay-bin.000002	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (6)
-slave-relay-bin.000002	#	Query	#	#	COMMIT
-[SLAVE] ********* SOW RELAYLOG EVENTS        *********
+slave-relay-bin.000003	#	Rotate	#	#	master-bin.000001;pos=4
+slave-relay-bin.000003	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
+slave-relay-bin.000003	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
+slave-relay-bin.000003	#	Query	#	#	BEGIN
+slave-relay-bin.000003	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
+slave-relay-bin.000003	#	Query	#	#	COMMIT
+slave-relay-bin.000003	#	Query	#	#	BEGIN
+slave-relay-bin.000003	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (2)
+slave-relay-bin.000003	#	Query	#	#	COMMIT
+slave-relay-bin.000003	#	Query	#	#	BEGIN
+slave-relay-bin.000003	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
+slave-relay-bin.000003	#	Query	#	#	COMMIT
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> LIMIT 1 ********
+show relaylog events in 'slave-relay-bin.000003' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-relay-bin.000003	#	Rotate	#	#	master-bin.000001;pos=4
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show relaylog events in 'slave-relay-bin.000003' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-relay-bin.000003	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
+slave-relay-bin.000003	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
+slave-relay-bin.000003	#	Query	#	#	BEGIN
+******** [slave] SHOW RELAYLOG EVENTS  ********
 show relaylog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000001	#	Rotate	#	#	slave-relay-bin.000002;pos=4
-[MASTER] ********* SOW RELAYLOG EVENTS ... LIMIT rows  *********
-show relaylog events in 'slave-relay-bin.000002' from <binlog_start> limit 3;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000002	#	Rotate	#	#	master-bin.000001;pos=4
-slave-relay-bin.000002	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
-slave-relay-bin.000002	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
-[MASTER] ********* SOW RELAYLOG EVENTS ... LIMIT offset,rows  *********
-show relaylog events in 'slave-relay-bin.000002' from <binlog_start> limit 1,3;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000002	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
-slave-relay-bin.000002	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
-slave-relay-bin.000002	#	Query	#	#	BEGIN
+slave-relay-bin.000002	#	Rotate	#	#	slave-relay-bin.000003;pos=4
 FLUSH LOGS;
 FLUSH LOGS;
 DROP TABLE t1;
-[MASTER] ********* SOW BINLOG EVENTS IN ...  *********
+******** [master] SHOW BINLOG EVENTS IN <FILE> ********
 show binlog events in 'master-bin.000002' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000002	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
-[MASTER] ********* SOW BINLOG EVENTS         *********
+******** [master] SHOW BINLOG EVENTS IN <FILE> LIMIT 1 ********
+show binlog events in 'master-bin.000002' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000002	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
+******** [master] SHOW BINLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show binlog events in 'master-bin.000002' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+******** [master] SHOW BINLOG EVENTS  ********
 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 (a INT)
@@ -181,21 +133,19 @@ master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
 master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (4)
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (5)
-master-bin.000001	#	Query	#	#	COMMIT
-master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (6)
-master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Rotate	#	#	master-bin.000002;pos=4
-[SLAVE] ********* SOW BINLOG EVENTS IN ...   *********
+******** [slave] SHOW BINLOG EVENTS IN <FILE> ********
 show binlog events in 'slave-bin.000002' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000002	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
-[SLAVE] ********* SOW BINLOG EVENTS          *********
+******** [slave] SHOW BINLOG EVENTS IN <FILE> LIMIT 1 ********
+show binlog events in 'slave-bin.000002' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-bin.000002	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
+******** [slave] SHOW BINLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show binlog events in 'slave-bin.000002' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+******** [slave] SHOW BINLOG EVENTS  ********
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT)
@@ -208,24 +158,25 @@ slave-bin.000001	#	Query	#	#	COMMIT
 slave-bin.000001	#	Query	#	#	BEGIN
 slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
 slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (4)
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (5)
-slave-bin.000001	#	Query	#	#	COMMIT
-slave-bin.000001	#	Query	#	#	BEGIN
-slave-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (6)
-slave-bin.000001	#	Query	#	#	COMMIT
 slave-bin.000001	#	Rotate	#	#	slave-bin.000002;pos=4
-[SLAVE] ********* SOW RELAYLOG EVENTS IN ... *********
-show relaylog events from <binlog_start>;
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> ********
+show relaylog events in 'slave-relay-bin.000006' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000004	#	Rotate	#	#	master-bin.000002;pos=4
-slave-relay-bin.000004	#	Rotate	#	#	slave-relay-bin.000005;pos=4
-[SLAVE] ********* SOW RELAYLOG EVENTS        *********
+slave-relay-bin.000006	#	Rotate	#	#	master-bin.000002;pos=4
+slave-relay-bin.000006	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
+slave-relay-bin.000006	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> LIMIT 1 ********
+show relaylog events in 'slave-relay-bin.000006' from <binlog_start> limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-relay-bin.000006	#	Rotate	#	#	master-bin.000002;pos=4
+******** [slave] SHOW RELAYLOG EVENTS IN <FILE> LIMIT 1,3 ********
+show relaylog events in 'slave-relay-bin.000006' from <binlog_start> limit 1,3;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-relay-bin.000006	#	Format_desc	#	#	SERVER_VERSION, BINLOG_VERSION
+slave-relay-bin.000006	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
+******** [slave] SHOW RELAYLOG EVENTS  ********
 show relaylog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-relay-bin.000004	#	Rotate	#	#	master-bin.000002;pos=4
-slave-relay-bin.000004	#	Rotate	#	#	slave-relay-bin.000005;pos=4
+slave-relay-bin.000005	#	Rotate	#	#	master-bin.000002;pos=4
+slave-relay-bin.000005	#	Rotate	#	#	slave-relay-bin.000006;pos=4
 include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_heartbeat_basic.test'
--- a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test	2011-01-13 21:36:21 +0000
@@ -21,6 +21,9 @@ call mtr.add_suppression("Slave I/O: The
 
 --echo
 
+# Set number of retries to connect to master
+let $connect_retry= 20;
+
 --echo *** Preparing ***
 --connection slave
 
@@ -65,7 +68,7 @@ RESET SLAVE;
 SET @@global.slave_net_timeout=30;
 --enable_warnings
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=5;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=5;
 RESET SLAVE;
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 --echo
@@ -76,7 +79,7 @@ SHOW GLOBAL STATUS LIKE 'slave_heartbeat
 SET @@global.slave_net_timeout=50;
 --enable_warnings
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root';
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry;
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 SET @@global.slave_net_timeout=@restore_slave_net_timeout;
 RESET SLAVE;
@@ -96,7 +99,7 @@ RESET SLAVE;
 let $slave_net_timeout= query_get_value(SHOW VARIABLES LIKE 'slave_net_timeout', Value, 1);
 inc $slave_net_timeout;
 --replace_result $MASTER_MYPORT MASTER_PORT $slave_net_timeout SLAVE_NET_TIMEOUT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=$slave_net_timeout;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=$slave_net_timeout;
 RESET SLAVE;
 --echo 
 
@@ -106,7 +109,7 @@ RESET SLAVE;
 SET @@global.slave_net_timeout=20;
 --enable_warnings
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=5;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=5;
 SHOW VARIABLES LIKE 'slave_net_timeout';
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 SET @@global.slave_net_timeout=2*@@global.slave_net_timeout;
@@ -126,7 +129,7 @@ SET @@global.slave_net_timeout=500;
 SET @@global.slave_net_timeout=200;
 RESET SLAVE;
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root';
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry;
 --source include/start_slave.inc
 --connection master
 --sync_slave_with_master
@@ -146,7 +149,7 @@ SET @@global.slave_net_timeout=@restore_
 SET @@global.slave_net_timeout=100;
 --enable_warnings
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=20;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=20;
 --source include/start_slave.inc
 --connection master
 --sync_slave_with_master
@@ -162,7 +165,7 @@ SHOW GLOBAL STATUS LIKE 'slave_heartbeat
 SET @@global.slave_net_timeout=50;
 --enable_warnings
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=30;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=30;
 --let $rpl_server_number= 2
 --source include/rpl_restart_server.inc
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
@@ -172,7 +175,7 @@ SET @restore_slave_net_timeout=@@global.
 # Disable heartbeat
 --echo *** Disable heartbeat ***
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=0;
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 SHOW STATUS LIKE 'slave_received_heartbeats';
 --source include/start_slave.inc
@@ -196,48 +199,48 @@ let $slave_heartbeat_timeout= query_get_
 
 --echo *** Min slave_heartbeat_timeout ***
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.001;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=0.001;
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 RESET SLAVE;
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.0009;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=0.0009;
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 RESET SLAVE;
 --echo
 
 --echo *** Max slave_heartbeat_timeout ***
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294967;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=4294967;
 SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period';
 RESET SLAVE;
 --replace_result $MASTER_MYPORT MASTER_PORT
 --error ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE 
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294968;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=4294968;
 RESET SLAVE;
 # Check double size of max allowed value for master_heartbeat_period
 --replace_result $MASTER_MYPORT MASTER_PORT
 --error ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE 
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=8589935;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=8589935;
 RESET SLAVE;
 # Check 2^32
 --replace_result $MASTER_MYPORT MASTER_PORT
 --error ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE 
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=4294967296;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=4294967296;
 RESET SLAVE;
 --echo
 
 --echo *** Misc incorrect values ***
 --replace_result $MASTER_MYPORT MASTER_PORT
 --error ER_PARSE_ERROR
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD='-1';
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD='-1';
 RESET SLAVE;
 --replace_result $MASTER_MYPORT MASTER_PORT
 --error ER_PARSE_ERROR
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD='123abc';
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD='123abc';
 RESET SLAVE;
 --replace_result $MASTER_MYPORT MASTER_PORT
 --error ER_PARSE_ERROR
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD='';
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD='';
 RESET SLAVE;
 --echo
 
@@ -248,7 +251,7 @@ RESET SLAVE;
 # Check received heartbeat events for running slave
 --echo *** Running slave ***
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=0.1;
 --source include/start_slave.inc
 --connection master
 --sync_slave_with_master
@@ -350,7 +353,7 @@ DELIMITER ;|
 --connection slave
 RESET SLAVE;
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=5;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=5;
 --source include/start_slave.inc
 --connection master
 # Enable scheduler
@@ -382,7 +385,7 @@ DROP TABLE t1;
 RESET MASTER;
 --connection slave
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.5;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=0.5;
 let $slave_param_comparison= =;
 --source include/start_slave.inc
 let $rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
@@ -409,7 +412,7 @@ SET @@global.slave_compressed_protocol=1
 RESET SLAVE;
 SET @@global.slave_compressed_protocol=1;
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=0.1;
 --source include/start_slave.inc
 let $status_var_value= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
 let $status_var= slave_received_heartbeats;
@@ -428,7 +431,7 @@ SET @@global.slave_compressed_protocol=0
 STOP SLAVE;
 RESET SLAVE;
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=0.1;
 --source include/start_slave.inc
 let $rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
 --connection master
@@ -447,7 +450,7 @@ let $result= query_get_value(SELECT ($rc
 STOP SLAVE;
 RESET SLAVE;
 --replace_result $MASTER_MYPORT MASTER_PORT
-eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=0.1, MASTER_CONNECT_RETRY = 5;
+eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=0.1;
 --source include/start_slave.inc
 # Wait until slave_received_heartbeats will be incremented
 let $status_var_value= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
@@ -482,7 +485,7 @@ let $status_var_comparsion= >;
 #let $slave_binlog= query_get_value(SHOW MASTER STATUS, File, 1);
 --connection master
 #--replace_result $SLAVE_MYPORT SLAVE_PORT $slave_binlog SLAVE_BINLOG
-#eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$SLAVE_MYPORT, MASTER_USER='root', MASTER_HEARTBEAT_PERIOD=1, MASTER_LOG_FILE='$slave_binlog';
+#eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$SLAVE_MYPORT, MASTER_USER='root', MASTER_CONNECT_RETRY=$connect_retry, MASTER_HEARTBEAT_PERIOD=1, MASTER_LOG_FILE='$slave_binlog';
 --source include/start_slave.inc
 
 # Insert data on master and on slave and make sure that it replicated for both directions

=== added file 'mysql-test/suite/sys_vars/r/autocommit_func4.result'
--- a/mysql-test/suite/sys_vars/r/autocommit_func4.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/autocommit_func4.result	2011-01-14 13:21:46 +0000
@@ -0,0 +1,46 @@
+CREATE TABLE t1
+(
+id INT NOT NULL auto_increment,
+PRIMARY KEY (id),
+name varchar(30)
+) ENGINE = INNODB;
+SELECT @@global.autocommit;
+@@global.autocommit
+1
+SELECT @@autocommit;
+@@autocommit
+1
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+set @@global.autocommit = 1-@@global.autocommit;
+set @@autocommit = 1-@@autocommit;
+SELECT @@global.autocommit;
+@@global.autocommit
+0
+SELECT @@autocommit;
+@@autocommit
+0
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+3	Record_1
+4	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+DROP TABLE t1;
+set @@global.autocommit = 1-@@global.autocommit;

=== added file 'mysql-test/suite/sys_vars/r/autocommit_func5.result'
--- a/mysql-test/suite/sys_vars/r/autocommit_func5.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/autocommit_func5.result	2011-01-14 13:21:46 +0000
@@ -0,0 +1,42 @@
+CREATE TABLE t1
+(
+id INT NOT NULL auto_increment,
+PRIMARY KEY (id),
+name varchar(30)
+) ENGINE = INNODB;
+SELECT @@global.autocommit;
+@@global.autocommit
+0
+SELECT @@autocommit;
+@@autocommit
+0
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+set @@global.autocommit = 1-@@global.autocommit;
+set @@autocommit = 1-@@autocommit;
+SELECT @@global.autocommit;
+@@global.autocommit
+1
+SELECT @@autocommit;
+@@autocommit
+1
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+3	Record_1
+4	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+3	Record_1
+4	Record_2
+DROP TABLE t1;
+set @@global.autocommit = 1-@@global.autocommit;

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func4-master.opt'
--- a/mysql-test/suite/sys_vars/t/autocommit_func4-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func4-master.opt	2011-01-14 13:21:46 +0000
@@ -0,0 +1 @@
+--autocommit=on

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func4.test'
--- a/mysql-test/suite/sys_vars/t/autocommit_func4.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func4.test	2011-01-14 13:21:46 +0000
@@ -0,0 +1 @@
+--source suite/sys_vars/inc/autocommit_func2.inc

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func5-master.opt'
--- a/mysql-test/suite/sys_vars/t/autocommit_func5-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func5-master.opt	2011-01-14 13:21:46 +0000
@@ -0,0 +1 @@
+--autocommit=off

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func5.test'
--- a/mysql-test/suite/sys_vars/t/autocommit_func5.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func5.test	2011-01-14 13:21:46 +0000
@@ -0,0 +1 @@
+--source suite/sys_vars/inc/autocommit_func2.inc

=== modified file 'mysql-test/t/func_math.test'
--- a/mysql-test/t/func_math.test	2010-12-24 11:30:28 +0000
+++ b/mysql-test/t/func_math.test	2011-01-14 15:36:19 +0000
@@ -489,3 +489,14 @@ as foo;
 CREATE TABLE t1(a char(0));
 INSERT INTO t1 (SELECT -pi());
 DROP TABLE t1;
+
+--echo #
+--echo # Bug #59241 invalid memory read
+--echo #            in do_div_mod with doubly assigned variables
+--echo #
+SELECT ((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa')));
+
+--echo #
+--echo # Bug #59498 div function broken in mysql-trunk
+--echo #
+SELECT 1 div null;

=== modified file 'mysql-test/t/func_str.test'
--- a/mysql-test/t/func_str.test	2010-12-14 16:29:15 +0000
+++ b/mysql-test/t/func_str.test	2011-01-13 08:19:52 +0000
@@ -1370,6 +1370,17 @@ DROP TABLE t1;
 SELECT '1' IN ('1', SUBSTRING(-9223372036854775809, 1));
 SELECT CONVERT(('' IN (REVERSE(CAST(('') AS DECIMAL)), '')), CHAR(3));
 
+--echo # 
+--echo # Bug#58165: "my_empty_string" gets modified and causes LOAD DATA to fail
+--echo # and other crashes
+--echo #
+CREATE TABLE t1 ( a TEXT );
+SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE 'bug58165.txt';
+SELECT insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' );
+LOAD DATA INFILE 'bug58165.txt' INTO TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
 --echo End of 5.1 tests
 
 --echo Start of 5.4 tests

=== modified file 'mysql-test/t/gis-precise.test'
--- a/mysql-test/t/gis-precise.test	2010-06-30 11:04:45 +0000
+++ b/mysql-test/t/gis-precise.test	2011-01-14 21:08:28 +0000
@@ -64,7 +64,9 @@ select ST_DISTANCE(geomfromtext('linestr
 
 
 # Operations tests
+--replace_result 23.85542168674699 23.855421686746986
 select astext(ST_Intersection(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))')));
+--replace_result 23.85542168674699 23.855421686746986
 select astext(ST_Intersection(GeomFromText('LINESTRING(0 0, 50 45, 40 50, 0 0)'), GeomFromText('LINESTRING(50 5, 55 10, 0 45, 50 5)')));
 select astext(ST_Intersection(GeomFromText('LINESTRING(0 0, 50 45, 40 50)'), GeomFromText('LINESTRING(50 5, 55 10, 0 45)')));
 select astext(ST_Intersection(GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), GeomFromText('POINT(20 20)')));
@@ -82,12 +84,13 @@ select astext(ST_buffer(geometryfromtext
 create table t1(geom geometrycollection);
 insert into t1 values (geomfromtext('POLYGON((0 0, 10 10, 0 8, 0 0))'));
 insert into t1 values (geomfromtext('POLYGON((1 1, 10 10, 0 8, 1 1))'));
+--replace_result 101.67150840374887 101.67150840374886 108.55539589266462 108.55539589266459
 select astext(geom), area(geom),area(ST_buffer(geom,2)) from t1;
-select astext(ST_buffer(geom,2)) from t1;
+select NUMPOINTS(EXTERIORRING(ST_buffer(geom,2))) from t1;
 
 set @geom=geomfromtext('LINESTRING(2 1, 4 2, 2 3, 2 5)');
 set @buff=ST_buffer(@geom,1);
-select astext(@buff);
+select NUMPOINTS(EXTERIORRING(@buff)) from t1;
 
 # cleanup
 DROP TABLE t1;

=== modified file 'mysql-test/t/gis.test'
--- a/mysql-test/t/gis.test	2010-11-04 15:40:18 +0000
+++ b/mysql-test/t/gis.test	2011-01-14 21:08:28 +0000
@@ -361,7 +361,7 @@ t1 where object_id=85998;
 
 # Expected result is 36.3310176346905, but IA64 returns 36.3310176346904
 # due to fused multiply-add instructions.
---replace_result 36.3310176346904 36.3310176346905
+--replace_result 36.3310176346904 36.3310176346905 -114.87787186923326 -114.87787186923313 36.33101763469053 36.33101763469059 36.33101763469043 36.33101763469059
 select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
 t1 where object_id=85984;
 
@@ -747,6 +747,16 @@ SET @a=0x0000000003000000000000000000000
 SET @a=POLYFROMWKB(@a);
 
 
+#
+# Bug #57321    crashes and valgrind errors from spatial types
+#
+
+create table t1(a polygon NOT NULL)engine=myisam;
+insert into t1 values (geomfromtext("point(0 1)"));
+insert into t1 values (geomfromtext("point(1 0)"));
+select * from (select polygon(t1.a) as p from t1 order by t1.a) d;
+drop table t1;
+
 --echo End of 5.1 tests
 
 #

=== modified file 'mysql-test/t/join_outer.test'
--- a/mysql-test/t/join_outer.test	2010-12-16 18:50:46 +0000
+++ b/mysql-test/t/join_outer.test	2011-01-13 09:08:47 +0000
@@ -1024,6 +1024,88 @@ GROUP BY t2.f1, t2.f2;
 
 DROP TABLE t1,t2;
 
+--echo #
+--echo # Bug#57034 incorrect OUTER JOIN result when joined on unique key
+--echo #
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, 
+                 col_int INT, 
+                 col_int_unique INT UNIQUE KEY);
+INSERT INTO t1 VALUES (1,NULL,2), (2,0,0);
+
+CREATE TABLE t2 (pk INT PRIMARY KEY,
+                 col_int INT,
+                 col_int_unique INT UNIQUE KEY);
+INSERT INTO t2 VALUES (1,0,1), (2,0,2);
+
+EXPLAIN
+SELECT * FROM t1 LEFT JOIN t2
+  ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int 
+  WHERE t1.pk=1;
+
+SELECT * FROM t1 LEFT JOIN t2
+  ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int 
+  WHERE t1.pk=1;
+
+DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug#48046 Server incorrectly processing JOINs on NULL values
+--echo #
+
+# bug#48046 is a duplicate of bug#57034
+
+CREATE TABLE `BB` (
+  `pk` int(11) NOT NULL AUTO_INCREMENT,
+  `time_key` time DEFAULT NULL,
+  `varchar_key` varchar(1) DEFAULT NULL,
+  `varchar_nokey` varchar(1) DEFAULT NULL,
+  PRIMARY KEY (`pk`),
+  KEY `time_key` (`time_key`),
+  KEY `varchar_key` (`varchar_key`)
+) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
+
+INSERT INTO `BB` VALUES (10,'18:27:58',NULL,NULL);
+
+SELECT table1.time_key AS field1, table2.pk 
+FROM BB table1  LEFT JOIN BB table2 
+ ON table2.varchar_nokey = table1.varchar_key
+ HAVING field1;
+
+DROP TABLE BB;
+
+--echo #
+--echo # Bug#49600 Server incorrectly processing RIGHT JOIN with 
+--echo #           constant WHERE clause and no index
+--echo #
+
+# bug#49600 is a duplicate of bug#57034
+
+CREATE TABLE `BB` (
+  `col_datetime_key` datetime DEFAULT NULL,
+  `col_varchar_key` varchar(1) DEFAULT NULL,
+  `col_varchar_nokey` varchar(1) DEFAULT NULL,
+  KEY `col_datetime_key` (`col_datetime_key`),
+  KEY `col_varchar_key` (`col_varchar_key`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+INSERT INTO `BB` VALUES ('1900-01-01 00:00:00',NULL,NULL);
+
+SELECT table1.col_datetime_key  
+FROM BB table1 RIGHT JOIN BB table2 
+ ON table2 .col_varchar_nokey = table1.col_varchar_key
+ WHERE 7;
+
+# Disable keys, and we get incorrect result for the same query
+ALTER TABLE BB DISABLE KEYS;
+
+SELECT table1.col_datetime_key  
+FROM BB table1 RIGHT JOIN BB table2
+ ON table2 .col_varchar_nokey = table1.col_varchar_key
+ WHERE 7;
+
+DROP TABLE BB;
+
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'mysql-test/t/mysqladmin.test'
--- a/mysql-test/t/mysqladmin.test	2010-09-30 10:28:49 +0000
+++ b/mysql-test/t/mysqladmin.test	2011-01-16 03:25:30 +0000
@@ -39,3 +39,14 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug106
 # - running mysqladmin --protcol=tcp --bind-address=127.0.0.1
 #
 --exec $MYSQLADMIN --no-defaults --protocol=tcp --bind-address=127.0.0.1 --host=127.0.0.1 -P $MASTER_MYPORT -u root ping 2>&1
+--echo #
+--echo # Bug#58221 : mysqladmin --sleep=x --count=x keeps looping
+--echo #
+
+--echo # Executing mysqladmin with --sleep=1 and --count=2.
+--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --sleep=1 --count=2 ping > $MYSQLTEST_VARDIR/tmp/mysqladmin.tmp
+--echo # Done.
+--echo # Displaying the output :
+--cat_file $MYSQLTEST_VARDIR/tmp/mysqladmin.tmp
+
+--remove_file $MYSQLTEST_VARDIR/tmp/mysqladmin.tmp

=== modified file 'mysql-test/t/mysqlbinlog_row_big.test'
--- a/mysql-test/t/mysqlbinlog_row_big.test	2009-04-02 22:34:18 +0000
+++ b/mysql-test/t/mysqlbinlog_row_big.test	2011-01-12 19:32:45 +0000
@@ -79,8 +79,8 @@ eval CREATE TABLE t1 (
 --echo # Insert some big rows.
 --echo #
 
---echo 256MB
-INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 16777216));
+--echo 64MB
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 4194304));
 
 --echo 32MB
 INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 2097152));

=== modified file 'mysql-test/t/mysqldump.test'
--- a/mysql-test/t/mysqldump.test	2010-10-18 12:18:18 +0000
+++ b/mysql-test/t/mysqldump.test	2011-01-14 14:49:16 +0000
@@ -2181,6 +2181,15 @@ truncate table t1;
 drop table t1;
 
 ###########################################################################
+
+--echo #
+--echo # Bug #13618 : mysqldump --xml ommit comment on table field
+--echo #
+
+CREATE TABLE `comment_table` (i INT COMMENT 'FIELD COMMENT') COMMENT = 'TABLE COMMENT';
+--exec $MYSQL_DUMP --compact --skip-create --xml test
+DROP TABLE `comment_table`;
+
 --echo #
 --echo # End of 5.1 tests
 --echo #

=== modified file 'mysql-test/t/plugin_auth.test'
--- a/mysql-test/t/plugin_auth.test	2010-12-17 11:28:59 +0000
+++ b/mysql-test/t/plugin_auth.test	2011-01-16 04:02:29 +0000
@@ -395,7 +395,7 @@ FLUSH PRIVILEGES;
 FLUSH PRIVILEGES;
 
 --echo #
---echo # Bug#58139 : default-auth option not recognized in MySQL standardi
+--echo # Bug#58139 : default-auth option not recognized in MySQL standard
 --echo #             command line clients
 --echo #
 
@@ -408,4 +408,7 @@ FLUSH PRIVILEGES;
 --echo # Executing 'mysqldump'
 --exec $MYSQL_DUMP -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --compact --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT test
 
+--echo # Executing 'mysql_upgrade'
+--exec $MYSQL_UPGRADE -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT --skip-verbose --force --upgrade-system-tables
+
 --echo End of 5.5 tests

=== modified file 'mysql-test/t/show_check.test'
--- a/mysql-test/t/show_check.test	2011-01-07 16:10:48 +0000
+++ b/mysql-test/t/show_check.test	2011-01-17 07:14:27 +0000
@@ -1,3 +1,33 @@
+# Copyright (c) 2001, 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
+#
+
+################################################################################
+#
+# NOTICE:
+#
+#  This file unfortunately contains characters in various different encodings. 
+#  Be careful when editing this file to ensure that you (or your editor) do
+#  not change things (such as encodings) on lines that you did not mean to 
+#  modify.
+#
+################################################################################
+
+
 # Uses GRANT commands that usually disabled in embedded server
 -- source include/not_embedded.inc
 
@@ -223,14 +253,6 @@ CREATE TABLE """a" (i INT);
 SHOW CREATE TABLE """a";
 DROP TABLE """a";
 
-# Bug#4374 SHOW TABLE STATUS FROM ignores collation_connection
-#set names latin1;
-#create database `�`;
-#create table `�`.`�` (a int) engine=heap;
-#--replace_column 7 # 8 # 9 #
-#show table status from `s around keywords.. :
 
 SET sql_mode= '';
@@ -362,15 +384,6 @@ delete from mysql.db
 where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
 flush privileges;
 
-# This test fails on MAC OSX, so it is temporary disabled.
-# This needs WL#1324 to be done.
-#set names latin1;
-#create database `�`;
-#create table `�`.`�` (a int) engine=heap;
-#--replace_column 7 # 8 # 9 #
-#show table status from `�` LIKE '�';
-#drop database `OW CREATE TABLE when it was
 # specified during table creation, but not otherwise. (Bug#7235)
 CREATE TABLE t1 (i int, KEY (i)) ENGINE=MEMORY;
@@ -1053,6 +1066,17 @@ show full tables;
 drop table `��t��`;
 set names latin1;
 
+--echo #
+--echo # Bug#4374 SHOW TABLE STATUS FROM ignores collation_connection
+--echo # Character set: Latin-1 (ISO-8859-1)
+--echo #
+SET NAMES latin1;
+CREATE DATABASE `�`;
+CREATE TABLE `�`.`�` (a int) ENGINE=Memory;
+--replace_column 7 # 8 # 9 #
+SHOW TABLE STATUS FROM `�` LIKE '�';
+DROP DATABASE `�`;
+
 #
 # Bug#26402 Server crashes with old-style named table
 #

=== modified file 'mysql-test/t/type_timestamp.test'
--- a/mysql-test/t/type_timestamp.test	2010-09-13 07:30:10 +0000
+++ b/mysql-test/t/type_timestamp.test	2011-01-12 12:58:47 +0000
@@ -377,3 +377,21 @@ SELECT a FROM t1;
 DROP TABLE t1;
 
 --echo End of Bug#50888
+
+--echo #
+--echo # Bug59330: Incorrect result when comparing an aggregate
+--echo #           function with TIMESTAMP
+--echo #
+CREATE TABLE t1 (dt DATETIME, ts TIMESTAMP);
+INSERT INTO t1 VALUES('2011-01-06 12:34:30', '2011-01-06 12:34:30');
+SELECT MAX(dt), MAX(ts) FROM t1;
+SELECT MAX(ts) < '2010-01-01 00:00:00' FROM t1;
+SELECT MAX(dt) < '2010-01-01 00:00:00' FROM t1;
+SELECT MAX(ts) > '2010-01-01 00:00:00' FROM t1;
+SELECT MAX(dt) > '2010-01-01 00:00:00' FROM t1;
+SELECT MAX(ts) = '2011-01-06 12:34:30' FROM t1;
+SELECT MAX(dt) = '2011-01-06 12:34:30' FROM t1;
+DROP TABLE t1;
+
+--echo End of 5.5 tests
+

=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2011-01-10 14:20:31 +0000
+++ b/mysys/my_getopt.c	2011-01-14 22:22:38 +0000
@@ -612,13 +612,21 @@ static char *check_struct_option(char *c
    @param[in] argument The value argument
    @return boolean value
 */
-static my_bool get_bool_argument(const char *argument)
+static my_bool get_bool_argument(const struct my_option *opts,
+                                 const char *argument)
 {
   if (!my_strcasecmp(&my_charset_latin1, argument, "true") ||
-      !my_strcasecmp(&my_charset_latin1, argument, "on"))
+      !my_strcasecmp(&my_charset_latin1, argument, "on") ||
+      !my_strcasecmp(&my_charset_latin1, argument, "1"))
     return 1;
-  else
-    return (my_bool) atoi(argument);
+  else if (!my_strcasecmp(&my_charset_latin1, argument, "false") ||
+      !my_strcasecmp(&my_charset_latin1, argument, "off") ||
+      !my_strcasecmp(&my_charset_latin1, argument, "0"))
+    return 0;
+  my_getopt_error_reporter(WARNING_LEVEL,
+      "option '%s': boolean value '%s' wasn't recognized. Set to OFF.",
+      opts->name, argument);
+  return 0;
 }
 
 /*
@@ -648,7 +656,7 @@ static int setval(const struct my_option
 
     switch ((opts->var_type & GET_TYPE_MASK)) {
     case GET_BOOL: /* If argument differs from 0, enable option, else disable */
-      *((my_bool*) value)= get_bool_argument(argument);
+      *((my_bool*) value)= get_bool_argument(opts, argument);
       break;
     case GET_INT:
       *((int*) value)= (int) getopt_ll(argument, opts, &err);

=== modified file 'mysys/my_getsystime.c'
--- a/mysys/my_getsystime.c	2011-01-11 13:53:50 +0000
+++ b/mysys/my_getsystime.c	2011-01-12 20:36:39 +0000
@@ -25,13 +25,25 @@
 #include "mysys_priv.h"
 #include "my_static.h"
 
+/**
+  Get high-resolution time.
+
+  @remark For windows platforms we need the frequency value of
+          the CPU. This is initialized in my_init.c through
+          QueryPerformanceFrequency(). If the Windows platform
+          doesn't support QueryPerformanceFrequency(), zero is
+          returned.
+
+  @retval current high-resolution time.
+*/
+
 ulonglong my_getsystime()
 {
 #ifdef HAVE_CLOCK_GETTIME
   struct timespec tp;
   clock_gettime(CLOCK_REALTIME, &tp);
   return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100;
-#elif defined(__WIN__)
+#elif defined(_WIN32)
   LARGE_INTEGER t_cnt;
   if (query_performance_frequency)
   {
@@ -50,22 +62,17 @@ ulonglong my_getsystime()
 }
 
 
-/*
-  Return current time
+/**
+  Return current time.
 
-  SYNOPSIS
-    my_time()
-    flags	If MY_WME is set, write error if time call fails
+  @param  flags   If MY_WME is set, write error if time call fails.
 
+  @retval current time.
 */
 
-time_t my_time(myf flags __attribute__((unused)))
+time_t my_time(myf flags)
 {
   time_t t;
-#ifdef HAVE_GETHRTIME
-  (void) my_micro_time_and_time(&t);
-  return t;
-#else
   /* The following loop is here beacuse time() may fail on some systems */
   while ((t= time(0)) == (time_t) -1)
   {
@@ -73,39 +80,26 @@ time_t my_time(myf flags __attribute__((
       fprintf(stderr, "%s: Warning: time() call failed\n", my_progname);
   }
   return t;
-#endif
 }
 
 
-/*
-  Return time in micro seconds
-
-  SYNOPSIS
-    my_micro_time()
-
-  NOTES
-    This function is to be used to measure performance in micro seconds.
-    As it's not defined whats the start time for the clock, this function
-    us only useful to measure time between two moments.
+/**
+  Return time in microseconds.
 
-    For windows platforms we need the frequency value of the CUP. This is
-    initalized in my_init.c through QueryPerformanceFrequency().
+  @remark This function is to be used to measure performance in
+          micro seconds. As it's not defined whats the start time
+          for the clock, this function us only useful to measure
+          time between two moments.
 
-    If Windows platform doesn't support QueryPerformanceFrequency() we will
-    obtain the time via GetClockCount, which only supports milliseconds.
-
-  RETURN
-    Value in microseconds from some undefined point in time
+  @retval Value in microseconds from some undefined point in time.
 */
 
 ulonglong my_micro_time()
 {
-#if defined(__WIN__)
+#ifdef _WIN32
   ulonglong newtime;
   GetSystemTimeAsFileTime((FILETIME*)&newtime);
   return (newtime/10);
-#elif defined(HAVE_GETHRTIME)
-  return gethrtime()/1000;
 #else
   ulonglong newtime;
   struct timeval t;
@@ -116,69 +110,37 @@ ulonglong my_micro_time()
   {}
   newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
   return newtime;
-#endif  /* defined(__WIN__) */
+#endif
 }
 
 
-/*
+/**
   Return time in seconds and timer in microseconds (not different start!)
 
-  SYNOPSIS
-    my_micro_time_and_time()
-    time_arg		Will be set to seconds since epoch (00:00:00 UTC,
-                        January 1, 1970)
-
-  NOTES
-    This function is to be useful when we need both the time and microtime.
-    For example in MySQL this is used to get the query time start of a query
-    and to measure the time of a query (for the slow query log)
-
-  IMPLEMENTATION
-    Value of time is as in time() call.
-    Value of microtime is same as my_micro_time(), which may be totally
-    unrealated to time()
+  @param  time_arg  Will be set to seconds since epoch.
 
-  RETURN
-    Value in microseconds from some undefined point in time
-*/
+  @remark This function is to be useful when we need both the time and
+          microtime. For example in MySQL this is used to get the query
+          time start of a query and to measure the time of a query (for
+          the slow query log)
+
+  @remark The time source is the same as for my_micro_time(), meaning
+          that time values returned by both functions can be intermixed
+          in meaningful ways (i.e. for comparison purposes).
 
-#define DELTA_FOR_SECONDS 500000000LL  /* Half a second */
+  @retval Value in microseconds from some undefined point in time.
+*/
 
 /* Difference between GetSystemTimeAsFileTime() and now() */
 #define OFFSET_TO_EPOCH 116444736000000000ULL
 
 ulonglong my_micro_time_and_time(time_t *time_arg)
 {
-#if defined(__WIN__)
+#ifdef _WIN32
   ulonglong newtime;
   GetSystemTimeAsFileTime((FILETIME*)&newtime);
   *time_arg= (time_t) ((newtime - OFFSET_TO_EPOCH) / 10000000);
   return (newtime/10);
-#elif defined(HAVE_GETHRTIME)
-  /*
-    Solaris has a very slow time() call. We optimize this by using the very
-    fast gethrtime() call and only calling time() every 1/2 second
-  */
-  static hrtime_t prev_gethrtime= 0;
-  static time_t cur_time= 0;
-  hrtime_t cur_gethrtime;
-
-  mysql_mutex_lock(&THR_LOCK_time);
-  cur_gethrtime= gethrtime();
-  /*
-    Due to bugs in the Solaris (x86) implementation of gethrtime(),
-    the time returned by it might not be monotonic. Don't use the
-    cached time(2) value if this is a case.
-  */
-  if ((prev_gethrtime > cur_gethrtime) ||
-      ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS))
-  {
-    cur_time= time(0);
-    prev_gethrtime= cur_gethrtime;
-  }
-  *time_arg= cur_time;
-  mysql_mutex_unlock(&THR_LOCK_time);
-  return cur_gethrtime/1000;
 #else
   ulonglong newtime;
   struct timeval t;
@@ -190,37 +152,31 @@ ulonglong my_micro_time_and_time(time_t
   *time_arg= t.tv_sec;
   newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
   return newtime;
-#endif  /* defined(__WIN__) */
+#endif
 }
 
 
-/*
-  Returns current time
+/**
+  Returns current time.
 
-  SYNOPSIS
-    my_time_possible_from_micro()
-    microtime		Value from very recent my_micro_time()
-
-  NOTES
-    This function returns the current time. The microtime argument is only used
-    if my_micro_time() uses a function that can safely be converted to the
-    current time.
+  @param  microtime Value from very recent my_micro_time().
 
-  RETURN
-    current time
+  @remark This function returns the current time. The microtime argument
+          is only used if my_micro_time() uses a function that can safely
+          be converted to the current time.
+
+  @retval current time.
 */
 
 time_t my_time_possible_from_micro(ulonglong microtime __attribute__((unused)))
 {
-#if defined(__WIN__)
+#ifdef _WIN32
   time_t t;
   while ((t= time(0)) == (time_t) -1)
   {}
   return t;
-#elif defined(HAVE_GETHRTIME)
-  return my_time(0);                            /* Cached time */
 #else
   return (time_t) (microtime / 1000000);
-#endif  /* defined(__WIN__) */
+#endif
 }
 

=== modified file 'mysys/my_init.c'
--- a/mysys/my_init.c	2011-01-11 09:09:21 +0000
+++ b/mysys/my_init.c	2011-01-13 11:31:20 +0000
@@ -510,7 +510,7 @@ PSI_mutex_key key_BITMAP_mutex, key_IO_C
   key_my_thread_var_mutex, key_THR_LOCK_charset, key_THR_LOCK_heap,
   key_THR_LOCK_isam, key_THR_LOCK_lock, key_THR_LOCK_malloc,
   key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net,
-  key_THR_LOCK_open, key_THR_LOCK_threads, key_THR_LOCK_time,
+  key_THR_LOCK_open, key_THR_LOCK_threads,
   key_TMPDIR_mutex, key_THR_LOCK_myisam_mmap;
 
 static PSI_mutex_info all_mysys_mutexes[]=
@@ -540,7 +540,6 @@ static PSI_mutex_info all_mysys_mutexes[
   { &key_THR_LOCK_net, "THR_LOCK_net", PSI_FLAG_GLOBAL},
   { &key_THR_LOCK_open, "THR_LOCK_open", PSI_FLAG_GLOBAL},
   { &key_THR_LOCK_threads, "THR_LOCK_threads", PSI_FLAG_GLOBAL},
-  { &key_THR_LOCK_time, "THR_LOCK_time", PSI_FLAG_GLOBAL},
   { &key_TMPDIR_mutex, "TMPDIR_mutex", PSI_FLAG_GLOBAL},
   { &key_THR_LOCK_myisam_mmap, "THR_LOCK_myisam_mmap", PSI_FLAG_GLOBAL}
 };

=== modified file 'mysys/my_thr_init.c'
--- a/mysys/my_thr_init.c	2011-01-11 09:09:21 +0000
+++ b/mysys/my_thr_init.c	2011-01-13 11:31:20 +0000
@@ -25,7 +25,7 @@
 pthread_key(struct st_my_thread_var*, THR_KEY_mysys);
 mysql_mutex_t THR_LOCK_malloc, THR_LOCK_open,
               THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_myisam, THR_LOCK_heap,
-              THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads, THR_LOCK_time,
+              THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads,
               THR_LOCK_myisam_mmap;
 
 mysql_cond_t  THR_COND_threads;
@@ -219,7 +219,6 @@ my_bool my_thread_global_init(void)
   mysql_mutex_init(key_THR_LOCK_myisam_mmap, &THR_LOCK_myisam_mmap, MY_MUTEX_INIT_FAST);
   mysql_mutex_init(key_THR_LOCK_heap, &THR_LOCK_heap, MY_MUTEX_INIT_FAST);
   mysql_mutex_init(key_THR_LOCK_net, &THR_LOCK_net, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(key_THR_LOCK_time, &THR_LOCK_time, MY_MUTEX_INIT_FAST);
   mysql_cond_init(key_THR_COND_threads, &THR_COND_threads, NULL);
 
 #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
@@ -288,7 +287,6 @@ void my_thread_global_end(void)
   mysql_mutex_destroy(&THR_LOCK_myisam_mmap);
   mysql_mutex_destroy(&THR_LOCK_heap);
   mysql_mutex_destroy(&THR_LOCK_net);
-  mysql_mutex_destroy(&THR_LOCK_time);
   mysql_mutex_destroy(&THR_LOCK_charset);
   if (all_threads_killed)
   {

=== modified file 'mysys/mysys_priv.h'
--- a/mysys/mysys_priv.h	2011-01-11 09:09:21 +0000
+++ b/mysys/mysys_priv.h	2011-01-13 11:31:20 +0000
@@ -45,7 +45,7 @@ extern PSI_mutex_key key_BITMAP_mutex, k
   key_my_thread_var_mutex, key_THR_LOCK_charset, key_THR_LOCK_heap,
   key_THR_LOCK_isam, key_THR_LOCK_lock, key_THR_LOCK_malloc,
   key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net,
-  key_THR_LOCK_open, key_THR_LOCK_threads, key_THR_LOCK_time,
+  key_THR_LOCK_open, key_THR_LOCK_threads,
   key_TMPDIR_mutex, key_THR_LOCK_myisam_mmap;
 
 extern PSI_cond_key key_COND_alarm, key_IO_CACHE_SHARE_cond,
@@ -60,7 +60,7 @@ extern PSI_thread_key key_thread_alarm;
 
 extern mysql_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache;
 extern mysql_mutex_t THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_net;
-extern mysql_mutex_t THR_LOCK_charset, THR_LOCK_time;
+extern mysql_mutex_t THR_LOCK_charset;
 
 #include <mysql/psi/mysql_file.h>
 

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-01-11 11:45:02 +0000
+++ b/sql/handler.cc	2011-01-13 07:33:03 +0000
@@ -5820,7 +5820,7 @@ int handler::ha_external_lock(THD *thd,
 */
 int handler::ha_reset()
 {
-  DBUG_ENTER("ha_reset");
+  DBUG_ENTER("handler::ha_reset");
   /* Check that we have called all proper deallocation functions */
   DBUG_ASSERT((uchar*) table->def_read_set.bitmap +
               table->s->column_bitmap_size ==
@@ -5833,7 +5833,13 @@ int handler::ha_reset()
   free_io_cache(table);
   /* reset the bitmaps to point to defaults */
   table->default_column_bitmaps();
+  /* Reset information about pushed engine conditions */
   pushed_cond= NULL;
+  /* Reset information about pushed index conditions */
+  pushed_idx_cond= NULL;
+  pushed_idx_cond_keyno= MAX_KEY;
+  in_range_check_pushed_down= false;
+ 
   const int retval= reset();
   DBUG_RETURN(retval);
 }

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2010-12-21 12:27:36 +0000
+++ b/sql/item.cc	2011-01-12 17:24:53 +0000
@@ -7500,8 +7500,7 @@ Item_cache* Item_cache::get_cache(const
     return new Item_cache_decimal();
   case STRING_RESULT:
     /* Not all functions that return DATE/TIME are actually DATE/TIME funcs. */
-    if ((item->field_type() == MYSQL_TYPE_DATE ||
-         item->field_type() == MYSQL_TYPE_DATETIME ||
+    if ((item->is_datetime() ||
          item->field_type() == MYSQL_TYPE_TIME) &&
         (const_cast<Item*>(item))->result_as_longlong())
       return new Item_cache_datetime(item->field_type());

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2010-12-29 00:38:59 +0000
+++ b/sql/item_cmpfunc.cc	2011-01-14 09:29:11 +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
@@ -2172,7 +2172,6 @@ void Item_func_interval::fix_length_and_
             if (dec != &range->dec)
             {
               range->dec= *dec;
-              range->dec.fix_buffer_pointer();
             }
           }
           else
@@ -5769,15 +5768,15 @@ longlong Item_equal::val_int()
     return 0;
   List_iterator_fast<Item_field> it(fields);
   Item *item= const_item ? const_item : it++;
+  eval_item->store_value(item);
   if ((null_value= item->null_value))
     return 0;
-  eval_item->store_value(item);
   while ((item_field= it++))
   {
     /* Skip fields of non-const tables. They haven't been read yet */
     if (item_field->field->table->const_table)
     {
-      if ((null_value= item_field->null_value) || eval_item->cmp(item_field))
+      if (eval_item->cmp(item_field) || (null_value= item_field->null_value))
         return 0;
     }
   }

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2010-12-29 00:38:59 +0000
+++ b/sql/item_func.cc	2011-01-14 15:36:19 +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
@@ -1599,24 +1599,27 @@ longlong Item_func_int_div::val_int()
   if (args[0]->result_type() != INT_RESULT ||
       args[1]->result_type() != INT_RESULT)
   {
-    my_decimal value0, value1, tmp;
-    my_decimal *val0, *val1;
-    longlong res;
-    int err;
+    my_decimal tmp;
+    my_decimal *val0p= args[0]->val_decimal(&tmp);
+    if ((null_value= args[0]->null_value))
+      return 0;
+    my_decimal val0= *val0p;
 
-    val0= args[0]->val_decimal(&value0);
-    val1= args[1]->val_decimal(&value1);
-    if ((null_value= (args[0]->null_value || args[1]->null_value)))
+    my_decimal *val1p= args[1]->val_decimal(&tmp);
+    if ((null_value= args[1]->null_value))
       return 0;
+    my_decimal val1= *val1p;
 
+    int err;
     if ((err= my_decimal_div(E_DEC_FATAL_ERROR & ~E_DEC_DIV_ZERO, &tmp,
-                             val0, val1, 0)) > 3)
+                             &val0, &val1, 0)) > 3)
     {
       if (err == E_DEC_DIV_ZERO)
         signal_divide_by_null();
       return 0;
     }
 
+    longlong res;
     if (my_decimal2int(E_DEC_FATAL_ERROR, &tmp, unsigned_flag, &res) &
         E_DEC_OVERFLOW)
       raise_integer_overflow();

=== modified file 'sql/item_geofunc.h'
--- a/sql/item_geofunc.h	2010-11-04 15:40:18 +0000
+++ b/sql/item_geofunc.h	2011-01-12 17:24:53 +0000
@@ -183,6 +183,7 @@ public:
   String *val_str(String *);
   void fix_length_and_dec()
   {
+    Item_geometry_func::fix_length_and_dec();
     for (unsigned int i= 0; i < arg_count; ++i)
     {
       if (args[i]->fixed && args[i]->field_type() != MYSQL_TYPE_GEOMETRY)

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2010-12-20 10:28:06 +0000
+++ b/sql/item_strfunc.cc	2011-01-13 08:19:52 +0000
@@ -57,6 +57,9 @@ C_MODE_START
 #include "../mysys/my_static.h"			// For soundex_map
 C_MODE_END
 
+/**
+   @todo Remove this. It is not safe to use a shared String object.
+ */
 String my_empty_string("",default_charset_info);
 
 /*
@@ -739,7 +742,7 @@ String *Item_func_des_encrypt::val_str(S
   if ((null_value= args[0]->null_value))
     return 0;                                   // ENCRYPT(NULL) == NULL
   if ((res_length=res->length()) == 0)
-    return &my_empty_string;
+    return make_empty_result();
   if (arg_count == 1)
   {
     /* Protect against someone doing FLUSH DES_KEY_FILE */
@@ -929,7 +932,7 @@ String *Item_func_concat_ws::val_str(Str
     }
 
   if (i ==  arg_count)
-    return &my_empty_string;
+    return make_empty_result();
 
   for (i++; i < arg_count ; i++)
   {
@@ -1075,7 +1078,7 @@ String *Item_func_reverse::val_str(Strin
     return 0;
   /* An empty string is a special case as the string pointer may be null */
   if (!res->length())
-    return &my_empty_string;
+    return make_empty_result();
   if (tmp_value.alloced_length() < res->length() &&
       tmp_value.realloc(res->length()))
   {
@@ -1408,8 +1411,7 @@ String *Item_func_left::val_str(String *
 
   /* if "unsigned_flag" is set, we have a *huge* positive number. */
   if ((length <= 0) && (!args[1]->unsigned_flag))
-    return &my_empty_string;
-
+    return make_empty_result();
   if ((res->length() <= (ulonglong) length) ||
       (res->length() <= (char_pos= res->charpos((int) length))))
     return res;
@@ -1454,7 +1456,7 @@ String *Item_func_right::val_str(String
 
   /* if "unsigned_flag" is set, we have a *huge* positive number. */
   if ((length <= 0) && (!args[1]->unsigned_flag))
-    return &my_empty_string; /* purecov: inspected */
+    return make_empty_result(); /* purecov: inspected */
 
   if (res->length() <= (ulonglong) length)
     return res; /* purecov: inspected */
@@ -1494,7 +1496,7 @@ String *Item_func_substr::val_str(String
   /* Negative or zero length, will return empty string. */
   if ((arg_count == 3) && (length <= 0) && 
       (length == 0 || !args[2]->unsigned_flag))
-    return &my_empty_string;
+    return make_empty_result();
 
   /* Assumes that the maximum length of a String is < INT_MAX32. */
   /* Set here so that rest of code sees out-of-bound value as such. */
@@ -1505,12 +1507,12 @@ String *Item_func_substr::val_str(String
   /* Assumes that the maximum length of a String is < INT_MAX32. */
   if ((!args[1]->unsigned_flag && (start < INT_MIN32 || start > INT_MAX32)) ||
       (args[1]->unsigned_flag && ((ulonglong) start > INT_MAX32)))
-    return &my_empty_string;
+    return make_empty_result();
 
   start= ((start < 0) ? res->numchars() + start : start - 1);
   start= res->charpos((int) start);
   if ((start < 0) || ((uint) start + 1 > res->length()))
-    return &my_empty_string;
+    return make_empty_result();
 
   length= res->charpos((int) length, (uint32) start);
   tmp_length= res->length() - start;
@@ -1573,7 +1575,7 @@ String *Item_func_substr_index::val_str(
   null_value=0;
   uint delimiter_length= delimiter->length();
   if (!res->length() || !delimiter_length || !count)
-    return &my_empty_string;		// Wrong parameters
+    return make_empty_result();		// Wrong parameters
 
   res->set_charset(collation.collation);
 
@@ -1923,7 +1925,7 @@ String *Item_func_password::val_str_asci
   if ((null_value=args[0]->null_value))
     return 0;
   if (res->length() == 0)
-    return &my_empty_string;
+    return make_empty_result();
   my_make_scrambled_password(tmp_value, res->ptr(), res->length());
   str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH, &my_charset_latin1);
   return str;
@@ -1947,7 +1949,7 @@ String *Item_func_old_password::val_str_
   if ((null_value=args[0]->null_value))
     return 0;
   if (res->length() == 0)
-    return &my_empty_string;
+    return make_empty_result();
   my_make_scrambled_password_323(tmp_value, res->ptr(), res->length());
   str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH_323, &my_charset_latin1);
   return str;
@@ -1975,8 +1977,7 @@ String *Item_func_encrypt::val_str(Strin
   if ((null_value=args[0]->null_value))
     return 0;
   if (res->length() == 0)
-    return &my_empty_string;
-
+    return make_empty_result();
   if (arg_count == 1)
   {					// generate random salt
     time_t timestamp=current_thd->query_start();
@@ -2238,7 +2239,7 @@ String *Item_func_soundex::val_str(Strin
   for ( ; ; ) /* Skip pre-space */
   {
     if ((rc= cs->cset->mb_wc(cs, &wc, (uchar*) from, (uchar*) end)) <= 0)
-      return &my_empty_string; /* EOL or invalid byte sequence */
+      return make_empty_result(); /* EOL or invalid byte sequence */
     
     if (rc == 1 && cs->ctype)
     {
@@ -2263,7 +2264,7 @@ String *Item_func_soundex::val_str(Strin
         {
           /* Extra safety - should not really happen */
           DBUG_ASSERT(false);
-          return &my_empty_string;
+          return make_empty_result();
         }
         to+= rc;
         break;
@@ -2604,7 +2605,7 @@ String *Item_func_make_set::val_str(Stri
 	  else
 	  {
 	    if (tmp_str.copy(*res))		// Don't use 'str'
-	      return &my_empty_string;
+              return make_empty_result();
 	    result= &tmp_str;
 	  }
 	}
@@ -2614,11 +2615,11 @@ String *Item_func_make_set::val_str(Stri
 	  {					// Copy data to tmp_str
 	    if (tmp_str.alloc(result->length()+res->length()+1) ||
 		tmp_str.copy(*result))
-	      return &my_empty_string;
+              return make_empty_result();
 	    result= &tmp_str;
 	  }
 	  if (tmp_str.append(STRING_WITH_LEN(","), &my_charset_bin) || tmp_str.append(*res))
-	    return &my_empty_string;
+            return make_empty_result();
 	}
       }
     }
@@ -2763,7 +2764,7 @@ String *Item_func_repeat::val_str(String
   null_value= 0;
 
   if (count <= 0 && (count == 0 || !args[1]->unsigned_flag))
-    return &my_empty_string;
+    return make_empty_result();
 
   /* Assumes that the maximum length of a String is < INT_MAX32. */
   /* Bounds check on count:  If this is triggered, we will error. */
@@ -3045,7 +3046,7 @@ String *Item_func_conv::val_str(String *
 
   ptr= longlong2str(dec, ans, to_base);
   if (str->copy(ans, (uint32) (ptr-ans), default_charset()))
-    return &my_empty_string;
+    return make_empty_result();
   return str;
 }
 
@@ -3264,7 +3265,7 @@ String *Item_func_hex::val_str_ascii(Str
       return 0;
     ptr= longlong2str(dec,ans,16);
     if (str->copy(ans,(uint32) (ptr-ans), &my_charset_numeric))
-      return &my_empty_string;			// End of memory
+      return make_empty_result();		// End of memory
     return str;
   }
 

=== modified file 'sql/item_strfunc.h'
--- a/sql/item_strfunc.h	2010-12-02 13:44:21 +0000
+++ b/sql/item_strfunc.h	2011-01-13 08:19:52 +0000
@@ -27,6 +27,16 @@ class MY_LOCALE;
 
 class Item_str_func :public Item_func
 {
+protected:
+  /**
+     Sets the result value of the function an empty string, using the current
+     character set. No memory is allocated.
+     @retval A pointer to the str_value member.
+   */
+  String *make_empty_result() {
+    str_value.set("", 0, collation.collation);
+    return &str_value; 
+  }
 public:
   Item_str_func() :Item_func() { decimals=NOT_FIXED_DEC; }
   Item_str_func(Item *a) :Item_func(a) {decimals=NOT_FIXED_DEC; }

=== modified file 'sql/my_decimal.h'
--- a/sql/my_decimal.h	2010-10-19 22:58:36 +0000
+++ b/sql/my_decimal.h	2011-01-14 09:29:11 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -102,6 +102,24 @@ class my_decimal :public decimal_t
 
 public:
 
+  my_decimal(const my_decimal &rhs) : decimal_t(rhs)
+  {
+    for (uint i= 0; i < DECIMAL_BUFF_LENGTH; i++)
+      buffer[i]= rhs.buffer[i];
+    fix_buffer_pointer();
+  }
+
+  my_decimal& operator=(const my_decimal &rhs)
+  {
+    if (this == &rhs)
+      return *this;
+    decimal_t::operator=(rhs);
+    for (uint i= 0; i < DECIMAL_BUFF_LENGTH; i++)
+      buffer[i]= rhs.buffer[i];
+    fix_buffer_pointer();
+    return *this;
+  }
+
   void init()
   {
     len= DECIMAL_BUFF_LENGTH;
@@ -248,7 +266,6 @@ inline
 void my_decimal2decimal(const my_decimal *from, my_decimal *to)
 {
   *to= *from;
-  to->fix_buffer_pointer();
 }
 
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-01-03 15:05:36 +0000
+++ b/sql/mysqld.cc	2011-01-14 13:42:41 +0000
@@ -282,6 +282,7 @@ const char *first_keyword= "first", *bin
 const char *my_localhost= "localhost", *delayed_user= "DELAYED";
 
 bool opt_large_files= sizeof(my_off_t) > 4;
+static my_bool opt_autocommit; ///< for --autocommit command-line option
 
 /*
   Used with --help for detailed option
@@ -5910,8 +5911,9 @@ struct my_option my_long_options[]=
     Because Sys_var_bit does not support command-line options, we need to
     explicitely add one for --autocommit
   */
-  {"autocommit", OPT_AUTOCOMMIT, "Set default value for autocommit (0 or 1)",
-   NULL, NULL, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, NULL},
+  {"autocommit", 0, "Set default value for autocommit (0 or 1)",
+   &opt_autocommit, &opt_autocommit, 0,
+   GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, NULL},
   {"binlog-do-db", OPT_BINLOG_DO_DB,
    "Tells the master it should log updates for the specified database, "
    "and exclude all others not explicitly mentioned.",
@@ -7347,13 +7349,6 @@ mysqld_get_one_option(int optid,
     if (argument == NULL) /* no argument */
       log_error_file_ptr= const_cast<char*>("");
     break;
-  case OPT_AUTOCOMMIT:
-    const ulonglong turn_bit_on= (argument && (atoi(argument) == 0)) ?
-      OPTION_NOT_AUTOCOMMIT : OPTION_AUTOCOMMIT;
-    global_system_variables.option_bits=
-      (global_system_variables.option_bits &
-       ~(OPTION_NOT_AUTOCOMMIT | OPTION_AUTOCOMMIT)) | turn_bit_on;
-    break;
   }
   return 0;
 }
@@ -7504,10 +7499,12 @@ static int get_options(int *argc_ptr, ch
   else
     global_system_variables.option_bits&= ~OPTION_BIG_SELECTS;
 
-  if (global_system_variables.option_bits & OPTION_AUTOCOMMIT)
-    global_system_variables.option_bits&= ~OPTION_NOT_AUTOCOMMIT;
-  else
-    global_system_variables.option_bits|= OPTION_NOT_AUTOCOMMIT;
+  // Synchronize @@global.autocommit on --autocommit
+  const ulonglong turn_bit_on= opt_autocommit ?
+    OPTION_AUTOCOMMIT : OPTION_NOT_AUTOCOMMIT;
+  global_system_variables.option_bits=
+    (global_system_variables.option_bits &
+     ~(OPTION_NOT_AUTOCOMMIT | OPTION_AUTOCOMMIT)) | turn_bit_on;
 
   global_system_variables.sql_mode=
     expand_sql_mode(global_system_variables.sql_mode);

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2010-12-17 11:28:59 +0000
+++ b/sql/mysqld.h	2011-01-14 13:42:41 +0000
@@ -405,8 +405,7 @@ enum options_mysqld
   OPT_UPDATE_LOG,
   OPT_WANT_CORE,
   OPT_ENGINE_CONDITION_PUSHDOWN,
-  OPT_LOG_ERROR,
-  OPT_AUTOCOMMIT
+  OPT_LOG_ERROR
 };
 
 

=== modified file 'sql/sql_analyse.cc'
--- a/sql/sql_analyse.cc	2010-07-16 21:00:50 +0000
+++ b/sql/sql_analyse.cc	2011-01-14 09:29:11 +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
@@ -521,9 +521,6 @@ void field_decimal::add()
   {
     found = 1;
     min_arg = max_arg = sum[0] = *dec;
-    min_arg.fix_buffer_pointer();
-    max_arg.fix_buffer_pointer();
-    sum[0].fix_buffer_pointer();
     my_decimal_mul(E_DEC_FATAL_ERROR, sum_sqr, dec, dec);
     cur_sum= 0;
     min_length = max_length = length;
@@ -545,12 +542,10 @@ void field_decimal::add()
     if (my_decimal_cmp(dec, &min_arg) < 0)
     {
       min_arg= *dec;
-      min_arg.fix_buffer_pointer();
     }
     if (my_decimal_cmp(dec, &max_arg) > 0)
     {
       max_arg= *dec;
-      max_arg.fix_buffer_pointer();
     }
   }
 }

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-01-12 09:52:10 +0000
+++ b/sql/sql_select.cc	2011-01-14 08:20:08 +0000
@@ -8929,29 +8929,37 @@ static bool create_ref_for_key(JOIN *joi
         j->ref.null_rejecting |= 1 << i;
       keyuse_uses_no_tables= keyuse_uses_no_tables && !keyuse->used_tables;
 
+      store_key* key= get_store_key(thd,
+				    keyuse,join->const_table_map,
+				    &keyinfo->key_part[i],
+				    key_buff, maybe_null);
+      if (unlikely(!key || thd->is_fatal_error))
+        DBUG_RETURN(TRUE);
+
       if (keyuse->used_tables || thd->lex->describe)
         /* 
           Comparing against a non-constant or executing an EXPLAIN
           query (which refers to this info when printing the 'ref'
           column of the query plan)
         */
-        *ref_key++= get_store_key(thd,
-                                  keyuse,join->const_table_map,
-                                  &keyinfo->key_part[i],
-                                  key_buff, maybe_null);
+        *ref_key++= key;
       else
-      { // Compare against constant
-        store_key_item tmp(thd, keyinfo->key_part[i].field,
-                           key_buff + maybe_null,
-                           maybe_null ?  key_buff : 0,
-                           keyinfo->key_part[i].length, keyuse->val);
-        if (thd->is_fatal_error)
-          DBUG_RETURN(TRUE);
-        /* 
-          The constant is the value to look for with this key. Copy
-          the value to ref->key_buff
-        */
-        tmp.copy(); 
+      {
+        /* key is const, copy value now and possibly skip it while ::exec() */
+        enum store_key::store_key_result result= key->copy();
+
+        /* Depending on 'result' it should be reevaluated in ::exec(), if either:
+         *  1) '::copy()' failed, in case we reevaluate - and refail in 
+         *       JOIN::exec() where the error can be handled.
+         *  2)  Constant evaluated to NULL value which we might need to 
+         *      handle as a special case during JOIN::exec()
+         *      (As in : 'Full scan on NULL key')
+         */
+        if (result!=store_key::STORE_KEY_OK  ||    // 1)
+            key->null_key)                         // 2)
+        {
+	  *ref_key++= key;  // Reevaluate in JOIN::exec() 
+        }
       }
       /*
 	Remember if we are going to use REF_OR_NULL
@@ -9676,7 +9684,7 @@ static bool make_join_select(JOIN *join,
               !first_inner_tab)
           {
             Item *push_cond= 
-              make_cond_for_table(tmp, current_map, current_map, 0);
+              make_cond_for_table(tmp, tab->table->map, tab->table->map, 0);
             if (push_cond)
             {
               /* Push condition to handler */
@@ -17841,7 +17849,7 @@ join_read_const_table(JOIN_TAB *tab, POS
       /* Mark for EXPLAIN that the row was not found */
       pos->records_read=0.0;
       pos->ref_depend_map= 0;
-      if (!table->maybe_null || error > 0)
+      if (!table->pos_in_table_list->outer_join || error > 0)
 	DBUG_RETURN(error);
     }
   }
@@ -17862,7 +17870,7 @@ join_read_const_table(JOIN_TAB *tab, POS
       /* Mark for EXPLAIN that the row was not found */
       pos->records_read=0.0;
       pos->ref_depend_map= 0;
-      if (!table->maybe_null || error > 0)
+      if (!table->pos_in_table_list->outer_join || error > 0)
 	DBUG_RETURN(error);
     }
   }
@@ -19140,7 +19148,7 @@ make_cond_for_table_from_pred(Item *root
 	new_cond->argument_list()->push_back(fix);
       }
       /*
-	Item_cond_and do not need fix_fields for execution, its parameters
+	Item_cond_or do not need fix_fields for execution, its parameters
 	are fixed or do not need fix_fields, too
       */
       new_cond->quick_fix_field();

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2010-12-29 00:38:59 +0000
+++ b/sql/sql_select.h	2011-01-14 08:20:08 +0000
@@ -2168,9 +2168,8 @@ public:
   store_key_const_item(THD *thd, Field *to_field_arg, uchar *ptr,
 		       uchar *null_ptr_arg, uint length,
 		       Item *item_arg)
-    :store_key_item(thd, to_field_arg,ptr,
-		    null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
-		    &err : (uchar*) 0, length, item_arg), inited(0)
+    :store_key_item(thd, to_field_arg, ptr,
+                    null_ptr_arg, length, item_arg), inited(0)
   {
   }
   const char *name() const { return "const"; }
@@ -2178,27 +2177,13 @@ public:
 protected:  
   enum store_key_result copy_inner()
   {
-    int res;
     if (!inited)
     {
       inited=1;
-      TABLE *table= to_field->table;
-      my_bitmap_map *old_map= dbug_tmp_use_all_columns(table,
-                                                       table->write_set);
-      if ((res= item->save_in_field(to_field, 1)))
-      {       
-        if (!err)
-          err= res < 0 ? 1 : res; /* 1=STORE_KEY_FATAL */
-      }
-      /*
-        Item::save_in_field() may call Item::val_xxx(). And if this is a subquery
-        we need to check for errors executing it and react accordingly
-        */
-      if (!err && to_field->table->in_use->is_error())
-        err= 1; /* STORE_KEY_FATAL */
-      dbug_tmp_restore_column_map(table->write_set, old_map);
+      int res= store_key_item::copy_inner();
+      if (res && !err)
+        err= res;
     }
-    null_key= to_field->is_null() || item->null_value;
     return (err > 2 ? STORE_KEY_FATAL : (store_key_result) err);
   }
 };

=== modified file 'sql/sql_string.cc'
--- a/sql/sql_string.cc	2010-12-14 13:26:35 +0000
+++ b/sql/sql_string.cc	2011-01-13 08:19:52 +0000
@@ -51,11 +51,33 @@ bool String::real_alloc(uint32 length)
 }
 
 
-/*
-** Check that string is big enough. Set string[alloc_length] to 0
-** (for C functions)
-*/
+/**
+   Allocates a new buffer on the heap for this String.
+
+   - If the String's internal buffer is privately owned and heap allocated,
+     one of the following is performed.
+
+     - If the requested length is greater than what fits in the buffer, a new
+       buffer is allocated, data moved and the old buffer freed.
+
+     - If the requested length is less or equal to what fits in the buffer, a
+       null character is inserted at the appropriate position.
+
+   - If the String does not keep a private buffer on the heap, such a buffer
+     will be allocated and the string copied accoring to its length, as found
+     in String::length().
+ 
+   For C compatibility, the new string buffer is null terminated.
 
+   @param alloc_length The requested string size in characters, excluding any
+   null terminator.
+
+   @retval false Either the copy operation is complete or, if the size of the
+   new buffer is smaller than the currently allocated buffer (if one exists),
+   no allocation occured.
+
+   @retval true An error occured when attempting to allocate memory.
+*/
 bool String::realloc(uint32 alloc_length)
 {
   uint32 len=ALIGN_SIZE(alloc_length+1);
@@ -128,6 +150,17 @@ bool String::copy()
   return FALSE;
 }
 
+/**
+   Copies the internal buffer from str. If this String has a private heap
+   allocated buffer where new data does not fit, a new buffer is allocated
+   before copying and the old buffer freed. Character set information is also
+   copied.
+   
+   @param str The string whose internal buffer is to be copied.
+   
+   @retval false Success.
+   @retval true Memory allocation failed.
+*/
 bool String::copy(const String &str)
 {
   if (alloc(str.str_length))

=== modified file 'sql/sql_string.h'
--- a/sql/sql_string.h	2010-10-27 14:46:44 +0000
+++ b/sql/sql_string.h	2011-01-13 08:19:52 +0000
@@ -148,6 +148,16 @@ public:
       Alloced_length=0;
     str_charset=str.str_charset;
   }
+
+
+  /**
+     Points the internal buffer to the supplied one. The old buffer is freed.
+     @param str Pointer to the new buffer.
+     @param arg_length Length of the new buffer in characters, excluding any 
+            null character.
+     @param cs Character set to use for interpreting string data.
+     @note The new buffer will not be null terminated.
+  */
   inline void set(char *str,uint32 arg_length, CHARSET_INFO *cs)
   {
     free();

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2011-01-07 12:02:31 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2011-01-13 07:33:03 +0000
@@ -2251,8 +2251,6 @@ ha_innobase::reset_template(void)
 	/* Reset index condition pushdown state */
 	prebuilt->idx_cond = NULL;
 	prebuilt->idx_cond_n_cols = 0;
-	pushed_idx_cond = NULL;
-	pushed_idx_cond_keyno = MAX_KEY;
 }
 
 /*****************************************************************//**

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2011-01-11 09:09:21 +0000
+++ b/storage/myisam/ha_myisam.cc	2011-01-13 07:33:03 +0000
@@ -1818,8 +1818,9 @@ int ha_myisam::extra(enum ha_extra_funct
 
 int ha_myisam::reset(void)
 {
-  pushed_idx_cond= NULL;
-  pushed_idx_cond_keyno= MAX_KEY;
+  /* Reset MyISAM specific part for index condition pushdown */
+  DBUG_ASSERT(pushed_idx_cond == NULL);
+  DBUG_ASSERT(pushed_idx_cond_keyno == MAX_KEY);
   mi_set_index_cond_func(file, NULL, 0);
   ds_mrr.dsmrr_close();
   return mi_reset(file);

=== modified file 'strings/decimal.c'
--- a/strings/decimal.c	2010-07-20 19:30:10 +0000
+++ b/strings/decimal.c	2011-01-14 09:05:14 +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
@@ -13,8 +13,6 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#line 18 "decimal.c"
-
 /*
 =======================================================================
   NOTE: this library implements SQL standard "exact numeric" type

=== modified file 'unittest/gunit/CMakeLists.txt'
--- a/unittest/gunit/CMakeLists.txt	2010-12-17 09:41:21 +0000
+++ b/unittest/gunit/CMakeLists.txt	2011-01-14 09:29:11 +0000
@@ -212,6 +212,7 @@ SET(TESTS
   dbug
   mdl
   mdl_mytap
+  my_decimal
   my_regex
   sql_list
   thread_utils

=== added file 'unittest/gunit/my_decimal-t.cc'
--- a/unittest/gunit/my_decimal-t.cc	1970-01-01 00:00:00 +0000
+++ b/unittest/gunit/my_decimal-t.cc	2011-01-14 09:29:11 +0000
@@ -0,0 +1,57 @@
+/* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include "my_config.h"
+#include <gtest/gtest.h>
+
+#include <my_decimal.h>
+
+namespace {
+
+class DecimalTest : public ::testing::Test
+{
+protected:
+  my_decimal d1;
+  my_decimal d2;
+};
+
+TEST_F(DecimalTest, CopyAndCompare)
+{
+  ulonglong val= 42;
+  EXPECT_EQ(0, ulonglong2decimal(val, &d1));
+
+  d2= d1;                                       // operator=()
+  my_decimal d3(d1);                            // Copy constructor.
+
+  EXPECT_EQ(0, my_decimal_cmp(&d1, &d2));
+  EXPECT_EQ(0, my_decimal_cmp(&d2, &d3));
+  EXPECT_EQ(0, my_decimal_cmp(&d3, &d1));
+
+  ulonglong val1, val2, val3;
+  EXPECT_EQ(0, decimal2ulonglong(&d1, &val1));
+  EXPECT_EQ(0, decimal2ulonglong(&d2, &val2));
+  EXPECT_EQ(0, decimal2ulonglong(&d3, &val3));
+  EXPECT_EQ(val, val1);
+  EXPECT_EQ(val, val2);
+  EXPECT_EQ(val, val3);
+
+  // The CTOR/operator=() generated by the compiler would fail here:
+  val= 45;
+  EXPECT_EQ(0, ulonglong2decimal(val, &d1));
+  EXPECT_EQ(1, my_decimal_cmp(&d1, &d2));
+  EXPECT_EQ(1, my_decimal_cmp(&d1, &d3));
+}
+
+}

No bundle (reason: revision is a merge).
Thread
bzr commit into mysql-trunk-mtr branch (bjorn.munch:3007) Bjorn Munch17 Jan