List:Commits« Previous MessageNext Message »
From:Evgeny Potemkin Date:September 9 2010 6:21pm
Subject:bzr commit into mysql-next-mr-bugfixing branch (epotemkin:3240)
View as plain text  
#At file:///work/bzrroot/mysql-next-mr-opt-backporting/ based on revid:oystein.grovlen@stripped

 3240 Evgeny Potemkin	2010-09-09 [merge]
      Manual merge: next-mr-bugfixing => next-mr-opt-backporting.

    modified:
      client/mysqltest.cc
      cmake/dtrace.cmake
      libmysqld/lib_sql.cc
      mysql-test/include/default_mysqld.cnf
      mysql-test/r/explain.result
      mysql-test/r/func_time.result
      mysql-test/r/parser.result
      mysql-test/r/select_all.result
      mysql-test/r/select_all_jcl6.result
      mysql-test/r/select_icp_mrr.result
      mysql-test/r/select_icp_mrr_jcl6.result
      mysql-test/r/select_none.result
      mysql-test/r/select_none_jcl6.result
      mysql-test/r/strict.result
      mysql-test/r/type_datetime.result
      mysql-test/suite/perfschema/r/start_server_no_cond_class.result
      mysql-test/suite/perfschema/r/start_server_no_cond_inst.result
      mysql-test/suite/perfschema/r/start_server_no_file_class.result
      mysql-test/suite/perfschema/r/start_server_no_file_inst.result
      mysql-test/suite/perfschema/r/start_server_no_mutex_class.result
      mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result
      mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result
      mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result
      mysql-test/suite/perfschema/r/start_server_no_table_hdl.result
      mysql-test/suite/perfschema/r/start_server_no_table_inst.result
      mysql-test/suite/perfschema/r/start_server_no_thread_class.result
      mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
      mysql-test/suite/perfschema/r/start_server_off.result
      mysql-test/suite/perfschema/r/start_server_on.result
      mysql-test/suite/rpl/t/disabled.def
      mysql-test/t/disabled.def
      mysql-test/t/explain.test
      mysql-test/t/strict.test
      mysql-test/t/type_datetime.test
      mysys/my_gethwaddr.c
      mysys/my_sync.c
      sql/derror.cc
      sql/item_timefunc.cc
      sql/item_timefunc.h
      sql/mysqld.cc
      sql/opt_range.cc
      sql/set_var.cc
      sql/set_var.h
      sql/share/errmsg-utf8.txt
      sql/sql_select.cc
      sql/sys_vars.h
      storage/myisam/mi_rprev.c
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2010-08-27 13:00:00 +0000
+++ b/client/mysqltest.cc	2010-09-08 07:10:51 +0000
@@ -248,10 +248,14 @@ struct st_connection
   my_bool pending;
 
 #ifdef EMBEDDED_LIBRARY
+  pthread_t tid;
   const char *cur_query;
   int cur_query_len;
-  pthread_mutex_t mutex;
-  pthread_cond_t cond;
+  int command, result;
+  pthread_mutex_t query_mutex;
+  pthread_cond_t query_cond;
+  pthread_mutex_t result_mutex;
+  pthread_cond_t result_cond;
   int query_done;
 #endif /*EMBEDDED_LIBRARY*/
 };
@@ -703,67 +707,148 @@ void handle_no_error(struct st_command*)
 
 #ifdef EMBEDDED_LIBRARY
 
+#define EMB_SEND_QUERY 1
+#define EMB_READ_QUERY_RESULT 2
+#define EMB_END_CONNECTION 3
+
 /* attributes of the query thread */
 pthread_attr_t cn_thd_attrib;
 
+
 /*
-  send_one_query executes query in separate thread, which is
-  necessary in embedded library to run 'send' in proper way.
-  This implementation doesn't handle errors returned
-  by mysql_send_query. It's technically possible, though
-  I don't see where it is needed.
+  This procedure represents the connection and actually
+  runs queries when in the EMBEDDED-SERVER mode.
+  The run_query_normal() just sends request for running
+  mysql_send_query and mysql_read_query_result() here.
 */
-pthread_handler_t send_one_query(void *arg)
+
+pthread_handler_t connection_thread(void *arg)
 {
   struct st_connection *cn= (struct st_connection*)arg;
 
   mysql_thread_init();
-  (void) mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len);
+  while (cn->command != EMB_END_CONNECTION)
+  {
+    if (!cn->command)
+    {
+      pthread_mutex_lock(&cn->query_mutex);
+      while (!cn->command)
+        pthread_cond_wait(&cn->query_cond, &cn->query_mutex);
+      pthread_mutex_unlock(&cn->query_mutex);
+    }
+    switch (cn->command)
+    {
+      case EMB_END_CONNECTION:
+        goto end_thread;
+      case EMB_SEND_QUERY:
+        cn->result= mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len);
+        break;
+      case EMB_READ_QUERY_RESULT:
+        cn->result= mysql_read_query_result(&cn->mysql);
+        break;
+      default:
+        DBUG_ASSERT(0);
+    }
+    cn->command= 0;
+    pthread_mutex_lock(&cn->result_mutex);
+    cn->query_done= 1;
+    pthread_cond_signal(&cn->result_cond);
+    pthread_mutex_unlock(&cn->result_mutex);
+  }
 
-  mysql_thread_end();
-  pthread_mutex_lock(&cn->mutex);
+end_thread:
   cn->query_done= 1;
-  pthread_cond_signal(&cn->cond);
-  pthread_mutex_unlock(&cn->mutex);
+  mysql_thread_end();
   pthread_exit(0);
   return 0;
 }
 
-static int do_send_query(struct st_connection *cn, const char *q, int q_len,
-                         int flags)
+
+static void wait_query_thread_done(struct st_connection *con)
+{
+  DBUG_ASSERT(con->tid);
+  if (!con->query_done)
+  {
+    pthread_mutex_lock(&con->result_mutex);
+    while (!con->query_done)
+      pthread_cond_wait(&con->result_cond, &con->result_mutex);
+    pthread_mutex_unlock(&con->result_mutex);
+  }
+}
+
+
+static void signal_connection_thd(struct st_connection *cn, int command)
 {
-  pthread_t tid;
+  DBUG_ASSERT(cn->tid);
+  cn->query_done= 0;
+  cn->command= command;
+  pthread_mutex_lock(&cn->query_mutex);
+  pthread_cond_signal(&cn->query_cond);
+  pthread_mutex_unlock(&cn->query_mutex);
+}
 
-  if (flags & QUERY_REAP_FLAG)
-    return mysql_send_query(&cn->mysql, q, q_len);
 
-  if (pthread_mutex_init(&cn->mutex, NULL) ||
-      pthread_cond_init(&cn->cond, NULL))
-    die("Error in the thread library");
+/*
+  Sometimes we try to execute queries when the connection is closed.
+  It's done to make sure it was closed completely.
+  So that if our connection is closed (cn->tid == 0), we just return
+  the mysql_send_query() result which is an error in this case.
+*/
 
+static int do_send_query(struct st_connection *cn, const char *q, int q_len)
+{
+  if (!cn->tid)
+    return mysql_send_query(&cn->mysql, q, q_len);
   cn->cur_query= q;
   cn->cur_query_len= q_len;
-  cn->query_done= 0;
-  if (pthread_create(&tid, &cn_thd_attrib, send_one_query, (void*)cn))
-    die("Cannot start new thread for query");
-
+  signal_connection_thd(cn, EMB_SEND_QUERY);
   return 0;
 }
 
-static void wait_query_thread_end(struct st_connection *con)
+
+static int do_read_query_result(struct st_connection *cn)
 {
-  if (!con->query_done)
-  {
-    pthread_mutex_lock(&con->mutex);
-    while (!con->query_done)
-      pthread_cond_wait(&con->cond, &con->mutex);
-    pthread_mutex_unlock(&con->mutex);
-  }
+  DBUG_ASSERT(cn->tid);
+  wait_query_thread_done(cn);
+  signal_connection_thd(cn, EMB_READ_QUERY_RESULT);
+  wait_query_thread_done(cn);
+
+  return cn->result;
+}
+
+
+static void emb_close_connection(struct st_connection *cn)
+{
+  if (!cn->tid)
+    return;
+  wait_query_thread_done(cn);
+  signal_connection_thd(cn, EMB_END_CONNECTION);
+  pthread_join(cn->tid, NULL);
+  cn->tid= 0;
+  pthread_mutex_destroy(&cn->query_mutex);
+  pthread_cond_destroy(&cn->query_cond);
+  pthread_mutex_destroy(&cn->result_mutex);
+  pthread_cond_destroy(&cn->result_cond);
 }
 
+
+static void init_connection_thd(struct st_connection *cn)
+{
+  cn->query_done= 1;
+  cn->command= 0;
+  if (pthread_mutex_init(&cn->query_mutex, NULL) ||
+      pthread_cond_init(&cn->query_cond, NULL) ||
+      pthread_mutex_init(&cn->result_mutex, NULL) ||
+      pthread_cond_init(&cn->result_cond, NULL) ||
+      pthread_create(&cn->tid, &cn_thd_attrib, connection_thread, (void*)cn))
+    die("Error in the thread library");
+}
+
+
 #else /*EMBEDDED_LIBRARY*/
 
-#define do_send_query(cn,q,q_len,flags) mysql_send_query(&cn->mysql, q, q_len)
+#define do_send_query(cn,q,q_len) mysql_send_query(&cn->mysql, q, q_len)
+#define do_read_query_result(cn) mysql_read_query_result(&cn->mysql)
 
 #endif /*EMBEDDED_LIBRARY*/
 
@@ -1106,6 +1191,9 @@ void close_connections()
   DBUG_ENTER("close_connections");
   for (--next_con; next_con >= connections; --next_con)
   {
+#ifdef EMBEDDED_LIBRARY
+    emb_close_connection(next_con);
+#endif
     if (next_con->stmt)
       mysql_stmt_close(next_con->stmt);
     next_con->stmt= 0;
@@ -4868,7 +4956,7 @@ void do_close_connection(struct st_comma
     we need to check if the query's thread was finished and probably wait
     (embedded-server specific)
   */
-  wait_query_thread_end(con);
+  emb_close_connection(con);
 #endif /*EMBEDDED_LIBRARY*/
   if (con->stmt)
     mysql_stmt_close(con->stmt);
@@ -5218,8 +5306,9 @@ void do_connect(struct st_command *comma
   }
 
 #ifdef EMBEDDED_LIBRARY
-  con_slot->query_done= 1;
-#endif
+  init_connection_thd(con_slot);
+#endif /*EMBEDDED_LIBRARY*/
+
   if (!mysql_init(&con_slot->mysql))
     die("Failed on mysql_init()");
 
@@ -6770,21 +6859,13 @@ void run_query_normal(struct st_connecti
     /*
       Send the query
     */
-    if (do_send_query(cn, query, query_len, flags))
+    if (do_send_query(cn, query, query_len))
     {
       handle_error(command, mysql_errno(mysql), mysql_error(mysql),
 		   mysql_sqlstate(mysql), ds);
       goto end;
     }
   }
-#ifdef EMBEDDED_LIBRARY
-  /*
-    Here we handle 'reap' command, so we need to check if the
-    query's thread was finished and probably wait
-  */
-  else if (flags & QUERY_REAP_FLAG)
-    wait_query_thread_end(cn);
-#endif /*EMBEDDED_LIBRARY*/
   if (!(flags & QUERY_REAP_FLAG))
   {
     cn->pending= TRUE;
@@ -6797,7 +6878,7 @@ void run_query_normal(struct st_connecti
       When  on first result set, call mysql_read_query_result to retrieve
       answer to the query sent earlier
     */
-    if ((counter==0) && mysql_read_query_result(mysql))
+    if ((counter==0) && do_read_query_result(cn))
     {
       handle_error(command, mysql_errno(mysql), mysql_error(mysql),
 		   mysql_sqlstate(mysql), ds);
@@ -7975,6 +8056,9 @@ int main(int argc, char **argv)
     ps_protocol_enabled= 1;
 
   st_connection *con= connections;
+#ifdef EMBEDDED_LIBRARY
+  init_connection_thd(con);
+#endif /*EMBEDDED_LIBRARY*/
   if (!( mysql_init(&con->mysql)))
     die("Failed in mysql_init()");
   if (opt_connect_timeout)

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

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

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

=== modified file 'mysql-test/r/explain.result'
--- a/mysql-test/r/explain.result	2010-09-01 13:46:08 +0000
+++ b/mysql-test/r/explain.result	2010-09-09 18:21:34 +0000
@@ -324,4 +324,77 @@ id	select_type	table	type	possible_keys	
 25	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,...,25>	ALL	NULL	NULL	NULL	NULL	NULL	
 # End BUG#30597
+#
+# BUG#53562: EXPLAIN statement should hint when 
+#            index is not used due to type conversion
+#
+CREATE TABLE t1 (url char(1) PRIMARY KEY);
+INSERT INTO t1 VALUES ('1'),('2'),('3'),('4'),('5');
+
+# Normally, lookup access on primary key is done
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url='1';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t1	const	PRIMARY	PRIMARY	1	const	1	100.00	Using index
+Warnings:
+Note	1003	select '1' AS `url` from `test`.`t1` where 1
+
+# Test that index can't be used for lookup due to type conversion
+# (comparing char and int)
+SELECT * FROM t1 WHERE url=1;
+url
+1
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t1	index	PRIMARY	PRIMARY	1	NULL	5	100.00	Using where; Using index
+Warnings:
+Warning	1708	Cannot use ref access on index 'PRIMARY' due to type or collation conversion on field 'url'
+Warning	1708	Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
+Note	1003	select `test`.`t1`.`url` AS `url` from `test`.`t1` where (`test`.`t1`.`url` = 1)
+
+# Test that index can't be used for lookup due to collation mismatch
+SELECT * FROM t1 WHERE url='1' collate latin1_german2_ci;
+url
+1
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url='1' collate latin1_german2_ci;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t1	index	PRIMARY	PRIMARY	1	NULL	5	100.00	Using where; Using index
+Warnings:
+Warning	1708	Cannot use ref access on index 'PRIMARY' due to type or collation conversion on field 'url'
+Warning	1708	Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
+Note	1003	select `test`.`t1`.`url` AS `url` from `test`.`t1` where (`test`.`t1`.`url` = <cache>(('1' collate latin1_german2_ci)))
+
+# Normally, range access on primary key is done
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url>'3';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	1	NULL	3	100.00	Using where; Using index
+Warnings:
+Note	1003	select `test`.`t1`.`url` AS `url` from `test`.`t1` where (`test`.`t1`.`url` > '3')
+
+# Test that range access on index can't be done due to type conversion
+# (comparing char and int)
+SELECT * FROM t1 WHERE url>3;
+url
+4
+5
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url>3;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t1	index	PRIMARY	PRIMARY	1	NULL	5	100.00	Using where; Using index
+Warnings:
+Warning	1708	Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
+Note	1003	select `test`.`t1`.`url` AS `url` from `test`.`t1` where (`test`.`t1`.`url` > 3)
+
+# Test that range access on index can't be done due to collation mismatch
+SELECT * FROM t1 WHERE url>'3' collate latin1_german2_ci;
+url
+4
+5
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url>'3' collate latin1_german2_ci;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t1	index	PRIMARY	PRIMARY	1	NULL	5	100.00	Using where; Using index
+Warnings:
+Warning	1708	Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
+Note	1003	select `test`.`t1`.`url` AS `url` from `test`.`t1` where (`test`.`t1`.`url` > <cache>(('3' collate latin1_german2_ci)))
+
+DROP TABLE t1;
+# End BUG#53562
 End of 6.0 tests.

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

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

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

=== modified file 'mysql-test/r/select_all_jcl6.result'
--- a/mysql-test/r/select_all_jcl6.result	2010-09-01 13:46:08 +0000
+++ b/mysql-test/r/select_all_jcl6.result	2010-09-09 18:21:34 +0000
@@ -4176,9 +4176,10 @@ str_to_date('2007-10-00','%Y-%m-%d') bet
 set SQL_MODE=TRADITIONAL;
 select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
 str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
-0
+NULL
 Warnings:
 Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34'
+Warning	1411	Incorrect datetime value: '2007-10-00 12:34' for function str_to_date
 select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
 str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
 0
@@ -4186,17 +4187,16 @@ Warnings:
 Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34'
 select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
 str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'
-0
+NULL
 Warnings:
-Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34:00'
+Warning	1411	Incorrect datetime value: '2007-10-00 12:34' for function str_to_date
 select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
                                                 and '2007/10/20';
 str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
                                                 and '2007/10/20'
-0
+NULL
 Warnings:
-Warning	1292	Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1
-Warning	1292	Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1
+Warning	1411	Incorrect datetime value: '2007-10-00' for function str_to_date
 set SQL_MODE=DEFAULT;
 select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
 str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'

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

=== modified file 'mysql-test/r/select_icp_mrr_jcl6.result'
--- a/mysql-test/r/select_icp_mrr_jcl6.result	2010-09-01 13:46:08 +0000
+++ b/mysql-test/r/select_icp_mrr_jcl6.result	2010-09-09 18:21:34 +0000
@@ -4176,9 +4176,10 @@ str_to_date('2007-10-00','%Y-%m-%d') bet
 set SQL_MODE=TRADITIONAL;
 select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
 str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
-0
+NULL
 Warnings:
 Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34'
+Warning	1411	Incorrect datetime value: '2007-10-00 12:34' for function str_to_date
 select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
 str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
 0
@@ -4186,17 +4187,16 @@ Warnings:
 Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34'
 select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
 str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'
-0
+NULL
 Warnings:
-Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34:00'
+Warning	1411	Incorrect datetime value: '2007-10-00 12:34' for function str_to_date
 select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
                                                 and '2007/10/20';
 str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
                                                 and '2007/10/20'
-0
+NULL
 Warnings:
-Warning	1292	Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1
-Warning	1292	Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1
+Warning	1411	Incorrect datetime value: '2007-10-00' for function str_to_date
 set SQL_MODE=DEFAULT;
 select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
 str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'

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

=== modified file 'mysql-test/r/select_none_jcl6.result'
--- a/mysql-test/r/select_none_jcl6.result	2010-09-01 13:46:08 +0000
+++ b/mysql-test/r/select_none_jcl6.result	2010-09-09 18:21:34 +0000
@@ -4175,9 +4175,10 @@ str_to_date('2007-10-00','%Y-%m-%d') bet
 set SQL_MODE=TRADITIONAL;
 select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
 str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
-0
+NULL
 Warnings:
 Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34'
+Warning	1411	Incorrect datetime value: '2007-10-00 12:34' for function str_to_date
 select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
 str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
 0
@@ -4185,17 +4186,16 @@ Warnings:
 Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34'
 select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
 str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'
-0
+NULL
 Warnings:
-Warning	1292	Truncated incorrect datetime value: '2007-10-00 12:34:00'
+Warning	1411	Incorrect datetime value: '2007-10-00 12:34' for function str_to_date
 select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
                                                 and '2007/10/20';
 str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
                                                 and '2007/10/20'
-0
+NULL
 Warnings:
-Warning	1292	Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1
-Warning	1292	Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1
+Warning	1411	Incorrect datetime value: '2007-10-00' for function str_to_date
 set SQL_MODE=DEFAULT;
 select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
 str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def	2010-09-06 10:54:47 +0000
+++ b/mysql-test/t/disabled.def	2010-09-09 18:21:34 +0000
@@ -14,9 +14,6 @@ lowercase_table3         : Bug#54845 201
 mysqlhotcopy_myisam      : Bug#54129 2010-08-31 alik mysqlhotcopy* fails
 mysqlhotcopy_archive     : Bug#54129 2010-08-31 alik mysqlhotcopy* fails
 partition_innodb_plugin  : Bug#53307 2010-04-30 VasilDimov valgrind warnings
-plugin                   : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
-plugin_load              : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
-plugin_not_embedded      : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
 query_cache_28249        : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
 sp_sync                  : Bug#48157 2010-02-06 5.5-m3 demands a differnt solution
 ctype_utf8mb4_ndb	: Bug#55799, Bug#51907, disabled by Konstantin 2010-08-06

=== modified file 'mysql-test/t/explain.test'
--- a/mysql-test/t/explain.test	2010-08-26 12:02:59 +0000
+++ b/mysql-test/t/explain.test	2010-09-09 10:58:40 +0000
@@ -279,4 +279,43 @@ EXPLAIN
 
 --echo # End BUG#30597
 
+--echo #
+--echo # BUG#53562: EXPLAIN statement should hint when 
+--echo #            index is not used due to type conversion
+--echo #
+
+CREATE TABLE t1 (url char(1) PRIMARY KEY);
+INSERT INTO t1 VALUES ('1'),('2'),('3'),('4'),('5');       
+
+--echo
+--echo # Normally, lookup access on primary key is done
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url='1';
+--echo
+--echo # Test that index can't be used for lookup due to type conversion
+--echo # (comparing char and int)
+SELECT * FROM t1 WHERE url=1;
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url=1;
+--echo
+--echo # Test that index can't be used for lookup due to collation mismatch
+SELECT * FROM t1 WHERE url='1' collate latin1_german2_ci;
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url='1' collate latin1_german2_ci;
+
+--echo
+--echo # Normally, range access on primary key is done
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url>'3';
+--echo
+--echo # Test that range access on index can't be done due to type conversion
+--echo # (comparing char and int)
+SELECT * FROM t1 WHERE url>3;
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url>3;
+--echo
+--echo # Test that range access on index can't be done due to collation mismatch
+SELECT * FROM t1 WHERE url>'3' collate latin1_german2_ci;
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE url>'3' collate latin1_german2_ci;
+
+--echo
+DROP TABLE t1;
+
+--echo # End BUG#53562
+
 --echo End of 6.0 tests.

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

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

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

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

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

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

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

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-09-01 13:06:14 +0000
+++ b/sql/mysqld.cc	2010-09-08 07:10:51 +0000
@@ -1486,6 +1486,7 @@ void clean_up(bool print_message)
   cleanup_errmsgs();
   MYSQL_CALLBACK(thread_scheduler, end, ());
   finish_client_errs();
+  (void) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); // finish server errs
   DBUG_PRINT("quit", ("Error messages freed"));
   /* Tell main we are ready */
   logger.cleanup_end();

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2010-08-26 14:32:33 +0000
+++ b/sql/opt_range.cc	2010-09-09 10:58:40 +0000
@@ -5772,7 +5772,18 @@ get_mm_leaf(RANGE_OPT_PARAM *param, Item
       ((Field_str*)field)->charset() != conf_func->compare_collation() &&
       !(conf_func->compare_collation()->state & MY_CS_BINSORT &&
         (type == Item_func::EQUAL_FUNC || type == Item_func::EQ_FUNC)))
+  {
+    if (param->thd->lex->describe & DESCRIBE_EXTENDED)
+      push_warning_printf(
+              param->thd,
+              MYSQL_ERROR::WARN_LEVEL_WARN, 
+              ER_WARN_INDEX_NOT_APPLICABLE,
+              ER(ER_WARN_INDEX_NOT_APPLICABLE),
+              "range",
+              field->table->key_info[param->real_keynr[key_part->key]].name,
+              field->field_name);
     goto end;
+  }
 
   if (key_part->image_type == Field::itMBR)
   {
@@ -5893,7 +5904,18 @@ get_mm_leaf(RANGE_OPT_PARAM *param, Item
   if (field->result_type() == STRING_RESULT &&
       value->result_type() != STRING_RESULT &&
       field->cmp_type() != value->result_type())
+  {
+    if (param->thd->lex->describe & DESCRIBE_EXTENDED)
+      push_warning_printf(
+              param->thd,
+              MYSQL_ERROR::WARN_LEVEL_WARN, 
+              ER_WARN_INDEX_NOT_APPLICABLE,
+              ER(ER_WARN_INDEX_NOT_APPLICABLE),
+              "range",
+              field->table->key_info[param->real_keynr[key_part->key]].name,
+              field->field_name);
     goto end;
+  }
   /* For comparison purposes allow invalid dates like 2000-01-32 */
   orig_sql_mode= field->table->in_use->variables.sql_mode;
   if (value->real_item()->type() == Item::STRING_ITEM &&

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

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

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2010-07-29 14:15:38 +0000
+++ b/sql/share/errmsg-utf8.txt	2010-09-09 10:58:40 +0000
@@ -6387,3 +6387,5 @@ ER_TABLES_DIFFERENT_METADATA
 ER_ROW_DOES_NOT_MATCH_PARTITION
   eng "Found row that does not match the partition"
   swe "Hittade rad som inte passar i partitionen"
+ER_WARN_INDEX_NOT_APPLICABLE
+  eng "Cannot use %-.64s access on index '%-.64s' due to type or collation conversion on field '%-.64s'"

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-09-08 08:19:03 +0000
+++ b/sql/sql_select.cc	2010-09-09 18:21:34 +0000
@@ -5307,6 +5307,46 @@ static uint get_semi_join_select_list_in
 }
 
 /**
+   @brief 
+   If EXPLAIN EXTENDED, add warning that an index cannot be used for
+   ref access
+
+   @details
+   If EXPLAIN EXTENDED, add a warning for each index that cannot be
+   used for ref access due to either type conversion or different
+   collations on the field used for comparison
+
+   Example type conversion (char compared to int):
+
+   CREATE TABLE t1 (url char(1) PRIMARY KEY);
+   SELECT * FROM t1 WHERE url=1;
+
+   Example different collations (danish vs german2):
+
+   CREATE TABLE t1 (url char(1) PRIMARY KEY) collate latin1_danish_ci;
+   SELECT * FROM t1 WHERE url='1' collate latin1_german2_ci;
+
+   @param thd                Thread for the connection that submitted the query
+   @param field              Field used in comparision
+   @param cant_use_indexes   Indexes that cannot be used for lookup
+ */
+static void 
+warn_index_not_applicable(THD *thd, const Field *field, 
+                          const key_map cant_use_index) 
+{
+  if (thd->lex->describe & DESCRIBE_EXTENDED)
+    for (uint j=0 ; j < field->table->s->keys ; j++)
+      if (cant_use_index.is_set(j))
+        push_warning_printf(thd,
+                            MYSQL_ERROR::WARN_LEVEL_WARN, 
+                            ER_WARN_INDEX_NOT_APPLICABLE,
+                            ER(ER_WARN_INDEX_NOT_APPLICABLE),
+                            "ref",
+                            field->table->key_info[j].name,
+                            field->field_name);
+}
+
+/**
   Add a possible key to array of possible keys if it's usable as a key
 
     @param key_fields      Pointer to add key, if usable
@@ -5331,6 +5371,7 @@ add_key_field(KEY_FIELD **key_fields,uin
               Field *field, bool eq_func, Item **value, uint num_values,
               table_map usable_tables, SARGABLE_PARAM **sargables)
 {
+  DBUG_PRINT("info",("add_key_field for field %s",field->field_name));
   uint exists_optimize= 0;
   if (!(field->flags & PART_KEY_FLAG))
   {
@@ -5432,7 +5473,10 @@ add_key_field(KEY_FIELD **key_fields,uin
         if ((*value)->result_type() != STRING_RESULT)
         {
           if (field->cmp_type() != (*value)->result_type())
+          {
+            warn_index_not_applicable(stat->join->thd, field, possible_keys);
             return;
+          }
         }
         else
         {
@@ -5442,7 +5486,10 @@ add_key_field(KEY_FIELD **key_fields,uin
           */
           if (field->cmp_type() == STRING_RESULT &&
               ((Field_str*)field)->charset() != cond->compare_collation())
+          {
+            warn_index_not_applicable(stat->join->thd, field, possible_keys);
             return;
+          }
         }
       }
     }

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

=== modified file 'storage/myisam/mi_rprev.c'
--- a/storage/myisam/mi_rprev.c	2010-05-07 08:04:15 +0000
+++ b/storage/myisam/mi_rprev.c	2010-09-03 01:38:27 +0000
@@ -72,7 +72,7 @@ int mi_rprev(MI_INFO *info, uchar *buf, 
     if (!error && res == 2) 
     {
       if (share->concurrent_insert)
-        rw_unlock(&share->key_root_lock[inx]);
+        mysql_rwlock_unlock(&share->key_root_lock[inx]);
       info->lastpos= HA_OFFSET_ERROR;
       DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
     }


Attachment: [text/bzr-bundle] bzr/epotemkin@mysql.com-20100909182134-vysl7t8uj4g4z0bb.bundle
Thread
bzr commit into mysql-next-mr-bugfixing branch (epotemkin:3240)Evgeny Potemkin9 Sep