List:Commits« Previous MessageNext Message »
From:Evgeny Potemkin Date:September 9 2010 10:55am
Subject:bzr commit into mysql-next-mr-opt-team branch (epotemkin:3215)
View as plain text  
#At file:///work/bzrroot/mysql-next-mr-opt-team/ based on revid:epotemkin@stripped29-sj84ub4lidcznarf

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

    added:

      include/mysql/service_thd_wait.h
      include/mysql/service_thread_scheduler.h
      libservices/my_thread_scheduler_service.c
      libservices/thd_wait_service.c
      mysql-test/include/ctype_filesort2.inc
      mysql-test/include/have_binlog_rows_query.inc
      mysql-test/include/not_blackhole.inc
      mysql-test/r/have_binlog_rows_query.require
      mysql-test/r/partition_not_blackhole.result
      mysql-test/std_data/parts/t1_blackhole.frm
      mysql-test/std_data/parts/t1_blackhole.par
      mysql-test/suite/rpl/r/rpl_row_ignorable_event.result
      mysql-test/suite/rpl/t/rpl_row_ignorable_event-master.opt
      mysql-test/suite/rpl/t/rpl_row_ignorable_event-slave.opt
      mysql-test/suite/rpl/t/rpl_row_ignorable_event.test
      mysql-test/suite/sys_vars/r/binlog_rows_query_log_events_basic.result
      mysql-test/suite/sys_vars/t/binlog_rows_query_log_events_basic.test
      mysql-test/t/partition_not_blackhole-master.opt
      mysql-test/t/partition_not_blackhole.test
      sql/sql_callback.h
    modified:
      client/mysqlbinlog.cc
      client/mysqldump.c
      client/mysqltest.cc
      include/Makefile.am
      include/m_ctype.h
      include/mysql/plugin.h
      include/mysql/plugin_audit.h.pp
      include/mysql/plugin_ftparser.h.pp
      include/mysql/services.h
      include/service_versions.h
      include/thr_lock.h
      include/violite.h
      libmysqld/Makefile.am
      libservices/CMakeLists.txt
      libservices/Makefile.am
      mysql-test/CMakeLists.txt
      mysql-test/collections/default.experimental
      mysql-test/extra/binlog_tests/binlog_insert_delayed.test
      mysql-test/extra/rpl_tests/create_recursive_construct.inc
      mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test
      mysql-test/include/mtr_warnings.sql
      mysql-test/include/range.inc
      mysql-test/include/show_binlog_events2.inc
      mysql-test/r/alter_table.result
      mysql-test/r/archive.result
      mysql-test/r/bootstrap.result
      mysql-test/r/create.result
      mysql-test/r/csv.result
      mysql-test/r/ctype_errors.result
      mysql-test/r/ctype_tis620.result
      mysql-test/r/ctype_ujis.result
      mysql-test/r/ctype_utf16.result
      mysql-test/r/ctype_utf32.result
      mysql-test/r/ctype_utf8.result
      mysql-test/r/ctype_utf8mb4.result
      mysql-test/r/ctype_utf8mb4_heap.result
      mysql-test/r/ctype_utf8mb4_innodb.result
      mysql-test/r/ctype_utf8mb4_myisam.result
      mysql-test/r/delete.result
      mysql-test/r/drop.result
      mysql-test/r/error_simulation.result
      mysql-test/r/func_gconcat.result
      mysql-test/r/func_group.result
      mysql-test/r/func_misc.result
      mysql-test/r/func_time.result
      mysql-test/r/gis-rtree.result
      mysql-test/r/grant.result
      mysql-test/r/handler_innodb.result
      mysql-test/r/handler_myisam.result
      mysql-test/r/key.result
      mysql-test/r/log_tables.result
      mysql-test/r/mdl_sync.result
      mysql-test/r/myisam-system.result
      mysql-test/r/myisam.result
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/r/mysqldump.result
      mysql-test/r/partition.result
      mysql-test/r/partition_disabled.result
      mysql-test/r/partition_error.result
      mysql-test/r/profiling.result
      mysql-test/r/ps.result
      mysql-test/r/ps_1general.result
      mysql-test/r/ps_ddl1.result
      mysql-test/r/range_all.result
      mysql-test/r/range_icp.result
      mysql-test/r/range_icp_mrr.result
      mysql-test/r/range_mrr.result
      mysql-test/r/range_none.result
      mysql-test/r/read_only.result
      mysql-test/r/rename.result
      mysql-test/r/signal.result
      mysql-test/r/signal_demo2.result
      mysql-test/r/signal_demo3.result
      mysql-test/r/sp-dynamic.result
      mysql-test/r/sp-error.result
      mysql-test/r/sp-prelocking.result
      mysql-test/r/sp-vars.result
      mysql-test/r/sp.result
      mysql-test/r/subquery_sj_all.result
      mysql-test/r/subquery_sj_all_jcl6.result
      mysql-test/r/subquery_sj_all_jcl7.result
      mysql-test/r/subquery_sj_dupsweed.result
      mysql-test/r/subquery_sj_dupsweed_jcl6.result
      mysql-test/r/subquery_sj_dupsweed_jcl7.result
      mysql-test/r/subquery_sj_firstmatch.result
      mysql-test/r/subquery_sj_firstmatch_jcl6.result
      mysql-test/r/subquery_sj_firstmatch_jcl7.result
      mysql-test/r/subquery_sj_loosescan.result
      mysql-test/r/subquery_sj_loosescan_jcl6.result
      mysql-test/r/subquery_sj_loosescan_jcl7.result
      mysql-test/r/subquery_sj_mat.result
      mysql-test/r/subquery_sj_mat_jcl6.result
      mysql-test/r/subquery_sj_mat_jcl7.result
      mysql-test/r/temp_table.result
      mysql-test/r/truncate_coverage.result
      mysql-test/r/type_newdecimal.result
      mysql-test/r/view.result
      mysql-test/r/warnings.result
      mysql-test/suite/binlog/r/binlog_row_binlog.result
      mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
      mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result
      mysql-test/suite/binlog/r/binlog_stm_binlog.result
      mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
      mysql-test/suite/binlog/r/binlog_unsafe.result
      mysql-test/suite/binlog/t/binlog_incident.test
      mysql-test/suite/binlog/t/binlog_unsafe.test
      mysql-test/suite/federated/federated.result
      mysql-test/suite/federated/federated_server.result
      mysql-test/suite/funcs_1/r/innodb_trig_0102.result
      mysql-test/suite/funcs_1/r/innodb_views.result
      mysql-test/suite/funcs_1/r/memory_trig_0102.result
      mysql-test/suite/funcs_1/r/memory_views.result
      mysql-test/suite/funcs_1/r/myisam_trig_0102.result
      mysql-test/suite/funcs_1/r/myisam_views.result
      mysql-test/suite/funcs_1/r/storedproc.result
      mysql-test/suite/innodb/r/innodb-autoinc.result
      mysql-test/suite/innodb/r/innodb.result
      mysql-test/suite/innodb/r/innodb_mysql.result
      mysql-test/suite/innodb/t/innodb_mysql.test
      mysql-test/suite/parts/r/part_ctype_utf32.result
      mysql-test/suite/perfschema/r/privilege_table_io.result
      mysql-test/suite/rpl/r/rpl000013.result
      mysql-test/suite/rpl/r/rpl_drop.result
      mysql-test/suite/rpl/r/rpl_drop_temp.result
      mysql-test/suite/rpl/r/rpl_drop_view.result
      mysql-test/suite/rpl/r/rpl_extraCol_innodb.result
      mysql-test/suite/rpl/r/rpl_extraCol_myisam.result
      mysql-test/suite/rpl/r/rpl_flush_logs.result
      mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result
      mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result
      mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result
      mysql-test/suite/rpl/r/rpl_multi_update3.result
      mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result
      mysql-test/suite/rpl/r/rpl_row_colSize.result
      mysql-test/suite/rpl/r/rpl_row_conflicts.result
      mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result
      mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result
      mysql-test/suite/rpl/r/rpl_session_var.result
      mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result
      mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result
      mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result
      mysql-test/suite/rpl/r/rpl_stm_no_op.result
      mysql-test/suite/rpl/r/rpl_stm_until.result
      mysql-test/suite/rpl/r/rpl_temp_table.result
      mysql-test/suite/rpl/t/rpl_delayed_slave.test
      mysql-test/suite/rpl/t/rpl_drop.test
      mysql-test/suite/rpl/t/rpl_flush_logs.test
      mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test
      mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test
      mysql-test/suite/rpl_ndb/r/rpl_ndb_multi.result
      mysql-test/suite/sys_vars/r/slow_query_log_func.result
      mysql-test/suite/sys_vars/r/sql_notes_func.result
      mysql-test/t/ctype_utf16.test
      mysql-test/t/ctype_utf32.test
      mysql-test/t/ctype_utf8mb4.test
      mysql-test/t/delete.test
      mysql-test/t/disabled.def
      mysql-test/t/drop.test
      mysql-test/t/func_gconcat.test
      mysql-test/t/func_group.test
      mysql-test/t/func_misc.test
      mysql-test/t/func_time.test
      mysys/my_getopt.c
      mysys/my_init.c
      mysys/thr_lock.c
      sql/CMakeLists.txt
      sql/authors.h
      sql/binlog.cc
      sql/binlog.h
      sql/ha_partition.cc
      sql/handler.cc
      sql/item_func.cc
      sql/item_sum.cc
      sql/item_sum.h
      sql/log.cc
      sql/log_event.cc
      sql/log_event.h
      sql/mysqld.cc
      sql/mysqld.h
      sql/opt_range.cc
      sql/rpl_injector.cc
      sql/rpl_rli.cc
      sql/rpl_rli.h
      sql/rpl_slave.cc
      sql/scheduler.cc
      sql/scheduler.h
      sql/sql_admin.cc
      sql/sql_base.cc
      sql/sql_binlog.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_connect.cc
      sql/sql_connect.h
      sql/sql_insert.cc
      sql/sql_join_cache.cc
      sql/sql_lex.h
      sql/sql_plugin_services.h
      sql/sql_select.cc
      sql/sql_select.h
      sql/sql_show.cc
      sql/sql_table.cc
      sql/sql_test.cc
      sql/sql_view.cc
      sql/sql_yacc.yy
      sql/sys_vars.cc
      sql/table.h
      storage/innobase/buf/buf0flu.c
      storage/innobase/buf/buf0rea.c
      storage/innobase/srv/srv0srv.c
      strings/ctype-ucs2.c
      strings/ctype-utf8.c
      vio/vio.c
      vio/vio_priv.h
      vio/viosocket.c
      vio/viossl.c
=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2010-08-06 08:54:01 +0000
+++ b/client/mysqlbinlog.cc	2010-09-01 02:51:08 +0000
@@ -895,6 +895,10 @@ Exit_status process_event(PRINT_EVENT_IN
 	my_free(fname);
       break;
     }
+    case ROWS_QUERY_LOG_EVENT:
+      if (verbose >= 2)
+        ev->print(result_file, print_event_info);
+      break;
     case TABLE_MAP_EVENT:
     {
       Table_map_log_event *map= ((Table_map_log_event *)ev);

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

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2010-08-16 07:30:40 +0000
+++ b/client/mysqltest.cc	2010-08-27 13:00:00 +0000
@@ -6230,8 +6230,10 @@ get_one_option(int optid, const struct m
     print_version();
     exit(0);
   case OPT_MYSQL_PROTOCOL:
+#ifndef EMBEDDED_LIBRARY
     opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
                                     opt->name);
+#endif
     break;
   case '?':
     usage();

=== modified file 'include/Makefile.am'
--- a/include/Makefile.am	2010-07-29 13:37:49 +0000
+++ b/include/Makefile.am	2010-09-01 13:05:01 +0000
@@ -26,6 +26,8 @@ HEADERS_ABI =		mysql.h mysql_com.h mysql
 pkginclude_HEADERS =	$(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
 			my_xml.h mysql_embed.h mysql/services.h \
 			mysql/service_my_snprintf.h mysql/service_thd_alloc.h \
+			mysql/service_thread_scheduler.h \
+			mysql/service_thd_wait.h \
 		  	my_pthread.h my_no_pthread.h \
 			decimal.h errmsg.h my_global.h my_net.h \
 			my_getopt.h sslopt-longopts.h my_dir.h \

=== modified file 'include/m_ctype.h'
--- a/include/m_ctype.h	2010-06-25 12:00:49 +0000
+++ b/include/m_ctype.h	2010-09-01 06:35:04 +0000
@@ -628,6 +628,11 @@ size_t my_strnxfrm_unicode(CHARSET_INFO 
                            uchar *dst, size_t dstlen, uint nweights,
                            const uchar *src, size_t srclen, uint flags);
 
+size_t my_strnxfrm_unicode_full_bin(CHARSET_INFO *,
+                                    uchar *dst, size_t dstlen, uint nweights,
+                                    const uchar *src, size_t srclen, uint flags);
+size_t  my_strnxfrmlen_unicode_full_bin(CHARSET_INFO *, size_t); 
+
 int my_wildcmp_unicode(CHARSET_INFO *cs,
                        const char *str, const char *str_end,
                        const char *wildstr, const char *wildend,

=== modified file 'include/mysql/plugin.h'
--- a/include/mysql/plugin.h	2010-08-18 08:14:49 +0000
+++ b/include/mysql/plugin.h	2010-09-01 13:06:14 +0000
@@ -71,7 +71,7 @@ typedef struct st_mysql_xid MYSQL_XID;
   Plugin API. Common for all plugin types.
 */
 
-#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0101
+#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0102
 
 /*
   The allowable types of plugins

=== modified file 'include/mysql/plugin_audit.h.pp'
--- a/include/mysql/plugin_audit.h.pp	2010-08-27 06:45:35 +0000
+++ b/include/mysql/plugin_audit.h.pp	2010-08-30 14:07:40 +0000
@@ -31,6 +31,27 @@ void *thd_memdup(void* thd, const void* 
 MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
                                       const char *str, unsigned int size,
                                       int allocate_lex_string);
+#include <mysql/service_thd_wait.h>
+typedef enum _thd_wait_type_e {
+  THD_WAIT_MUTEX= 1,
+  THD_WAIT_DISKIO= 2,
+  THD_WAIT_ROW_TABLE_LOCK= 3,
+  THD_WAIT_GLOBAL_LOCK= 4
+} thd_wait_type;
+extern struct thd_wait_service_st {
+  void (*thd_wait_begin_func)(void*, thd_wait_type);
+  void (*thd_wait_end_func)(void*);
+} *thd_wait_service;
+void thd_wait_begin(void* thd, thd_wait_type wait_type);
+void thd_wait_end(void* thd);
+#include <mysql/service_thread_scheduler.h>
+struct scheduler_functions;
+extern struct my_thread_scheduler_service {
+  int (*set)(struct scheduler_functions *scheduler);
+  int (*reset)();
+} *my_thread_scheduler_service;
+int my_thread_scheduler_set(struct scheduler_functions *scheduler);
+int my_thread_scheduler_reset();
 struct st_mysql_xid {
   long formatID;
   long gtrid_length;

=== modified file 'include/mysql/plugin_ftparser.h.pp'
--- a/include/mysql/plugin_ftparser.h.pp	2010-08-27 06:45:35 +0000
+++ b/include/mysql/plugin_ftparser.h.pp	2010-08-30 14:07:40 +0000
@@ -31,6 +31,27 @@ void *thd_memdup(void* thd, const void* 
 MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
                                       const char *str, unsigned int size,
                                       int allocate_lex_string);
+#include <mysql/service_thd_wait.h>
+typedef enum _thd_wait_type_e {
+  THD_WAIT_MUTEX= 1,
+  THD_WAIT_DISKIO= 2,
+  THD_WAIT_ROW_TABLE_LOCK= 3,
+  THD_WAIT_GLOBAL_LOCK= 4
+} thd_wait_type;
+extern struct thd_wait_service_st {
+  void (*thd_wait_begin_func)(void*, thd_wait_type);
+  void (*thd_wait_end_func)(void*);
+} *thd_wait_service;
+void thd_wait_begin(void* thd, thd_wait_type wait_type);
+void thd_wait_end(void* thd);
+#include <mysql/service_thread_scheduler.h>
+struct scheduler_functions;
+extern struct my_thread_scheduler_service {
+  int (*set)(struct scheduler_functions *scheduler);
+  int (*reset)();
+} *my_thread_scheduler_service;
+int my_thread_scheduler_set(struct scheduler_functions *scheduler);
+int my_thread_scheduler_reset();
 struct st_mysql_xid {
   long formatID;
   long gtrid_length;

=== added file 'include/mysql/service_thd_wait.h'
--- a/include/mysql/service_thd_wait.h	1970-01-01 00:00:00 +0000
+++ b/include/mysql/service_thd_wait.h	2010-06-07 14:01:39 +0000
@@ -0,0 +1,83 @@
+/* Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifndef MYSQL_SERVICE_THD_WAIT_INCLUDED
+#define MYSQL_SERVICE_THD_WAIT_INCLUDED
+
+/**
+  @file include/mysql/service_thd_wait.h
+  This service provides functions for plugins and storage engines to report
+  when they are going to sleep/stall.
+  
+  SYNOPSIS
+  thd_wait_begin() - call just before a wait begins
+  thd                     Thread object
+                          Use NULL if the thd is NOT known.
+  wait_type               Type of wait
+                          1 -- short wait (e.g. for mutex)
+                          2 -- medium wait (e.g. for disk io)
+                          3 -- large wait (e.g. for locked row/table)
+  NOTES
+    This is used by the threadpool to have better knowledge of which
+    threads that currently are actively running on CPUs. When a thread
+    reports that it's going to sleep/stall, the threadpool scheduler is
+    free to start another thread in the pool most likely. The expected wait
+    time is simply an indication of how long the wait is expected to
+    become, the real wait time could be very different.
+
+  thd_wait_end() called immediately after the wait is complete
+
+  thd_wait_end() MUST be called if thd_wait_begin() was called.
+
+  Using thd_wait_...() service is optional but recommended.  Using it will
+  improve performance as the thread pool will be more active at managing the
+  thread workload.
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum _thd_wait_type_e {
+  THD_WAIT_MUTEX= 1,
+  THD_WAIT_DISKIO= 2,
+  THD_WAIT_ROW_TABLE_LOCK= 3,
+  THD_WAIT_GLOBAL_LOCK= 4
+} thd_wait_type;
+
+extern struct thd_wait_service_st {
+  void (*thd_wait_begin_func)(MYSQL_THD, thd_wait_type);
+  void (*thd_wait_end_func)(MYSQL_THD);
+} *thd_wait_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+
+#define thd_wait_begin(_THD, _WAIT_TYPE) \
+  thd_wait_service->thd_wait_begin_func(_THD, _WAIT_TYPE)
+#define thd_wait_end(_THD) thd_wait_service->thd_wait_end_func(_THD)
+
+#else
+
+void thd_wait_begin(MYSQL_THD thd, thd_wait_type wait_type);
+void thd_wait_end(MYSQL_THD thd);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+

=== added file 'include/mysql/service_thread_scheduler.h'
--- a/include/mysql/service_thread_scheduler.h	1970-01-01 00:00:00 +0000
+++ b/include/mysql/service_thread_scheduler.h	2010-06-07 14:01:39 +0000
@@ -0,0 +1,65 @@
+/*
+  Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#ifndef SERVICE_THREAD_SCHEDULER_INCLUDED
+#define SERVICE_THREAD_SCHEDULER_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct scheduler_functions;
+
+extern struct my_thread_scheduler_service {
+  int (*set)(struct scheduler_functions *scheduler);
+  int (*reset)();
+} *my_thread_scheduler_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+
+#define my_thread_scheduler_set(F) my_thread_scheduler_service->set((F))
+#define my_thread_scheduler_reset() my_thread_scheduler_service->reset()
+
+#else
+
+/**
+  Set the thread scheduler to use for the server.
+
+  @param scheduler Pointer to scheduler callbacks to use.
+  @retval 0 Scheduler installed correctly.
+  @retval 1 Invalid value (NULL) used for scheduler.
+*/
+int my_thread_scheduler_set(struct scheduler_functions *scheduler);
+
+/**
+  Restore the previous thread scheduler.
+
+  @note If no thread scheduler was installed previously with
+  thd_set_thread_scheduler, this function will report an error.
+
+  @retval 0 Scheduler installed correctly.
+  @retval 1 No scheduler installed.
+*/
+int my_thread_scheduler_reset();
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SERVICE_THREAD_SCHEDULER_INCLUDED */

=== modified file 'include/mysql/services.h'
--- a/include/mysql/services.h	2009-11-02 20:05:42 +0000
+++ b/include/mysql/services.h	2010-06-07 14:01:39 +0000
@@ -20,6 +20,8 @@ extern "C" {
 
 #include <mysql/service_my_snprintf.h>
 #include <mysql/service_thd_alloc.h>
+#include <mysql/service_thd_wait.h>
+#include <mysql/service_thread_scheduler.h>
 
 #ifdef __cplusplus
 }

=== modified file 'include/service_versions.h'
--- a/include/service_versions.h	2009-11-02 20:05:42 +0000
+++ b/include/service_versions.h	2010-06-07 14:01:39 +0000
@@ -21,4 +21,5 @@
 
 #define VERSION_my_snprintf     0x0100
 #define VERSION_thd_alloc       0x0100
-
+#define VERSION_thd_wait        0x0100
+#define VERSION_my_thread_scheduler 0x0100

=== modified file 'include/thr_lock.h'
--- a/include/thr_lock.h	2010-07-27 12:42:36 +0000
+++ b/include/thr_lock.h	2010-08-16 12:50:27 +0000
@@ -155,6 +155,8 @@ void    thr_downgrade_write_lock(THR_LOC
                                  enum thr_lock_type new_lock_type);
 my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data,
                                   ulong lock_wait_timeout);
+void thr_set_lock_wait_callback(void (*before_wait)(void),
+                                void (*after_wait)(void));
 #ifdef	__cplusplus
 }
 #endif

=== modified file 'include/violite.h'
--- a/include/violite.h	2010-04-13 15:04:45 +0000
+++ b/include/violite.h	2010-06-07 14:01:39 +0000
@@ -217,6 +217,7 @@ struct st_vio
   void	  (*timeout)(Vio*, unsigned int which, unsigned int timeout);
   my_bool (*poll_read)(Vio *vio, uint timeout);
   my_bool (*is_connected)(Vio*);
+  my_bool (*has_data) (Vio*);
 #ifdef HAVE_OPENSSL
   void	  *ssl_arg;
 #endif

=== modified file 'libmysqld/Makefile.am'
--- a/libmysqld/Makefile.am	2010-08-20 09:15:16 +0000
+++ b/libmysqld/Makefile.am	2010-09-01 12:52:09 +0000
@@ -1,21 +1,17 @@
 # Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
 # 
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; version 2
-# of the License.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
 # 
-# This library is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Library General Public License for more details.
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
 # 
-# You should have received a copy of the GNU Library General Public
-# License along with this library; if not, write to the Free
-# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-# MA 02111-1307, USA
-#
-# This file is public domain and comes with NO WARRANTY of any kind
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
 MYSQLDATAdir =		$(localstatedir)
 MYSQLSHAREdir =		$(pkgdatadir)

=== modified file 'libservices/CMakeLists.txt'
--- a/libservices/CMakeLists.txt	2010-08-12 15:19:57 +0000
+++ b/libservices/CMakeLists.txt	2010-08-16 12:50:27 +0000
@@ -15,7 +15,11 @@
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 
-SET(MYSQLSERVICES_SOURCES my_snprintf_service.c thd_alloc_service.c)
+SET(MYSQLSERVICES_SOURCES
+  my_snprintf_service.c
+  thd_alloc_service.c
+  thd_wait_service.c
+  my_thread_scheduler_service.c)
 
 ADD_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES})
 INSTALL(TARGETS mysqlservices DESTINATION ${INSTALL_LIBDIR})

=== modified file 'libservices/Makefile.am'
--- a/libservices/Makefile.am	2009-11-02 20:05:42 +0000
+++ b/libservices/Makefile.am	2010-06-07 14:01:39 +0000
@@ -15,5 +15,7 @@
 
 AM_CPPFLAGS =		-I$(top_srcdir)/include
 pkglib_LIBRARIES =	libmysqlservices.a
-libmysqlservices_a_SOURCES =  my_snprintf_service.c thd_alloc_service.c
+libmysqlservices_a_SOURCES =	my_snprintf_service.c thd_alloc_service.c \
+				thd_wait_service.c \
+				my_thread_scheduler_service.c
 EXTRA_DIST = CMakeLists.txt

=== added file 'libservices/my_thread_scheduler_service.c'
--- a/libservices/my_thread_scheduler_service.c	1970-01-01 00:00:00 +0000
+++ b/libservices/my_thread_scheduler_service.c	2010-06-07 14:01:39 +0000
@@ -0,0 +1,21 @@
+/*
+  Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA
+*/
+
+#include <service_versions.h>
+SERVICE_VERSION my_thread_scheduler_service=
+  (void*)VERSION_my_thread_scheduler;

=== added file 'libservices/thd_wait_service.c'
--- a/libservices/thd_wait_service.c	1970-01-01 00:00:00 +0000
+++ b/libservices/thd_wait_service.c	2010-06-07 14:01:39 +0000
@@ -0,0 +1,19 @@
+/*
+  Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include <service_versions.h>
+SERVICE_VERSION *thd_wait_service= (void*)VERSION_thd_wait;

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

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

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

=== modified file 'mysql-test/extra/rpl_tests/create_recursive_construct.inc'
--- a/mysql-test/extra/rpl_tests/create_recursive_construct.inc	2010-08-10 11:58:46 +0000
+++ b/mysql-test/extra/rpl_tests/create_recursive_construct.inc	2010-09-01 02:51:08 +0000
@@ -338,10 +338,21 @@ if (`SELECT '$CRC_RET_stmt_sidef' != ''`
     SHOW BINLOG EVENTS;
     --die Warnings printed
   }
-  # The first event is format_description, the second is
-  # Query_event('BEGIN'), and the third should be our Table_map.
   --let $event_type= query_get_value(SHOW BINLOG EVENTS, Event_type, 3)
-  if (`SELECT '$event_type' != 'Table_map'`) {
+  # The first event is format_description, the second is
+  # Query_event('BEGIN'), and the third should be our Query
+  # for 'INSERT DELAYED' unsafe_type 3, which is safe after
+  # the fix of bug#54579.
+  if (`SELECT $unsafe_type = 3 AND '$event_type' != 'Query'`) {
+    --enable_query_log
+    --echo ******** Failure! Event number 3 was a '$event_type', not a 'Query'. ********
+    SHOW BINLOG EVENTS;
+    --die Wrong events in binlog.
+  }
+  # The first event is format_description, the second is
+  # Query_event('BEGIN'), and the third should be our Table_map
+  # for unsafe statement.
+  if (`SELECT $unsafe_type != 3 AND '$event_type' != 'Table_map'`) {
     --enable_query_log
     --echo ******** Failure! Event number 3 was a '$event_type', not a 'Table_map'. ********
     SHOW WARNINGS;

=== modified file 'mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test'
--- a/mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test	2010-07-12 11:55:16 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test	2010-08-30 06:38:09 +0000
@@ -22,7 +22,7 @@ DROP TABLE IF EXISTS t1, t2,t3,t4,t5,t6,
 #          should stop the slave.               #
 #################################################
 
-call mtr.add_suppression("Slave: Unknown table 't6' Error_code: 1051");
+call mtr.add_suppression("Slave: Unknown table 'test.t6' Error_code: 1051");
 
 --echo **** Diff Table Def Start ****
 

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

=== added file 'mysql-test/include/have_binlog_rows_query.inc'
--- a/mysql-test/include/have_binlog_rows_query.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/have_binlog_rows_query.inc	2010-08-06 02:20:44 +0000
@@ -0,0 +1,13 @@
+# ==== Purpose ====
+# 
+# Ensure that the server is running with binlog_rows_query_log_events on
+#
+# ==== Usage ====
+#
+# source include/have_binlog_rows_query.inc;
+
+-- require r/have_binlog_rows_query.require
+disable_query_log;
+--replace_result ON OFF
+show variables like 'binlog_rows_query_log_events';
+enable_query_log;

=== modified file 'mysql-test/include/mtr_warnings.sql'
--- a/mysql-test/include/mtr_warnings.sql	2010-08-04 12:38:29 +0000
+++ b/mysql-test/include/mtr_warnings.sql	2010-08-30 06:38:09 +0000
@@ -178,7 +178,7 @@ INSERT INTO global_suppressions VALUES
       this error message.
   */
  ("Can't find file: '.\\\\test\\\\\\?{8}.frm'"),
- ("Slave: Unknown table 't1' Error_code: 1051"),
+ ("Slave: Unknown table 'test.t1' Error_code: 1051"),
 
  /* Added 2009-08-XX after fixing Bug #42408 */
 
@@ -189,7 +189,7 @@ INSERT INTO global_suppressions VALUES
  ("The path specified for the variable .* is not a directory or cannot be written:"),
  ("Master server does not support or not configured semi-sync replication, fallback to asynchronous"),
  (": The MySQL server is running with the --secure-backup-file-priv option so it cannot execute this statement"),
- ("Slave: Unknown table 't1' Error_code: 1051"),
+ ("Slave: Unknown table 'test.t1' Error_code: 1051"),
 
  /* Messages from valgrind */
  ("==[0-9]*== Memcheck,"),

=== added file 'mysql-test/include/not_blackhole.inc'
--- a/mysql-test/include/not_blackhole.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/not_blackhole.inc	2010-07-08 12:36:55 +0000
@@ -0,0 +1,5 @@
+if (`SELECT count(*) FROM information_schema.engines WHERE
+     (support = 'YES' OR support = 'DEFAULT') AND
+     engine = 'blackhole'`){
+  skip Blackhole engine enabled;
+}

=== modified file 'mysql-test/include/range.inc'
--- a/mysql-test/include/range.inc	2010-08-16 06:58:42 +0000
+++ b/mysql-test/include/range.inc	2010-08-26 14:32:33 +0000
@@ -1313,6 +1313,18 @@ SELECT * FROM t1 FORCE INDEX (PRIMARY) 
 
 DROP TABLE t1;
 
+--echo #
+--echo # Bug #54802: 'NOT BETWEEN' evaluation is incorrect
+--echo #
+
+CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key));
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+
+EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+
+DROP TABLE t1;
+
 --echo End of 5.1 tests
 
 #

=== modified file 'mysql-test/include/show_binlog_events2.inc'
--- a/mysql-test/include/show_binlog_events2.inc	2009-09-29 11:16:23 +0000
+++ b/mysql-test/include/show_binlog_events2.inc	2010-07-07 06:48:50 +0000
@@ -1,4 +1,11 @@
---let $binlog_start=107
+if (!$binlog_start)
+{
+  # If $binlog_start is not set, we will set it as the second event's
+  # position.  The first event(Description Event) is always ignored. For
+  # description event's length might be changed because of adding new events,
+  # 'SHOW BINLOG EVENTS LIMIT 1' is used to get the right value.
+  --let $binlog_start= query_get_value(SHOW BINLOG EVENTS LIMIT 1, End_log_pos, 1)
+}
 --replace_result $binlog_start <binlog_start>
 --replace_column 2 # 5 #
 --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/

=== modified file 'mysql-test/r/alter_table.result'
--- a/mysql-test/r/alter_table.result	2010-07-26 09:22:38 +0000
+++ b/mysql-test/r/alter_table.result	2010-08-30 06:38:09 +0000
@@ -380,8 +380,8 @@ ERROR 42000: Incorrect table name ''
 drop table t1;
 drop table if exists t1, t2;
 Warnings:
-Note	1051	Unknown table 't1'
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t1'
+Note	1051	Unknown table 'test.t2'
 create table t1 ( a varchar(10) not null primary key ) engine=myisam;
 create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1);
 flush tables;
@@ -666,7 +666,7 @@ create database mysqltest;
 create table t1 (c1 int);
 alter table t1 rename mysqltest.t1;
 drop table t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 alter table mysqltest.t1 rename t1;
 drop table t1;
 create table t1 (c1 int);

=== modified file 'mysql-test/r/archive.result'
--- a/mysql-test/r/archive.result	2010-07-29 09:55:07 +0000
+++ b/mysql-test/r/archive.result	2010-08-31 06:28:15 +0000
@@ -12747,7 +12747,7 @@ FLUSH TABLE t1;
 SELECT * FROM t1;
 ERROR HY000: Can't find file: 't1' (errno: 2)
 DROP TABLE t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 #
 # Ensure that TRUNCATE fails for non-empty archive tables.
 #

=== modified file 'mysql-test/r/bootstrap.result'
--- a/mysql-test/r/bootstrap.result	2007-02-20 11:48:15 +0000
+++ b/mysql-test/r/bootstrap.result	2010-08-30 06:38:09 +0000
@@ -1,7 +1,7 @@
 drop table if exists t1;
 drop table t1;
 drop table t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 set @my_max_allowed_packet= @@max_allowed_packet;
 set global max_allowed_packet=100*@@max_allowed_packet;
 set global max_allowed_packet=@my_max_allowed_packet;

=== modified file 'mysql-test/r/create.result'
--- a/mysql-test/r/create.result	2010-09-01 21:53:29 +0000
+++ b/mysql-test/r/create.result	2010-09-09 10:54:19 +0000
@@ -28,15 +28,15 @@ create table t2 select auto+1 from t1;
 ERROR 42S02: Table 'test.t1' doesn't exist
 drop table if exists t1,t2;
 Warnings:
-Note	1051	Unknown table 't1'
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t1'
+Note	1051	Unknown table 'test.t2'
 create table t1 (b char(0) not null, index(b));
 ERROR 42000: The used storage engine can't index column 'b'
 create table t1 (a int not null,b text) engine=heap;
 ERROR 42000: The used table type doesn't support BLOB/TEXT columns
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid)) engine=heap;
 ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
 create table not_existing_database.test (a int);
@@ -157,17 +157,17 @@ create table t2 (a int, a float) select 
 ERROR 42S21: Duplicate column name 'a'
 drop table if exists t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 create table t2 (a int) select a as b, a+1 as b from t1;
 ERROR 42S21: Duplicate column name 'b'
 drop table if exists t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 create table t2 (b int) select a as b, a+1 as b from t1;
 ERROR 42S21: Duplicate column name 'b'
 drop table if exists t1,t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 CREATE TABLE t1 (a int not null);
 INSERT INTO t1 values (1),(2),(1);
 CREATE TABLE t2 (primary key(a)) SELECT * FROM t1;
@@ -177,7 +177,7 @@ ERROR 42S02: Table 'test.t2' doesn't exi
 DROP TABLE t1;
 DROP TABLE IF EXISTS t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 create table t1 (a int not null, b int, primary key(a), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b));
 show create table t1;
 Table	Create Table
@@ -1593,12 +1593,12 @@ CREATE TABLE t2 (primary key (a)) select
 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
 drop table if exists t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
 drop table if exists t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 CREATE TABLE t2 (a int, b int, primary key (a));
 INSERT INTO t2 select * from t1;
 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'

=== modified file 'mysql-test/r/csv.result'
--- a/mysql-test/r/csv.result	2010-08-16 07:30:40 +0000
+++ b/mysql-test/r/csv.result	2010-08-30 06:38:09 +0000
@@ -4925,9 +4925,9 @@ period
 9410
 drop table if exists t1,t2,t3,t4;
 Warnings:
-Note	1051	Unknown table 't2'
-Note	1051	Unknown table 't3'
-Note	1051	Unknown table 't4'
+Note	1051	Unknown table 'test.t2'
+Note	1051	Unknown table 'test.t3'
+Note	1051	Unknown table 'test.t4'
 DROP TABLE IF EXISTS bug13894;
 CREATE TABLE bug13894 ( val integer not null ) ENGINE = CSV;
 INSERT INTO bug13894 VALUES (5);

=== modified file 'mysql-test/r/ctype_errors.result'
--- a/mysql-test/r/ctype_errors.result	2009-10-15 12:23:43 +0000
+++ b/mysql-test/r/ctype_errors.result	2010-08-30 06:38:09 +0000
@@ -24,7 +24,7 @@ lc_messages	ru_RU
 SET GLOBAL lc_messages=en_US;
 DROP TABLE t1;
 drop table `ק`;
-ERROR 42S02: Unknown table 'ק'
+ERROR 42S02: Unknown table 'test.ק'
 SET lc_messages=cs_CZ;
 SET NAMES UTF8;
 USE nonexistant;

=== modified file 'mysql-test/r/ctype_tis620.result'
--- a/mysql-test/r/ctype_tis620.result	2010-03-22 09:13:41 +0000
+++ b/mysql-test/r/ctype_tis620.result	2010-08-30 06:38:09 +0000
@@ -138,7 +138,7 @@ year
 DROP TABLE t1;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1
 (
 name varchar(50) NOT NULL default '',

=== modified file 'mysql-test/r/ctype_ujis.result'
--- a/mysql-test/r/ctype_ujis.result	2010-03-22 09:13:41 +0000
+++ b/mysql-test/r/ctype_ujis.result	2010-08-30 06:38:09 +0000
@@ -94,7 +94,7 @@ select @ujis4 = CONVERT(@utf84 USING uji
 1
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 create table t1 (c1 varchar(8)) default character set 'ujis';
 insert into t1 values (0xA4A2),(0xA2A2),(0xA4A2);
 select c1 as 'no index' from t1 where c1 like cast(concat(0xA4A2, '%') as char character set ujis);
@@ -168,7 +168,7 @@ a	b
 DROP TABLE t1;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1(c char(1)) character set ujis;
 INSERT INTO t1 VALUES(0xA2AF);
 INSERT INTO t1 VALUES(0xA2B0);

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

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

=== modified file 'mysql-test/r/ctype_utf8.result'
--- a/mysql-test/r/ctype_utf8.result	2010-08-19 12:54:22 +0000
+++ b/mysql-test/r/ctype_utf8.result	2010-08-30 06:38:09 +0000
@@ -1282,7 +1282,7 @@ DROP TABLE t1;
 SET NAMES utf8;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
 INSERT INTO t1 VALUES('uu');

=== modified file 'mysql-test/r/ctype_utf8mb4.result'
--- a/mysql-test/r/ctype_utf8mb4.result	2010-06-25 11:42:42 +0000
+++ b/mysql-test/r/ctype_utf8mb4.result	2010-09-01 07:40:09 +0000
@@ -1043,6 +1043,38 @@ utf8mb4_bin	6109
 utf8mb4_bin	61
 utf8mb4_bin	6120
 drop table t1;
+#
+# Bug#55980 Character sets: supplementary character _bin ordering is wrong
+#
+CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84);
+INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080);
+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
+HEX(a)	HEX(CONVERT(a USING utf8mb4))
+CE85	CE85
+EFBE9D	EFBE9D
+F0908E84	F0908E84
+F4808080	F4808080
+ALTER TABLE t1 ADD KEY(a);
+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
+HEX(a)	HEX(CONVERT(a USING utf8mb4))
+CE85	CE85
+EFBE9D	EFBE9D
+F0908E84	F0908E84
+F4808080	F4808080
+# Additional test for bug#37244 Character sets: short utf8_bin weight_string value
+SELECT HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a;
+HEX(a)	HEX(WEIGHT_STRING(a))
+CE85	000385
+EFBE9D	00FF9D
+F0908E84	010384
+F4808080	100000
+DROP TABLE IF EXISTS t1;
 select @@collation_connection;
 @@collation_connection
 utf8mb4_bin
@@ -1287,7 +1319,7 @@ DROP TABLE t1;
 SET NAMES utf8mb4;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
 Warnings:
 Warning	1071	Specified key was too long; max key length is 1000 bytes

=== modified file 'mysql-test/r/ctype_utf8mb4_heap.result'
--- a/mysql-test/r/ctype_utf8mb4_heap.result	2010-06-25 11:42:42 +0000
+++ b/mysql-test/r/ctype_utf8mb4_heap.result	2010-08-30 06:38:09 +0000
@@ -1216,7 +1216,7 @@ DROP TABLE t1;
 SET NAMES utf8mb4;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=heap DEFAULT CHARSET=utf8mb4;
 INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
 INSERT INTO t1 VALUES('uu');

=== modified file 'mysql-test/r/ctype_utf8mb4_innodb.result'
--- a/mysql-test/r/ctype_utf8mb4_innodb.result	2010-06-25 11:42:42 +0000
+++ b/mysql-test/r/ctype_utf8mb4_innodb.result	2010-08-30 06:38:09 +0000
@@ -1287,7 +1287,7 @@ DROP TABLE t1;
 SET NAMES utf8mb4;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 Warnings:
 Warning	1071	Specified key was too long; max key length is 767 bytes

=== modified file 'mysql-test/r/ctype_utf8mb4_myisam.result'
--- a/mysql-test/r/ctype_utf8mb4_myisam.result	2010-06-25 11:42:42 +0000
+++ b/mysql-test/r/ctype_utf8mb4_myisam.result	2010-08-30 06:38:09 +0000
@@ -1287,7 +1287,7 @@ DROP TABLE t1;
 SET NAMES utf8mb4;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
 Warnings:
 Warning	1071	Specified key was too long; max key length is 1000 bytes

=== modified file 'mysql-test/r/delete.result'
--- a/mysql-test/r/delete.result	2010-05-23 20:41:18 +0000
+++ b/mysql-test/r/delete.result	2010-08-30 22:22:01 +0000
@@ -499,4 +499,13 @@ INDEX(a), INDEX(b), INDEX(c));
 INSERT INTO t1 VALUES (1,2,3), (4,5,6), (7,8,9);
 DELETE FROM t1 WHERE a = 10 OR b = 20 ORDER BY c LIMIT 1;
 DROP TABLE t1;
+#
+# Bug #53034: Multiple-table DELETE statements not accepting
+#             "Access compatibility" syntax
+#
+CREATE TABLE t1 (id INT);
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+DELETE FROM t1.*, test.t2.*, a.* USING t1, t2, t3 AS a;
+DROP TABLE t1, t2, t3;
 End of 5.1 tests

=== modified file 'mysql-test/r/drop.result'
--- a/mysql-test/r/drop.result	2010-06-07 15:27:40 +0000
+++ b/mysql-test/r/drop.result	2010-08-30 06:38:09 +0000
@@ -2,7 +2,7 @@ drop table if exists t1;
 drop database if exists mysqltest;
 drop database if exists client_test_db;
 drop table t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 create table t1(n int);
 insert into t1 values(1);
 create temporary table t1( n int);
@@ -30,13 +30,13 @@ table7, table8, table9, table10, table11
 table14, table15, table16, table17, table18, table19, table20,
 table21, table22, table23, table24, table25, table26, table27,
 table28;
-ERROR 42S02: Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table'
+ERROR 42S02: Unknown table 'mysqltest.table1,mysqltest.table2,mysqltest.table3,mysqltest.table4,mysqltest.table5,mysqltest.table'
 drop table table1, table2, table3, table4, table5, table6,
 table7, table8, table9, table10, table11, table12, table13,
 table14, table15, table16, table17, table18, table19, table20,
 table21, table22, table23, table24, table25, table26, table27,
 table28, table29, table30;
-ERROR 42S02: Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table'
+ERROR 42S02: Unknown table 'mysqltest.table1,mysqltest.table2,mysqltest.table3,mysqltest.table4,mysqltest.table5,mysqltest.table'
 use test;
 drop database mysqltest;
 flush tables with read lock;
@@ -149,10 +149,10 @@ End of 5.1 tests
 # --
 DROP TABLE IF EXISTS t1;
 DROP TABLE t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 SHOW WARNINGS;
 Level	Code	Message
-Error	1051	Unknown table 't1'
+Error	1051	Unknown table 'test.t1'
 
 # --
 # -- End of Bug#37431.
@@ -167,3 +167,39 @@ DROP TABLE t1, t1;
 ERROR 42000: Not unique table/alias: 't1'
 UNLOCK TABLES;
 DROP TABLE t1;
+#
+# BUG#34750: Print database name in Unknown Table error message
+#
+
+# Test error message when droping table/view
+DROP TABLE table1;
+ERROR 42S02: Unknown table 'test.table1'
+DROP TABLE table1,table2;
+ERROR 42S02: Unknown table 'test.table1,test.table2'
+DROP VIEW view1,view2,view3,view4;
+ERROR 42S02: Unknown table 'test.view1,test.view2,test.view3,test.view4'
+
+DROP TABLE IF EXISTS table1;
+Warnings:
+Note	1051	Unknown table 'test.table1'
+DROP TABLE IF EXISTS table1,table2;
+Warnings:
+Note	1051	Unknown table 'test.table1'
+Note	1051	Unknown table 'test.table2'
+DROP VIEW IF EXISTS view1,view2,view3,view4;
+Warnings:
+Note	1051	Unknown table 'test.view1'
+Note	1051	Unknown table 'test.view2'
+Note	1051	Unknown table 'test.view3'
+Note	1051	Unknown table 'test.view4'
+
+# Test error message when trigger does not find table
+CREATE TABLE table1(a int);
+CREATE TABLE table2(b int);
+CREATE TRIGGER trg1 AFTER INSERT ON table1
+FOR EACH ROW
+INSERT INTO table2 SELECT t.notable.*;
+INSERT INTO table1 VALUES (1);
+ERROR 42S02: Unknown table 't.notable'
+DROP TABLE table1,table2;
+# End BUG#34750

=== modified file 'mysql-test/r/error_simulation.result'
--- a/mysql-test/r/error_simulation.result	2010-06-24 13:21:23 +0000
+++ b/mysql-test/r/error_simulation.result	2010-08-30 06:38:09 +0000
@@ -1,6 +1,6 @@
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (
 a varchar(32) character set utf8 collate utf8_bin NOT NULL,
 b varchar(32) character set utf8 collate utf8_bin NOT NULL )

=== modified file 'mysql-test/r/func_gconcat.result'
--- a/mysql-test/r/func_gconcat.result	2010-06-21 16:58:57 +0000
+++ b/mysql-test/r/func_gconcat.result	2010-08-26 14:32:33 +0000
@@ -1003,6 +1003,7 @@ SELECT 1 FROM
 1
 1
 DROP TABLE t1;
+End of 5.0 tests
 #
 # Bug #52397: another crash with explain extended and group_concat
 #
@@ -1019,6 +1020,25 @@ Warnings:
 Note	1003	select 1 AS `1` from dual
 DROP TABLE t1;
 End of 5.0 tests
+#
+# Bug #54476: crash when group_concat and 'with rollup' in prepared statements
+# 
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2);
+PREPARE stmt FROM "SELECT GROUP_CONCAT(t1.a ORDER BY t1.a) FROM t1 JOIN t1 t2 GROUP BY t1.a WITH ROLLUP";
+EXECUTE stmt;
+GROUP_CONCAT(t1.a ORDER BY t1.a)
+1,1
+2,2
+1,1,2,2
+EXECUTE stmt;
+GROUP_CONCAT(t1.a ORDER BY t1.a)
+1,1
+2,2
+1,1,2,2
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+End of 5.1 tests
 DROP TABLE IF EXISTS t1, t2;
 CREATE TABLE t1 (a VARCHAR(6), b INT);
 CREATE TABLE t2 (a VARCHAR(6), b INT);

=== modified file 'mysql-test/r/func_group.result'
--- a/mysql-test/r/func_group.result	2010-08-25 08:37:49 +0000
+++ b/mysql-test/r/func_group.result	2010-08-30 08:40:42 +0000
@@ -1713,6 +1713,17 @@ f1	f2	f3	f4	f1 = f2
 NULL	NULL	NULL	NULL	NULL
 drop table t1;
 #
+# Bug #54465: assert: field_types == 0 || field_types[field_pos] ==
+#             MYSQL_TYPE_LONGLONG
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2);
+SELECT MAX((SELECT 1 FROM t1 ORDER BY @var LIMIT 1)) m FROM t1 t2, t1 
+ORDER BY t1.a;
+m
+1
+DROP TABLE t1;
+#
 End of 5.1 tests
 #
 # Bug#52123 Assertion failed: aggregator == aggr->Aggrtype(),

=== modified file 'mysql-test/r/func_misc.result'
--- a/mysql-test/r/func_misc.result	2010-04-07 09:59:02 +0000
+++ b/mysql-test/r/func_misc.result	2010-08-20 11:22:46 +0000
@@ -337,6 +337,21 @@ select connection_id() > 0;
 connection_id() > 0
 1
 #
+# Bug #54461: crash with longblob and union or update with subquery
+#
+CREATE TABLE t1 (a INT, b LONGBLOB);
+INSERT INTO t1 VALUES (1, '2'), (2, '3'), (3, '2');
+SELECT DISTINCT LEAST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1;
+LEAST(a, (SELECT b FROM t1 LIMIT 1))
+1
+2
+SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1;
+GREATEST(a, (SELECT b FROM t1 LIMIT 1))
+2
+3
+1
+DROP TABLE t1;
+#
 # Bug #52165: Assertion failed: file .\dtoa.c, line 465
 # 
 CREATE TABLE t1 (a SET('a'), b INT);

=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	2010-05-14 08:14:09 +0000
+++ b/mysql-test/r/func_time.result	2010-08-18 07:24:32 +0000
@@ -1305,6 +1305,14 @@ date_sub("0069-01-01 00:00:01",INTERVAL 
 select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
 date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND)
 0168-12-31 23:59:59
+CREATE TABLE t1(a DOUBLE NOT NULL);
+INSERT INTO t1 VALUES (0),(9.216e-096);
+# should not crash
+SELECT 1 FROM t1 ORDER BY @x:=makedate(a,a);
+1
+1
+1
+DROP TABLE t1;
 End of 5.1 tests
 #
 # BUG#43578 "MyISAM&Maria gives wrong rows with range access

=== modified file 'mysql-test/r/gis-rtree.result'
--- a/mysql-test/r/gis-rtree.result	2010-03-25 11:49:01 +0000
+++ b/mysql-test/r/gis-rtree.result	2010-08-30 06:38:09 +0000
@@ -712,7 +712,7 @@ count(*)
 DROP TABLE t2;
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (a geometry NOT NULL, SPATIAL (a));
 INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
 INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));

=== modified file 'mysql-test/r/grant.result'
--- a/mysql-test/r/grant.result	2010-08-05 13:10:22 +0000
+++ b/mysql-test/r/grant.result	2010-08-30 06:38:09 +0000
@@ -1228,7 +1228,7 @@ FLUSH PRIVILEGES;
 DROP TABLE mysql.user;
 drop table if exists test;
 Warnings:
-Note	1051	Unknown table 'test'
+Note	1051	Unknown table 'test.test'
 drop function if exists test_function;
 Warnings:
 Note	1305	FUNCTION test.test_function does not exist

=== modified file 'mysql-test/r/handler_innodb.result'
--- a/mysql-test/r/handler_innodb.result	2010-07-05 11:59:34 +0000
+++ b/mysql-test/r/handler_innodb.result	2010-08-30 06:38:09 +0000
@@ -515,7 +515,7 @@ select * from t1;
 ERROR 42S02: Table 'test.t1' doesn't exist
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 drop table if exists t1;
 create table t1 (a int) ENGINE=MEMORY;
 --> client 2

=== modified file 'mysql-test/r/handler_myisam.result'
--- a/mysql-test/r/handler_myisam.result	2010-07-05 11:59:34 +0000
+++ b/mysql-test/r/handler_myisam.result	2010-08-30 06:38:09 +0000
@@ -514,7 +514,7 @@ select * from t1;
 ERROR 42S02: Table 'test.t1' doesn't exist
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 drop table if exists t1;
 create table t1 (a int) ENGINE=MEMORY;
 --> client 2

=== added file 'mysql-test/r/have_binlog_rows_query.require'
--- a/mysql-test/r/have_binlog_rows_query.require	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/have_binlog_rows_query.require	2010-08-06 02:20:44 +0000
@@ -0,0 +1,2 @@
+Variable_name	Value
+binlog_rows_query_log_events	OFF

=== modified file 'mysql-test/r/key.result'
--- a/mysql-test/r/key.result	2010-07-13 17:29:44 +0000
+++ b/mysql-test/r/key.result	2010-08-30 06:38:09 +0000
@@ -273,7 +273,7 @@ t
 drop table t1;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (
 c1 int,
 c2 varbinary(240),

=== modified file 'mysql-test/r/log_tables.result'
--- a/mysql-test/r/log_tables.result	2009-12-22 11:02:52 +0000
+++ b/mysql-test/r/log_tables.result	2010-08-30 06:38:09 +0000
@@ -256,9 +256,9 @@ set storage_engine= @save_storage_engine
 drop table mysql.slow_log;
 drop table mysql.general_log;
 drop table mysql.general_log;
-ERROR 42S02: Unknown table 'general_log'
+ERROR 42S02: Unknown table 'mysql.general_log'
 drop table mysql.slow_log;
-ERROR 42S02: Unknown table 'slow_log'
+ERROR 42S02: Unknown table 'mysql.slow_log'
 use mysql;
 CREATE TABLE `general_log` (
 `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP

=== modified file 'mysql-test/r/mdl_sync.result'
--- a/mysql-test/r/mdl_sync.result	2010-08-12 13:50:23 +0000
+++ b/mysql-test/r/mdl_sync.result	2010-08-30 06:38:09 +0000
@@ -16,7 +16,7 @@ connection: con1
 connection: default
 unlock tables;
 connection: con2
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 drop table t3;
 SET DEBUG_SYNC= 'RESET';
 #
@@ -2878,7 +2878,7 @@ SET DEBUG_SYNC= 'now SIGNAL blocked';
 # Reaping: DROP DATABASE db1
 # Connection con2
 # Reaping: DROP TABLE db1.t1
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'db1.t1'
 # Connection default
 SET DEBUG_SYNC= 'RESET';
 #

=== modified file 'mysql-test/r/myisam-system.result'
--- a/mysql-test/r/myisam-system.result	2009-09-10 09:18:29 +0000
+++ b/mysql-test/r/myisam-system.result	2010-08-30 06:38:09 +0000
@@ -10,4 +10,4 @@ create table t1 (a int) engine=myisam;
 drop table t1;
 Got one of the listed errors
 drop table t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'

=== modified file 'mysql-test/r/myisam.result'
--- a/mysql-test/r/myisam.result	2010-08-14 07:28:31 +0000
+++ b/mysql-test/r/myisam.result	2010-09-09 10:54:19 +0000
@@ -430,7 +430,7 @@ a	b	c
 drop table t1;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a));
 INSERT t1 VALUES ("can \tcan");
 INSERT t1 VALUES ("can   can");

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2010-09-01 21:53:29 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2010-09-09 10:54:19 +0000
@@ -65,6 +65,8 @@ The following options may be given as th
  The maximum size of a row-based binary log event in
  bytes. Rows will be grouped into events smaller than this
  size if possible. The value has to be a multiple of 256.
+ --binlog-rows-query-log-events 
+ Allow writing of Rows_query_log events into binary log.
  --bootstrap         Used by mysql installation scripts.
  --bulk-insert-buffer-size=# 
  Size of tree cache used in bulk insert optimisation. Note
@@ -685,7 +687,7 @@ The following options may be given as th
  How many threads we should keep in a cache for reuse
  --thread-handling=name 
  Define threads usage for handling queries, one of
- one-thread-per-connection, no-threads
+ one-thread-per-connection, no-threads, loaded-dynamically
  --thread-stack=#    The stack size for each thread
  --time-format=name  The TIME format (ignored)
  --timed-mutexes     Specify whether to time mutexes (only InnoDB mutexes are
@@ -730,6 +732,7 @@ binlog-cache-size 32768
 binlog-direct-non-transactional-updates FALSE
 binlog-format STATEMENT
 binlog-row-event-max-size 1024
+binlog-rows-query-log-events FALSE
 bulk-insert-buffer-size 8388608
 character-set-client-handshake TRUE
 character-set-filesystem binary

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	2010-09-01 21:53:29 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2010-09-09 10:54:19 +0000
@@ -65,6 +65,8 @@ The following options may be given as th
  The maximum size of a row-based binary log event in
  bytes. Rows will be grouped into events smaller than this
  size if possible. The value has to be a multiple of 256.
+ --binlog-rows-query-log-events 
+ Allow writing of Rows_query_log events into binary log.
  --bootstrap         Used by mysql installation scripts.
  --bulk-insert-buffer-size=# 
  Size of tree cache used in bulk insert optimisation. Note
@@ -689,7 +691,7 @@ The following options may be given as th
  How many threads we should keep in a cache for reuse
  --thread-handling=name 
  Define threads usage for handling queries, one of
- one-thread-per-connection, no-threads
+ one-thread-per-connection, no-threads, loaded-dynamically
  --thread-stack=#    The stack size for each thread
  --time-format=name  The TIME format (ignored)
  --timed-mutexes     Specify whether to time mutexes (only InnoDB mutexes are
@@ -734,6 +736,7 @@ binlog-cache-size 32768
 binlog-direct-non-transactional-updates FALSE
 binlog-format STATEMENT
 binlog-row-event-max-size 1024
+binlog-rows-query-log-events FALSE
 bulk-insert-buffer-size 8388608
 character-set-client-handshake TRUE
 character-set-filesystem binary

=== modified file 'mysql-test/r/mysqldump.result'
--- a/mysql-test/r/mysqldump.result	2010-07-05 11:57:49 +0000
+++ b/mysql-test/r/mysqldump.result	2010-08-30 06:38:09 +0000
@@ -2613,13 +2613,13 @@ DROP TABLE t1, t2;
 #
 DROP TABLE IF EXISTS `test1`;
 Warnings:
-Note	1051	Unknown table 'test1'
+Note	1051	Unknown table 'test.test1'
 CREATE TABLE `test1` (
 `a1` int(11) default NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 DROP TABLE IF EXISTS `test2`;
 Warnings:
-Note	1051	Unknown table 'test2'
+Note	1051	Unknown table 'test.test2'
 CREATE TABLE `test2` (
 `a2` int(11) default NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2010-08-26 21:32:48 +0000
+++ b/mysql-test/r/partition.result	2010-08-30 06:38:09 +0000
@@ -1742,7 +1742,7 @@ INSERT INTO t1 VALUES
 ('2006-09-29 21:50:01',22589,'Verified');
 DROP TABLE IF EXISTS t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 CREATE TABLE t2 (
 id int(8) NOT NULL,
 severity tinyint(4) NOT NULL DEFAULT '0',

=== modified file 'mysql-test/r/partition_disabled.result'
--- a/mysql-test/r/partition_disabled.result	2010-08-16 12:53:30 +0000
+++ b/mysql-test/r/partition_disabled.result	2010-08-30 06:38:09 +0000
@@ -56,7 +56,7 @@ ERROR HY000: The MySQL server is running
 ALTER TABLE t1 PARTITION BY KEY(joined) PARTITIONS 2;
 ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
 drop table t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 CREATE TABLE t1 (
 firstname VARCHAR(25) NOT NULL,
 lastname VARCHAR(25) NOT NULL,
@@ -73,7 +73,7 @@ PARTITION p4 VALUES LESS THAN MAXVALUE
 );
 ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
 drop table t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 CREATE TABLE t1 (id INT, purchased DATE)
 PARTITION BY RANGE( YEAR(purchased) )
 SUBPARTITION BY HASH( TO_DAYS(purchased) )
@@ -84,7 +84,7 @@ PARTITION p2 VALUES LESS THAN MAXVALUE
 );
 ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
 drop table t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 create table t1 (a varchar(10) charset latin1 collate latin1_bin);
 insert into t1 values (''),(' '),('a'),('a '),('a  ');
 explain partitions select * from t1 where a='a ' OR a='a';

=== modified file 'mysql-test/r/partition_error.result'
--- a/mysql-test/r/partition_error.result	2010-06-17 10:37:03 +0000
+++ b/mysql-test/r/partition_error.result	2010-08-30 06:38:09 +0000
@@ -14,7 +14,7 @@ ERROR HY000: Failed to read from the .pa
 # Note that it is currently impossible to drop a partitioned table
 # without the .par file
 DROP TABLE t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 #
 # Bug#49477: Assertion `0' failed in ha_partition.cc:5530
 # with temporary table and partitions

=== added file 'mysql-test/r/partition_not_blackhole.result'
--- a/mysql-test/r/partition_not_blackhole.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/partition_not_blackhole.result	2010-09-06 07:27:38 +0000
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+#
+# Bug#46086: crash when dropping a partitioned table and
+#            the original engine is disabled
+# Copy a .frm and .par file which was created with:
+# create table `t1` (`id` int primary key) engine=blackhole
+# partition by key () partitions 1;
+SHOW TABLES;
+Tables_in_test
+t1
+SHOW CREATE TABLE t1;
+ERROR HY000: Incorrect information in file: './test/t1.frm'
+DROP TABLE t1;
+ERROR 42S02: Unknown table 'test.t1'
+t1.frm
+t1.par

=== modified file 'mysql-test/r/profiling.result'
--- a/mysql-test/r/profiling.result	2009-12-22 09:35:56 +0000
+++ b/mysql-test/r/profiling.result	2010-08-30 06:38:09 +0000
@@ -123,8 +123,8 @@ select query_id, count(*), sum(duration)
 select CPU_user, CPU_system, Context_voluntary, Context_involuntary, Block_ops_in, Block_ops_out, Messages_sent, Messages_received, Page_faults_major, Page_faults_minor, Swaps, Source_function, Source_file, Source_line from information_schema.profiling;
 drop table if exists t1, t2, t3;
 Warnings:
-Note	1051	Unknown table 't2'
-Note	1051	Unknown table 't3'
+Note	1051	Unknown table 'test.t2'
+Note	1051	Unknown table 'test.t3'
 create table t1 (id int );
 create table t2 (id int not null);
 create table t3 (id int not null primary key);
@@ -309,7 +309,7 @@ select @@profiling;
 set session profiling = OFF;
 drop table if exists profile_log;
 Warnings:
-Note	1051	Unknown table 'profile_log'
+Note	1051	Unknown table 'test.profile_log'
 create table profile_log (how_many int);
 drop procedure if exists p1;
 drop procedure if exists p2;

=== modified file 'mysql-test/r/ps.result'
--- a/mysql-test/r/ps.result	2010-08-05 12:53:09 +0000
+++ b/mysql-test/r/ps.result	2010-08-30 06:38:09 +0000
@@ -50,7 +50,7 @@ execute stmt4;
 prepare stmt4 from 'drop table t2';
 execute stmt4;
 execute stmt4;
-ERROR 42S02: Unknown table 't2'
+ERROR 42S02: Unknown table 'test.t2'
 prepare stmt5 from 'select ? + a from t1';
 set @a=1;
 execute stmt5 using @a;
@@ -519,7 +519,7 @@ FOUND_ROWS()
 deallocate prepare stmt;
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 create table t1 (c1 int(11) not null, c2 int(11) not null,
 primary key  (c1,c2), key c2 (c2), key c1 (c1));
 insert into t1 values (200887, 860);
@@ -2792,48 +2792,48 @@ drop table if exists t2;
 create procedure proc_1() show warnings;
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 call proc_1();
 Level	Code	Message
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 drop table if exists t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 call proc_1();
 Level	Code	Message
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 drop table if exists t1, t2;
 Warnings:
-Note	1051	Unknown table 't1'
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t1'
+Note	1051	Unknown table 'test.t2'
 call proc_1();
 Level	Code	Message
-Note	1051	Unknown table 't1'
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t1'
+Note	1051	Unknown table 'test.t2'
 drop procedure proc_1;
 create function func_1() returns int begin show warnings; return 1; end|
 ERROR 0A000: Not allowed to return a result set from a function
 prepare abc from "show warnings";
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 execute abc;
 Level	Code	Message
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 drop table if exists t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 execute abc;
 Level	Code	Message
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 drop table if exists t1, t2;
 Warnings:
-Note	1051	Unknown table 't1'
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t1'
+Note	1051	Unknown table 'test.t2'
 execute abc;
 Level	Code	Message
-Note	1051	Unknown table 't1'
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t1'
+Note	1051	Unknown table 'test.t2'
 deallocate prepare abc;
 set @my_password="password";
 set @my_data="clear text to encode";
@@ -2919,7 +2919,7 @@ i	j
 DROP TABLE t1, t2;
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 prepare stmt
 from "create table t1 (c char(100) character set utf8, key (c(10)))";
 execute stmt;

=== modified file 'mysql-test/r/ps_1general.result'
--- a/mysql-test/r/ps_1general.result	2010-08-14 07:28:31 +0000
+++ b/mysql-test/r/ps_1general.result	2010-09-09 10:54:19 +0000
@@ -325,10 +325,10 @@ drop table if exists t5;
 prepare stmt1 from ' drop table if exists t5 ' ;
 execute stmt1 ;
 Warnings:
-Note	1051	Unknown table 't5'
+Note	1051	Unknown table 'test.t5'
 prepare stmt1 from ' drop table t5 ' ;
 execute stmt1 ;
-ERROR 42S02: Unknown table 't5'
+ERROR 42S02: Unknown table 'test.t5'
 prepare stmt1 from ' SELECT @@version ' ;
 execute stmt1 ;
 @@version

=== modified file 'mysql-test/r/ps_ddl1.result'
--- a/mysql-test/r/ps_ddl1.result	2009-12-29 12:19:05 +0000
+++ b/mysql-test/r/ps_ddl1.result	2010-08-30 06:38:09 +0000
@@ -420,7 +420,7 @@ call p_verify_reprepare_count(0);
 SUCCESS
 
 execute stmt;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 call p_verify_reprepare_count(0);
 SUCCESS
 

=== modified file 'mysql-test/r/range_all.result'
--- a/mysql-test/r/range_all.result	2010-08-16 06:58:42 +0000
+++ b/mysql-test/r/range_all.result	2010-08-26 14:32:33 +0000
@@ -1654,6 +1654,19 @@ a	b
 0	0
 1	1
 DROP TABLE t1;
+#
+# Bug #54802: 'NOT BETWEEN' evaluation is incorrect
+#
+CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key));
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	c_key	NULL	NULL	NULL	3	Using where
+SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+c_key	c_notkey
+1	1
+3	3
+DROP TABLE t1;
 End of 5.1 tests
 CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1));
 INSERT INTO t1 VALUES (1),(2),(3);

=== modified file 'mysql-test/r/range_icp.result'
--- a/mysql-test/r/range_icp.result	2010-08-23 11:28:58 +0000
+++ b/mysql-test/r/range_icp.result	2010-09-06 10:54:47 +0000
@@ -1654,6 +1654,19 @@ a	b
 0	0
 1	1
 DROP TABLE t1;
+#
+# Bug #54802: 'NOT BETWEEN' evaluation is incorrect
+#
+CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key));
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	c_key	NULL	NULL	NULL	3	Using where
+SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+c_key	c_notkey
+1	1
+3	3
+DROP TABLE t1;
 End of 5.1 tests
 CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1));
 INSERT INTO t1 VALUES (1),(2),(3);

=== modified file 'mysql-test/r/range_icp_mrr.result'
--- a/mysql-test/r/range_icp_mrr.result	2010-08-23 11:28:58 +0000
+++ b/mysql-test/r/range_icp_mrr.result	2010-09-06 10:54:47 +0000
@@ -1654,6 +1654,19 @@ a	b
 0	0
 1	1
 DROP TABLE t1;
+#
+# Bug #54802: 'NOT BETWEEN' evaluation is incorrect
+#
+CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key));
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	c_key	NULL	NULL	NULL	3	Using where
+SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+c_key	c_notkey
+1	1
+3	3
+DROP TABLE t1;
 End of 5.1 tests
 CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1));
 INSERT INTO t1 VALUES (1),(2),(3);

=== modified file 'mysql-test/r/range_mrr.result'
--- a/mysql-test/r/range_mrr.result	2010-08-23 11:28:58 +0000
+++ b/mysql-test/r/range_mrr.result	2010-09-06 10:54:47 +0000
@@ -1654,6 +1654,19 @@ a	b
 0	0
 1	1
 DROP TABLE t1;
+#
+# Bug #54802: 'NOT BETWEEN' evaluation is incorrect
+#
+CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key));
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	c_key	NULL	NULL	NULL	3	Using where
+SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+c_key	c_notkey
+1	1
+3	3
+DROP TABLE t1;
 End of 5.1 tests
 CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1));
 INSERT INTO t1 VALUES (1),(2),(3);

=== modified file 'mysql-test/r/range_none.result'
--- a/mysql-test/r/range_none.result	2010-08-16 07:21:40 +0000
+++ b/mysql-test/r/range_none.result	2010-08-27 14:15:52 +0000
@@ -1653,6 +1653,19 @@ a	b
 0	0
 1	1
 DROP TABLE t1;
+#
+# Bug #54802: 'NOT BETWEEN' evaluation is incorrect
+#
+CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key));
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	c_key	NULL	NULL	NULL	3	Using where
+SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+c_key	c_notkey
+1	1
+3	3
+DROP TABLE t1;
 End of 5.1 tests
 CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1));
 INSERT INTO t1 VALUES (1),(2),(3);

=== modified file 'mysql-test/r/read_only.result'
--- a/mysql-test/r/read_only.result	2009-03-06 14:56:17 +0000
+++ b/mysql-test/r/read_only.result	2010-08-30 06:38:09 +0000
@@ -119,10 +119,10 @@ select @@global.read_only;
 1
 unlock tables;
 drop temporary table ttt;
-ERROR 42S02: Unknown table 'ttt'
+ERROR 42S02: Unknown table 'test.ttt'
 drop temporary table if exists ttt;
 Warnings:
-Note	1051	Unknown table 'ttt'
+Note	1051	Unknown table 'test.ttt'
 connection default;
 set global read_only=0;
 drop table t1,t2;

=== modified file 'mysql-test/r/rename.result'
--- a/mysql-test/r/rename.result	2010-05-28 05:25:11 +0000
+++ b/mysql-test/r/rename.result	2010-08-30 06:38:09 +0000
@@ -39,7 +39,7 @@ select * from t3;
 3	table 3
 drop table if exists t1,t2,t3,t4;
 Warnings:
-Note	1051	Unknown table 't4'
+Note	1051	Unknown table 'test.t4'
 CREATE TABLE t1 (a int);
 CREATE TABLE t3 (a int);
 FLUSH TABLES WITH READ LOCK;

=== modified file 'mysql-test/r/signal.result'
--- a/mysql-test/r/signal.result	2010-07-30 15:28:36 +0000
+++ b/mysql-test/r/signal.result	2010-08-30 06:38:09 +0000
@@ -1562,7 +1562,7 @@ end $$
 call test_resignal() $$
 before RESIGNAL
 before RESIGNAL
-ERROR 42S02: Unknown table 'no_such_table'
+ERROR 42S02: Unknown table 'test.no_such_table'
 drop procedure test_resignal $$
 create procedure test_resignal()
 begin
@@ -2059,7 +2059,7 @@ before RESIGNAL
 after RESIGNAL
 after RESIGNAL
 Warnings:
-Error	1051	Unknown table 'no_such_table'
+Error	1051	Unknown table 'test.no_such_table'
 Warning	5555	RESIGNAL to a warning
 drop procedure test_resignal $$
 create procedure test_resignal()
@@ -2080,7 +2080,7 @@ before RESIGNAL
 ERROR 02444: RESIGNAL to a not found
 show warnings $$
 Level	Code	Message
-Error	1051	Unknown table 'no_such_table'
+Error	1051	Unknown table 'test.no_such_table'
 Error	5555	RESIGNAL to a not found
 drop procedure test_resignal $$
 create procedure test_resignal()
@@ -2101,7 +2101,7 @@ before RESIGNAL
 ERROR 44444: RESIGNAL to an error
 show warnings $$
 Level	Code	Message
-Error	1051	Unknown table 'no_such_table'
+Error	1051	Unknown table 'test.no_such_table'
 Error	5555	RESIGNAL to an error
 drop procedure test_resignal $$
 #

=== modified file 'mysql-test/r/signal_demo2.result'
--- a/mysql-test/r/signal_demo2.result	2009-09-10 09:18:29 +0000
+++ b/mysql-test/r/signal_demo2.result	2010-08-30 06:38:09 +0000
@@ -74,7 +74,7 @@ In proc_bottom()
 In proc_bottom()
 Doing something that fail (simulate an error) ...
 Doing something that fail (simulate an error) ...
-ERROR 42S02: Unknown table 'no_such_table'
+ERROR 42S02: Unknown table 'demo.no_such_table'
 call proc_top_a(3);
 Starting ...
 Starting ...
@@ -167,7 +167,7 @@ Doing something that fail (simulate an e
 Doing something that fail (simulate an error) ...
 Doing cleanup !
 Doing cleanup !
-ERROR 42S02: Unknown table 'no_such_table'
+ERROR 42S02: Unknown table 'demo.no_such_table'
 call proc_top_b(3);
 Starting ...
 Starting ...

=== modified file 'mysql-test/r/signal_demo3.result'
--- a/mysql-test/r/signal_demo3.result	2010-07-30 15:28:36 +0000
+++ b/mysql-test/r/signal_demo3.result	2010-08-30 06:38:09 +0000
@@ -77,7 +77,7 @@ call proc_1();
 ERROR 45000: Oops in proc_1
 show warnings;
 Level	Code	Message
-Error	1051	Unknown table 'oops_it_is_not_here'
+Error	1051	Unknown table 'demo.oops_it_is_not_here'
 Error	1644	Oops in proc_9
 Error	1644	Oops in proc_8
 Error	1644	Oops in proc_7
@@ -95,7 +95,7 @@ call proc_1();
 ERROR 45000: Oops in proc_1
 show warnings;
 Level	Code	Message
-Error	1051	Unknown table 'oops_it_is_not_here'
+Error	1051	Unknown table 'demo.oops_it_is_not_here'
 Error	1644	Oops in proc_9
 Error	1644	Oops in proc_8
 Error	1644	Oops in proc_7
@@ -108,7 +108,7 @@ call proc_1();
 ERROR 45000: Oops in proc_1
 show warnings;
 Level	Code	Message
-Error	1051	Unknown table 'oops_it_is_not_here'
+Error	1051	Unknown table 'demo.oops_it_is_not_here'
 Error	1644	Oops in proc_9
 Error	1644	Oops in proc_8
 Error	1644	Oops in proc_7
@@ -123,7 +123,7 @@ call proc_1();
 ERROR 45000: Oops in proc_1
 show warnings;
 Level	Code	Message
-Error	1051	Unknown table 'oops_it_is_not_here'
+Error	1051	Unknown table 'demo.oops_it_is_not_here'
 Error	1644	Oops in proc_9
 Error	1644	Oops in proc_8
 Error	1644	Oops in proc_7

=== modified file 'mysql-test/r/sp-dynamic.result'
--- a/mysql-test/r/sp-dynamic.result	2009-09-10 09:18:29 +0000
+++ b/mysql-test/r/sp-dynamic.result	2010-08-30 06:38:09 +0000
@@ -249,7 +249,7 @@ drop procedure p1|
 drop table if exists t1|
 drop table if exists t2|
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 create table t1 (id integer primary key auto_increment,
 stmt_text char(35), status varchar(20))|
 insert into t1 (stmt_text) values

=== modified file 'mysql-test/r/sp-error.result'
--- a/mysql-test/r/sp-error.result	2010-07-30 15:30:30 +0000
+++ b/mysql-test/r/sp-error.result	2010-08-30 06:38:09 +0000
@@ -466,7 +466,7 @@ drop table t5;
 end|
 create table t5 (x int)|
 call bug3294()|
-ERROR 42S02: Unknown table 't5'
+ERROR 42S02: Unknown table 'test.t5'
 drop procedure bug3294|
 drop procedure if exists bug8776_1|
 drop procedure if exists bug8776_2|
@@ -1567,7 +1567,7 @@ f2()
 1
 drop function f2;
 drop table t2;
-ERROR 42S02: Unknown table 't2'
+ERROR 42S02: Unknown table 'test.t2'
 End of 5.1 tests
 drop procedure if exists proc_33983_a;
 drop procedure if exists proc_33983_b;

=== modified file 'mysql-test/r/sp-prelocking.result'
--- a/mysql-test/r/sp-prelocking.result	2007-07-27 14:59:09 +0000
+++ b/mysql-test/r/sp-prelocking.result	2010-08-30 06:38:09 +0000
@@ -22,7 +22,7 @@ call sp1();
 my-col
 1
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'mysqltest.t1'
 select database();
 database()
 mysqltest
@@ -34,7 +34,7 @@ call mysqltest.sp1();
 my-col
 1
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'mysqltest.t1'
 select database();
 database()
 test

=== modified file 'mysql-test/r/sp-vars.result'
--- a/mysql-test/r/sp-vars.result	2010-02-23 18:43:26 +0000
+++ b/mysql-test/r/sp-vars.result	2010-08-30 06:38:09 +0000
@@ -400,7 +400,7 @@ Warnings:
 Note	1305	PROCEDURE test.p2 does not exist
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1(log_msg VARCHAR(1024));
 CREATE PROCEDURE p1(arg VARCHAR(255))
 BEGIN

=== modified file 'mysql-test/r/sp.result'
--- a/mysql-test/r/sp.result	2010-08-04 10:34:01 +0000
+++ b/mysql-test/r/sp.result	2010-08-30 06:38:09 +0000
@@ -3272,9 +3272,9 @@ Warnings:
 Note	1051	Unknown table 'test.tv'
 DROP TABLE IF EXISTS tt1,tt2,tt3|
 Warnings:
-Note	1051	Unknown table 'tt1'
-Note	1051	Unknown table 'tt2'
-Note	1051	Unknown table 'tt3'
+Note	1051	Unknown table 'test.tt1'
+Note	1051	Unknown table 'test.tt2'
+Note	1051	Unknown table 'test.tt3'
 CREATE TABLE tt1 (a1 int, a2 int, a3 int, data varchar(10))|
 CREATE TABLE tt2 (a2 int, data2 varchar(10))|
 CREATE TABLE tt3 (a3 int, data3 varchar(10))|

=== modified file 'mysql-test/r/subquery_sj_all.result'
--- a/mysql-test/r/subquery_sj_all.result	2010-08-12 11:48:10 +0000
+++ b/mysql-test/r/subquery_sj_all.result	2010-09-02 07:34:10 +0000
@@ -2577,8 +2577,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, regular buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;

=== modified file 'mysql-test/r/subquery_sj_all_jcl6.result'
--- a/mysql-test/r/subquery_sj_all_jcl6.result	2010-08-12 11:48:10 +0000
+++ b/mysql-test/r/subquery_sj_all_jcl6.result	2010-09-02 07:34:10 +0000
@@ -2581,8 +2581,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, incremental buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;
@@ -4052,8 +4052,8 @@ explain extended select * from t0
 where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
 t1.b=t2.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where
-1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Start temporary; Using join buffer (BKA, incremental buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Using join buffer (BKA, incremental buffers)
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	100.00	Using where; End temporary; Using join buffer (BKA, incremental buffers)
 Warnings:
 Note	1276	Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1
@@ -4064,11 +4064,12 @@ create temporary table tmp select * from
 (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b);
 create temporary table tmp_as_ref (a int);
 insert into tmp_as_ref values(0),(1),(2),(3);
-
-# The result below is wrong due to Bug#49129
 select * from tmp;
 a
 0
+1
+2
+3
 drop table t0, t1, t2, tmp, tmp_as_ref;
 CREATE TABLE t1 (
 id int(11) NOT NULL,

=== modified file 'mysql-test/r/subquery_sj_all_jcl7.result'
--- a/mysql-test/r/subquery_sj_all_jcl7.result	2010-08-12 11:48:10 +0000
+++ b/mysql-test/r/subquery_sj_all_jcl7.result	2010-09-02 07:34:10 +0000
@@ -2581,8 +2581,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, regular buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;
@@ -4052,8 +4052,8 @@ explain extended select * from t0
 where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
 t1.b=t2.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where
-1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Start temporary; Using join buffer (BKA_UNIQUE, regular buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Using join buffer (BKA_UNIQUE, regular buffers)
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	100.00	Using where; End temporary; Using join buffer (BKA_UNIQUE, regular buffers)
 Warnings:
 Note	1276	Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1
@@ -4064,11 +4064,12 @@ create temporary table tmp select * from
 (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b);
 create temporary table tmp_as_ref (a int);
 insert into tmp_as_ref values(0),(1),(2),(3);
-
-# The result below is wrong due to Bug#49129
 select * from tmp;
 a
 0
+1
+2
+3
 drop table t0, t1, t2, tmp, tmp_as_ref;
 CREATE TABLE t1 (
 id int(11) NOT NULL,

=== modified file 'mysql-test/r/subquery_sj_dupsweed.result'
--- a/mysql-test/r/subquery_sj_dupsweed.result	2010-08-12 11:48:10 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed.result	2010-09-02 07:34:10 +0000
@@ -1686,8 +1686,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1727,8 +1727,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1833,8 +1833,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t3	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 i
@@ -2576,8 +2576,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, regular buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;

=== modified file 'mysql-test/r/subquery_sj_dupsweed_jcl6.result'
--- a/mysql-test/r/subquery_sj_dupsweed_jcl6.result	2010-08-12 11:48:10 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed_jcl6.result	2010-09-02 07:34:10 +0000
@@ -59,8 +59,8 @@ a
 4
 explain extended select * from t2 where t2.a in (select a from t1);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index
-1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using index; Start temporary; End temporary
+1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using index; End temporary
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`)
 select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
@@ -69,8 +69,8 @@ a
 4
 explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index
-1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using where; Using index; Start temporary; End temporary
+1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using where; Using index; End temporary
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
 select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
@@ -96,8 +96,8 @@ a
 4
 explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index
-1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using where; Using index; Start temporary; End temporary
+1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using where; Using index; End temporary
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
 drop table t0, t1, t2, t3;
@@ -1690,8 +1690,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, incremental buffers)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1731,8 +1731,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, incremental buffers)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1837,8 +1837,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t3	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, incremental buffers)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 i
@@ -2179,8 +2179,8 @@ create table t3 (a int);
 insert into t3 select A.a + 10*B.a from t0 A, t0 B;
 explain select * from t3 where a in (select kp1 from t1 where kp1<20);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where
-1	PRIMARY	t1	ref	kp1	kp1	5	test.t3.a	1	Using index; Start temporary; End temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where; Start temporary
+1	PRIMARY	t1	ref	kp1	kp1	5	test.t3.a	1	Using index; End temporary
 select * from t3 where a in (select kp1 from t1 where kp1<20);
 a
 0
@@ -2208,8 +2208,8 @@ insert into t4 select a from t3;
 explain select * from t3 where a in 
 (select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where
-1	PRIMARY	t1	ref	kp1	kp1	5	test.t3.a	1	Using where; Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where; Start temporary
+1	PRIMARY	t1	ref	kp1	kp1	5	test.t3.a	1	Using where
 1	PRIMARY	t4	eq_ref	PRIMARY	PRIMARY	4	test.t1.c	1	Using index; End temporary
 select * from t3 where a in 
 (select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c);
@@ -2370,12 +2370,12 @@ insert into t1 select A.a, B.a, 'filler'
 create table t2 as select * from t1;
 explain select * from t2 where a in (select b from t1 where a=3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	100	Using where
-1	PRIMARY	t1	ref	a	a	10	const,test.t2.a	1	Using index; Start temporary; End temporary
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	100	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	10	const,test.t2.a	1	Using index; End temporary
 explain select * from t2 where (b,a) in (select a,b from t1 where a=3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	100	Using where
-1	PRIMARY	t1	ref	a	a	10	const,test.t2.a	1	Using index; Start temporary; End temporary
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	100	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	10	const,test.t2.a	1	Using index; End temporary
 drop table t1,t2;
 create table t1 (a int, b int);
 insert into t1 select a,a from t0;
@@ -2580,8 +2580,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, incremental buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;
@@ -4029,8 +4029,8 @@ EXPLAIN SELECT Name FROM t1 
 WHERE t1.Code IN (
 SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t1	ALL	PRIMARY	NULL	NULL	NULL	31	
-1	PRIMARY	t2	ref	CountryCode	CountryCode	3	test.t1.Code	18	Using where; Start temporary; End temporary
+1	PRIMARY	t1	ALL	PRIMARY	NULL	NULL	NULL	31	Start temporary
+1	PRIMARY	t2	ref	CountryCode	CountryCode	3	test.t1.Code	18	Using where; End temporary
 SELECT Name FROM t1 
 WHERE t1.Code IN (
 SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
@@ -4051,8 +4051,8 @@ explain extended select * from t0
 where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
 t1.b=t2.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where
-1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Start temporary
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	100.00	Using where; End temporary
 Warnings:
 Note	1276	Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1
@@ -4307,8 +4307,8 @@ alter table t3 add primary key(id), add 
 The following must use loose index scan over t3, key a:
 explain select count(a) from t2 where a in ( SELECT  a FROM t3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t2	index	a	a	5	NULL	1000	Using where; Using index
-1	PRIMARY	t3	ref	a	a	5	test.t2.a	30	Using index; Start temporary; End temporary
+1	PRIMARY	t2	index	a	a	5	NULL	1000	Using where; Using index; Start temporary
+1	PRIMARY	t3	ref	a	a	5	test.t2.a	30	Using index; End temporary
 select count(a) from t2 where a in ( SELECT  a FROM t3);
 count(a)
 1000

=== modified file 'mysql-test/r/subquery_sj_dupsweed_jcl7.result'
--- a/mysql-test/r/subquery_sj_dupsweed_jcl7.result	2010-08-12 11:48:10 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed_jcl7.result	2010-09-02 07:34:10 +0000
@@ -59,8 +59,8 @@ a
 4
 explain extended select * from t2 where t2.a in (select a from t1);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index
-1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using index; Start temporary; End temporary
+1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using index; End temporary
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`)
 select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
@@ -69,8 +69,8 @@ a
 4
 explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index
-1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using where; Using index; Start temporary; End temporary
+1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using where; Using index; End temporary
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
 select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
@@ -96,8 +96,8 @@ a
 4
 explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index
-1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using where; Using index; Start temporary; End temporary
+1	PRIMARY	t2	index	a	a	5	NULL	4	100.00	Using where; Using index; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t2.a	101	100.00	Using where; Using index; End temporary
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
 drop table t0, t1, t2, t3;
@@ -1690,8 +1690,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, regular buffers)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1731,8 +1731,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, regular buffers)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1837,8 +1837,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t3	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, regular buffers)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 i
@@ -2179,8 +2179,8 @@ create table t3 (a int);
 insert into t3 select A.a + 10*B.a from t0 A, t0 B;
 explain select * from t3 where a in (select kp1 from t1 where kp1<20);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where
-1	PRIMARY	t1	ref	kp1	kp1	5	test.t3.a	1	Using index; Start temporary; End temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where; Start temporary
+1	PRIMARY	t1	ref	kp1	kp1	5	test.t3.a	1	Using index; End temporary
 select * from t3 where a in (select kp1 from t1 where kp1<20);
 a
 0
@@ -2208,8 +2208,8 @@ insert into t4 select a from t3;
 explain select * from t3 where a in 
 (select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where
-1	PRIMARY	t1	ref	kp1	kp1	5	test.t3.a	1	Using where; Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	100	Using where; Start temporary
+1	PRIMARY	t1	ref	kp1	kp1	5	test.t3.a	1	Using where
 1	PRIMARY	t4	eq_ref	PRIMARY	PRIMARY	4	test.t1.c	1	Using index; End temporary
 select * from t3 where a in 
 (select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c);
@@ -2370,12 +2370,12 @@ insert into t1 select A.a, B.a, 'filler'
 create table t2 as select * from t1;
 explain select * from t2 where a in (select b from t1 where a=3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	100	Using where
-1	PRIMARY	t1	ref	a	a	10	const,test.t2.a	1	Using index; Start temporary; End temporary
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	100	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	10	const,test.t2.a	1	Using index; End temporary
 explain select * from t2 where (b,a) in (select a,b from t1 where a=3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	100	Using where
-1	PRIMARY	t1	ref	a	a	10	const,test.t2.a	1	Using index; Start temporary; End temporary
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	100	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	10	const,test.t2.a	1	Using index; End temporary
 drop table t1,t2;
 create table t1 (a int, b int);
 insert into t1 select a,a from t0;
@@ -2580,8 +2580,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, regular buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;
@@ -4029,8 +4029,8 @@ EXPLAIN SELECT Name FROM t1 
 WHERE t1.Code IN (
 SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t1	ALL	PRIMARY	NULL	NULL	NULL	31	
-1	PRIMARY	t2	ref	CountryCode	CountryCode	3	test.t1.Code	18	Using where; Start temporary; End temporary
+1	PRIMARY	t1	ALL	PRIMARY	NULL	NULL	NULL	31	Start temporary
+1	PRIMARY	t2	ref	CountryCode	CountryCode	3	test.t1.Code	18	Using where; End temporary
 SELECT Name FROM t1 
 WHERE t1.Code IN (
 SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
@@ -4051,8 +4051,8 @@ explain extended select * from t0
 where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
 t1.b=t2.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where
-1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Start temporary
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	100.00	Using where; End temporary
 Warnings:
 Note	1276	Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1
@@ -4307,8 +4307,8 @@ alter table t3 add primary key(id), add 
 The following must use loose index scan over t3, key a:
 explain select count(a) from t2 where a in ( SELECT  a FROM t3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t2	index	a	a	5	NULL	1000	Using where; Using index
-1	PRIMARY	t3	ref	a	a	5	test.t2.a	30	Using index; Start temporary; End temporary
+1	PRIMARY	t2	index	a	a	5	NULL	1000	Using where; Using index; Start temporary
+1	PRIMARY	t3	ref	a	a	5	test.t2.a	30	Using index; End temporary
 select count(a) from t2 where a in ( SELECT  a FROM t3);
 count(a)
 1000

=== modified file 'mysql-test/r/subquery_sj_firstmatch.result'
--- a/mysql-test/r/subquery_sj_firstmatch.result	2010-08-14 07:28:31 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch.result	2010-09-09 10:54:19 +0000
@@ -2577,8 +2577,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, regular buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;

=== modified file 'mysql-test/r/subquery_sj_firstmatch_jcl6.result'
--- a/mysql-test/r/subquery_sj_firstmatch_jcl6.result	2010-08-12 11:48:10 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch_jcl6.result	2010-09-02 07:34:10 +0000
@@ -2581,8 +2581,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, incremental buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;
@@ -4052,8 +4052,8 @@ explain extended select * from t0
 where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
 t1.b=t2.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where
-1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Start temporary
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	100.00	Using where; End temporary
 Warnings:
 Note	1276	Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1

=== modified file 'mysql-test/r/subquery_sj_firstmatch_jcl7.result'
--- a/mysql-test/r/subquery_sj_firstmatch_jcl7.result	2010-08-12 11:48:10 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch_jcl7.result	2010-09-02 07:34:10 +0000
@@ -2581,8 +2581,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, regular buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;
@@ -4052,8 +4052,8 @@ explain extended select * from t0
 where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
 t1.b=t2.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where
-1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Start temporary
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	100.00	Using where; End temporary
 Warnings:
 Note	1276	Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1

=== modified file 'mysql-test/r/subquery_sj_loosescan.result'
--- a/mysql-test/r/subquery_sj_loosescan.result	2010-08-12 11:48:10 +0000
+++ b/mysql-test/r/subquery_sj_loosescan.result	2010-09-02 07:34:10 +0000
@@ -1687,8 +1687,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1728,8 +1728,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1834,8 +1834,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t3	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 i
@@ -2577,8 +2577,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, regular buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;

=== modified file 'mysql-test/r/subquery_sj_loosescan_jcl6.result'
--- a/mysql-test/r/subquery_sj_loosescan_jcl6.result	2010-08-12 09:02:11 +0000
+++ b/mysql-test/r/subquery_sj_loosescan_jcl6.result	2010-09-02 07:34:10 +0000
@@ -1691,8 +1691,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, incremental buffers)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1732,8 +1732,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, incremental buffers)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1838,8 +1838,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t3	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, incremental buffers)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 i
@@ -2581,8 +2581,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, incremental buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;
@@ -4034,8 +4034,8 @@ EXPLAIN SELECT Name FROM t1 
 WHERE t1.Code IN (
 SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t1	ALL	PRIMARY	NULL	NULL	NULL	31	
-1	PRIMARY	t2	ref	CountryCode	CountryCode	3	test.t1.Code	18	Using where; Start temporary; End temporary
+1	PRIMARY	t1	ALL	PRIMARY	NULL	NULL	NULL	31	Start temporary
+1	PRIMARY	t2	ref	CountryCode	CountryCode	3	test.t1.Code	18	Using where; End temporary
 SELECT Name FROM t1 
 WHERE t1.Code IN (
 SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
@@ -4056,8 +4056,8 @@ explain extended select * from t0
 where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
 t1.b=t2.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where
-1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Start temporary
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	100.00	Using where; End temporary
 Warnings:
 Note	1276	Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1

=== modified file 'mysql-test/r/subquery_sj_loosescan_jcl7.result'
--- a/mysql-test/r/subquery_sj_loosescan_jcl7.result	2010-08-12 09:02:11 +0000
+++ b/mysql-test/r/subquery_sj_loosescan_jcl7.result	2010-09-02 07:34:10 +0000
@@ -1691,8 +1691,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, regular buffers)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1732,8 +1732,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, regular buffers)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1838,8 +1838,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t3	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, regular buffers)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i);
 i
@@ -2581,8 +2581,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, regular buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;
@@ -4034,8 +4034,8 @@ EXPLAIN SELECT Name FROM t1 
 WHERE t1.Code IN (
 SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t1	ALL	PRIMARY	NULL	NULL	NULL	31	
-1	PRIMARY	t2	ref	CountryCode	CountryCode	3	test.t1.Code	18	Using where; Start temporary; End temporary
+1	PRIMARY	t1	ALL	PRIMARY	NULL	NULL	NULL	31	Start temporary
+1	PRIMARY	t2	ref	CountryCode	CountryCode	3	test.t1.Code	18	Using where; End temporary
 SELECT Name FROM t1 
 WHERE t1.Code IN (
 SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
@@ -4056,8 +4056,8 @@ explain extended select * from t0
 where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
 t1.b=t2.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where
-1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Start temporary
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	100.00	Using where; End temporary
 Warnings:
 Note	1276	Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1

=== modified file 'mysql-test/r/subquery_sj_mat.result'
--- a/mysql-test/r/subquery_sj_mat.result	2010-08-12 09:02:11 +0000
+++ b/mysql-test/r/subquery_sj_mat.result	2010-09-02 07:34:10 +0000
@@ -1728,8 +1728,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2577,8 +2577,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, regular buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;

=== modified file 'mysql-test/r/subquery_sj_mat_jcl6.result'
--- a/mysql-test/r/subquery_sj_mat_jcl6.result	2010-08-12 09:02:11 +0000
+++ b/mysql-test/r/subquery_sj_mat_jcl6.result	2010-09-02 07:34:10 +0000
@@ -1732,8 +1732,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, incremental buffers)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2581,8 +2581,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, incremental buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, incremental buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;
@@ -4052,8 +4052,8 @@ explain extended select * from t0
 where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
 t1.b=t2.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where
-1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Start temporary
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	100.00	Using where; End temporary
 Warnings:
 Note	1276	Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1

=== modified file 'mysql-test/r/subquery_sj_mat_jcl7.result'
--- a/mysql-test/r/subquery_sj_mat_jcl7.result	2010-08-12 09:02:11 +0000
+++ b/mysql-test/r/subquery_sj_mat_jcl7.result	2010-09-02 07:34:10 +0000
@@ -1732,8 +1732,8 @@ 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	t2	system	NULL	NULL	NULL	NULL	1	
-1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary; End temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (BNL, regular buffers)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2581,8 +2581,8 @@ explain select * 
 from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	
-1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Start temporary; Using join buffer (BNL, regular buffers)
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
+1	PRIMARY	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (BNL, regular buffers)
 1	PRIMARY	t2	ref	a	a	5	test.t1.a	1	Using index
 1	PRIMARY	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
 drop table t0, t1,t2,t3;
@@ -4052,8 +4052,8 @@ explain extended select * from t0
 where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
 t1.b=t2.b);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
-1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where
-1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	Start temporary
+1	PRIMARY	t0	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Start temporary
+1	PRIMARY	t1	ref	a	a	5	test.t0.a	1	100.00	
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	100.00	Using where; End temporary
 Warnings:
 Note	1276	Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1

=== modified file 'mysql-test/r/temp_table.result'
--- a/mysql-test/r/temp_table.result	2010-06-23 11:34:40 +0000
+++ b/mysql-test/r/temp_table.result	2010-08-30 06:38:09 +0000
@@ -145,7 +145,7 @@ DROP TABLE t1;
 CREATE TABLE t1 (i INT);
 CREATE TEMPORARY TABLE t2 (i INT);
 DROP TEMPORARY TABLE t2, t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 SELECT * FROM t2;
 ERROR 42S02: Table 'test.t2' doesn't exist
 SELECT * FROM t1;

=== modified file 'mysql-test/r/truncate_coverage.result'
--- a/mysql-test/r/truncate_coverage.result	2010-06-11 13:32:12 +0000
+++ b/mysql-test/r/truncate_coverage.result	2010-08-30 06:38:09 +0000
@@ -50,7 +50,7 @@ HANDLER t1 CLOSE;
 ERROR 42S02: Table 'test.t1' doesn't exist
 UNLOCK TABLES;
 DROP TABLE t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 SET DEBUG_SYNC='RESET';
 CREATE TABLE t1 (c1 INT);
 INSERT INTO t1 VALUES (1);

=== modified file 'mysql-test/r/type_newdecimal.result'
--- a/mysql-test/r/type_newdecimal.result	2010-04-11 06:52:42 +0000
+++ b/mysql-test/r/type_newdecimal.result	2010-08-30 06:38:09 +0000
@@ -680,7 +680,7 @@ select 0.8 = 0.7 + 0.1;
 1
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 create table t1 (col1 decimal(38));
 insert into t1 values (12345678901234567890123456789012345678);
 select * from t1;

=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result	2010-08-04 10:34:01 +0000
+++ b/mysql-test/r/view.result	2010-08-30 06:38:09 +0000
@@ -199,11 +199,11 @@ c	d
 2	5
 3	10
 drop view v100;
-ERROR 42S02: Unknown table 'v100'
+ERROR 42S02: Unknown table 'test.v100'
 drop view t1;
 ERROR HY000: 'test.t1' is not VIEW
 drop table v1;
-ERROR 42S02: Unknown table 'v1'
+ERROR 42S02: Unknown table 'test.v1'
 drop view v1,v2;
 drop table t1;
 create table t1 (a int);
@@ -2868,7 +2868,7 @@ Tables_in_test
 t1
 v1
 DROP VIEW v2,v1;
-ERROR 42S02: Unknown table 'v2'
+ERROR 42S02: Unknown table 'test.v2'
 SHOW TABLES;
 Tables_in_test
 t1

=== modified file 'mysql-test/r/warnings.result'
--- a/mysql-test/r/warnings.result	2010-03-20 09:35:40 +0000
+++ b/mysql-test/r/warnings.result	2010-08-30 06:38:09 +0000
@@ -48,13 +48,13 @@ drop table t1;
 set SQL_WARNINGS=0;
 drop temporary table if exists not_exists;
 Warnings:
-Note	1051	Unknown table 'not_exists'
+Note	1051	Unknown table 'test.not_exists'
 drop table if exists not_exists_table;
 Warnings:
-Note	1051	Unknown table 'not_exists_table'
+Note	1051	Unknown table 'test.not_exists_table'
 show warnings limit 1;
 Level	Code	Message
-Note	1051	Unknown table 'not_exists_table'
+Note	1051	Unknown table 'test.not_exists_table'
 drop database if exists not_exists_db;
 Warnings:
 Note	1008	Can't drop database 'not_exists_db'; database doesn't exist
@@ -311,8 +311,8 @@ insert into t2 values(@q);
 ERROR 22001: Data too long for column 'c_tinyblob' at row 1
 drop table t1, t2;
 DROP TABLE t1;
-ERROR 42S02: Unknown table 't1'
+ERROR 42S02: Unknown table 'test.t1'
 SHOW ERRORS;
 Level	Code	Message
-Error	1051	Unknown table 't1'
+Error	1051	Unknown table 'test.t1'
 End of 5.0 tests

=== added file 'mysql-test/std_data/parts/t1_blackhole.frm'
Files a/mysql-test/std_data/parts/t1_blackhole.frm	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/parts/t1_blackhole.frm	2010-07-08 12:36:55 +0000 differ

=== added file 'mysql-test/std_data/parts/t1_blackhole.par'
Files a/mysql-test/std_data/parts/t1_blackhole.par	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/parts/t1_blackhole.par	2010-07-08 12:36:55 +0000 differ

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

=== modified file 'mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result'
--- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result	2010-08-20 03:51:38 +0000
+++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result	2010-08-30 06:38:09 +0000
@@ -308,7 +308,7 @@ CREATE TABLE t2 (primary key (a)) engine
 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
 DROP TABLE if exists t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 INSERT INTO t1 values (3,3);
 CREATE TEMPORARY TABLE t2 (primary key (a)) engine=innodb select * from t1;
 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
@@ -317,7 +317,7 @@ Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
 DROP TABLE IF EXISTS t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb;
 INSERT INTO t1 VALUES (4,4);
 CREATE TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;

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

=== modified file 'mysql-test/suite/binlog/r/binlog_stm_binlog.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result	2010-08-20 03:37:42 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result	2010-09-01 02:51:08 +0000
@@ -462,9 +462,9 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 112 )
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 111 )
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 110 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 109 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 108 )
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( <binlog_start> )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 108 )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 107 )
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 106 )
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 105 )
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 104 )
@@ -758,8 +758,9 @@ master-bin.000001	#	Table_map	#	#	table_
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	use `test`; FLUSH TABLES
-insert delayed into t1 values (null),(null),(null),(null);
-insert delayed into t1 values (null),(null),(400),(null);
+RESET MASTER;
+insert /* before delayed */ delayed /* after delayed */ into t1 values (null),(null),(null),(null);
+insert  /*! delayed */ into t1 values (null),(null),(400),(null);
 select * from t1;
 a
 207

=== modified file 'mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result	2010-08-20 03:51:38 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result	2010-08-30 06:38:09 +0000
@@ -302,7 +302,7 @@ CREATE TABLE t2 (primary key (a)) engine
 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
 DROP TABLE if exists t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 INSERT INTO t1 values (3,3);
 CREATE TEMPORARY TABLE t2 (primary key (a)) engine=innodb select * from t1;
 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
@@ -311,7 +311,7 @@ Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
 DROP TABLE IF EXISTS t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb;
 INSERT INTO t1 VALUES (4,4);
 CREATE TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;

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

=== modified file 'mysql-test/suite/binlog/t/binlog_incident.test'
--- a/mysql-test/suite/binlog/t/binlog_incident.test	2009-12-01 19:07:18 +0000
+++ b/mysql-test/suite/binlog/t/binlog_incident.test	2010-07-07 06:48:50 +0000
@@ -8,6 +8,8 @@ source include/have_debug.inc;
 let $MYSQLD_DATADIR= `select @@datadir`;
 RESET MASTER;
 
+let $start_pos= query_get_value("SHOW MASTER STATUS", Position, 1);
+let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1);
 CREATE TABLE t1 (a INT);
 
 INSERT INTO t1 VALUES (1),(2),(3);
@@ -20,7 +22,7 @@ REPLACE INTO t1 VALUES (4);
 DROP TABLE t1;
 FLUSH LOGS;
 
-exec $MYSQL_BINLOG --start-position=107 $MYSQLD_DATADIR/master-bin.000001 >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
+exec $MYSQL_BINLOG --start-position=$start_pos $MYSQLD_DATADIR/$master_binlog >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
 --disable_query_log
 eval SELECT cont LIKE '%RELOAD DATABASE; # Shall generate syntax error%' AS `Contain RELOAD DATABASE` FROM (SELECT load_file('$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql') AS cont) AS tbl;
 --enable_query_log

=== modified file 'mysql-test/suite/binlog/t/binlog_unsafe.test'
--- a/mysql-test/suite/binlog/t/binlog_unsafe.test	2010-08-10 11:58:46 +0000
+++ b/mysql-test/suite/binlog/t/binlog_unsafe.test	2010-08-30 06:11:20 +0000
@@ -179,13 +179,13 @@ while (`SELECT $unsafe_type < 9`) {
   }
 
   if (`SELECT $unsafe_type = 3`) {
-    --echo ==== Testing INSERT DELAYED unsafeness ====
+    --echo ==== Testing INSERT DELAYED safeness after BUG#54579 is fixed ====
     --let $desc_0= unsafe INSERT DELAYED statement
     --let $stmt_sidef_0= INSERT DELAYED INTO t0 VALUES (1), (2)
     --let $value_0=
     --let $sel_sidef_0=
     --let $sel_retval_0=
-    --let $CRC_ARG_expected_number_of_warnings= 1
+    --let $CRC_ARG_expected_number_of_warnings= 0
   }
 
   if (`SELECT $unsafe_type = 4`) {
@@ -227,7 +227,7 @@ while (`SELECT $unsafe_type < 9`) {
     --let $value_0=
     --let $sel_sidef_0=
     --let $sel_retval_0=
-    --let $CRC_ARG_expected_number_of_warnings= 7
+    --let $CRC_ARG_expected_number_of_warnings= 6
   }
 
   if (`SELECT $unsafe_type = 8`) {

=== modified file 'mysql-test/suite/federated/federated.result'
--- a/mysql-test/suite/federated/federated.result	2010-05-14 10:58:39 +0000
+++ b/mysql-test/suite/federated/federated.result	2010-08-31 06:28:15 +0000
@@ -6,7 +6,7 @@ SET @OLD_SLAVE_CONCURRENT_INSERT= @@GLOB
 SET @@GLOBAL.CONCURRENT_INSERT= 0;
 DROP TABLE IF EXISTS federated.t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'federated.t1'
 CREATE TABLE federated.t1 (
 `id` int(20) NOT NULL,
 `group` int NOT NULL default 0,
@@ -17,7 +17,7 @@ CREATE TABLE federated.t1 (
 DEFAULT CHARSET=latin1;
 DROP TABLE IF EXISTS federated.t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'federated.t1'
 CREATE TABLE federated.t1 (
 `id` int(20) NOT NULL,
 `group` int NOT NULL default 0,
@@ -87,7 +87,7 @@ DELETE FROM federated.t1;
 DROP TABLE federated.t1;
 DROP TABLE IF EXISTS federated.t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'federated.t2'
 CREATE TABLE federated.t2 (
 `id` int(20) NOT NULL,
 `name` varchar(32) NOT NULL default ''
@@ -110,7 +110,7 @@ DROP TABLE federated.t2;
 DROP TABLE IF EXISTS federated.t1;
 DROP TABLE IF EXISTS federated.`t1%`;
 Warnings:
-Note	1051	Unknown table 't1%'
+Note	1051	Unknown table 'federated.t1%'
 CREATE TABLE federated.`t1%` (
 `id` int(20) NOT NULL,
 `name` varchar(32) NOT NULL default ''
@@ -118,7 +118,7 @@ CREATE TABLE federated.`t1%` (
 DEFAULT CHARSET=latin1;
 DROP TABLE IF EXISTS federated.t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'federated.t1'
 CREATE TABLE federated.t1 (
 `id` int(20) NOT NULL,
 `name` varchar(32) NOT NULL default ''
@@ -150,7 +150,7 @@ DROP TABLE IF EXISTS federated.`t1%`;
 DROP TABLE IF EXISTS federated.`t1%`;
 DROP TABLE IF EXISTS federated.t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'federated.t1'
 CREATE TABLE federated.t1 (
 `id` int(20) NOT NULL auto_increment,
 `name` varchar(32) NOT NULL default '',
@@ -1389,7 +1389,7 @@ PRIMARY KEY  (`id`),
 key (country_id));
 DROP TABLE IF EXISTS federated.countries;
 Warnings:
-Note	1051	Unknown table 'countries'
+Note	1051	Unknown table 'federated.countries'
 CREATE TABLE federated.countries (
 `id` int(20) NOT NULL auto_increment,
 `country` varchar(32),
@@ -1542,13 +1542,13 @@ drop table federated.t1;
 drop table federated.t1;
 DROP TABLE IF EXISTS federated.t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'federated.t1'
 CREATE TABLE federated.t1 (
 `id` int(20) NOT NULL auto_increment,
 PRIMARY KEY  (`id`));
 DROP TABLE IF EXISTS federated.t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'federated.t1'
 CREATE TABLE federated.t1 (
 `id` int(20) NOT NULL auto_increment,
 PRIMARY KEY  (`id`)

=== modified file 'mysql-test/suite/federated/federated_server.result'
--- a/mysql-test/suite/federated/federated_server.result	2010-07-31 13:10:27 +0000
+++ b/mysql-test/suite/federated/federated_server.result	2010-08-31 06:28:15 +0000
@@ -5,7 +5,7 @@ create database second_db;
 use first_db;
 DROP TABLE IF EXISTS first_db.t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'first_db.t1'
 CREATE TABLE first_db.t1 (
 `id` int(20) NOT NULL,
 `name` varchar(64) NOT NULL default ''
@@ -13,7 +13,7 @@ CREATE TABLE first_db.t1 (
 DEFAULT CHARSET=latin1;
 DROP TABLE IF EXISTS first_db.t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'first_db.t2'
 CREATE TABLE first_db.t2 (
 `id` int(20) NOT NULL,
 `name` varchar(64) NOT NULL default ''
@@ -22,7 +22,7 @@ DEFAULT CHARSET=latin1;
 use second_db;
 DROP TABLE IF EXISTS second_db.t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'second_db.t1'
 CREATE TABLE second_db.t1 (
 `id` int(20) NOT NULL,
 `name` varchar(64) NOT NULL default ''
@@ -30,7 +30,7 @@ CREATE TABLE second_db.t1 (
 DEFAULT CHARSET=latin1;
 DROP TABLE IF EXISTS second_db.t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'second_db.t2'
 CREATE TABLE second_db.t2 (
 `id` int(20) NOT NULL,
 `name` varchar(64) NOT NULL default ''
@@ -60,7 +60,7 @@ server_one	127.0.0.1	first_db	root		SLAV
 server_two	127.0.0.1	second_db	root		SLAVE_PORT		mysql	root
 DROP TABLE IF EXISTS federated.old;
 Warnings:
-Note	1051	Unknown table 'old'
+Note	1051	Unknown table 'federated.old'
 CREATE TABLE federated.old (
 `id` int(20) NOT NULL,
 `name` varchar(64) NOT NULL default ''
@@ -73,7 +73,7 @@ id	name
 1	federated.old-> first_db.t1, url format
 DROP TABLE IF EXISTS federated.old2;
 Warnings:
-Note	1051	Unknown table 'old2'
+Note	1051	Unknown table 'federated.old2'
 CREATE TABLE federated.old2 (
 `id` int(20) NOT NULL,
 `name` varchar(64) NOT NULL default ''
@@ -86,7 +86,7 @@ id	name
 1	federated.old2-> first_db.t2, url format
 DROP TABLE IF EXISTS federated.urldb2t1;
 Warnings:
-Note	1051	Unknown table 'urldb2t1'
+Note	1051	Unknown table 'federated.urldb2t1'
 CREATE TABLE federated.urldb2t1 (
 `id` int(20) NOT NULL,
 `name` varchar(64) NOT NULL default ''
@@ -99,7 +99,7 @@ id	name
 1	federated.urldb2t1 -> second_db.t1, url format
 DROP TABLE IF EXISTS federated.urldb2t2;
 Warnings:
-Note	1051	Unknown table 'urldb2t2'
+Note	1051	Unknown table 'federated.urldb2t2'
 CREATE TABLE federated.urldb2t2 (
 `id` int(20) NOT NULL,
 `name` varchar(64) NOT NULL default ''
@@ -112,7 +112,7 @@ id	name
 1	federated.urldb2t2 -> second_db.t2, url format
 DROP TABLE IF EXISTS federated.t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'federated.t1'
 CREATE TABLE federated.t1 (
 `id` int(20) NOT NULL,
 `name` varchar(64) NOT NULL default ''
@@ -126,7 +126,7 @@ id	name
 1	server_one, new scheme, first_db.t1
 DROP TABLE IF EXISTS federated.whatever;
 Warnings:
-Note	1051	Unknown table 'whatever'
+Note	1051	Unknown table 'federated.whatever'
 CREATE TABLE federated.whatever (
 `id` int(20) NOT NULL,
 `name` varchar(64) NOT NULL default ''

=== modified file 'mysql-test/suite/funcs_1/r/innodb_trig_0102.result'
--- a/mysql-test/suite/funcs_1/r/innodb_trig_0102.result	2009-02-13 18:07:56 +0000
+++ b/mysql-test/suite/funcs_1/r/innodb_trig_0102.result	2010-08-31 06:28:15 +0000
@@ -185,7 +185,7 @@ Testcase 3.5.1.7: - need to fix
 -------------------------------
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 create table t1 (f1 int, f2 char(25),f3 int) engine = <engine_to_be_used>;
 CREATE TRIGGER trg5_1 BEFORE INSERT on test.t1
 for each row set new.f3 = '14';

=== modified file 'mysql-test/suite/funcs_1/r/innodb_views.result'
--- a/mysql-test/suite/funcs_1/r/innodb_views.result	2010-05-30 07:48:22 +0000
+++ b/mysql-test/suite/funcs_1/r/innodb_views.result	2010-08-31 06:28:15 +0000
@@ -21300,7 +21300,7 @@ CREATE TABLE t1 ( f1 VARCHAR(1000) ) ENG
 CREATE VIEW  v1 AS SELECT f1 FROM t1;
 DROP VIEW v1;
 DROP VIEW v1;
-ERROR 42S02: Unknown table 'v1'
+ERROR 42S02: Unknown table 'test.v1'
 CREATE VIEW  v1 AS SELECT f1 FROM t1;
 DROP VIEW IF EXISTS v1;
 DROP VIEW IF EXISTS v1;
@@ -21317,31 +21317,31 @@ CREATE VIEW  v1_base AS SELECT * FROM t1
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_top  ;
 DROP VIEW v1_top;
-ERROR 42S02: Unknown table 'v1_top'
+ERROR 42S02: Unknown table 'test.v1_top'
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_base  ;
 DROP VIEW v1_base;
-ERROR 42S02: Unknown table 'v1_base'
+ERROR 42S02: Unknown table 'test.v1_base'
 DROP VIEW v1_top;
 CREATE VIEW  v1_base AS SELECT * FROM t1;
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_top CASCADE ;
 DROP VIEW v1_top;
-ERROR 42S02: Unknown table 'v1_top'
+ERROR 42S02: Unknown table 'test.v1_top'
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_base CASCADE ;
 DROP VIEW v1_base;
-ERROR 42S02: Unknown table 'v1_base'
+ERROR 42S02: Unknown table 'test.v1_base'
 DROP VIEW v1_top;
 CREATE VIEW  v1_base AS SELECT * FROM t1;
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_top RESTRICT ;
 DROP VIEW v1_top;
-ERROR 42S02: Unknown table 'v1_top'
+ERROR 42S02: Unknown table 'test.v1_top'
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_base RESTRICT ;
 DROP VIEW v1_base;
-ERROR 42S02: Unknown table 'v1_base'
+ERROR 42S02: Unknown table 'test.v1_base'
 DROP VIEW v1_top;
 
 Testcase 3.3.1.69, 3.3.1.70, 3.3.1.A5 

=== modified file 'mysql-test/suite/funcs_1/r/memory_trig_0102.result'
--- a/mysql-test/suite/funcs_1/r/memory_trig_0102.result	2009-02-13 18:07:56 +0000
+++ b/mysql-test/suite/funcs_1/r/memory_trig_0102.result	2010-08-31 06:28:15 +0000
@@ -186,7 +186,7 @@ Testcase 3.5.1.7: - need to fix
 -------------------------------
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 create table t1 (f1 int, f2 char(25),f3 int) engine = <engine_to_be_used>;
 CREATE TRIGGER trg5_1 BEFORE INSERT on test.t1
 for each row set new.f3 = '14';

=== modified file 'mysql-test/suite/funcs_1/r/memory_views.result'
--- a/mysql-test/suite/funcs_1/r/memory_views.result	2010-05-30 07:48:22 +0000
+++ b/mysql-test/suite/funcs_1/r/memory_views.result	2010-08-31 06:28:15 +0000
@@ -21302,7 +21302,7 @@ CREATE TABLE t1 ( f1 VARCHAR(1000) ) ENG
 CREATE VIEW  v1 AS SELECT f1 FROM t1;
 DROP VIEW v1;
 DROP VIEW v1;
-ERROR 42S02: Unknown table 'v1'
+ERROR 42S02: Unknown table 'test.v1'
 CREATE VIEW  v1 AS SELECT f1 FROM t1;
 DROP VIEW IF EXISTS v1;
 DROP VIEW IF EXISTS v1;
@@ -21319,31 +21319,31 @@ CREATE VIEW  v1_base AS SELECT * FROM t1
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_top  ;
 DROP VIEW v1_top;
-ERROR 42S02: Unknown table 'v1_top'
+ERROR 42S02: Unknown table 'test.v1_top'
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_base  ;
 DROP VIEW v1_base;
-ERROR 42S02: Unknown table 'v1_base'
+ERROR 42S02: Unknown table 'test.v1_base'
 DROP VIEW v1_top;
 CREATE VIEW  v1_base AS SELECT * FROM t1;
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_top CASCADE ;
 DROP VIEW v1_top;
-ERROR 42S02: Unknown table 'v1_top'
+ERROR 42S02: Unknown table 'test.v1_top'
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_base CASCADE ;
 DROP VIEW v1_base;
-ERROR 42S02: Unknown table 'v1_base'
+ERROR 42S02: Unknown table 'test.v1_base'
 DROP VIEW v1_top;
 CREATE VIEW  v1_base AS SELECT * FROM t1;
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_top RESTRICT ;
 DROP VIEW v1_top;
-ERROR 42S02: Unknown table 'v1_top'
+ERROR 42S02: Unknown table 'test.v1_top'
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_base RESTRICT ;
 DROP VIEW v1_base;
-ERROR 42S02: Unknown table 'v1_base'
+ERROR 42S02: Unknown table 'test.v1_base'
 DROP VIEW v1_top;
 
 Testcase 3.3.1.69, 3.3.1.70, 3.3.1.A5 

=== modified file 'mysql-test/suite/funcs_1/r/myisam_trig_0102.result'
--- a/mysql-test/suite/funcs_1/r/myisam_trig_0102.result	2009-02-13 18:07:56 +0000
+++ b/mysql-test/suite/funcs_1/r/myisam_trig_0102.result	2010-08-31 06:28:15 +0000
@@ -186,7 +186,7 @@ Testcase 3.5.1.7: - need to fix
 -------------------------------
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 create table t1 (f1 int, f2 char(25),f3 int) engine = <engine_to_be_used>;
 CREATE TRIGGER trg5_1 BEFORE INSERT on test.t1
 for each row set new.f3 = '14';

=== modified file 'mysql-test/suite/funcs_1/r/myisam_views.result'
--- a/mysql-test/suite/funcs_1/r/myisam_views.result	2010-05-30 07:48:22 +0000
+++ b/mysql-test/suite/funcs_1/r/myisam_views.result	2010-08-31 06:28:15 +0000
@@ -22977,7 +22977,7 @@ CREATE TABLE t1 ( f1 VARCHAR(1000) ) ENG
 CREATE VIEW  v1 AS SELECT f1 FROM t1;
 DROP VIEW v1;
 DROP VIEW v1;
-ERROR 42S02: Unknown table 'v1'
+ERROR 42S02: Unknown table 'test.v1'
 CREATE VIEW  v1 AS SELECT f1 FROM t1;
 DROP VIEW IF EXISTS v1;
 DROP VIEW IF EXISTS v1;
@@ -22994,31 +22994,31 @@ CREATE VIEW  v1_base AS SELECT * FROM t1
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_top  ;
 DROP VIEW v1_top;
-ERROR 42S02: Unknown table 'v1_top'
+ERROR 42S02: Unknown table 'test.v1_top'
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_base  ;
 DROP VIEW v1_base;
-ERROR 42S02: Unknown table 'v1_base'
+ERROR 42S02: Unknown table 'test.v1_base'
 DROP VIEW v1_top;
 CREATE VIEW  v1_base AS SELECT * FROM t1;
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_top CASCADE ;
 DROP VIEW v1_top;
-ERROR 42S02: Unknown table 'v1_top'
+ERROR 42S02: Unknown table 'test.v1_top'
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_base CASCADE ;
 DROP VIEW v1_base;
-ERROR 42S02: Unknown table 'v1_base'
+ERROR 42S02: Unknown table 'test.v1_base'
 DROP VIEW v1_top;
 CREATE VIEW  v1_base AS SELECT * FROM t1;
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_top RESTRICT ;
 DROP VIEW v1_top;
-ERROR 42S02: Unknown table 'v1_top'
+ERROR 42S02: Unknown table 'test.v1_top'
 CREATE VIEW  v1_top AS SELECT * FROM v1_base;
 DROP VIEW v1_base RESTRICT ;
 DROP VIEW v1_base;
-ERROR 42S02: Unknown table 'v1_base'
+ERROR 42S02: Unknown table 'test.v1_base'
 DROP VIEW v1_top;
 
 Testcase 3.3.1.69, 3.3.1.70, 3.3.1.A5 

=== modified file 'mysql-test/suite/funcs_1/r/storedproc.result'
--- a/mysql-test/suite/funcs_1/r/storedproc.result	2010-08-16 07:30:40 +0000
+++ b/mysql-test/suite/funcs_1/r/storedproc.result	2010-08-31 06:28:15 +0000
@@ -1822,7 +1822,7 @@ grant execute on db_storedproc.* to 'use
 flush privileges;
 drop table IF EXISTS mysql.t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'mysql.t1'
 create table mysql.t1( f1 char );
 DROP PROCEDURE IF EXISTS sp11;
 Warnings:
@@ -22352,7 +22352,7 @@ Warnings:
 Note	1305	FUNCTION db_storedproc.fn1 does not exist
 drop table IF EXISTS res_t9;
 Warnings:
-Note	1051	Unknown table 'res_t9'
+Note	1051	Unknown table 'db_storedproc.res_t9'
 create table res_t9 (f1 int, f2 char(25), f3 int);
 insert into res_t9 values (10, 'abc', 20);
 CREATE FUNCTION fn1(i1 longtext) returns longtext
@@ -22378,7 +22378,7 @@ Warnings:
 Note	1305	FUNCTION db_storedproc.fn1 does not exist
 drop  table IF EXISTS res_t9;
 Warnings:
-Note	1051	Unknown table 'res_t9'
+Note	1051	Unknown table 'db_storedproc.res_t9'
 create table res_t9 (f1 int, f2 char(25), f3 int);
 CREATE FUNCTION fn1(i1 longtext) returns longtext
 BEGIN

=== modified file 'mysql-test/suite/innodb/r/innodb-autoinc.result'
--- a/mysql-test/suite/innodb/r/innodb-autoinc.result	2010-04-16 16:19:07 +0000
+++ b/mysql-test/suite/innodb/r/innodb-autoinc.result	2010-08-30 06:38:09 +0000
@@ -171,7 +171,7 @@ t1	CREATE TABLE `t1` (
 DROP TABLE t1;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES (NULL, 1);
 DELETE FROM t1 WHERE c1 = 1;
@@ -184,7 +184,7 @@ c1	c2
 DROP TABLE t1;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES (NULL, 1);
 DELETE FROM t1 WHERE c1 = 1;
@@ -203,7 +203,7 @@ auto_increment_increment	100
 auto_increment_offset	10
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES (NULL),(5),(NULL);
 INSERT INTO t1 VALUES (250),(NULL);
@@ -236,7 +236,7 @@ auto_increment_increment	1
 auto_increment_offset	1
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES(0);
 SELECT * FROM t1;
@@ -275,7 +275,7 @@ auto_increment_increment	1
 auto_increment_offset	1
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES(-1);
 SELECT * FROM t1;
@@ -321,7 +321,7 @@ auto_increment_increment	1
 auto_increment_offset	1
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES(-1);
 Warnings:
@@ -376,7 +376,7 @@ auto_increment_increment	1
 auto_increment_offset	1
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES(-1);
 Warnings:
@@ -425,7 +425,7 @@ auto_increment_increment	1
 auto_increment_offset	1
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES(NULL);
 INSERT INTO t1 VALUES (9223372036854775794);
@@ -458,7 +458,7 @@ auto_increment_increment	1
 auto_increment_offset	1
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES(NULL);
 INSERT INTO t1 VALUES (18446744073709551603);
@@ -491,7 +491,7 @@ auto_increment_increment	1
 auto_increment_offset	1
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES(NULL);
 INSERT INTO t1 VALUES (18446744073709551603);
@@ -520,7 +520,7 @@ auto_increment_increment	1
 auto_increment_offset	1
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES(NULL);
 INSERT INTO t1 VALUES(-9223372036854775806);
@@ -556,7 +556,7 @@ auto_increment_increment	1
 auto_increment_offset	1
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
 INSERT INTO t1 VALUES(NULL);
 INSERT INTO t1 VALUES (18446744073709551610);
@@ -630,10 +630,10 @@ DROP TABLE t1;
 SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 DROP TABLE IF EXISTS t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 CREATE TABLE t1 (
 a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
 b INT(10) UNSIGNED NOT NULL,
@@ -850,10 +850,10 @@ DROP TABLE t1;
 DROP TABLE t2;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 DROP TABLE IF EXISTS t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 CREATE TABLE t1(
 c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
 PRIMARY KEY) ENGINE=InnoDB;
@@ -1099,7 +1099,7 @@ c1	c2
 DROP TABLE t1;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY, C2 CHAR(10)) ENGINE=InnoDB;
 INSERT INTO t1(C1, C2) VALUES (1, 'innodb'), (3, 'innodb');
 INSERT INTO t1(C2) VALUES ('innodb');
@@ -1124,7 +1124,7 @@ t1	CREATE TABLE `t1` (
 DROP TABLE t1;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (c1 INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
 INSERT INTO t1 SET c1 = 1;
 SHOW CREATE TABLE t1;
@@ -1163,7 +1163,7 @@ t1	CREATE TABLE `t1` (
 DROP TABLE t1;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1  (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB;
 INSERT INTO  t1 VALUES (-685113344), (1), (NULL), (NULL);
 SELECT * FROM t1;

=== modified file 'mysql-test/suite/innodb/r/innodb.result'
--- a/mysql-test/suite/innodb/r/innodb.result	2010-08-14 07:28:31 +0000
+++ b/mysql-test/suite/innodb/r/innodb.result	2010-09-09 10:54:19 +0000
@@ -3073,7 +3073,7 @@ c29 CHAR(255), c30 CHAR(255), c31 CHAR(2
 ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1(
 id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
 ) ENGINE=InnoDB;
@@ -3092,8 +3092,8 @@ SET TX_ISOLATION='read-committed';
 SET AUTOCOMMIT=0;
 DROP TABLE IF EXISTS t1, t2;
 Warnings:
-Note	1051	Unknown table 't1'
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t1'
+Note	1051	Unknown table 'test.t2'
 CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
 CREATE TABLE t2 LIKE t1;
 SELECT * FROM t2;

=== modified file 'mysql-test/suite/innodb/r/innodb_mysql.result'
--- a/mysql-test/suite/innodb/r/innodb_mysql.result	2010-09-01 21:53:29 +0000
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result	2010-09-09 10:54:19 +0000
@@ -435,7 +435,7 @@ set global query_cache_size=10*1024*1024
 set global query_cache_type=1;
 drop table if exists `test`;
 Warnings:
-Note	1051	Unknown table 'test'
+Note	1051	Unknown table 'test.test'
 CREATE TABLE `test` (`test1` varchar(3) NOT NULL,
 `test2` varchar(4) NOT NULL,PRIMARY KEY  (`test1`))
 ENGINE=InnoDB DEFAULT CHARSET=latin1;
@@ -633,7 +633,7 @@ select * from bug29807;
 ERROR 42S02: Table 'test.bug29807' doesn't exist
 drop table t1;
 drop table bug29807;
-ERROR 42S02: Unknown table 'bug29807'
+ERROR 42S02: Unknown table 'test.bug29807'
 create table bug29807 (a int);
 drop table bug29807;
 CREATE TABLE t1 (a INT) ENGINE=InnoDB;
@@ -710,12 +710,12 @@ CREATE TABLE t2 (primary key (a)) select
 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
 drop table if exists t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
 drop table if exists t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 CREATE TABLE t2 (a int, b int, primary key (a));
 BEGIN;
 INSERT INTO t2 values(100,100);
@@ -2576,6 +2576,64 @@ LOCK TABLES t1 READ;
 ALTER TABLE t1 COMMENT 'test';
 UNLOCK TABLES;
 DROP TABLE t1;
+#
+# Bug#55656: mysqldump can be slower after bug #39653 fix
+#
+CREATE TABLE t1 (a INT , b INT, c INT, d INT,
+KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB;
+INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3);
+EXPLAIN SELECT COUNT(*) FROM t1;
+id	1
+select_type	SIMPLE
+table	t1
+type	index
+possible_keys	NULL
+key	b
+key_len	4
+ref	NULL
+rows	3
+Extra	Using index
+DROP INDEX b ON t1;
+CREATE INDEX b ON t1(a,b);
+EXPLAIN SELECT COUNT(*) FROM t1;
+id	1
+select_type	SIMPLE
+table	t1
+type	index
+possible_keys	NULL
+key	b
+key_len	8
+ref	NULL
+rows	3
+Extra	Using index
+DROP INDEX b ON t1;
+CREATE INDEX b ON t1(a,b,c);
+EXPLAIN SELECT COUNT(*) FROM t1;
+id	1
+select_type	SIMPLE
+table	t1
+type	index
+possible_keys	NULL
+key	b
+key_len	13
+ref	NULL
+rows	3
+Extra	Using index
+DROP INDEX b ON t1;
+CREATE INDEX b ON t1(a,b,c,d);
+EXPLAIN SELECT COUNT(*) FROM t1;
+id	1
+select_type	SIMPLE
+table	t1
+type	index
+possible_keys	NULL
+key	PRIMARY
+key_len	8
+ref	NULL
+rows	3
+Extra	Using index
+DROP TABLE t1;
+#
 End of 5.1 tests
 #
 # Test for bug #39932 "create table fails if column for FK is in different

=== modified file 'mysql-test/suite/innodb/t/innodb_mysql.test'
--- a/mysql-test/suite/innodb/t/innodb_mysql.test	2010-08-16 07:30:40 +0000
+++ b/mysql-test/suite/innodb/t/innodb_mysql.test	2010-08-27 13:00:00 +0000
@@ -746,6 +746,31 @@ UNLOCK TABLES;
 
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#55656: mysqldump can be slower after bug #39653 fix
+--echo #
+
+CREATE TABLE t1 (a INT , b INT, c INT, d INT,
+  KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB;
+INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3);
+--query_vertical EXPLAIN SELECT COUNT(*) FROM t1
+
+DROP INDEX b ON t1;
+CREATE INDEX b ON t1(a,b);
+--query_vertical EXPLAIN SELECT COUNT(*) FROM t1
+
+DROP INDEX b ON t1;
+CREATE INDEX b ON t1(a,b,c);
+--query_vertical EXPLAIN SELECT COUNT(*) FROM t1
+
+DROP INDEX b ON t1;
+CREATE INDEX b ON t1(a,b,c,d);
+--query_vertical EXPLAIN SELECT COUNT(*) FROM t1
+
+DROP TABLE t1;
+
+--echo #
+
 
 --echo End of 5.1 tests
 

=== modified file 'mysql-test/suite/parts/r/part_ctype_utf32.result'
--- a/mysql-test/suite/parts/r/part_ctype_utf32.result	2010-08-23 09:56:21 +0000
+++ b/mysql-test/suite/parts/r/part_ctype_utf32.result	2010-08-31 06:28:15 +0000
@@ -3,7 +3,7 @@
 #
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1 (
 a enum('a') CHARACTER SET utf32 COLLATE utf32_spanish2_ci
 ) ENGINE=MYISAM PARTITION BY KEY(a) PARTITIONS 2;

=== modified file 'mysql-test/suite/perfschema/r/privilege_table_io.result'
--- a/mysql-test/suite/perfschema/r/privilege_table_io.result	2010-09-01 21:53:29 +0000
+++ b/mysql-test/suite/perfschema/r/privilege_table_io.result	2010-09-09 10:54:19 +0000
@@ -64,6 +64,7 @@ wait/io/table/sql/handler	handler.cc:	TA
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	user	fetch	NULL
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	user	fetch	NULL
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	user	fetch	NULL
+wait/io/table/sql/handler	handler.cc:	TABLE	mysql	user	fetch	NULL
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	db	fetch	NULL
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	db	fetch	NULL
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	db	fetch	NULL

=== modified file 'mysql-test/suite/rpl/r/rpl000013.result'
--- a/mysql-test/suite/rpl/r/rpl000013.result	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl000013.result	2010-08-30 06:38:09 +0000
@@ -25,4 +25,4 @@ Variable_name	Value
 Slave_open_temp_tables	0
 drop table if exists t1,t2;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'

=== modified file 'mysql-test/suite/rpl/r/rpl_drop.result'
--- a/mysql-test/suite/rpl/r/rpl_drop.result	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_drop.result	2010-09-01 13:13:01 +0000
@@ -7,4 +7,4 @@ start slave;
 drop table if exists t1, t2;
 create table t1 (a int);
 drop table t1, t2;
-ERROR 42S02: Unknown table 't2'
+ERROR 42S02: Unknown table 'test.t2'

=== modified file 'mysql-test/suite/rpl/r/rpl_drop_temp.result'
--- a/mysql-test/suite/rpl/r/rpl_drop_temp.result	2010-06-29 10:54:58 +0000
+++ b/mysql-test/suite/rpl/r/rpl_drop_temp.result	2010-08-30 06:38:09 +0000
@@ -14,12 +14,12 @@ Slave_open_temp_tables	0
 drop database mysqltest;
 DROP TEMPORARY TABLE IF EXISTS tmp1;
 Warnings:
-Note	1051	Unknown table 'tmp1'
+Note	1051	Unknown table 'test.tmp1'
 CREATE TEMPORARY TABLE t1 ( a int );
 DROP TEMPORARY TABLE t1, t2;
-ERROR 42S02: Unknown table 't2'
+ERROR 42S02: Unknown table 'test.t2'
 DROP TEMPORARY TABLE tmp2;
-ERROR 42S02: Unknown table 'tmp2'
+ERROR 42S02: Unknown table 'test.tmp2'
 stop slave;
 **** On Master ****
 CREATE TEMPORARY TABLE tmp3 (a int);

=== modified file 'mysql-test/suite/rpl/r/rpl_drop_view.result'
--- a/mysql-test/suite/rpl/r/rpl_drop_view.result	2008-11-13 19:19:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_drop_view.result	2010-08-30 06:38:09 +0000
@@ -13,9 +13,9 @@ create view v1 as select * from t1;
 create view v2 as select * from t2;
 create view v3 as select * from t3;
 drop view not_exist_view;
-ERROR 42S02: Unknown table 'not_exist_view'
+ERROR 42S02: Unknown table 'test.not_exist_view'
 drop view v1, not_exist_view;
-ERROR 42S02: Unknown table 'not_exist_view'
+ERROR 42S02: Unknown table 'test.not_exist_view'
 select * from v1;
 ERROR 42S02: Table 'test.v1' doesn't exist
 drop view v2, v3;

=== modified file 'mysql-test/suite/rpl/r/rpl_extraCol_innodb.result'
--- a/mysql-test/suite/rpl/r/rpl_extraCol_innodb.result	2010-07-12 11:55:16 +0000
+++ b/mysql-test/suite/rpl/r/rpl_extraCol_innodb.result	2010-08-30 06:38:09 +0000
@@ -4,7 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-call mtr.add_suppression("Slave: Unknown table 't6' Error_code: 1051");
+call mtr.add_suppression("Slave: Unknown table 'test.t6' Error_code: 1051");
 **** Diff Table Def Start ****
 *** On Slave ***
 STOP SLAVE;

=== modified file 'mysql-test/suite/rpl/r/rpl_extraCol_myisam.result'
--- a/mysql-test/suite/rpl/r/rpl_extraCol_myisam.result	2010-07-12 11:55:16 +0000
+++ b/mysql-test/suite/rpl/r/rpl_extraCol_myisam.result	2010-08-30 06:38:09 +0000
@@ -4,7 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-call mtr.add_suppression("Slave: Unknown table 't6' Error_code: 1051");
+call mtr.add_suppression("Slave: Unknown table 'test.t6' Error_code: 1051");
 **** Diff Table Def Start ****
 *** On Slave ***
 STOP SLAVE;

=== modified file 'mysql-test/suite/rpl/r/rpl_flush_logs.result'
--- a/mysql-test/suite/rpl/r/rpl_flush_logs.result	2009-12-03 08:59:58 +0000
+++ b/mysql-test/suite/rpl/r/rpl_flush_logs.result	2010-08-30 09:09:28 +0000
@@ -4,12 +4,8 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-# Make sure the 'master_log.err-old' file does not
-# exist before execute 'flush error logs' statement.
 # Test if support 'flush error logs' statement.
 flush error logs;
-# Check the 'master_log.err-old' file is created
-# after executed 'flush error logs' statement.
 # Make sure binary logs was not be flushed
 # after execute 'flush error logs' statement.
 # Make sure relay logs was not be flushed 
@@ -42,12 +38,8 @@ flush binary logs;
 # after executed 'flush binary logs' statement.
 # Make sure the 'slave-relay-bin.000007' file does not exist
 # exist before execute 'flush error logs, relay logs' statement.
-# Make sure the 'master_log.err-old' file does not exist
-# before execute 'flush error logs, relay logs' statement.
 # Test if support to combine all kinds of logs into one statement.
 flush error logs, relay logs;
-# Check the 'master_log.err-old' file is created
-# after executed 'flush error logs, relay logs' statement.
 # Make sure binary logs was not be flushed
 # after execute 'flush error logs, relay logs' statement.
 # Check the 'slave-relay-bin.000007' file is created after
@@ -55,12 +47,8 @@ flush error logs, relay logs;
 # Make sure the 'slave-relay-bin.000008' and 'slave-relay-bin.000009' 
 # files do not exist before execute 'flush error logs, relay logs' 
 # statement.
-# Make sure the 'master_log.err-old' file does not exist
-# before execute 'flush logs' statement.
 # Test if 'flush logs' statement works fine and flush all the logs.
 flush logs;
-# Check the 'master_log.err-old' file is created
-# after executed 'flush logs' statement.
 # Check 'master-bin.000003' is created
 # after execute 'flush logs' statement.
 # Check the 'slave-relay-bin.000008' and 'slave-relay-bin.000009' 

=== modified file 'mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result'
--- a/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result	2010-06-30 15:25:13 +0000
+++ b/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result	2010-08-30 06:38:09 +0000
@@ -129,5 +129,5 @@ DROP TABLE IF EXISTS t4;
 DROP TABLE IF EXISTS t5;
 DROP TABLE IF EXISTS t6;
 Warnings:
-Note	1051	Unknown table 't6'
+Note	1051	Unknown table 'test.t6'
 DROP PROCEDURE p1;

=== modified file 'mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result'
--- a/mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result	2010-08-20 02:59:58 +0000
+++ b/mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result	2010-08-30 06:38:09 +0000
@@ -15,35 +15,35 @@ CREATE TEMPORARY TABLE nt_tmp_xx_1 ( id 
 CREATE TEMPORARY TABLE tt_tmp_xx_1 ( id INT ) ENGINE = Innodb;
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2;
 Warnings:
-Note	1051	Unknown table 'nt_tmp_2'
+Note	1051	Unknown table 'test.nt_tmp_2'
 CREATE TEMPORARY TABLE nt_tmp_2 ( id INT ) ENGINE = MyIsam;
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_1;
 Warnings:
-Note	1051	Unknown table 'nt_tmp_1'
+Note	1051	Unknown table 'test.nt_tmp_1'
 CREATE TEMPORARY TABLE nt_tmp_1 ( id INT ) ENGINE = MyIsam;
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2;
 Warnings:
-Note	1051	Unknown table 'tt_tmp_2'
+Note	1051	Unknown table 'test.tt_tmp_2'
 CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) ENGINE = Innodb;
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_1;
 Warnings:
-Note	1051	Unknown table 'tt_tmp_1'
+Note	1051	Unknown table 'test.tt_tmp_1'
 CREATE TEMPORARY TABLE tt_tmp_1 ( id INT ) ENGINE = Innodb;
 DROP TABLE IF EXISTS nt_2;
 Warnings:
-Note	1051	Unknown table 'nt_2'
+Note	1051	Unknown table 'test.nt_2'
 CREATE TABLE nt_2 ( id INT ) ENGINE = MyIsam;
 DROP TABLE IF EXISTS nt_1;
 Warnings:
-Note	1051	Unknown table 'nt_1'
+Note	1051	Unknown table 'test.nt_1'
 CREATE TABLE nt_1 ( id INT ) ENGINE = MyIsam;
 DROP TABLE IF EXISTS tt_2;
 Warnings:
-Note	1051	Unknown table 'tt_2'
+Note	1051	Unknown table 'test.tt_2'
 CREATE TABLE tt_2 ( id INT ) ENGINE = Innodb;
 DROP TABLE IF EXISTS tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 CREATE TABLE tt_1 ( id INT ) ENGINE = Innodb;
 SET @commands= '';
 #########################################################################
@@ -69,7 +69,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Temp-Xe-Temp';
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-Xe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 -e-e-e-e-e-e-e-e-e-e-e- >> Drop-Temp-Xe-Temp << -e-e-e-e-e-e-e-e-e-e-e-
@@ -77,7 +77,7 @@ Log_name	Pos	Event_type	Server_id	End_lo
 SET @commands= 'Drop-Temp-If-Xe-Temp';
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-If-Xe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
@@ -85,7 +85,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Temp-TXe-Temp';
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-TXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
@@ -94,7 +94,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-Temp-If-TXe-Temp';
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-If-TXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2`,`tt_1` /* generated by server */
@@ -102,7 +102,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Temp-NXe-Temp';
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-NXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_2` /* generated by server */
@@ -111,7 +111,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-Temp-If-NXe-Temp';
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-If-NXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `nt_tmp_2` /* generated by server */
@@ -218,7 +218,7 @@ SET @commands= 'B T Drop-Temp-Xe-Temp C'
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -231,10 +231,10 @@ SET @commands= 'B T Drop-Temp-Xe-Temp N 
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-Xe-Temp N Drop-Temp-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -251,7 +251,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -266,11 +266,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -288,7 +288,7 @@ SET @commands= 'B T Drop-Temp-TXe-Temp C
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -302,10 +302,10 @@ SET @commands= 'B T Drop-Temp-TXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-TXe-Temp N Drop-Temp-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -324,7 +324,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -339,11 +339,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-TXe-Temp N Drop-Temp-If-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -361,7 +361,7 @@ SET @commands= 'B T Drop-Temp-NXe-Temp C
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -377,10 +377,10 @@ SET @commands= 'B T Drop-Temp-NXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NXe-Temp N Drop-Temp-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -403,7 +403,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -421,11 +421,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-NXe-Temp N Drop-Temp-If-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -632,7 +632,7 @@ SET @commands= 'B T Drop-Temp-Xe-Temp R'
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -645,10 +645,10 @@ SET @commands= 'B T Drop-Temp-Xe-Temp N 
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -667,7 +667,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -682,11 +682,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -706,7 +706,7 @@ SET @commands= 'B T Drop-Temp-TXe-Temp R
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-TXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -720,10 +720,10 @@ SET @commands= 'B T Drop-Temp-TXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -744,7 +744,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-TXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -759,11 +759,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -783,7 +783,7 @@ SET @commands= 'B T Drop-Temp-NXe-Temp R
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -799,10 +799,10 @@ SET @commands= 'B T Drop-Temp-NXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -827,7 +827,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-NXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -845,11 +845,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -1005,7 +1005,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Xe';
 DROP TABLE xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 -e-e-e-e-e-e-e-e-e-e-e- >> Drop-Xe << -e-e-e-e-e-e-e-e-e-e-e-
@@ -1013,7 +1013,7 @@ Log_name	Pos	Event_type	Server_id	End_lo
 SET @commands= 'Drop-If-Xe';
 DROP TABLE IF EXISTS xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-If-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `xx_1` /* generated by server */
@@ -1021,7 +1021,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-TXe';
 DROP TABLE tt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `tt_2`,`xx_1` /* generated by server */
@@ -1030,7 +1030,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-If-TXe';
 DROP TABLE IF EXISTS tt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-If-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `tt_2`,`xx_1` /* generated by server */
@@ -1038,7 +1038,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-NXe';
 DROP TABLE nt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `nt_2`,`xx_1` /* generated by server */
@@ -1047,7 +1047,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-If-NXe';
 DROP TABLE IF EXISTS nt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-If-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `nt_2`,`xx_1` /* generated by server */
@@ -1123,7 +1123,7 @@ SET @commands= 'B T Drop-Xe';
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1136,7 +1136,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE IF EXISTS xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-If-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1149,7 +1149,7 @@ SET @commands= 'B T Drop-TXe';
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE tt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1163,7 +1163,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE IF EXISTS tt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-If-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1176,7 +1176,7 @@ SET @commands= 'B T Drop-NXe';
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE nt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1190,7 +1190,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE IF EXISTS nt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-If-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN

=== modified file 'mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result'
--- a/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result	2010-08-20 03:37:42 +0000
+++ b/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result	2010-08-30 06:38:09 +0000
@@ -487,7 +487,7 @@ master-bin.000001	#	Query	#	#	use `test`
 INSERT INTO tt_1(ddl_case) VALUES (3);
 DROP TABLE IF EXISTS tt_xx, new_tt_xx;
 Warnings:
-Note	1051	Unknown table 'tt_xx'
+Note	1051	Unknown table 'test.tt_xx'
 -e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
 -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info

=== modified file 'mysql-test/suite/rpl/r/rpl_multi_update3.result'
--- a/mysql-test/suite/rpl/r/rpl_multi_update3.result	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_multi_update3.result	2010-08-30 06:38:09 +0000
@@ -124,10 +124,10 @@ i	j	x	y	z
 DROP TABLE t1, t2, t3;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 DROP TABLE IF EXISTS t2;
 Warnings:
-Note	1051	Unknown table 't2'
+Note	1051	Unknown table 'test.t2'
 CREATE TABLE t1 (
 idp int(11) NOT NULL default '0',
 idpro int(11) default NULL,

=== modified file 'mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result'
--- a/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result	2010-04-28 12:47:49 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result	2010-08-30 06:38:09 +0000
@@ -130,9 +130,9 @@ DROP TABLE t2;
 DROP TABLE t3;
 DROP TABLE IF EXISTS t4;
 Warnings:
-Note	1051	Unknown table 't4'
+Note	1051	Unknown table 'test.t4'
 DROP TABLE IF EXISTS t5;
 DROP TABLE IF EXISTS t6;
 Warnings:
-Note	1051	Unknown table 't6'
+Note	1051	Unknown table 'test.t6'
 DROP PROCEDURE p1;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_colSize.result'
--- a/mysql-test/suite/rpl/r/rpl_row_colSize.result	2010-07-27 14:04:13 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_colSize.result	2010-08-30 06:38:09 +0000
@@ -10,7 +10,7 @@ DROP TABLE IF EXISTS t1;
 Checking MYSQL_TYPE_NEWDECIMAL fields
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 STOP SLAVE;
 RESET SLAVE;
 CREATE TABLE t1 (a DECIMAL(5,2));

=== modified file 'mysql-test/suite/rpl/r/rpl_row_conflicts.result'
--- a/mysql-test/suite/rpl/r/rpl_row_conflicts.result	2010-07-16 18:25:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_conflicts.result	2010-09-01 02:51:08 +0000
@@ -51,7 +51,7 @@ SELECT * FROM t1;
 a
 [on slave]
 ---- Wait until slave stops with an error ----
-Last_SQL_Error = Could not execute Delete_rows event on table test.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log master-bin.000001, end_log_pos 983 (expected "can't find record" error)
+Last_SQL_Error = Could not execute Delete_rows event on table test.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log master-bin.000001, end_log_pos 985 (expected "can't find record" error)
 SELECT * FROM t1;
 a
 ---- Resolve the conflict on the slave and restart SQL thread ----

=== modified file 'mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result'
--- a/mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result	2010-08-20 02:59:58 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result	2010-08-30 06:38:09 +0000
@@ -15,35 +15,35 @@ CREATE TEMPORARY TABLE nt_tmp_xx_1 ( id 
 CREATE TEMPORARY TABLE tt_tmp_xx_1 ( id INT ) ENGINE = Innodb;
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2;
 Warnings:
-Note	1051	Unknown table 'nt_tmp_2'
+Note	1051	Unknown table 'test.nt_tmp_2'
 CREATE TEMPORARY TABLE nt_tmp_2 ( id INT ) ENGINE = MyIsam;
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_1;
 Warnings:
-Note	1051	Unknown table 'nt_tmp_1'
+Note	1051	Unknown table 'test.nt_tmp_1'
 CREATE TEMPORARY TABLE nt_tmp_1 ( id INT ) ENGINE = MyIsam;
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2;
 Warnings:
-Note	1051	Unknown table 'tt_tmp_2'
+Note	1051	Unknown table 'test.tt_tmp_2'
 CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) ENGINE = Innodb;
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_1;
 Warnings:
-Note	1051	Unknown table 'tt_tmp_1'
+Note	1051	Unknown table 'test.tt_tmp_1'
 CREATE TEMPORARY TABLE tt_tmp_1 ( id INT ) ENGINE = Innodb;
 DROP TABLE IF EXISTS nt_2;
 Warnings:
-Note	1051	Unknown table 'nt_2'
+Note	1051	Unknown table 'test.nt_2'
 CREATE TABLE nt_2 ( id INT ) ENGINE = MyIsam;
 DROP TABLE IF EXISTS nt_1;
 Warnings:
-Note	1051	Unknown table 'nt_1'
+Note	1051	Unknown table 'test.nt_1'
 CREATE TABLE nt_1 ( id INT ) ENGINE = MyIsam;
 DROP TABLE IF EXISTS tt_2;
 Warnings:
-Note	1051	Unknown table 'tt_2'
+Note	1051	Unknown table 'test.tt_2'
 CREATE TABLE tt_2 ( id INT ) ENGINE = Innodb;
 DROP TABLE IF EXISTS tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 CREATE TABLE tt_1 ( id INT ) ENGINE = Innodb;
 SET @commands= '';
 #########################################################################
@@ -69,7 +69,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Temp-Xe-Temp';
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-Xe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 -e-e-e-e-e-e-e-e-e-e-e- >> Drop-Temp-Xe-Temp << -e-e-e-e-e-e-e-e-e-e-e-

@@ -77,7 +77,7 @@ Log_name	Pos	Event_type	Server_id	End_lo
 SET @commands= 'Drop-Temp-If-Xe-Temp';
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-If-Xe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
@@ -85,7 +85,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Temp-TXe-Temp';
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-TXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
@@ -94,7 +94,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-Temp-If-TXe-Temp';
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-If-TXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2`,`tt_1` /* generated by server */
@@ -102,7 +102,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Temp-NXe-Temp';
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-NXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `nt_tmp_2` /* generated by server */
@@ -111,7 +111,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-Temp-If-NXe-Temp';
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-If-NXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `nt_tmp_2` /* generated by server */
@@ -224,7 +224,7 @@ SET @commands= 'B T Drop-Temp-Xe-Temp C'
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -238,10 +238,10 @@ SET @commands= 'B T Drop-Temp-Xe-Temp N 
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-Xe-Temp N Drop-Temp-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -260,7 +260,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -276,11 +276,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -300,7 +300,7 @@ SET @commands= 'B T Drop-Temp-TXe-Temp C
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -315,10 +315,10 @@ SET @commands= 'B T Drop-Temp-TXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-TXe-Temp N Drop-Temp-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -339,7 +339,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -355,11 +355,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-TXe-Temp N Drop-Temp-If-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -379,7 +379,7 @@ SET @commands= 'B T Drop-Temp-NXe-Temp C
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -396,10 +396,10 @@ SET @commands= 'B T Drop-Temp-NXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NXe-Temp N Drop-Temp-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -424,7 +424,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -443,11 +443,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-NXe-Temp N Drop-Temp-If-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -671,7 +671,7 @@ SET @commands= 'B T Drop-Temp-Xe-Temp R'
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -685,10 +685,10 @@ SET @commands= 'B T Drop-Temp-Xe-Temp N 
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -709,7 +709,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -725,11 +725,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -751,7 +751,7 @@ SET @commands= 'B T Drop-Temp-TXe-Temp R
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-TXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -766,10 +766,10 @@ SET @commands= 'B T Drop-Temp-TXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -792,7 +792,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-TXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -808,11 +808,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -834,7 +834,7 @@ SET @commands= 'B T Drop-Temp-NXe-Temp R
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -851,10 +851,10 @@ SET @commands= 'B T Drop-Temp-NXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -881,7 +881,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-NXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -900,11 +900,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -1071,7 +1071,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Xe';
 DROP TABLE xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 -e-e-e-e-e-e-e-e-e-e-e- >> Drop-Xe << -e-e-e-e-e-e-e-e-e-e-e-
@@ -1079,7 +1079,7 @@ Log_name	Pos	Event_type	Server_id	End_lo
 SET @commands= 'Drop-If-Xe';
 DROP TABLE IF EXISTS xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-If-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `xx_1` /* generated by server */
@@ -1087,7 +1087,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-TXe';
 DROP TABLE tt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `tt_2`,`xx_1` /* generated by server */
@@ -1096,7 +1096,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-If-TXe';
 DROP TABLE IF EXISTS tt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-If-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `tt_2`,`xx_1` /* generated by server */
@@ -1104,7 +1104,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-NXe';
 DROP TABLE nt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `nt_2`,`xx_1` /* generated by server */
@@ -1113,7 +1113,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-If-NXe';
 DROP TABLE IF EXISTS nt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-If-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `nt_2`,`xx_1` /* generated by server */
@@ -1191,7 +1191,7 @@ SET @commands= 'B T Drop-Xe';
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1205,7 +1205,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE IF EXISTS xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-If-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1219,7 +1219,7 @@ SET @commands= 'B T Drop-TXe';
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE tt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1234,7 +1234,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE IF EXISTS tt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-If-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1248,7 +1248,7 @@ SET @commands= 'B T Drop-NXe';
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE nt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1263,7 +1263,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE IF EXISTS nt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-If-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN

=== added file 'mysql-test/suite/rpl/r/rpl_row_ignorable_event.result'
--- a/mysql-test/suite/rpl/r/rpl_row_ignorable_event.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_ignorable_event.result	2010-09-01 02:51:08 +0000
@@ -0,0 +1,1007 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+# Test non-transaction
+create table t1(a int, b int) engine= myisam;
+insert into t1(a,b) values(1,1),(2,1);
+update t1 set a = a + 5 where b = 1 LIMIT 1;
+delete from t1 where a = 6;
+# Test transaction
+create table t2(a int, b int) engine=innodb;
+begin;
+insert into t2(a,b) values(2,1),(3,1);
+update t2 set a = a + 5 where b = 1;
+delete from t2 where a = 7;
+commit;
+# Test mixed transaction
+begin;
+insert into t1(a,b) values(1,5);
+insert into t2(a,b) values(2,5);
+insert into t2(a,b) values(2,6);
+insert into t1(a,b) values(1,7);
+commit;
+drop table t1, t2;
+create table t3(a int, b int) engine= myisam;
+create table t4(a int, b int) engine= myisam;
+create table t5(a int, b int) engine= myisam;
+insert into t3(a, b) values(1,1);
+# Test the Rows_query log event will be filtered out if slave applys
+# '--replicate-ignore-table' option on the table
+insert into t4(a, b) values(2,1);
+# Test the Rows_query log event will be relayed if slave
+# filters out part Rows event from a rows statement
+update t3,t4 set t3.a=3, t4.a=4 where t3.b=t4.b;
+# Test the Rows_query log event will be filtered out if slave applys
+# '--replicate-wild-ignore-table' option on the table
+insert into t5(a, b) values(3,1);
+# Test the Rows_query log event will be filtered out if slave filters
+# out all its related tables by replication filtering rules
+update t4,t5 set t4.a=4, t5.a=5 where t4.b=t5.b;
+# Test insert delayed ...
+insert delayed into t3(a,b) values(1,5),(1,6),(1,7);
+# Test load data infile
+create table t6(a VARCHAR(60)) engine= myisam;
+load data infile '../../std_data/words.dat' into table t6;
+drop table t3, t6;
+drop table t4, t5;
+# SHOW BINLOG EVENTS ON MASTER before '--exec MYSQL_BINLOG'
+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, b int) engine= myisam
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,1),(2,1)
+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	#	Rows_query	#	#	# update t1 set a = a + 5 where b = 1 LIMIT 1
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# delete from t1 where a = 6
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `test`; create table t2(a int, b int) engine=innodb
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,1),(3,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# update t2 set a = a + 5 where b = 1
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# delete from t2 where a = 7
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,5)
+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	#	Rows_query	#	#	# insert into t1(a,b) values(1,7)
+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	#	Rows_query	#	#	# insert into t2(a,b) values(2,5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,6)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t1`,`t2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; create table t3(a int, b int) engine= myisam
+master-bin.000001	#	Query	#	#	use `test`; create table t4(a int, b int) engine= myisam
+master-bin.000001	#	Query	#	#	use `test`; create table t5(a int, b int) engine= myisam
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t3(a, b) values(1,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t4(a, b) values(2,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t4)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# update t3,t4 set t3.a=3, t4.a=4 where t3.b=t4.b
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t4)
+master-bin.000001	#	Update_rows	#	#	table_id: #
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t5(a, b) values(3,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t5)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# update t4,t5 set t4.a=4, t5.a=5 where t4.b=t5.b
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t4)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t5)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert delayed into t3(a,b) values(1,5),(1,6),(1,7)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `test`; create table t6(a VARCHAR(60)) engine= myisam
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# load data infile '../../std_data/words.dat' into table t6
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t3`,`t6` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t4`,`t5` /* generated by server */
+# MYSQL_BINLOG output base on master-bin.000001
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# at #
+#server id #  end_log_pos # 	Start: binlog v#, server v #.##.## created # #:#:# at startup
+# Warning: this binlog is either in use or was not closed properly.
+ROLLBACK/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+use test/*!*/;
+SET TIMESTAMP=t/*!*/;
+SET @@session.pseudo_thread_id=#/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+create table t1(a int, b int) engine= myisam
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t1(a,b) values(1,1),(2,1)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t1` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t1
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### INSERT INTO test.t1
+### SET
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# update t1 set a = a + 5 where b = 1 LIMIT 1
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t1` mapped to number #
+#server id #  end_log_pos # 	Update_rows: table id # flags: STMT_END_F
+### UPDATE test.t1
+### WHERE
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=6 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# delete from t1 where a = 6
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t1` mapped to number #
+#server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
+### DELETE FROM test.t1
+### WHERE
+###   @1=6 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+create table t2(a int, b int) engine=innodb
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t2(a,b) values(2,1),(3,1)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t2` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t2
+### SET
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### INSERT INTO test.t2
+### SET
+###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Rows_query
+# update t2 set a = a + 5 where b = 1
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t2` mapped to number #
+#server id #  end_log_pos # 	Update_rows: table id # flags: STMT_END_F
+### UPDATE test.t2
+### WHERE
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=7 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### UPDATE test.t2
+### WHERE
+###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=8 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Rows_query
+# delete from t2 where a = 7
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t2` mapped to number #
+#server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
+### DELETE FROM test.t2
+### WHERE
+###   @1=7 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Xid = #
+COMMIT/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t1(a,b) values(1,5)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t1` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t1
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=5 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t1(a,b) values(1,7)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t1` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t1
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=7 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t2(a,b) values(2,5)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t2` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t2
+### SET
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=5 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t2(a,b) values(2,6)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t2` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t2
+### SET
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=6 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Xid = #
+COMMIT/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+DROP TABLE `t1`,`t2` /* generated by server */
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+create table t3(a int, b int) engine= myisam
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+create table t4(a int, b int) engine= myisam
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+create table t5(a int, b int) engine= myisam
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t3(a, b) values(1,1)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t3` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t3
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t4(a, b) values(2,1)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t4` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t4
+### SET
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# update t3,t4 set t3.a=3, t4.a=4 where t3.b=t4.b
+# at #
+# at #
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t3` mapped to number #
+#server id #  end_log_pos # 	Table_map: `test`.`t4` mapped to number #
+#server id #  end_log_pos # 	Update_rows: table id #
+#server id #  end_log_pos # 	Update_rows: table id # flags: STMT_END_F
+### UPDATE test.t3
+### WHERE
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### UPDATE test.t4
+### WHERE
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=4 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t5(a, b) values(3,1)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t5` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t5
+### SET
+###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# update t4,t5 set t4.a=4, t5.a=5 where t4.b=t5.b
+# at #
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t4` mapped to number #
+#server id #  end_log_pos # 	Table_map: `test`.`t5` mapped to number #
+#server id #  end_log_pos # 	Update_rows: table id # flags: STMT_END_F
+### UPDATE test.t5
+### WHERE
+###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=5 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert delayed into t3(a,b) values(1,5),(1,6),(1,7)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t3` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t3
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=5 /* INT meta=0 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=6 /* INT meta=0 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=7 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+create table t6(a VARCHAR(60)) engine= myisam
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# load data infile '../../std_data/words.dat' into table t6
+# at #
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t6` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t6
+### SET
+###   @1='Aarhus' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Aaron' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Ababa' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='aback' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abaft' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandon' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandoned' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandoning' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandonment' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandons' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Aarhus' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Aaron' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Ababa' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='aback' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abaft' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandon' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandoned' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandoning' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandonment' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandons' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abase' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abased' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abasement' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abasements' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abases' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abash' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abashed' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abashes' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abashing' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abasing' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abate' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abated' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abatement' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abatements' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abater' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abates' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abating' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abba' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbe' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbey' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbeys' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbot' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbots' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abbott' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviate' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviated' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviates' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviating' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviation' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviations' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abby' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abdomen' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abdomens' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abdominal' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abduct' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abducted' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abduction' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abductions' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abductor' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abductors' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abducts' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abe' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abed' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abel' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abelian' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abelson' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Aberdeen' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abernathy' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='aberrant' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='aberration' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+DROP TABLE `t3`,`t6` /* generated by server */
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+DROP TABLE `t4`,`t5` /* generated by server */
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+# Test the Rows_query log event can be applied
+# SHOW BINLOG EVENTS ON MASTER after '--exec MYSQL_BINLOG'
+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, b int) engine= myisam
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,1),(2,1)
+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	#	Rows_query	#	#	# update t1 set a = a + 5 where b = 1 LIMIT 1
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# delete from t1 where a = 6
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `test`; create table t2(a int, b int) engine=innodb
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,1),(3,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# update t2 set a = a + 5 where b = 1
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# delete from t2 where a = 7
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,5)
+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	#	Rows_query	#	#	# insert into t1(a,b) values(1,7)
+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	#	Rows_query	#	#	# insert into t2(a,b) values(2,5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,6)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t1`,`t2` /* generated by server */
+# SHOW BINLOG EVENTS ON 2nd CONNECTION TO MASTE
+set @@session.binlog_rows_query_log_events= off;
+# Test statements from the 2nd connection have no comment event
+# when setting binlog_rows_query_log_events= off
+create table t7(a bigint) engine= myisam;
+insert into t7(a) values(1),(2);
+delete from t7 where a = 1;
+set session binlog_format=mixed;
+set @@session.binlog_rows_query_log_events= on;
+# Test the comment event is sent in mixed mode for special
+# functions when setting binlog_rows_query_log_events= on
+insert into t7(a) values(UUID_SHORT());
+drop table t7;
+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 t7(a bigint) engine= myisam
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t7)
+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.t7)
+master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t7(a) values(UUID_SHORT())
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t7)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t7` /* generated by server */
+# Test The Rows_query log event can be relayed.
+# SHOW BINLOG EVENTS ON SLAVE
+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, b int) engine= myisam
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,1),(2,1)
+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	#	Rows_query	#	#	# update t1 set a = a + 5 where b = 1 LIMIT 1
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# delete from t1 where a = 6
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; create table t2(a int, b int) engine=innodb
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,1),(3,1)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# update t2 set a = a + 5 where b = 1
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# delete from t2 where a = 7
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Xid	#	#	COMMIT /* XID */
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,5)
+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	#	Rows_query	#	#	# insert into t1(a,b) values(1,7)
+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	#	Rows_query	#	#	# insert into t2(a,b) values(2,5)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,6)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Xid	#	#	COMMIT /* XID */
+slave-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t1`,`t2` /* generated by server */
+slave-bin.000001	#	Query	#	#	use `test`; create table t3(a int, b int) engine= myisam
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t3(a, b) values(1,1)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# update t3,t4 set t3.a=3, t4.a=4 where t3.b=t4.b
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+slave-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert delayed into t3(a,b) values(1,5),(1,6),(1,7)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; create table t6(a VARCHAR(60)) engine= myisam
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# load data infile '../../std_data/words.dat' into table t6
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t6)
+slave-bin.000001	#	Write_rows	#	#	table_id: #
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t3`,`t6` /* generated by server */
+slave-bin.000001	#	Query	#	#	use `test`; create table t1(a int, b int) engine= myisam
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,1),(2,1)
+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	#	Rows_query	#	#	# update t1 set a = a + 5 where b = 1 LIMIT 1
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# delete from t1 where a = 6
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; create table t2(a int, b int) engine=innodb
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,1),(3,1)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# update t2 set a = a + 5 where b = 1
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# delete from t2 where a = 7
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Xid	#	#	COMMIT /* XID */
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,5)
+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	#	Rows_query	#	#	# insert into t1(a,b) values(1,7)
+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	#	Rows_query	#	#	# insert into t2(a,b) values(2,5)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,6)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Xid	#	#	COMMIT /* XID */
+slave-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t1`,`t2` /* generated by server */
+slave-bin.000001	#	Query	#	#	use `test`; create table t7(a bigint) engine= myisam
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t7)
+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.t7)
+slave-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t7(a) values(UUID_SHORT())
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t7)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t7` /* generated by server */

=== modified file 'mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result'
--- a/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result	2010-08-20 02:59:58 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result	2010-08-30 06:38:09 +0000
@@ -522,7 +522,7 @@ master-bin.000001	#	Query	#	#	use `test`
 INSERT INTO tt_1(ddl_case) VALUES (3);
 DROP TABLE IF EXISTS tt_xx, new_tt_xx;
 Warnings:
-Note	1051	Unknown table 'tt_xx'
+Note	1051	Unknown table 'test.tt_xx'
 -e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
 -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info

=== modified file 'mysql-test/suite/rpl/r/rpl_session_var.result'
--- a/mysql-test/suite/rpl/r/rpl_session_var.result	2007-07-28 09:10:56 +0000
+++ b/mysql-test/suite/rpl/r/rpl_session_var.result	2010-08-30 06:38:09 +0000
@@ -6,7 +6,7 @@ drop table if exists t1,t2,t3,t4,t5,t6,t
 start slave;
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 create table t1(a varchar(100),b int);
 set @@session.sql_mode=pipes_as_concat;
 insert into t1 values('My'||'SQL', 1);

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result	2010-06-30 20:56:21 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result	2010-08-30 06:38:09 +0000
@@ -129,5 +129,5 @@ DROP TABLE IF EXISTS t4;
 DROP TABLE IF EXISTS t5;
 DROP TABLE IF EXISTS t6;
 Warnings:
-Note	1051	Unknown table 't6'
+Note	1051	Unknown table 'test.t6'
 DROP PROCEDURE p1;

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result	2010-08-20 02:59:58 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result	2010-08-30 06:38:09 +0000
@@ -15,35 +15,35 @@ CREATE TEMPORARY TABLE nt_tmp_xx_1 ( id 
 CREATE TEMPORARY TABLE tt_tmp_xx_1 ( id INT ) ENGINE = Innodb;
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2;
 Warnings:
-Note	1051	Unknown table 'nt_tmp_2'
+Note	1051	Unknown table 'test.nt_tmp_2'
 CREATE TEMPORARY TABLE nt_tmp_2 ( id INT ) ENGINE = MyIsam;
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_1;
 Warnings:
-Note	1051	Unknown table 'nt_tmp_1'
+Note	1051	Unknown table 'test.nt_tmp_1'
 CREATE TEMPORARY TABLE nt_tmp_1 ( id INT ) ENGINE = MyIsam;
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2;
 Warnings:
-Note	1051	Unknown table 'tt_tmp_2'
+Note	1051	Unknown table 'test.tt_tmp_2'
 CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) ENGINE = Innodb;
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_1;
 Warnings:
-Note	1051	Unknown table 'tt_tmp_1'
+Note	1051	Unknown table 'test.tt_tmp_1'
 CREATE TEMPORARY TABLE tt_tmp_1 ( id INT ) ENGINE = Innodb;
 DROP TABLE IF EXISTS nt_2;
 Warnings:
-Note	1051	Unknown table 'nt_2'
+Note	1051	Unknown table 'test.nt_2'
 CREATE TABLE nt_2 ( id INT ) ENGINE = MyIsam;
 DROP TABLE IF EXISTS nt_1;
 Warnings:
-Note	1051	Unknown table 'nt_1'
+Note	1051	Unknown table 'test.nt_1'
 CREATE TABLE nt_1 ( id INT ) ENGINE = MyIsam;
 DROP TABLE IF EXISTS tt_2;
 Warnings:
-Note	1051	Unknown table 'tt_2'
+Note	1051	Unknown table 'test.tt_2'
 CREATE TABLE tt_2 ( id INT ) ENGINE = Innodb;
 DROP TABLE IF EXISTS tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 CREATE TABLE tt_1 ( id INT ) ENGINE = Innodb;
 SET @commands= '';
 #########################################################################
@@ -69,7 +69,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Temp-Xe-Temp';
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-Xe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 -e-e-e-e-e-e-e-e-e-e-e- >> Drop-Temp-Xe-Temp << -e-e-e-e-e-e-e-e-e-e-e-
@@ -77,7 +77,7 @@ Log_name	Pos	Event_type	Server_id	End_lo
 SET @commands= 'Drop-Temp-If-Xe-Temp';
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-If-Xe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
@@ -85,7 +85,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Temp-TXe-Temp';
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-TXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
@@ -94,7 +94,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-Temp-If-TXe-Temp';
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-If-TXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2`,`tt_1` /* generated by server */
@@ -102,7 +102,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Temp-NXe-Temp';
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-NXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_2` /* generated by server */
@@ -111,7 +111,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-Temp-If-NXe-Temp';
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Temp-If-NXe-Temp << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `nt_tmp_2` /* generated by server */
@@ -218,7 +218,7 @@ SET @commands= 'B T Drop-Temp-Xe-Temp C'
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -231,10 +231,10 @@ SET @commands= 'B T Drop-Temp-Xe-Temp N 
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-Xe-Temp N Drop-Temp-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -251,7 +251,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -266,11 +266,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -288,7 +288,7 @@ SET @commands= 'B T Drop-Temp-TXe-Temp C
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -302,10 +302,10 @@ SET @commands= 'B T Drop-Temp-TXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-TXe-Temp N Drop-Temp-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -324,7 +324,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -339,11 +339,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-TXe-Temp N Drop-Temp-If-TXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -361,7 +361,7 @@ SET @commands= 'B T Drop-Temp-NXe-Temp C
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -377,10 +377,10 @@ SET @commands= 'B T Drop-Temp-NXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NXe-Temp N Drop-Temp-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -403,7 +403,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -421,11 +421,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 COMMIT;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-NXe-Temp N Drop-Temp-If-NXe-Temp C << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -632,7 +632,7 @@ SET @commands= 'B T Drop-Temp-Xe-Temp R'
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -645,10 +645,10 @@ SET @commands= 'B T Drop-Temp-Xe-Temp N 
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_xx_1;
-ERROR 42S02: Unknown table 'tt_xx_1'
+ERROR 42S02: Unknown table 'test.tt_xx_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -667,7 +667,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -682,11 +682,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
-Note	1051	Unknown table 'tt_xx_1'
+Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -706,7 +706,7 @@ SET @commands= 'B T Drop-Temp-TXe-Temp R
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-TXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -720,10 +720,10 @@ SET @commands= 'B T Drop-Temp-TXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE tt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -744,7 +744,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-TXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -759,11 +759,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS tt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -783,7 +783,7 @@ SET @commands= 'B T Drop-Temp-NXe-Temp R
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -799,10 +799,10 @@ SET @commands= 'B T Drop-Temp-NXe-Temp N
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_2, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE nt_tmp_1, tt_1;
-ERROR 42S02: Unknown table 'tt_1'
+ERROR 42S02: Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -827,7 +827,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-NXe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -845,11 +845,11 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 INSERT INTO nt_xx_1() VALUES (1);
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_1, tt_1;
 Warnings:
-Note	1051	Unknown table 'tt_1'
+Note	1051	Unknown table 'test.tt_1'
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
@@ -1005,7 +1005,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-Xe';
 DROP TABLE xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 -e-e-e-e-e-e-e-e-e-e-e- >> Drop-Xe << -e-e-e-e-e-e-e-e-e-e-e-
@@ -1013,7 +1013,7 @@ Log_name	Pos	Event_type	Server_id	End_lo
 SET @commands= 'Drop-If-Xe';
 DROP TABLE IF EXISTS xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-If-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `xx_1` /* generated by server */
@@ -1021,7 +1021,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-TXe';
 DROP TABLE tt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `tt_2`,`xx_1` /* generated by server */
@@ -1030,7 +1030,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-If-TXe';
 DROP TABLE IF EXISTS tt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-If-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `tt_2`,`xx_1` /* generated by server */
@@ -1038,7 +1038,7 @@ master-bin.000001	#	Query	#	#	use `test`
 
 SET @commands= 'Drop-NXe';
 DROP TABLE nt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `nt_2`,`xx_1` /* generated by server */
@@ -1047,7 +1047,7 @@ master-bin.000001	#	Query	#	#	use `test`
 SET @commands= 'Drop-If-NXe';
 DROP TABLE IF EXISTS nt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> Drop-If-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS `nt_2`,`xx_1` /* generated by server */
@@ -1123,7 +1123,7 @@ SET @commands= 'B T Drop-Xe';
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1136,7 +1136,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE IF EXISTS xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-If-Xe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1149,7 +1149,7 @@ SET @commands= 'B T Drop-TXe';
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE tt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1163,7 +1163,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE IF EXISTS tt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-If-TXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1176,7 +1176,7 @@ SET @commands= 'B T Drop-NXe';
 BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE nt_2, xx_1;
-ERROR 42S02: Unknown table 'xx_1'
+ERROR 42S02: Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -1190,7 +1190,7 @@ BEGIN;
 INSERT INTO tt_xx_1() VALUES (1);
 DROP TABLE IF EXISTS nt_2, xx_1;
 Warnings:
-Note	1051	Unknown table 'xx_1'
+Note	1051	Unknown table 'test.xx_1'
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-If-NXe << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result	2010-08-20 03:37:42 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result	2010-08-30 06:38:09 +0000
@@ -486,7 +486,7 @@ master-bin.000001	#	Query	#	#	use `test`
 INSERT INTO tt_1(ddl_case) VALUES (3);
 DROP TABLE IF EXISTS tt_xx, new_tt_xx;
 Warnings:
-Note	1051	Unknown table 'tt_xx'
+Note	1051	Unknown table 'test.tt_xx'
 -e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e-
 -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_no_op.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_no_op.result	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_no_op.result	2010-08-30 06:38:09 +0000
@@ -13,7 +13,7 @@ ERROR 42000: Unknown database 'mysqltest
 create table t1 (a int);
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 select * from t1;
 ERROR 42S02: Table 'test.t1' doesn't exist
 create table t1 (a int, b int);

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_until.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_until.result	2010-07-27 14:04:13 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_until.result	2010-08-30 06:38:09 +0000
@@ -92,7 +92,7 @@ drop table if exists t1,t2,t3,t4,t5,t6,t
 start slave;
 drop table if exists t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 flush logs;
 stop slave;
 reset slave;

=== modified file 'mysql-test/suite/rpl/r/rpl_temp_table.result'
--- a/mysql-test/suite/rpl/r/rpl_temp_table.result	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_temp_table.result	2010-08-30 06:38:09 +0000
@@ -45,4 +45,4 @@ Variable_name	Value
 Slave_open_temp_tables	0
 drop table if exists t1,t2;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'

=== modified file 'mysql-test/suite/rpl/t/rpl_delayed_slave.test'
--- a/mysql-test/suite/rpl/t/rpl_delayed_slave.test	2010-06-21 12:32:29 +0000
+++ b/mysql-test/suite/rpl/t/rpl_delayed_slave.test	2010-09-04 00:24:29 +0000
@@ -183,15 +183,16 @@ INSERT INTO t1(a) VALUES (delay_on_slave
 --echo # sleep 1*T
 --sleep $time1
 
+let $bug_53167_is_fixed= 1;
 if ($bug_53167_is_fixed) {
-
---let $seconds_behind_master= query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1)
-if (`SELECT $seconds_behind_master <= 0 OR $seconds_behind_master >= $time2`) {
-  --echo Seconds_Behind_Master was $seconds_behind_master. Expected that 0 < Seconds_Behind_Master < SQL_Delay = $time2
-  --source include/show_rpl_debug_info.inc
-  --die Seconds_Behind_Master was wrong
-}
-
+  --let $seconds_behind_master= query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1)
+  # The value of Seconds_Behind_Master will be zero
+  # before the first non-FD event is executed.
+  if (`SELECT $seconds_behind_master < 0 OR $seconds_behind_master >= $time2`) {
+    --echo Seconds_Behind_Master was $seconds_behind_master. Expected that 0 =< Seconds_Behind_Master < SQL_Delay = $time2
+    --source include/show_rpl_debug_info.inc
+    --die Seconds_Behind_Master was wrong
+  }
 }

 
 --echo # sleep 1*T

=== modified file 'mysql-test/suite/rpl/t/rpl_drop.test'
--- a/mysql-test/suite/rpl/t/rpl_drop.test	2009-11-27 23:34:47 +0000
+++ b/mysql-test/suite/rpl/t/rpl_drop.test	2010-08-20 11:22:46 +0000
@@ -10,3 +10,4 @@ drop table t1, t2;
 sync_slave_with_master;
 
 # End of 4.1 tests
+

=== modified file 'mysql-test/suite/rpl/t/rpl_flush_logs.test'
--- a/mysql-test/suite/rpl/t/rpl_flush_logs.test	2009-12-03 08:59:58 +0000
+++ b/mysql-test/suite/rpl/t/rpl_flush_logs.test	2010-08-30 09:09:28 +0000
@@ -9,17 +9,10 @@
 connection master;
 
 # Test 'flush error logs' statement.
---echo # Make sure the 'master_log.err-old' file does not
---echo # exist before execute 'flush error logs' statement.
---error 1
-file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
 
 --echo # Test if support 'flush error logs' statement.
 flush error logs;
 
---echo # Check the 'master_log.err-old' file is created
---echo # after executed 'flush error logs' statement.
-file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
 file_exists $MYSQLTEST_VARDIR/tmp/master_log.err;
 
 --echo # Make sure binary logs was not be flushed
@@ -109,19 +102,10 @@ sync_slave_with_master;
 file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000007;
 
 connection master;
-remove_file $MYSQLTEST_VARDIR/tmp/master_log.err-old;
-
---echo # Make sure the 'master_log.err-old' file does not exist
---echo # before execute 'flush error logs, relay logs' statement.
---error 1
-file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
 
 --echo # Test if support to combine all kinds of logs into one statement.
 flush error logs, relay logs;
 
---echo # Check the 'master_log.err-old' file is created
---echo # after executed 'flush error logs, relay logs' statement.
-file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
 file_exists $MYSQLTEST_VARDIR/tmp/master_log.err;
 
 --echo # Make sure binary logs was not be flushed
@@ -145,19 +129,10 @@ file_exists $MYSQLTEST_VARDIR/mysqld.2/d
 file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000009;
 
 connection master;
-remove_file $MYSQLTEST_VARDIR/tmp/master_log.err-old;
-
---echo # Make sure the 'master_log.err-old' file does not exist
---echo # before execute 'flush logs' statement.
---error 1
-file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
 
 --echo # Test if 'flush logs' statement works fine and flush all the logs.
 flush logs;
 
---echo # Check the 'master_log.err-old' file is created
---echo # after executed 'flush logs' statement.
-file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
 file_exists $MYSQLTEST_VARDIR/tmp/master_log.err;
 
 --echo # Check 'master-bin.000003' is created

=== modified file 'mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test'
--- a/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test	2009-09-29 11:16:23 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test	2010-07-07 06:48:50 +0000
@@ -1,7 +1,7 @@
 # depends on the binlog output
 -- source include/have_binlog_format_row.inc
 
-let $rename_event_pos= 898;
+let $rename_event_pos= 900;
 
 # Bug#18326: Do not lock table for writing during prepare of statement
 # The use of the ps protocol causes extra table maps in the binlog, so

=== added file 'mysql-test/suite/rpl/t/rpl_row_ignorable_event-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_row_ignorable_event-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_ignorable_event-master.opt	2010-08-06 02:20:44 +0000
@@ -0,0 +1 @@
+--binlog-row-event-max-size=512 --binlog-rows-query-log-events=1

=== added file 'mysql-test/suite/rpl/t/rpl_row_ignorable_event-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_row_ignorable_event-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_ignorable_event-slave.opt	2010-08-06 02:20:44 +0000
@@ -0,0 +1 @@
+--binlog-row-event-max-size=512 --binlog-rows-query-log-events=1 --replicate-ignore-table=test.t4 --replicate-wild-ignore-table=test.t5

=== added file 'mysql-test/suite/rpl/t/rpl_row_ignorable_event.test'
--- a/mysql-test/suite/rpl/t/rpl_row_ignorable_event.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_ignorable_event.test	2010-08-06 02:20:44 +0000
@@ -0,0 +1,110 @@
+#
+# WL#4033 & WL#5404
+# This test verifies if the query of the rows event
+# is displayed with its row event as comment in RBR
+# by SHOW BINLOG EVENTS and MYSQLBINLOG DUMP.
+# Verifies if the Rows_query log event can be applied
+# and relayed 
+#
+
+source include/have_binlog_format_row.inc;
+source include/master-slave.inc;
+source include/have_binlog_rows_query.inc;
+source include/have_innodb.inc;
+
+--echo # Test non-transaction
+let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
+let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1);
+create table t1(a int, b int) engine= myisam;
+insert into t1(a,b) values(1,1),(2,1);
+update t1 set a = a + 5 where b = 1 LIMIT 1;
+delete from t1 where a = 6;
+
+-- echo # Test transaction
+create table t2(a int, b int) engine=innodb;
+begin;
+insert into t2(a,b) values(2,1),(3,1);
+update t2 set a = a + 5 where b = 1;
+delete from t2 where a = 7;
+commit;
+
+--echo # Test mixed transaction
+begin;
+insert into t1(a,b) values(1,5);
+insert into t2(a,b) values(2,5);
+insert into t2(a,b) values(2,6);
+insert into t1(a,b) values(1,7);
+commit;
+
+drop table t1, t2;
+let $end_pos= query_get_value("SHOW MASTER STATUS", Position, 1);
+
+create table t3(a int, b int) engine= myisam;
+create table t4(a int, b int) engine= myisam;
+create table t5(a int, b int) engine= myisam;
+insert into t3(a, b) values(1,1);
+--echo # Test the Rows_query log event will be filtered out if slave applys
+--echo # '--replicate-ignore-table' option on the table
+insert into t4(a, b) values(2,1);
+--echo # Test the Rows_query log event will be relayed if slave
+--echo # filters out part Rows event from a rows statement
+update t3,t4 set t3.a=3, t4.a=4 where t3.b=t4.b;
+
+--echo # Test the Rows_query log event will be filtered out if slave applys
+--echo # '--replicate-wild-ignore-table' option on the table
+insert into t5(a, b) values(3,1);
+--echo # Test the Rows_query log event will be filtered out if slave filters
+--echo # out all its related tables by replication filtering rules
+update t4,t5 set t4.a=4, t5.a=5 where t4.b=t5.b;
+
+--echo # Test insert delayed ...
+insert delayed into t3(a,b) values(1,5),(1,6),(1,7);
+
+--echo # Test load data infile
+create table t6(a VARCHAR(60)) engine= myisam;
+load data infile '../../std_data/words.dat' into table t6;
+
+drop table t3, t6;
+drop table t4, t5;
+
+--echo # SHOW BINLOG EVENTS ON MASTER before '--exec MYSQL_BINLOG'
+source include/show_binlog_events.inc;
+
+--echo # MYSQL_BINLOG output base on master-bin.000001
+let $MYSQLD_DATADIR= `select @@datadir`;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_regex /TIMESTAMP=[0-9]*/TIMESTAMP=t/ /#[0-9]*[ ]*[0-9]*:[0-9]*:[0-9]* server id [0-9]*/#server id #/ /exec_time=[0-9]*/exec_time=#/ /error_code=[0-9]*/error_code=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /Start: binlog v [0-9]*/Start: binlog v#/ /created [0-9]*[ ]*[0-9]*:[0-9]*:[0-9]* at startup/created # #:#:# at startup/
+--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/$master_binlog
+
+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
+--echo # Test the Rows_query log event can be applied
+--exec $MYSQL_BINLOG -v -v --stop-position=$end_pos $MYSQLD_DATADIR/$master_binlog | $MYSQL test 2>&1
+
+--echo # SHOW BINLOG EVENTS ON MASTER after '--exec MYSQL_BINLOG'
+source include/show_binlog_events.inc;
+
+connect (master2,localhost,root,,);
+connection master2;
+--echo # SHOW BINLOG EVENTS ON 2nd CONNECTION TO MASTE
+set @@session.binlog_rows_query_log_events= off;
+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
+--echo # Test statements from the 2nd connection have no comment event
+--echo # when setting binlog_rows_query_log_events= off
+create table t7(a bigint) engine= myisam;
+insert into t7(a) values(1),(2);
+delete from t7 where a = 1;
+
+set session binlog_format=mixed;
+set @@session.binlog_rows_query_log_events= on;
+--echo # Test the comment event is sent in mixed mode for special
+--echo # functions when setting binlog_rows_query_log_events= on
+insert into t7(a) values(UUID_SHORT());
+drop table t7;
+source include/show_binlog_events.inc;
+
+sync_slave_with_master;
+--let $binlog_start= query_get_value(SHOW BINLOG EVENTS LIMIT 1, End_log_pos, 1)
+--echo # Test The Rows_query log event can be relayed.
+--echo # SHOW BINLOG EVENTS ON SLAVE
+source include/show_binlog_events.inc;
+

=== modified file 'mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test	2009-11-03 19:02:56 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test	2010-07-07 06:48:50 +0000
@@ -1,7 +1,7 @@
 # depends on the binlog output
 --source include/have_binlog_format_mixed_or_statement.inc
 
-let $rename_event_pos= 931;
+let $rename_event_pos= 933;
 -- source extra/rpl_tests/rpl_flsh_tbls.test
 
 # End of 4.1 tests

=== modified file 'mysql-test/suite/rpl_ndb/r/rpl_ndb_multi.result'
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_multi.result	2010-07-17 11:16:36 +0000
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_multi.result	2010-09-01 02:51:08 +0000
@@ -26,7 +26,7 @@ stop slave;
 SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
 FROM mysql.ndb_binlog_index WHERE epoch = <the_epoch> ;
 @the_pos:=Position	@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
-107	master-bin.000001
+109	master-bin.000001
 CHANGE MASTER TO
 master_port=<MASTER_PORT1>,
 master_log_file = 'master-bin.000001',

=== added file 'mysql-test/suite/sys_vars/r/binlog_rows_query_log_events_basic.result'
--- a/mysql-test/suite/sys_vars/r/binlog_rows_query_log_events_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/binlog_rows_query_log_events_basic.result	2010-07-07 06:48:50 +0000
@@ -0,0 +1,76 @@
+SELECT @@GLOBAL.binlog_rows_query_log_events;
+@@GLOBAL.binlog_rows_query_log_events
+0
+'#---------------------BS_STVARS_002_01----------------------#'
+SET @start_value= @@global.binlog_rows_query_log_events;
+SELECT COUNT(@@GLOBAL.binlog_rows_query_log_events);
+COUNT(@@GLOBAL.binlog_rows_query_log_events)
+1
+1 Expected
+SELECT COUNT(@@SESSION.binlog_rows_query_log_events);
+COUNT(@@SESSION.binlog_rows_query_log_events)
+1
+1 Expected
+'#---------------------BS_STVARS_002_02----------------------#'
+SET @@GLOBAL.binlog_rows_query_log_events=TRUE;
+SELECT @@GLOBAL.binlog_rows_query_log_events;
+@@GLOBAL.binlog_rows_query_log_events
+1
+SET @@SESSION.binlog_rows_query_log_events=TRUE;
+SELECT @@SESSION.binlog_rows_query_log_events;
+@@SESSION.binlog_rows_query_log_events
+1
+'#---------------------BS_STVARS_002_03----------------------#'
+SELECT
+IF(@@GLOBAL.binlog_rows_query_log_events, "ON", "OFF") = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='binlog_rows_query_log_events';
+IF(@@GLOBAL.binlog_rows_query_log_events, "ON", "OFF") = VARIABLE_VALUE
+1
+1 Expected
+SELECT COUNT(@@GLOBAL.binlog_rows_query_log_events);
+COUNT(@@GLOBAL.binlog_rows_query_log_events)
+1
+1 Expected
+SELECT COUNT(VARIABLE_VALUE)
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='binlog_rows_query_log_events';
+COUNT(VARIABLE_VALUE)
+1
+1 Expected
+'#---------------------BS_STVARS_002_04----------------------#'
+SELECT
+IF(@@SESSION.binlog_rows_query_log_events, "ON", "OFF") = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='binlog_rows_query_log_events';
+IF(@@SESSION.binlog_rows_query_log_events, "ON", "OFF") = VARIABLE_VALUE
+1
+1 Expected
+SELECT COUNT(@@SESSION.binlog_rows_query_log_events);
+COUNT(@@SESSION.binlog_rows_query_log_events)
+1
+1 Expected
+SELECT COUNT(VARIABLE_VALUE)
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='binlog_rows_query_log_events';
+COUNT(VARIABLE_VALUE)
+1
+1 Expected
+'#---------------------BS_STVARS_002_05----------------------#'
+SELECT COUNT(@@binlog_rows_query_log_events);
+COUNT(@@binlog_rows_query_log_events)
+1
+1 Expected
+SELECT COUNT(@@local.binlog_rows_query_log_events);
+COUNT(@@local.binlog_rows_query_log_events)
+1
+1 Expected
+SELECT COUNT(@@SESSION.binlog_rows_query_log_events);
+COUNT(@@SESSION.binlog_rows_query_log_events)
+1
+1 Expected
+SELECT COUNT(@@GLOBAL.binlog_rows_query_log_events);
+COUNT(@@GLOBAL.binlog_rows_query_log_events)
+1
+1 Expected
+SET @@global.binlog_rows_query_log_events= @start_value;

=== modified file 'mysql-test/suite/sys_vars/r/slow_query_log_func.result'
--- a/mysql-test/suite/sys_vars/r/slow_query_log_func.result	2010-06-08 08:58:19 +0000
+++ b/mysql-test/suite/sys_vars/r/slow_query_log_func.result	2010-08-30 06:38:09 +0000
@@ -81,7 +81,7 @@ DROP FUNCTION f_slow_current_time;
 DROP TABLE t1;
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 CREATE TABLE t1(c1 INT) ENGINE=MyISAM;
 DROP PROCEDURE IF EXISTS p1;
 CREATE PROCEDURE p1()

=== modified file 'mysql-test/suite/sys_vars/r/sql_notes_func.result'
--- a/mysql-test/suite/sys_vars/r/sql_notes_func.result	2008-12-19 15:12:15 +0000
+++ b/mysql-test/suite/sys_vars/r/sql_notes_func.result	2010-08-30 06:38:09 +0000
@@ -13,7 +13,7 @@ SELECT @@warning_count;
 0 Expected
 DROP TABLE IF EXISTS t1;
 Warnings:
-Note	1051	Unknown table 't1'
+Note	1051	Unknown table 'test.t1'
 SELECT @@warning_count;
 @@warning_count
 1

=== added file 'mysql-test/suite/sys_vars/t/binlog_rows_query_log_events_basic.test'
--- a/mysql-test/suite/sys_vars/t/binlog_rows_query_log_events_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/binlog_rows_query_log_events_basic.test	2010-07-07 06:48:50 +0000
@@ -0,0 +1,97 @@
+######### mysql-test\t\binlog_rows_query_log_events.test ########### 
+#                                                                             #
+# Variable Name: binlog_rows_query_log_events                      #
+# Scope: Global & Session                                                     #
+# Access Type: Static                                                         #
+# Data Type: bool                                                             #
+#                                                                             #
+# Description:Test Cases of Dynamic System Variable                           #
+#             binlog_rows_query_log_events                         #
+#             that checks the behavior of this variable in the following ways #
+#              * Value Check                                                  #
+#              * Scope Check                                                  #
+#                                                                             #
+# Reference:                                                                  #
+#    http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html      #
+#                                                                             #
+###############################################################################
+
+SELECT @@GLOBAL.binlog_rows_query_log_events;
+
+--echo '#---------------------BS_STVARS_002_01----------------------#'
+####################################################################
+#   Displaying default value                                       #
+####################################################################
+SET @start_value= @@global.binlog_rows_query_log_events;
+
+SELECT COUNT(@@GLOBAL.binlog_rows_query_log_events);
+--echo 1 Expected
+
+SELECT COUNT(@@SESSION.binlog_rows_query_log_events);
+--echo 1 Expected
+
+--echo '#---------------------BS_STVARS_002_02----------------------#'
+####################################################################
+#   Check if Value can set                                         #
+####################################################################
+SET @@GLOBAL.binlog_rows_query_log_events=TRUE;
+SELECT @@GLOBAL.binlog_rows_query_log_events;
+
+SET @@SESSION.binlog_rows_query_log_events=TRUE;
+SELECT @@SESSION.binlog_rows_query_log_events;
+
+--echo '#---------------------BS_STVARS_002_03----------------------#'
+#################################################################
+# Check if the value in GLOBAL Table matches value in variable  #
+#################################################################
+
+SELECT
+IF(@@GLOBAL.binlog_rows_query_log_events, "ON", "OFF") = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='binlog_rows_query_log_events';
+--echo 1 Expected
+
+SELECT COUNT(@@GLOBAL.binlog_rows_query_log_events);
+--echo 1 Expected
+
+SELECT COUNT(VARIABLE_VALUE)
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='binlog_rows_query_log_events';
+--echo 1 Expected
+
+
+--echo '#---------------------BS_STVARS_002_04----------------------#'
+#################################################################
+# Check if the value in SESSION Table matches value in variable #
+#################################################################
+
+SELECT
+IF(@@SESSION.binlog_rows_query_log_events, "ON", "OFF") = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='binlog_rows_query_log_events';
+--echo 1 Expected
+
+SELECT COUNT(@@SESSION.binlog_rows_query_log_events);
+--echo 1 Expected
+
+SELECT COUNT(VARIABLE_VALUE)
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='binlog_rows_query_log_events';
+--echo 1 Expected
+
+
+--echo '#---------------------BS_STVARS_002_05----------------------#'
+################################################################################
+#   Check if binlog_format can be accessed with and without @@ sign            #
+################################################################################
+
+SELECT COUNT(@@binlog_rows_query_log_events);
+--echo 1 Expected
+SELECT COUNT(@@local.binlog_rows_query_log_events);
+--echo 1 Expected
+SELECT COUNT(@@SESSION.binlog_rows_query_log_events);
+--echo 1 Expected
+SELECT COUNT(@@GLOBAL.binlog_rows_query_log_events);
+--echo 1 Expected
+
+SET @@global.binlog_rows_query_log_events= @start_value;

=== modified file 'mysql-test/t/ctype_utf16.test'
--- a/mysql-test/t/ctype_utf16.test	2010-07-08 10:57:38 +0000
+++ b/mysql-test/t/ctype_utf16.test	2010-09-01 06:35:04 +0000
@@ -327,6 +327,7 @@ SET collation_connection='utf16_general_
 SET NAMES latin1;
 SET collation_connection='utf16_bin';
 -- source include/ctype_filesort.inc
+-- source include/ctype_filesort2.inc
 -- source include/ctype_like_escape.inc
 
 #

=== modified file 'mysql-test/t/ctype_utf32.test'
--- a/mysql-test/t/ctype_utf32.test	2010-08-26 13:21:49 +0000
+++ b/mysql-test/t/ctype_utf32.test	2010-09-01 07:34:59 +0000
@@ -328,6 +328,7 @@ SET collation_connection='utf32_general_
 SET NAMES latin1;
 SET collation_connection='utf32_bin';
 -- source include/ctype_filesort.inc
+-- source include/ctype_filesort2.inc
 -- source include/ctype_like_escape.inc
 
 #

=== modified file 'mysql-test/t/ctype_utf8mb4.test'
--- a/mysql-test/t/ctype_utf8mb4.test	2010-06-02 12:23:50 +0000
+++ b/mysql-test/t/ctype_utf8mb4.test	2010-08-31 13:54:26 +0000
@@ -733,6 +733,7 @@ SET collation_connection='utf8mb4_genera
 -- source include/ctype_german.inc
 SET collation_connection='utf8mb4_bin';
 -- source include/ctype_filesort.inc
+-- source include/ctype_filesort2.inc
 -- source include/ctype_like_escape.inc
 
 #

=== modified file 'mysql-test/t/delete.test'
--- a/mysql-test/t/delete.test	2010-05-23 20:41:18 +0000
+++ b/mysql-test/t/delete.test	2010-08-30 22:22:01 +0000
@@ -540,4 +540,17 @@ DELETE FROM t1 WHERE a = 10 OR b = 20 OR
 
 DROP TABLE t1;
 
+--echo #
+--echo # Bug #53034: Multiple-table DELETE statements not accepting
+--echo #             "Access compatibility" syntax
+--echo #
+
+CREATE TABLE t1 (id INT);
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+
+DELETE FROM t1.*, test.t2.*, a.* USING t1, t2, t3 AS a;
+
+DROP TABLE t1, t2, t3;
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def	2010-09-01 13:46:08 +0000
+++ b/mysql-test/t/disabled.def	2010-09-06 10:54:47 +0000
@@ -11,6 +11,8 @@
 ##############################################################################
 kill                     : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild.
 lowercase_table3         : Bug#54845 2010-06-30 alik main.lowercase_table3 on Mac OSX
+mysqlhotcopy_myisam      : Bug#54129 2010-08-31 alik mysqlhotcopy* fails
+mysqlhotcopy_archive     : Bug#54129 2010-08-31 alik mysqlhotcopy* fails
 partition_innodb_plugin  : Bug#53307 2010-04-30 VasilDimov valgrind warnings
 plugin                   : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
 plugin_load              : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5

=== modified file 'mysql-test/t/drop.test'
--- a/mysql-test/t/drop.test	2010-06-07 15:27:40 +0000
+++ b/mysql-test/t/drop.test	2010-08-30 06:38:09 +0000
@@ -273,3 +273,40 @@ DROP TABLE t1, t1;
 
 UNLOCK TABLES;
 DROP TABLE t1;
+
+--echo #
+--echo # BUG#34750: Print database name in Unknown Table error message
+--echo #
+
+--echo 
+--echo # Test error message when droping table/view
+
+--error ER_BAD_TABLE_ERROR
+DROP TABLE table1;

+--error ER_BAD_TABLE_ERROR
+DROP TABLE table1,table2;
+--error ER_BAD_TABLE_ERROR
+DROP VIEW view1,view2,view3,view4;
+--echo
+DROP TABLE IF EXISTS table1;
+DROP TABLE IF EXISTS table1,table2;
+DROP VIEW IF EXISTS view1,view2,view3,view4;
+
+--echo
+--echo # Test error message when trigger does not find table
+
+CREATE TABLE table1(a int);
+CREATE TABLE table2(b int);
+
+# Database name is only available (for printing) if specified in 
+# the trigger definition
+CREATE TRIGGER trg1 AFTER INSERT ON table1
+FOR EACH ROW
+  INSERT INTO table2 SELECT t.notable.*;
+
+--error ER_BAD_TABLE_ERROR
+INSERT INTO table1 VALUES (1);
+
+DROP TABLE table1,table2;
+
+--echo # End BUG#34750

=== modified file 'mysql-test/t/func_gconcat.test'
--- a/mysql-test/t/func_gconcat.test	2010-04-03 17:35:51 +0000
+++ b/mysql-test/t/func_gconcat.test	2010-08-20 11:22:46 +0000
@@ -708,6 +708,7 @@ SELECT 1 FROM
 
 DROP TABLE t1;
 
+--echo End of 5.0 tests
 
 --echo #
 --echo # Bug #52397: another crash with explain extended and group_concat
@@ -722,6 +723,26 @@ DROP TABLE t1;
 
 --echo End of 5.0 tests
 
+
+--echo #
+--echo # Bug #54476: crash when group_concat and 'with rollup' in prepared statements
+--echo # 
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2);
+
+PREPARE stmt FROM "SELECT GROUP_CONCAT(t1.a ORDER BY t1.a) FROM t1 JOIN t1 t2 GROUP BY t1.a WITH ROLLUP";
+EXECUTE stmt;
+EXECUTE stmt;
+
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+
+
+--echo End of 5.1 tests

+
+
+
 #
 # Bug#36785: Wrong error message when group_concat() exceeds max length
 #

=== modified file 'mysql-test/t/func_group.test'
--- a/mysql-test/t/func_group.test	2010-08-25 08:37:49 +0000
+++ b/mysql-test/t/func_group.test	2010-08-30 08:40:42 +0000
@@ -1082,6 +1082,20 @@ select a.f1 as a, b.f4 as b, a.f1 > b.f4
 from t1 a, t1 b;
 select *, f1 = f2 from t1;
 drop table t1;
+
+--echo #
+--echo # Bug #54465: assert: field_types == 0 || field_types[field_pos] ==
+--echo #             MYSQL_TYPE_LONGLONG
+--echo #
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2);
+
+SELECT MAX((SELECT 1 FROM t1 ORDER BY @var LIMIT 1)) m FROM t1 t2, t1 
+       ORDER BY t1.a;
+
+DROP TABLE t1;
+
 --echo #
 --echo End of 5.1 tests
 

=== modified file 'mysql-test/t/func_misc.test'
--- a/mysql-test/t/func_misc.test	2010-04-07 09:59:02 +0000
+++ b/mysql-test/t/func_misc.test	2010-08-20 11:22:46 +0000
@@ -468,6 +468,19 @@ select NAME_CONST('_id',1234) as id;
 select connection_id() > 0;
 
 --echo #
+--echo # Bug #54461: crash with longblob and union or update with subquery
+--echo #
+
+CREATE TABLE t1 (a INT, b LONGBLOB);
+INSERT INTO t1 VALUES (1, '2'), (2, '3'), (3, '2');
+
+SELECT DISTINCT LEAST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1;
+SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1;
+
+DROP TABLE t1;
+
+
+--echo #
 --echo # Bug #52165: Assertion failed: file .\dtoa.c, line 465
 --echo # 
 
@@ -478,4 +491,5 @@ SELECT COALESCE(a) = COALESCE(b) FROM t1
 
 DROP TABLE t1;
 
+
 --echo End of tests

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	2010-05-14 08:14:09 +0000
+++ b/mysql-test/t/func_time.test	2010-08-18 07:24:32 +0000
@@ -821,6 +821,17 @@ select date_sub("0069-01-01 00:00:01",IN
 select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
 
 
+#
+# Bug #55565: debug assertion when ordering by expressions with user
+# variable assignments
+#
+
+CREATE TABLE t1(a DOUBLE NOT NULL);
+INSERT INTO t1 VALUES (0),(9.216e-096);
+--echo # should not crash
+SELECT 1 FROM t1 ORDER BY @x:=makedate(a,a);
+DROP TABLE t1;
+
 --echo End of 5.1 tests
 
 --echo #

=== added file 'mysql-test/t/partition_not_blackhole-master.opt'
--- a/mysql-test/t/partition_not_blackhole-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/partition_not_blackhole-master.opt	2010-07-08 12:36:55 +0000
@@ -0,0 +1 @@
+--loose-skip-blackhole

=== added file 'mysql-test/t/partition_not_blackhole.test'
--- a/mysql-test/t/partition_not_blackhole.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/partition_not_blackhole.test	2010-08-20 19:17:51 +0000
@@ -0,0 +1,26 @@
+--source include/have_partition.inc
+--source include/not_blackhole.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+
+--echo #
+--echo # Bug#46086: crash when dropping a partitioned table and
+--echo #            the original engine is disabled
+--echo # Copy a .frm and .par file which was created with:
+--echo # create table `t1` (`id` int primary key) engine=blackhole
+--echo # partition by key () partitions 1;
+--copy_file std_data/parts/t1_blackhole.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/parts/t1_blackhole.par $MYSQLD_DATADIR/test/t1.par
+SHOW TABLES;
+--replace_result $MYSQLD_DATADIR ./
+--error ER_NOT_FORM_FILE
+SHOW CREATE TABLE t1;
+--error ER_BAD_TABLE_ERROR
+DROP TABLE t1;
+--list_files $MYSQLD_DATADIR/test t1*
+--remove_file $MYSQLD_DATADIR/test/t1.frm
+--remove_file $MYSQLD_DATADIR/test/t1.par

=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2010-08-26 15:23:47 +0000
+++ b/mysys/my_getopt.c	2010-09-02 01:50:32 +0000
@@ -163,7 +163,6 @@ int handle_options(int *argc, char ***ar
   int error, i;
   my_bool is_cmdline_arg= 1;
 
-  LINT_INIT(opt_found);
   /* handle_options() assumes arg0 (program name) always exists */
   DBUG_ASSERT(argc && *argc >= 1);
   DBUG_ASSERT(argv && *argv);
@@ -188,6 +187,7 @@ int handle_options(int *argc, char ***ar
   {
     char **first= pos;
     char *cur_arg= *pos;
+    opt_found= 0;
     if (!is_cmdline_arg && (cur_arg == args_separator))
     {
       is_cmdline_arg= 1;

=== modified file 'mysys/my_init.c'
--- a/mysys/my_init.c	2010-07-23 20:16:29 +0000
+++ b/mysys/my_init.c	2010-08-16 12:50:27 +0000
@@ -477,7 +477,7 @@ static my_bool win32_init_tcp_ip()
 {
   if (win32_have_tcpip())
   {
-    WORD wVersionRequested = MAKEWORD( 2, 0 );
+    WORD wVersionRequested = MAKEWORD( 2, 2 );
     WSADATA wsaData;
  	/* Be a good citizen: maybe another lib has already initialised
  		sockets, so dont clobber them unless necessary */

=== modified file 'mysys/thr_lock.c'
--- a/mysys/thr_lock.c	2010-08-20 08:48:59 +0000
+++ b/mysys/thr_lock.c	2010-09-01 13:05:01 +0000
@@ -92,6 +92,16 @@ enum thr_lock_type thr_upgraded_concurre
 LIST *thr_lock_thread_list;			/* List of threads in use */
 ulong max_write_lock_count= ~(ulong) 0L;
 
+static void (*before_lock_wait)(void)= 0;
+static void (*after_lock_wait)(void)= 0;
+
+void thr_set_lock_wait_callback(void (*before_wait)(void),
+                                void (*after_wait)(void))
+{
+  before_lock_wait= before_wait;
+  after_lock_wait= after_wait;
+}
+
 static inline mysql_cond_t *get_cond(void)
 {
   return &my_thread_var->suspend;
@@ -432,6 +442,19 @@ wait_for_lock(struct st_lock_list *wait,
   old_proc_info= proc_info_hook(NULL, "Waiting for table level lock",
                                 __func__, __FILE__, __LINE__);
 
+  /*
+    Since before_lock_wait potentially can create more threads to
+    scheduler work for, we don't want to call the before_lock_wait
+    callback unless it will really start to wait.
+
+    For similar reasons, we do not want to call before_lock_wait and
+    after_lock_wait for each lap around the loop, so we restrict
+    ourselves to call it before_lock_wait once before starting to wait
+    and once after the thread has exited the wait loop.
+   */
+  if ((!thread_var->abort || in_wait_list) && before_lock_wait)
+    (*before_lock_wait)();
+
   set_timespec(wait_timeout, lock_wait_timeout);
   while (!thread_var->abort || in_wait_list)
   {
@@ -463,6 +486,14 @@ wait_for_lock(struct st_lock_list *wait,
       /* purecov: end */
     }
   }
+
+  /*
+    We call the after_lock_wait callback once the wait loop has
+    finished.
+   */
+  if (after_lock_wait)
+    (*after_lock_wait)();
+
   DBUG_PRINT("thr_lock", ("aborted: %d  in_wait_list: %d",
                           thread_var->abort, in_wait_list));
 

=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt	2010-08-20 09:15:16 +0000
+++ b/sql/CMakeLists.txt	2010-09-02 22:34:48 +0000
@@ -289,8 +289,7 @@ IF(WIN32 AND MYSQLD_EXECUTABLE)
      COMMAND ${CMAKE_COMMAND}
      ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake
      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data
-     COMMAND  ${CMAKE_COMMAND} -E touch initdb.dep
-     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+     COMMAND  ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep
      DEPENDS mysqld
   )
   ADD_CUSTOM_TARGET(initial_database  

=== modified file 'sql/authors.h'
--- a/sql/authors.h	2010-07-02 18:15:21 +0000
+++ b/sql/authors.h	2010-09-09 10:54:19 +0000
@@ -94,6 +94,7 @@ struct show_table_authors_st show_table_
   { "Arjen Lentz", "Brisbane, Australia",
     "Documentation (2001-2004), Dutch error messages, LOG2()" },
   { "Marc Liyanage", "", "Created Mac OS X packages" },
+  { "Kelly Long", "Denver, CO, USA", "Pool Of Threads" },
   { "Zarko Mocnik", "", "Sorting for Slovenian language" },
   { "Per-Erik Martin", "Uppsala, Sweden", "Stored Procedures (5.0)" },
   { "Alexis Mikhailov", "", "User-defined functions" },
@@ -119,6 +120,8 @@ struct show_table_authors_st show_table_
   { "Jan Pazdziora", "", "Czech sorting order" },
   { "Benjamin Pflugmann", "",
     "Extended MERGE storage engine to handle INSERT" },
+  { "Evgeny Potemkin", "Russia",
+    "Filesort and derived tables optimizations, bugfixes" },
   { "Igor Romanenko", "",
     "mysqldump" },
   { "Mikael Ronström", "Stockholm, Sweden",

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2010-08-20 03:37:42 +0000
+++ b/sql/binlog.cc	2010-09-04 00:24:29 +0000
@@ -1597,6 +1597,9 @@ bool MYSQL_BIN_LOG::open(const char *log
       if (!s.is_valid())
         goto err;
       s.dont_set_created= null_created_arg;
+      /* Set LOG_EVENT_RELAY_LOG_F flag for relay log's FD */
+      if (is_relay_log)
+        s.set_relay_log_event();
       if (s.write(&log_file))
         goto err;
       bytes_written+= s.data_written;
@@ -3948,14 +3951,22 @@ void THD::binlog_set_stmt_begin() {
   Note that in order to keep the signature uniform with related methods,
   we use a redundant parameter to indicate whether a transactional table
   was changed or not.
+  Sometimes it will write a Rows_query_log_event into binary log before
+  the table map too.
  
   @param table             a pointer to the table.
   @param is_transactional  @c true indicates a transactional table,
                            otherwise @c false a non-transactional.
+  @param binlog_rows_query @c true indicates a Rows_query log event
+                           will be binlogged before table map,
+                           otherwise @c false indicates it will not
+                           be binlogged.
   @return
-    nonzero if an error pops up when writing the table map event.
+    nonzero if an error pops up when writing the table map event
+    or the Rows_query log event.
 */
-int THD::binlog_write_table_map(TABLE *table, bool is_transactional)
+int THD::binlog_write_table_map(TABLE *table, bool is_transactional,
+                                bool binlog_rows_query)
 {
   int error;
   DBUG_ENTER("THD::binlog_write_table_map");
@@ -3978,6 +3989,16 @@ int THD::binlog_write_table_map(TABLE *t
 
   IO_CACHE *file=
     cache_mngr->get_binlog_cache_log(use_trans_cache(this, is_transactional));
+
+  if (binlog_rows_query && this->query())
+  {
+    /* Write the Rows_query_log_event into binlog before the table map */
+    Rows_query_log_event
+      rows_query_ev(this, this->query(), this->query_length());
+    if ((error= rows_query_ev.write(file)))
+      DBUG_RETURN(error);
+  }
+
   if ((error= the_event.write(file)))
     DBUG_RETURN(error);
 

=== modified file 'sql/binlog.h'
--- a/sql/binlog.h	2010-07-02 02:58:51 +0000
+++ b/sql/binlog.h	2010-08-26 14:29:22 +0000
@@ -162,10 +162,10 @@ public:
   /* Use this to start writing a new log file */
   void new_file();
 
-  bool write(Log_event* event_info);
+  bool write(Log_event* event_info); // binary log write
   bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event, bool incident);
-  bool write_incident(THD *thd, bool lock);
 
+  bool write_incident(THD *thd, bool lock);
   int  write_cache(IO_CACHE *cache, bool lock_log, bool flush_and_sync);
   void set_write_error(THD *thd);
   bool check_write_error(THD *thd);

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2010-08-04 10:34:01 +0000
+++ b/sql/ha_partition.cc	2010-08-26 14:32:33 +0000
@@ -2447,9 +2447,14 @@ bool ha_partition::get_from_handler_file
   tot_partition_words= (m_tot_parts + 3) / 4;
   engine_array= (handlerton **) my_alloca(m_tot_parts * sizeof(handlerton*));
   for (i= 0; i < m_tot_parts; i++)
+  {
     engine_array[i]= ha_resolve_by_legacy_type(ha_thd(),
                                                (enum legacy_db_type)
-                                               *(uchar *) ((file_buffer) + 12 + i));
+                                               *(uchar *) ((file_buffer) +
+                                                           12 + i));
+    if (!engine_array[i])
+      goto err3;
+  }
   address_tot_name_len= file_buffer + 12 + 4 * tot_partition_words;
   tot_name_words= (uint4korr(address_tot_name_len) + 3) / 4;
   if (len_words != (tot_partition_words + tot_name_words + 4))

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2010-08-20 09:15:16 +0000
+++ b/sql/handler.cc	2010-09-01 02:51:08 +0000
@@ -5595,6 +5595,7 @@ static int write_locked_table_maps(THD *
       if (lock == NULL)
         continue;
 
+      bool need_binlog_rows_query= thd->variables.binlog_rows_query_log_events;
       TABLE **const end_ptr= lock->table + lock->table_count;
       for (TABLE **table_ptr= lock->table ; 
            table_ptr != end_ptr ;
@@ -5620,7 +5621,12 @@ static int write_locked_table_maps(THD *
           */
           bool const has_trans= thd->lex->sql_command == SQLCOM_CREATE_TABLE ||
                                 table->file->has_transactions();
-          int const error= thd->binlog_write_table_map(table, has_trans);
+          int const error= thd->binlog_write_table_map(table, has_trans,
+                                                       need_binlog_rows_query);
+          /* Binlog Rows_query log event once for one statement which updates
+             two or more tables.*/
+          if (need_binlog_rows_query)
+            need_binlog_rows_query= FALSE;
           /*
             If an error occurs, it is the responsibility of the caller to
             roll back the transaction.

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2010-08-19 12:54:22 +0000
+++ b/sql/item_func.cc	2010-08-30 08:40:42 +0000
@@ -2551,6 +2551,8 @@ void Item_func_min_max::fix_length_and_d
                                                                  decimals,
                                                                  unsigned_flag));
   }
+  else if (cmp_type == REAL_RESULT)
+    fix_char_length(float_length(decimals));
   cached_field_type= agg_field_type(args, arg_count);
 }
 

=== modified file 'sql/item_sum.cc'
--- a/sql/item_sum.cc	2010-07-23 17:51:11 +0000
+++ b/sql/item_sum.cc	2010-08-30 08:36:38 +0000
@@ -434,26 +434,6 @@ void Item_sum::mark_as_sum_func()
 }
 
 
-void Item_sum::make_field(Send_field *tmp_field)
-{
-  if (args[0]->type() == Item::FIELD_ITEM && keep_field_type())
-  {
-    ((Item_field*) args[0])->field->make_field(tmp_field);
-    /* For expressions only col_name should be non-empty string. */
-    char *empty_string= (char*)"";
-    tmp_field->db_name= empty_string;
-    tmp_field->org_table_name= empty_string;
-    tmp_field->table_name= empty_string;
-    tmp_field->org_col_name= empty_string;
-    tmp_field->col_name= name;
-    if (maybe_null)
-      tmp_field->flags&= ~NOT_NULL_FLAG;
-  }
-  else
-    init_make_field(tmp_field, field_type());
-}
-
-
 void Item_sum::print(String *str, enum_query_type query_type)
 {
   /* orig_args is not filled with valid values until fix_fields() */
@@ -987,7 +967,8 @@ bool Aggregator_distinct::add()
   {
     int error;
     copy_fields(tmp_table_param);
-    copy_funcs(tmp_table_param->items_to_copy);
+    if (copy_funcs(tmp_table_param->items_to_copy, table->in_use))
+      return TRUE;
 
     for (Field **field=table->field ; *field ; field++)
       if ((*field)->is_real_null(0))
@@ -3061,7 +3042,6 @@ Item_func_group_concat::Item_func_group_
   tree(item->tree),
   unique_filter(item->unique_filter),
   table(item->table),
-  order(item->order),
   context(item->context),
   arg_count_order(item->arg_count_order),
   arg_count_field(item->arg_count_field),
@@ -3074,6 +3054,24 @@ Item_func_group_concat::Item_func_group_
 {
   quick_group= item->quick_group;
   result.set_charset(collation.collation);
+
+  /*
+    Since the ORDER structures pointed to by the elements of the 'order' array
+    may be modified in find_order_in_list() called from
+    Item_func_group_concat::setup(), create a copy of those structures so that
+    such modifications done in this object would not have any effect on the
+    object being copied.
+  */
+  ORDER *tmp;
+  if (!(order= (ORDER **) thd->alloc(sizeof(ORDER *) * arg_count_order +
+                                     sizeof(ORDER) * arg_count_order)))
+    return;
+  tmp= (ORDER *)(order + arg_count_order);
+  for (uint i= 0; i < arg_count_order; i++, tmp++)
+  {
+    memcpy(tmp, item->order[i], sizeof(ORDER));
+    order[i]= tmp;
+  }
 }
 
 
@@ -3139,7 +3137,8 @@ bool Item_func_group_concat::add()
   if (always_null)
     return 0;
   copy_fields(tmp_table_param);
-  copy_funcs(tmp_table_param->items_to_copy);
+  if (copy_funcs(tmp_table_param->items_to_copy, table->in_use))
+    return TRUE;
 
   for (uint i= 0; i < arg_count_field; i++)
   {

=== modified file 'sql/item_sum.h'
--- a/sql/item_sum.h	2010-07-28 23:39:52 +0000
+++ b/sql/item_sum.h	2010-08-30 08:36:38 +0000
@@ -427,7 +427,6 @@ public:  
     forced_const= TRUE; 
   }
   virtual bool const_item() const { return forced_const; }
-  void make_field(Send_field *field);
   virtual void print(String *str, enum_query_type query_type);
   void fix_num_length_and_dec();
 

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2010-08-20 03:51:38 +0000
+++ b/sql/log.cc	2010-08-30 08:40:42 +0000
@@ -1993,70 +1993,93 @@ void sql_perror(const char *message)
 }
 
 
+#ifdef __WIN__
+extern "C" my_bool reopen_fstreams(const char *filename,
+                                   FILE *outstream, FILE *errstream)
+{
+  int handle_fd;
+  int stream_fd;
+  HANDLE osfh;
+
+  DBUG_ASSERT(filename && (outstream || errstream));
+
+  if ((osfh= CreateFile(filename, GENERIC_READ | GENERIC_WRITE,
+                        FILE_SHARE_READ | FILE_SHARE_WRITE |
+                        FILE_SHARE_DELETE, NULL,
+                        OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,
+                        NULL)) == INVALID_HANDLE_VALUE)
+    return TRUE;
+
+  if ((handle_fd= _open_osfhandle((intptr_t)osfh,
+                                  _O_APPEND | _O_TEXT)) == -1)
+  {
+    CloseHandle(osfh);
+    return TRUE;
+  }
+
+  if (outstream)
+  {
+    stream_fd= _fileno(outstream);
+    if (_dup2(handle_fd, stream_fd) < 0)
+    {
+      CloseHandle(osfh);
+      return TRUE;
+    }
+  }
+
+  if (errstream)
+  {
+    stream_fd= _fileno(errstream);
+    if (_dup2(handle_fd, stream_fd) < 0)
+    {
+      CloseHandle(osfh);
+      return TRUE;
+    }
+  }
+
+  _close(handle_fd);
+  return FALSE;
+}
+#else
+extern "C" my_bool reopen_fstreams(const char *filename,
+                                   FILE *outstream, FILE *errstream)
+{
+  if (outstream && !freopen(filename, "a+", outstream))
+    return TRUE;
+
+  if (errstream && !freopen(filename, "a+", errstream))
+    return TRUE;
+
+  return FALSE;
+}
+#endif
+
+
 /*
   Unfortunately, there seems to be no good way
   to restore the original streams upon failure.
 */
 static bool redirect_std_streams(const char *file)
 {
-  if (freopen(file, "a+", stdout) && freopen(file, "a+", stderr))
-  {
-    setbuf(stderr, NULL);
-    return FALSE;
-  }
+  if (reopen_fstreams(file, stdout, stderr))
+    return TRUE;
 
-  return TRUE;
+  setbuf(stderr, NULL);
+  return FALSE;
 }
 
 
 bool flush_error_log()
 {
-  bool result=0;
+  bool result= 0;
   if (opt_error_log)
   {
-    char err_renamed[FN_REFLEN], *end;
-    end= strmake(err_renamed,log_error_file,FN_REFLEN-5);
-    strmov(end, "-old");
     mysql_mutex_lock(&LOCK_error_log);
-#ifdef __WIN__
-    char err_temp[FN_REFLEN+5];
-    /*
-     On Windows is necessary a temporary file for to rename
-     the current error file.
-    */
-    strxmov(err_temp, err_renamed,"-tmp",NullS);
-    my_delete(err_temp, MYF(0));
-    if (freopen(err_temp,"a+",stdout))
-    {

-      int fd;
-      size_t bytes;
-      uchar buf[IO_SIZE];
-
-      freopen(err_temp,"a+",stderr);
-      setbuf(stderr, NULL);
-      my_delete(err_renamed, MYF(0));
-      my_rename(log_error_file, err_renamed, MYF(0));
-      redirect_std_streams(log_error_file);
-
-      if ((fd= my_open(err_temp, O_RDONLY, MYF(0))) >= 0)
-      {
-        while ((bytes= mysql_file_read(fd, buf, IO_SIZE, MYF(0))) &&
-               bytes != MY_FILE_ERROR)
-          my_fwrite(stderr, buf, bytes, MYF(0));
-        mysql_file_close(fd, MYF(0));
-      }
-      my_delete(err_temp, MYF(0));
-    }
-    else
-     result= 1;
-#else
-   my_rename(log_error_file, err_renamed, MYF(0));
-   if (redirect_std_streams(log_error_file))
-     result= 1;
-#endif
+    if (redirect_std_streams(log_error_file))
+      result= 1;
     mysql_mutex_unlock(&LOCK_error_log);
   }
-   return result;
+  return result;
 }
 
 #ifdef _WIN32

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-08-24 12:59:07 +0000
+++ b/sql/log_event.cc	2010-09-01 02:51:08 +0000
@@ -126,6 +126,36 @@ static const char *HA_ERR(int i)
 }

 
 /**
+  Delay to delete the Rows_query log event until all its rows event are applied
+
+  @param ev    log event should be deleted
+  @param rli   Relay_log_info structure for the slave IO thread.
+*/
+void handle_rows_query_log_event(Log_event *ev, Relay_log_info *rli)
+{
+  DBUG_ENTER("handle_rows_query_log_event");
+  Log_event_type ev_type= ev->get_type_code();
+
+  /* Delete the Rows_query log event after its last rows event are applied */
+  if ((ev_type == WRITE_ROWS_EVENT || ev_type == DELETE_ROWS_EVENT ||
+       ev_type == UPDATE_ROWS_EVENT) && rli->rows_query_ev != NULL &&
+      ((Rows_log_event*) ev)->get_flags(Rows_log_event::STMT_END_F))
+  {
+    delete rli->rows_query_ev;
+    rli->rows_query_ev= NULL;
+  }
+
+  /* Record the Rows_query log event until all its rows event are applied */
+  if (ev_type == ROWS_QUERY_LOG_EVENT)
+  {
+    DBUG_ASSERT(rli->rows_query_ev == NULL);
+    rli->rows_query_ev= (Rows_query_log_event*) ev;
+  }
+
+  DBUG_VOID_RETURN;
+}
+
+/**
    Error reporting facility for Rows_log_event::do_apply_event
 
    @param level     error, warning or info
@@ -654,6 +684,8 @@ const char* Log_event::get_type_str(Log_
   case BEGIN_LOAD_QUERY_EVENT: return "Begin_load_query";
   case EXECUTE_LOAD_QUERY_EVENT: return "Execute_load_query";
   case INCIDENT_EVENT: return "Incident";
+  case IGNORABLE_LOG_EVENT: return "Ignorable";
+  case ROWS_QUERY_LOG_EVENT: return "Rows_query";
   default: return "Unknown";				/* impossible */
   }
 }
@@ -1295,10 +1327,24 @@ Log_event* Log_event::read_log_event(con
     case INCIDENT_EVENT:
       ev = new Incident_log_event(buf, event_len, description_event);
       break;
+    case ROWS_QUERY_LOG_EVENT:
+      ev= new Rows_query_log_event(buf, event_len, description_event);
+      break;
     default:
-      DBUG_PRINT("error",("Unknown event code: %d",
-                          (int) buf[EVENT_TYPE_OFFSET]));
-      ev= NULL;
+      /*
+        Create an object of Ignorable_log_event for unrecognized sub-class.
+        So that SLAVE SQL THREAD will only update the position and continue.
+      */
+      if (uint2korr(buf + FLAGS_OFFSET) & LOG_EVENT_IGNORABLE_F)
+      {
+        ev= new Ignorable_log_event(buf, description_event);
+      }
+      else
+      {
+        DBUG_PRINT("error",("Unknown event code: %d",
+                            (int) buf[EVENT_TYPE_OFFSET]));
+        ev= NULL;
+      }
       break;
     }
   }
@@ -3854,6 +3900,8 @@ Format_description_log_event(uint8 binlo
                       post_header_len[DELETE_ROWS_EVENT-1]= 6;);
       post_header_len[INCIDENT_EVENT-1]= INCIDENT_HEADER_LEN;
       post_header_len[HEARTBEAT_LOG_EVENT-1]= 0;
+      post_header_len[IGNORABLE_LOG_EVENT-1]= IGNORABLE_HEADER_LEN;
+      post_header_len[ROWS_QUERY_LOG_EVENT-1]= IGNORABLE_HEADER_LEN;
 
       // Sanity-check that all post header lengths are initialized.
       int i;
@@ -9756,6 +9804,127 @@ Incident_log_event::write_data_body(IO_C
 }
 
 
+Ignorable_log_event::Ignorable_log_event(const char *buf,
+                                         const Format_description_log_event *descr_event)
+  : Log_event(buf, descr_event)
+{
+  DBUG_ENTER("Ignorable_log_event::Ignorable_log_event");
+  DBUG_VOID_RETURN;
+}
+
+Ignorable_log_event::~Ignorable_log_event()
+{
+}
+
+#ifndef MYSQL_CLIENT
+/* Pack info for its unrecognized ignorable event */
+void Ignorable_log_event::pack_info(Protocol *protocol)
+{
+  char buf[256];
+  size_t bytes;
+  bytes= my_snprintf(buf, sizeof(buf), "# Unrecognized ignorable event");
+  protocol->store(buf, bytes, &my_charset_bin);
+}
+#endif
+
+#ifdef MYSQL_CLIENT
+/* Print for its unrecognized ignorable event */
+void
+Ignorable_log_event::print(FILE *file,
+                           PRINT_EVENT_INFO *print_event_info)
+{
+  if (print_event_info->short_form)
+    return;
+
+  Write_on_release_cache cache(&print_event_info->head_cache, file);
+  print_header(&cache, print_event_info, FALSE);
+  my_b_printf(&cache, "\tIgnorable\n");
+  my_b_printf(&cache, "# Unrecognized ignorable event\n");
+}
+#endif
+
+
+Rows_query_log_event::Rows_query_log_event(const char *buf, uint event_len,
+                                           const Format_description_log_event *descr_event)
+  : Ignorable_log_event(buf, descr_event)
+{
+  DBUG_ENTER("Rows_query_log_event::Rows_query_log_event");
+  uint8 const common_header_len=
+    descr_event->common_header_len;
+  uint8 const post_header_len=
+    descr_event->post_header_len[ROWS_QUERY_LOG_EVENT-1];
+
+  DBUG_PRINT("info",("event_len: %u; common_header_len: %d; post_header_len: %d",
+                     event_len, common_header_len, post_header_len));
+
+  char const *ptr= buf + common_header_len + post_header_len;
+  char const *const str_end= buf + event_len;
+  uint8 len= 0;                   // Assignment to keep compiler happy
+  const char *str= NULL;          // Assignment to keep compiler happy
+  read_str(&ptr, str_end, &str, &len);
+  if (!(m_rows_query= (char*) my_malloc(len+1, MYF(MY_WME))))
+    return;
+  my_snprintf(m_rows_query, len+1, "%s", str);
+  DBUG_PRINT("info", ("m_rows_query: %s", m_rows_query));
+  DBUG_VOID_RETURN;
+}
+
+Rows_query_log_event::~Rows_query_log_event()
+{
+  my_free(m_rows_query);
+}
+
+#ifndef MYSQL_CLIENT
+void Rows_query_log_event::pack_info(Protocol *protocol)
+{
+  char *buf;
+  size_t bytes;
+  ulong len= sizeof("# ") + (ulong) strlen(m_rows_query);
+  if (!(buf= (char*) my_malloc(len, MYF(MY_WME))))
+    return;
+  bytes= my_snprintf(buf, len, "# %s", m_rows_query);
+  protocol->store(buf, bytes, &my_charset_bin);
+  my_free(buf);
+}
+#endif
+
+#ifdef MYSQL_CLIENT
+void
+Rows_query_log_event::print(FILE *file,
+                         PRINT_EVENT_INFO *print_event_info)
+{
+  if (print_event_info->short_form)
+    return;
+
+  Write_on_release_cache cache(&print_event_info->head_cache, file);
+  print_header(&cache, print_event_info, FALSE);
+  my_b_printf(&cache, "\tRows_query\n");
+  my_b_printf(&cache, "# %s\n", m_rows_query);
+
+  IO_CACHE *const body= &print_event_info->body_cache;
+  print_base64(body, print_event_info, true);
+}
+#endif
+
+bool
+Rows_query_log_event::write_data_body(IO_CACHE *file)
+{
+  DBUG_ENTER("Rows_query_log_event::write_data_body");
+  DBUG_RETURN(write_str(file, m_rows_query, (uint) strlen(m_rows_query)));
+}
+
+#ifndef MYSQL_CLIENT
+int Rows_query_log_event::do_apply_event(Relay_log_info const *rli)
+{
+  DBUG_ENTER("Rows_query_log_event::do_apply_event");
+  DBUG_ASSERT(rli->sql_thd == thd);
+  /* Set query for writing Rows_query log event into binlog later.*/
+  thd->set_query(m_rows_query, (uint32) strlen(m_rows_query));
+  DBUG_RETURN(0);
+}
+#endif /* !MYSQL_CLIENT */
+
+
 #ifdef MYSQL_CLIENT
 /**
   The default values for these variables should be values that are

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2010-08-12 00:26:10 +0000
+++ b/sql/log_event.h	2010-09-01 02:51:08 +0000
@@ -256,6 +256,7 @@ struct sql_ex_info
 #define EXECUTE_LOAD_QUERY_HEADER_LEN  (QUERY_HEADER_LEN + EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN)
 #define INCIDENT_HEADER_LEN    2
 #define HEARTBEAT_HEADER_LEN   0
+#define IGNORABLE_HEADER_LEN   0
 /* 
   Max number of possible extra bytes in a replication event compared to a
   packet (i.e. a query) sent from client to master;
@@ -497,6 +498,17 @@ struct sql_ex_info
 #define LOG_EVENT_RELAY_LOG_F 0x40
 
 /**
+   @def LOG_EVENT_IGNORABLE_F
+
+   For an event, 'e', carrying a type code, that a slave,
+   's', does not recognize, 's' will check 'e' for
+   LOG_EVENT_IGNORABLE_F, and if the flag is set, then 'e'
+   is ignored. Otherwise, 's' acknowledges that it has
+   found an unknown event in the relay log.
+*/
+#define LOG_EVENT_IGNORABLE_F 0x80
+
+/**
   @def OPTIONS_WRITTEN_TO_BIN_LOG
 
   OPTIONS_WRITTEN_TO_BIN_LOG are the bits of thd->options which must
@@ -593,7 +605,16 @@ enum Log_event_type
     to ensure master's online status to slave 
   */
   HEARTBEAT_LOG_EVENT= 27,
-  
+
+  /*
+    In some situations, it is necessary to send over ignorable
+    data to the slave: data that a slave can handle in case there
+    is code for handling it, but which can be ignored if it is not
+    recognized.
+  */
+  IGNORABLE_LOG_EVENT= 28,
+  ROWS_QUERY_LOG_EVENT= 29,
+
   /*
     Add new events here - right above this comment!
     Existing events (except ENUM_END_EVENT) should never change their numbers
@@ -1071,6 +1092,7 @@ public:
   void set_relay_log_event() { flags |= LOG_EVENT_RELAY_LOG_F; }
   bool is_artificial_event() const { return flags & LOG_EVENT_ARTIFICIAL_F; }
   bool is_relay_log_event() const { return flags & LOG_EVENT_RELAY_LOG_F; }
+  bool is_ignorable_event() const { return flags & LOG_EVENT_IGNORABLE_F; }
   inline bool use_trans_cache() const
   { 
     return (cache_type == Log_event::EVENT_TRANSACTIONAL_CACHE);
@@ -4037,6 +4059,96 @@ private:
   LEX_STRING m_message;
 };
 
+
+/**
+  @class Ignorable_log_event
+
+  Base class for ignorable log events. Events deriving from
+  this class can be safely ignored by slaves that cannot
+  recognize them. Newer slaves, will be able to read and
+  handle them. This has been designed to be an open-ended
+  architecture, so adding new derived events shall not harm
+  the old slaves that support ignorable log event mechanism
+  (they will just ignore unrecognized ignorable events).
+**/
+class Ignorable_log_event : public Log_event {
+public:
+#ifndef MYSQL_CLIENT
+  Ignorable_log_event(THD *thd_arg)
+      : Log_event(thd_arg, LOG_EVENT_IGNORABLE_F, FALSE)
+  {
+    DBUG_ENTER("Ignorable_log_event::Ignorable_log_event");
+    DBUG_VOID_RETURN;
+  }
+#endif
+
+  Ignorable_log_event(const char *buf,
+                      const Format_description_log_event *descr_event);
+
+  virtual ~Ignorable_log_event();
+
+#ifndef MYSQL_CLIENT
+  void pack_info(Protocol*);
+#endif
+
+#ifdef MYSQL_CLIENT
+  virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
+#endif
+
+  virtual Log_event_type get_type_code() { return IGNORABLE_LOG_EVENT; }
+
+  virtual bool is_valid() const { return 1; }
+
+  virtual int get_data_size() { return IGNORABLE_HEADER_LEN; }
+};
+
+
+class Rows_query_log_event : public Ignorable_log_event {
+public:
+#ifndef MYSQL_CLIENT
+  Rows_query_log_event(THD *thd_arg, const char * query, ulong query_len)
+    : Ignorable_log_event(thd_arg)
+  {
+    DBUG_ENTER("Rows_query_log_event::Rows_query_log_event");
+    if (!(m_rows_query= (char*) my_malloc(query_len + 1, MYF(MY_WME))))
+      return;
+    my_snprintf(m_rows_query, query_len + 1, "%s", query);
+    DBUG_PRINT("enter", ("%s", m_rows_query));
+    DBUG_VOID_RETURN;
+  }
+#endif
+
+#ifndef MYSQL_CLIENT
+  void pack_info(Protocol*);
+#endif
+
+  Rows_query_log_event(const char *buf, uint event_len,
+                     const Format_description_log_event *descr_event);
+
+  virtual ~Rows_query_log_event();
+
+#ifdef MYSQL_CLIENT
+  virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
+#endif
+  virtual bool write_data_body(IO_CACHE *file);
+
+  virtual Log_event_type get_type_code() { return ROWS_QUERY_LOG_EVENT; }
+
+  virtual int get_data_size()
+  {
+    return IGNORABLE_HEADER_LEN + 1 + (uint) strlen(m_rows_query);
+  }
+
+private:
+#if !defined(MYSQL_CLIENT)
+  virtual int do_apply_event(Relay_log_info const* rli);
+#endif
+
+  char * m_rows_query;
+};
+
+
+
 static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache,
                                                        FILE *file)
 {
@@ -4084,6 +4196,7 @@ private:
 int append_query_string(CHARSET_INFO *csinfo,
                         String const *from, String *to);
 bool sqlcom_can_generate_row_events(const THD *thd);
+void handle_rows_query_log_event(Log_event *ev, Relay_log_info *rli);
 
 /**
   @} (end of group Replication)

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-08-26 21:32:48 +0000
+++ b/sql/mysqld.cc	2010-09-01 13:06:14 +0000
@@ -63,7 +63,9 @@
 #include "events.h"
 #include "sql_audit.h"
 #include "probes_mysql.h"
+#include "scheduler.h"
 #include "debug_sync.h"
+#include "sql_callback.h"
 
 #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
 #include "../storage/perfschema/pfs_server.h"
@@ -192,6 +194,9 @@ typedef fp_except fp_except_t;
 # endif
 #endif
 
+extern "C" my_bool reopen_fstreams(const char *filename,
+                                   FILE *outstream, FILE *errstream);
+
 inline void setup_fpu()
 {
 #if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
@@ -455,7 +460,7 @@ ulong slave_trans_retries;
 uint  slave_net_timeout;
 ulong slave_exec_mode_options;
 ulonglong slave_type_conversions_options;
-ulong thread_cache_size=0, thread_pool_size= 0;
+ulong thread_cache_size=0;
 ulong binlog_cache_size=0;
 ulonglong  max_binlog_cache_size=0;
 ulong query_cache_size=0;
@@ -898,8 +903,6 @@ my_bool opt_enable_shared_memory;
 HANDLE smem_event_connect_request= 0;
 #endif
 
-scheduler_functions thread_scheduler;
-
 my_bool opt_use_ssl  = 0;
 char *opt_ssl_ca= NULL, *opt_ssl_capath= NULL, *opt_ssl_cert= NULL,
      *opt_ssl_cipher= NULL, *opt_ssl_key= NULL;
@@ -1087,7 +1090,8 @@ static void close_connections(void)
       continue;
 
     tmp->killed= THD::KILL_CONNECTION;
-    thread_scheduler.post_kill_notification(tmp);
+    MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (tmp));
+    mysql_mutex_lock(&tmp->LOCK_thd_data);
     if (tmp->mysys_var)
     {
       tmp->mysys_var->abort=1;
@@ -1100,6 +1104,7 @@ static void close_connections(void)
       }
       mysql_mutex_unlock(&tmp->mysys_var->mutex);
     }
+    mysql_mutex_unlock(&tmp->LOCK_thd_data);
   }
   mysql_mutex_unlock(&LOCK_thread_count); // For unlink from list
 
@@ -1479,7 +1484,7 @@ void clean_up(bool print_message)
   if (print_message && my_default_lc_messages && server_start_time)
     sql_print_information(ER_DEFAULT(ER_SHUTDOWN_COMPLETE),my_progname);
   cleanup_errmsgs();
-  thread_scheduler.end();
+  MYSQL_CALLBACK(thread_scheduler, end, ());
   finish_client_errs();
   DBUG_PRINT("quit", ("Error messages freed"));
   /* Tell main we are ready */
@@ -1748,7 +1753,7 @@ static void network_init(void)
   DBUG_ENTER("network_init");
   LINT_INIT(ret);
 
-  if (thread_scheduler.init())
+  if (MYSQL_CALLBACK_ELSE(thread_scheduler, init, (), 0))
     unireg_abort(1);			/* purecov: inspected */
 
   set_ports();
@@ -1996,7 +2001,7 @@ extern "C" sig_handler end_thread_signal
   if (thd && ! thd->bootstrap)
   {
     statistic_increment(killed_threads, &LOCK_status);
-    thread_scheduler.end_thread(thd,0);		/* purecov: inspected */
+    MYSQL_CALLBACK(thread_scheduler, end_thread, (thd,0)); /* purecov: inspected */
   }
   DBUG_VOID_RETURN;				/* purecov: deadcode */
 }
@@ -2392,7 +2397,7 @@ and this may fail.\n\n");
           (ulong) dflt_key_cache->key_cache_mem_size);
   fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
   fprintf(stderr, "max_used_connections=%lu\n", max_used_connections);
-  fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads);
+  fprintf(stderr, "max_threads=%u\n", thread_scheduler->max_threads);
   fprintf(stderr, "thread_count=%u\n", thread_count);
   fprintf(stderr, "connection_count=%u\n", connection_count);
   fprintf(stderr, "It is possible that mysqld could use up to \n\
@@ -2400,7 +2405,7 @@ key_buffer_size + (read_buffer_size + so
 bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size +
 		     (global_system_variables.read_buff_size +
 		      global_system_variables.sortbuff_size) *
-		     thread_scheduler.max_threads +
+		     thread_scheduler->max_threads +
                      max_connections * sizeof(THD)) / 1024);
   fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n");
 
@@ -2647,7 +2652,7 @@ pthread_handler_t signal_hand(void *arg 
     This should actually be '+ max_number_of_slaves' instead of +10,
     but the +10 should be quite safe.
   */
-  init_thr_alarm(thread_scheduler.max_threads +
+  init_thr_alarm(thread_scheduler->max_threads +
 		 global_system_variables.max_insert_delayed_threads + 10);
   if (thd_lib_detected != THD_LIB_LT && (test_flags & TEST_SIGINT))
   {
@@ -3886,13 +3891,15 @@ static int init_server_components()
       opt_error_log= 0;                         // Too long file name
     else
     {
+      my_bool res;
 #ifndef EMBEDDED_LIBRARY
-      if (freopen(log_error_file, "a+", stdout))
+      res= reopen_fstreams(log_error_file, stdout, stderr);
+#else
+      res= reopen_fstreams(log_error_file, NULL, stderr);
 #endif
-      {
-        if (freopen(log_error_file, "a+", stderr))
-          setbuf(stderr, NULL);
-      }
+
+      if (!res)
+        setbuf(stderr, NULL);
     }
   }
 
@@ -4501,23 +4508,6 @@ int mysqld_main(int argc, char **argv)
   }
 #endif
 
-#ifdef	__WIN__
-  /*
-    Before performing any socket operation (like retrieving hostname
-    in init_common_variables we have to call WSAStartup
-  */
-  {
-    WSADATA WsaData;
-    if (SOCKET_ERROR == WSAStartup (0x0101, &WsaData))
-    {
-      /* errors are not read yet, so we use english text here */
-      my_message(ER_WSAS_FAILED, "WSAStartup Failed", MYF(0));
-      /* Not enough initializations for unireg_abort() */
-      return 1;
-    }
-  }
-#endif /* __WIN__ */
-
   if (init_common_variables())
     unireg_abort(1);				// Will do exit
 
@@ -4618,8 +4608,8 @@ int mysqld_main(int argc, char **argv)
 #ifdef __WIN__
   if (!opt_console)
   {
-    freopen(log_error_file,"a+",stdout);
-    freopen(log_error_file,"a+",stderr);
+    if (reopen_fstreams(log_error_file, stdout, stderr))
+      unireg_abort(1);
     setbuf(stderr, NULL);
     FreeConsole();				// Remove window
   }
@@ -5189,7 +5179,7 @@ static void create_new_thread(THD *thd)
 
   thread_count++;
 
-  thread_scheduler.add_connection(thd);
+  MYSQL_CALLBACK(thread_scheduler, add_connection, (thd));
 
   DBUG_VOID_RETURN;
 }
@@ -7494,14 +7484,12 @@ static int get_options(int *argc_ptr, ch
     return 1;
 
 #ifdef EMBEDDED_LIBRARY
-  one_thread_scheduler(&thread_scheduler);
+  one_thread_scheduler();
 #else
   if (thread_handling <= SCHEDULER_ONE_THREAD_PER_CONNECTION)
-    one_thread_per_connection_scheduler(&thread_scheduler);
-  else if (thread_handling == SCHEDULER_NO_THREADS)
-    one_thread_scheduler(&thread_scheduler);
-  else
-    pool_of_threads_scheduler(&thread_scheduler);  /* purecov: tested */
+    one_thread_per_connection_scheduler();
+  else                  /* thread_handling == SCHEDULER_NO_THREADS) */
+    one_thread_scheduler();
 #endif
 
   global_system_variables.engine_condition_pushdown=

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2010-08-20 09:15:16 +0000
+++ b/sql/mysqld.h	2010-09-01 13:06:14 +0000
@@ -28,7 +28,7 @@ class THD;
 struct handlerton;
 class Time_zone;
 
-class scheduler_functions;
+struct scheduler_functions;
 
 typedef struct st_mysql_const_lex_string LEX_CSTRING;
 typedef struct st_mysql_show_var SHOW_VAR;
@@ -179,7 +179,7 @@ extern ulong binlog_cache_size, open_fil
 extern ulonglong max_binlog_cache_size;
 extern ulong max_binlog_size, max_relay_log_size;
 extern ulong opt_binlog_rows_event_max_size;
-extern ulong thread_cache_size, thread_pool_size;
+extern ulong thread_cache_size;
 extern ulong back_log;
 extern char language[FN_REFLEN];
 extern ulong server_id, concurrency;
@@ -211,7 +211,7 @@ extern my_bool old_mode;
 extern LEX_STRING opt_init_connect, opt_init_slave;
 extern int bootstrap_error;
 extern I_List<THD> threads;
-extern scheduler_functions thread_scheduler;
+extern char err_shared_dir[];
 extern TYPELIB thread_handling_typelib;
 extern my_decimal decimal_zero;
 

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2010-08-04 10:34:01 +0000
+++ b/sql/opt_range.cc	2010-08-26 14:32:33 +0000
@@ -5591,7 +5591,11 @@ static SEL_TREE *get_mm_tree(RANGE_OPT_P
         SEL_TREE *tmp= get_full_func_mm_tree(param, cond_func, 
                                     field_item, (Item*)(intptr)i, inv);
         if (inv)
+        {
           tree= !tree ? tmp : tree_or(param, tree, tmp);
+          if (tree == NULL)
+            break;
+        }
         else 
           tree= tree_and(param, tree, tmp);
       }

=== modified file 'sql/rpl_injector.cc'
--- a/sql/rpl_injector.cc	2010-07-08 21:42:23 +0000
+++ b/sql/rpl_injector.cc	2010-09-01 02:51:08 +0000
@@ -111,7 +111,7 @@ int injector::transaction::use_table(ser
   server_id_type save_id= m_thd->server_id;
   m_thd->set_server_id(sid);
   error= m_thd->binlog_write_table_map(tbl.get_table(),
-                                       tbl.is_transactional());
+                                       tbl.is_transactional(), FALSE);
   m_thd->set_server_id(save_id);
   DBUG_RETURN(error);
 }

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2010-08-06 08:54:01 +0000
+++ b/sql/rpl_rli.cc	2010-09-01 02:51:08 +0000
@@ -47,7 +47,7 @@ Relay_log_info::Relay_log_info(bool is_s
    tables_to_lock(0), tables_to_lock_count(0),
    last_event_start_time(0),
    sql_delay(0), sql_delay_end(0),
-   m_flags(0)
+   m_flags(0), rows_query_ev(NULL)
 {
   DBUG_ENTER("Relay_log_info::Relay_log_info");
 
@@ -1289,6 +1289,11 @@ void Relay_log_info::cleanup_context(THD
   {
     trans_rollback_stmt(thd); // if a "statement transaction"
     trans_rollback(thd);      // if a "real transaction"
+    if (rows_query_ev)
+    {
+      delete rows_query_ev;
+      rows_query_ev= NULL;
+    }
   }
   m_table_map.clear_tables();
   slave_close_thread_tables(thd);

=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h	2010-07-02 02:58:51 +0000
+++ b/sql/rpl_rli.h	2010-09-01 02:51:08 +0000
@@ -357,6 +357,8 @@ public:
   RPL_TABLE_LIST *tables_to_lock;           /* RBR: Tables to lock  */
   uint tables_to_lock_count;        /* RBR: Count of tables to lock */
   table_mapping m_table_map;      /* RBR: Mapping table-id to table */
+  /* RBR: Record Rows_query log event */
+  Rows_query_log_event* rows_query_ev;
 
   bool get_table_data(TABLE *table_arg, table_def **tabledef_var, TABLE **conv_table_var) const
   {

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2010-08-12 00:26:10 +0000
+++ b/sql/rpl_slave.cc	2010-09-04 00:24:29 +0000
@@ -2721,16 +2721,17 @@ static int exec_relay_log_event(THD* thd
   {
     int exec_res;
 
-    /* 
+    /*
       Even if we don't execute this event, we keep the master timestamp,
       so that seconds behind master shows correct delta (there are events
       that are not replayed, so we keep falling behind).
 
       If it is an artificial event, or a relay log event (IO thread generated
-      event) or ev->when is set to 0, we don't update the 
+      event) or ev->when is set to 0, or a FD from master, we don't update the
       last_master_timestamp.
-     */
-    if (!(ev->is_artificial_event() || ev->is_relay_log_event() || (ev->when == 0)))
+    */
+    if (!(ev->is_artificial_event() || ev->is_relay_log_event() ||
+          (ev->when == 0) || ev->get_type_code() == FORMAT_DESCRIPTION_EVENT))
     {
       rli->last_master_timestamp= ev->when + (time_t) ev->exec_time;
       DBUG_ASSERT(rli->last_master_timestamp >= 0);
@@ -2785,8 +2786,15 @@ static int exec_relay_log_event(THD* thd
     */
     if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT)
     {
+      if (thd->variables.binlog_rows_query_log_events)
+        handle_rows_query_log_event(ev, rli);
+
       DBUG_PRINT("info", ("Deleting the event after it has been executed"));
-      delete ev;
+      if (ev->get_type_code() != ROWS_QUERY_LOG_EVENT)
+      {
+        delete ev;
+        ev= NULL;
+      }
     }
 
     /*

=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc	2010-07-02 02:58:51 +0000
+++ b/sql/scheduler.cc	2010-09-01 13:05:01 +0000
@@ -25,55 +25,103 @@
 #include "unireg.h"                    // REQUIRED: for other includes
 #include "scheduler.h"
 #include "sql_connect.h"         // init_new_connection_handler_thread
+#include "scheduler.h"
+#include "sql_callback.h"
 
 /*
-  'Dummy' functions to be used when we don't need any handling for a scheduler
-  event
- */
+  End connection, in case when we are using 'no-threads'
+*/
 
-static bool init_dummy(void) {return 0;}
-static void post_kill_dummy(THD* thd) {}  
-static void end_dummy(void) {}
-static bool end_thread_dummy(THD *thd, bool cache_thread) { return 0; }
+static bool no_threads_end(THD *thd, bool put_in_cache)
+{
+  unlink_thd(thd);
+  mysql_mutex_unlock(&LOCK_thread_count);
+  return 1;                                     // Abort handle_one_connection
+}
 
-/*
-  Initialize default scheduler with dummy functions so that setup functions
-  only need to declare those that are relvant for their usage
+static scheduler_functions one_thread_scheduler_functions=
+{
+  1,                                     // max_threads
+  NULL,                                  // init
+  init_new_connection_handler_thread,    // init_new_connection_thread
+#ifndef EMBEDDED_LIBRARY
+  handle_connection_in_main_thread,      // add_connection
+#else
+  NULL,                                  // add_connection
+#endif // EMBEDDED_LIBRARY
+  NULL,                                  // thd_wait_begin
+  NULL,                                  // thd_wait_end
+  NULL,                                  // post_kill_notification
+  no_threads_end,                        // end_thread
+  NULL,                                  // end
+};
+
+#ifndef EMBEDDED_LIBRARY
+static scheduler_functions one_thread_per_connection_scheduler_functions=
+{
+  0,                                     // max_threads
+  NULL,                                  // init
+  init_new_connection_handler_thread,    // init_new_connection_thread
+  create_thread_to_handle_connection,    // add_connection
+  NULL,                                  // thd_wait_begin
+  NULL,                                  // thd_wait_end
+  NULL,                                  // post_kill_notification
+  one_thread_per_connection_end,         // end_thread
+  NULL,                                  // end
+};
+#endif  // EMBEDDED_LIBRARY
+
+
+scheduler_functions *thread_scheduler= NULL;
+
+/** @internal
+  Helper functions to allow mysys to call the thread scheduler when
+  waiting for locks.
 */
 
-scheduler_functions::scheduler_functions()
-  :init(init_dummy),
-   init_new_connection_thread(init_new_connection_handler_thread),
-   add_connection(0),                           // Must be defined
-   post_kill_notification(post_kill_dummy),
-   end_thread(end_thread_dummy), end(end_dummy)
-{}
+/**@{*/
+static void scheduler_wait_begin(void) {
+  MYSQL_CALLBACK(thread_scheduler,
+                 thd_wait_begin, (current_thd, THD_WAIT_ROW_TABLE_LOCK));
+}
+
+static void scheduler_wait_end(void) {
+  MYSQL_CALLBACK(thread_scheduler, thd_wait_end, (current_thd));
+}
+/**@}*/
 
+/**
+  Common scheduler init function.
+
+  The scheduler is either initialized by calling
+  one_thread_scheduler() or one_thread_per_connection_scheduler() in
+  mysqld.cc, so this init function will always be called.
+ */
+static void scheduler_init() {
+  thr_set_lock_wait_callback(scheduler_wait_begin, scheduler_wait_end);
+}
 
 /*
-  End connection, in case when we are using 'no-threads'
+  Initialize scheduler for --thread-handling=one-thread-per-connection
 */
 
-static bool no_threads_end(THD *thd, bool put_in_cache)
+#ifndef EMBEDDED_LIBRARY
+void one_thread_per_connection_scheduler()
 {
-  unlink_thd(thd);
-  mysql_mutex_unlock(&LOCK_thread_count);
-  return 1;                                     // Abort handle_one_connection
+  scheduler_init();
+  one_thread_per_connection_scheduler_functions.max_threads= max_connections;
+  thread_scheduler= &one_thread_per_connection_scheduler_functions;
 }
-
+#endif
 
 /*
   Initailize scheduler for --thread-handling=no-threads
 */
 
-void one_thread_scheduler(scheduler_functions* func)
+void one_thread_scheduler()
 {
-  func->max_threads= 1;
-#ifndef EMBEDDED_LIBRARY
-  func->add_connection= handle_connection_in_main_thread;
-#endif
-  func->init_new_connection_thread= init_dummy;
-  func->end_thread= no_threads_end;
+  scheduler_init();
+  thread_scheduler= &one_thread_scheduler_functions;
 }
 
 
@@ -81,11 +129,58 @@ void one_thread_scheduler(scheduler_func
   Initialize scheduler for --thread-handling=one-thread-per-connection
 */
 
-#ifndef EMBEDDED_LIBRARY
-void one_thread_per_connection_scheduler(scheduler_functions* func)
+/*
+  thd_scheduler keeps the link between THD and events.
+  It's embedded in the THD class.
+*/
+
+thd_scheduler::thd_scheduler()
+  : m_psi(NULL), data(NULL)
+{
+#ifndef DBUG_OFF
+  dbug_explain[0]= '\0';
+  set_explain= FALSE;
+#endif
+}
+
+
+thd_scheduler::~thd_scheduler()
+{
+}
+
+static scheduler_functions *saved_thread_scheduler;
+static uint saved_thread_handling;
+
+extern "C"
+int my_thread_scheduler_set(scheduler_functions *scheduler)
+{
+  DBUG_ASSERT(scheduler != 0);
+
+  if (scheduler == NULL)
+    return 1;
+
+  saved_thread_scheduler= thread_scheduler;
+  saved_thread_handling= thread_handling;
+  thread_scheduler= scheduler;
+  // Scheduler loaded dynamically
+  thread_handling= SCHEDULER_TYPES_COUNT;
+  return 0;
+}
+
+
+extern "C"
+int my_thread_scheduler_reset()
 {
-  func->max_threads= max_connections;
-  func->add_connection= create_thread_to_handle_connection;
-  func->end_thread= one_thread_per_connection_end;
+  DBUG_ASSERT(saved_thread_scheduler != NULL);
+
+  if (saved_thread_scheduler == NULL)
+    return 1;
+
+  thread_scheduler= saved_thread_scheduler;
+  thread_handling= saved_thread_handling;
+  saved_thread_scheduler= 0;
+  return 0;
 }
-#endif /* EMBEDDED_LIBRARY */
+
+
+

=== modified file 'sql/scheduler.h'
--- a/sql/scheduler.h	2010-07-02 18:15:21 +0000
+++ b/sql/scheduler.h	2010-09-01 13:05:01 +0000
@@ -28,38 +28,77 @@ class THD;
 
 /* Functions used when manipulating threads */
 
-class scheduler_functions
+struct scheduler_functions
 {
-public:
   uint max_threads;
   bool (*init)(void);
   bool (*init_new_connection_thread)(void);
   void (*add_connection)(THD *thd);
+  void (*thd_wait_begin)(THD *thd, int wait_type);
+  void (*thd_wait_end)(THD *thd);
   void (*post_kill_notification)(THD *thd);
   bool (*end_thread)(THD *thd, bool cache_thread);
   void (*end)(void);
-  scheduler_functions();
 };
 
+
+/**
+  Scheduler types enumeration.
+
+  The default of --thread-handling is the first one in the
+  thread_handling_names array, this array has to be consistent with
+  the order in this array, so to change default one has to change the
+  first entry in this enum and the first entry in the
+  thread_handling_names array.
+
+  @note The last entry of the enumeration is also used to mark the
+  thread handling as dynamic. In this case the name of the thread
+  handling is fetched from the name of the plugin that implements it.
+*/
 enum scheduler_types
 {
   SCHEDULER_ONE_THREAD_PER_CONNECTION=0,
   SCHEDULER_NO_THREADS,
-  SCHEDULER_POOL_OF_THREADS
+  SCHEDULER_TYPES_COUNT
 };
 
-void one_thread_per_connection_scheduler(scheduler_functions* func);
-void one_thread_scheduler(scheduler_functions* func);
+void one_thread_per_connection_scheduler();
+void one_thread_scheduler();
 
 enum pool_command_op
 {
   NOT_IN_USE_OP= 0, NORMAL_OP= 1, CONNECT_OP, KILL_OP, DIE_OP
 };
 
-#define HAVE_POOL_OF_THREADS 0                  /* For easyer tests */
-#define pool_of_threads_scheduler(A) one_thread_per_connection_scheduler(A)
-
+/*
+ To be used for pool-of-threads (implemeneted differently on various OSs)
+*/
 class thd_scheduler
-{};
+{
+public:
+  /*
+    Thread instrumentation for the user job.
+    This member holds the instrumentation while the user job is not run
+    by a thread.
+
+    Note that this member is not conditionally declared
+    (ifdef HAVE_PSI_INTERFACE), because doing so will change the binary
+    layout of THD, which is exposed to plugin code that may be compiled
+    differently.
+  */
+  PSI_thread *m_psi;
+
+  void *data;                  /* scheduler-specific data structure */
+
+#  ifndef DBUG_OFF
+  char dbug_explain[512];
+  bool set_explain;
+#  endif
+
+  thd_scheduler();
+  ~thd_scheduler();
+};
+
+extern scheduler_functions *thread_scheduler;
 
-#endif /* SCHEDULER_INCLUDED */
+#endif

=== modified file 'sql/sql_admin.cc'
--- a/sql/sql_admin.cc	2010-08-24 10:52:32 +0000
+++ b/sql/sql_admin.cc	2010-08-30 06:38:09 +0000
@@ -591,8 +591,14 @@ send_result_message:
     case HA_ADMIN_NOT_BASE_TABLE:
       {
         char buf[MYSQL_ERRMSG_SIZE];
+
+        String tbl_name;
+        tbl_name.append(String(db,system_charset_info));
+        tbl_name.append('.');
+        tbl_name.append(String(table_name,system_charset_info));
+
         size_t length= my_snprintf(buf, sizeof(buf),
-                                 ER(ER_BAD_TABLE_ERROR), table_name);
+                                   ER(ER_BAD_TABLE_ERROR), tbl_name.c_ptr());
         protocol->store(STRING_WITH_LEN("note"), system_charset_info);
         protocol->store(buf, length, system_charset_info);
       }

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2010-08-20 09:15:16 +0000
+++ b/sql/sql_base.cc	2010-08-30 06:38:09 +0000
@@ -8167,7 +8167,17 @@ insert_fields(THD *thd, Name_resolution_
   if (!table_name)
     my_message(ER_NO_TABLES_USED, ER(ER_NO_TABLES_USED), MYF(0));
   else
-    my_error(ER_BAD_TABLE_ERROR, MYF(0), table_name);
+  {
+    String tbl_name;
+    if (db_name)
+    {
+      tbl_name.append(String(db_name,system_charset_info));
+      tbl_name.append('.');
+    }
+    tbl_name.append(String(table_name,system_charset_info));
+
+    my_error(ER_BAD_TABLE_ERROR, MYF(0), tbl_name.c_ptr());
+  }
 
   DBUG_RETURN(TRUE);
 }

=== modified file 'sql/sql_binlog.cc'
--- a/sql/sql_binlog.cc	2010-08-06 08:54:01 +0000
+++ b/sql/sql_binlog.cc	2010-09-01 02:51:08 +0000
@@ -73,7 +73,8 @@ static int check_event_type(int type, Re
 
     /* It is always allowed to execute FD events. */
     return 0;
-    
+
+  case ROWS_QUERY_LOG_EVENT:
   case TABLE_MAP_EVENT:
   case WRITE_ROWS_EVENT:
   case UPDATE_ROWS_EVENT:
@@ -273,8 +274,15 @@ void mysql_client_binlog_statement(THD* 
         i.e. when this thread terminates.
       */
       if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT)
-        delete ev; 
-      ev= 0;
+      {
+        if (thd->variables.binlog_rows_query_log_events)
+          handle_rows_query_log_event(ev, rli);
+        if (ev->get_type_code() != ROWS_QUERY_LOG_EVENT)
+        {
+          delete ev;
+          ev= NULL;
+        }
+      }
       if (err)
       {
         /*
@@ -292,6 +300,11 @@ void mysql_client_binlog_statement(THD* 
   my_ok(thd);
 
 end:
+  if ((error || err) && rli->rows_query_ev)
+  {
+    delete rli->rows_query_ev;
+    rli->rows_query_ev= NULL;
+  }
   rli->slave_close_thread_tables(thd);
   my_free(buf);
   DBUG_VOID_RETURN;

=== added file 'sql/sql_callback.h'
--- a/sql/sql_callback.h	1970-01-01 00:00:00 +0000
+++ b/sql/sql_callback.h	2010-06-07 14:01:39 +0000
@@ -0,0 +1,43 @@
+/*
+  Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#ifndef SQL_CALLBACK_INCLUDED
+#define SQL_CALLBACK_INCLUDED
+
+/**
+   Macro used for an internal callback.
+
+   The macro will check that the object exists and that the function
+   is defined. If that is the case, it will call the function with the
+   given parameters.
+
+   If the object or the function is not defined, the callback will be
+   considered successful (nothing needed to be done) and will
+   therefore return no error.
+ */
+
+#define MYSQL_CALLBACK(OBJ, FUNC, PARAMS)         \
+  do {                                            \
+    if ((OBJ) && ((OBJ)->FUNC))                   \
+      (OBJ)->FUNC PARAMS;                         \
+  } while (0)
+
+#define MYSQL_CALLBACK_ELSE(OBJ, FUNC, PARAMS, ELSE)    \
+  (((OBJ) && ((OBJ)->FUNC)) ? (OBJ)->FUNC PARAMS : (ELSE))
+
+
+#endif /* SQL_CALLBACK_INCLUDED */

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-08-20 03:51:38 +0000
+++ b/sql/sql_class.cc	2010-09-01 13:06:14 +0000
@@ -57,6 +57,7 @@
 #include "transaction.h"
 #include "debug_sync.h"
 #include "sql_parse.h"                          // is_update_query
+#include "sql_callback.h"
 
 /*
   The following is used to initialise Table_ident with a internal
@@ -1075,6 +1076,7 @@ THD::~THD()
   DBUG_ENTER("~THD()");
   /* Ensure that no one is using THD */
   mysql_mutex_lock(&LOCK_thd_data);
+  mysys_var=0;					// Safety (shouldn't be needed)
   mysql_mutex_unlock(&LOCK_thd_data);
   add_to_status(&global_status_var, &status_var);
 
@@ -1100,7 +1102,6 @@ THD::~THD()
   my_free(db);
   db= NULL;
   free_root(&transaction.mem_root,MYF(0));
-  mysys_var=0;					// Safety (shouldn't be needed)
   mysql_mutex_destroy(&LOCK_thd_data);
 #ifndef DBUG_OFF
   dbug_sentry= THD_SENTRY_GONE;
@@ -1189,7 +1190,7 @@ void THD::awake(THD::killed_state state_
   {
     thr_alarm_kill(thread_id);
     if (!slave_thread)
-      thread_scheduler.post_kill_notification(this);
+      MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (this));
 #ifdef SIGNAL_WITH_VIO_CLOSE
     if (this != current_thd)
     {
@@ -1258,6 +1259,15 @@ bool THD::store_globals()
   if (my_pthread_setspecific_ptr(THR_THD,  this) ||
       my_pthread_setspecific_ptr(THR_MALLOC, &mem_root))
     return 1;
+  /*
+    mysys_var is concurrently readable by a killer thread.
+    It is protected by LOCK_thd_data, it is not needed to lock while the
+    pointer is changing from NULL not non-NULL. If the kill thread reads
+    NULL it doesn't refer to anything, but if it is non-NULL we need to
+    ensure that the thread doesn't proceed to assign another thread to
+    have the mysys_var reference (which in fact refers to the worker
+    threads local storage with key THR_KEY_mysys. 
+  */
   mysys_var=my_thread_var;
   /*
     Let mysqld define the thread id (not mysys)
@@ -3188,6 +3198,60 @@ extern "C" bool thd_sqlcom_can_generate_
 {
   return sqlcom_can_generate_row_events(thd);
 }
+
+#ifndef EMBEDDED_LIBRARY
+extern "C" void thd_pool_wait_begin(MYSQL_THD thd, int wait_type);
+extern "C" void thd_pool_wait_end(MYSQL_THD thd);
+
+/*
+  Interface for MySQL Server, plugins and storage engines to report
+  when they are going to sleep/stall.
+  
+  SYNOPSIS
+  thd_wait_begin()
+  thd                     Thread object
+  wait_type               Type of wait
+                          1 -- short wait (e.g. for mutex)
+                          2 -- medium wait (e.g. for disk io)
+                          3 -- large wait (e.g. for locked row/table)
+  NOTES
+    This is used by the threadpool to have better knowledge of which
+    threads that currently are actively running on CPUs. When a thread
+    reports that it's going to sleep/stall, the threadpool scheduler is
+    free to start another thread in the pool most likely. The expected wait
+    time is simply an indication of how long the wait is expected to
+    become, the real wait time could be very different.
+
+  thd_wait_end MUST be called immediately after waking up again.
+*/
+extern "C" void thd_wait_begin(MYSQL_THD thd, thd_wait_type wait_type)
+{
+  MYSQL_CALLBACK(thread_scheduler, thd_wait_begin, (thd, wait_type));
+}
+
+/**
+  Interface for MySQL Server, plugins and storage engines to report
+  when they waking up from a sleep/stall.
+
+  @param  thd   Thread handle
+*/
+extern "C" void thd_wait_end(MYSQL_THD thd)
+{
+  MYSQL_CALLBACK(thread_scheduler, thd_wait_end, (thd));
+}
+#else
+extern "C" void thd_wait_begin(MYSQL_THD thd, thd_wait_type wait_type)
+{
+  /* do NOTHING for the embedded library */
+  return;
+}
+
+extern "C" void thd_wait_end(MYSQL_THD thd)
+{
+  /* do NOTHING for the embedded library */
+  return;
+}
+#endif
 #endif // INNODB_COMPATIBILITY_HOOKS */
 
 /****************************************************************************
@@ -3371,6 +3435,13 @@ void THD::set_query_id(query_id_t new_qu
   mysql_mutex_unlock(&LOCK_thd_data);
 }
 
+/** Assign a new value to thd->mysys_var.  */
+void THD::set_mysys_var(struct st_my_thread_var *new_mysys_var)
+{
+  mysql_mutex_lock(&LOCK_thd_data);
+  mysys_var= new_mysys_var;
+  mysql_mutex_unlock(&LOCK_thd_data);
+}
 
 /**
   Leave explicit LOCK TABLES or prelocked mode and restore value of

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-08-23 12:05:47 +0000
+++ b/sql/sql_class.h	2010-09-06 10:54:47 +0000

@@ -475,6 +475,7 @@ typedef struct system_variables
   Time_zone *time_zone;
 
   my_bool sysdate_is_now;
+  my_bool binlog_rows_query_log_events;
 
   double long_query_time_double;
 
@@ -1539,7 +1540,8 @@ public:
   */
   void binlog_start_trans_and_stmt();
   void binlog_set_stmt_begin();
-  int binlog_write_table_map(TABLE *table, bool is_transactional);
+  int binlog_write_table_map(TABLE *table, bool is_transactional,
+                             bool binlog_rows_query);
   int binlog_write_row(TABLE* table, bool is_transactional,
                        MY_BITMAP const* cols, size_t colcnt,
                        const uchar *buf);
@@ -1659,6 +1661,10 @@ public:
         xid_state.xid.null();
       free_root(&mem_root,MYF(MY_KEEP_PREALLOC));
     }
+    my_bool is_active()
+    {
+      return (all.ha_list != NULL);
+    }
     st_transactions()
     {
       bzero((char*)this, sizeof(*this));
@@ -2689,7 +2695,7 @@ public:
   virtual void set_statement(Statement *stmt);
 
   /**
-    Assign a new value to thd->query and thd->query_id.
+    Assign a new value to thd->query and thd->query_id and mysys_var.
     Protected with LOCK_thd_data mutex.
   */
   void set_query(char *query_arg, uint32 query_length_arg);
@@ -2702,6 +2708,7 @@ public:
     open_tables= open_tables_arg;
     mysql_mutex_unlock(&LOCK_thd_data);
   }
+  void set_mysys_var(struct st_my_thread_var *new_mysys_var);
   void enter_locked_tables_mode(enum_locked_tables_mode mode_arg)
   {
     DBUG_ASSERT(locked_tables_mode == LTM_NONE);

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2010-08-05 13:10:22 +0000
+++ b/sql/sql_connect.cc	2010-09-01 13:05:01 +0000
@@ -35,6 +35,7 @@
 #include "hostname.h" // inc_host_errors, ip_to_hostname,
                       // reset_host_errors
 #include "sql_acl.h"  // acl_getroot, NO_ACCESS, SUPER_ACL
+#include "sql_callback.h"
 
 #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
 /*
@@ -966,7 +967,7 @@ bool setup_connection_thread_globals(THD
   {
     close_connection(thd, ER_OUT_OF_RESOURCES, 1);
     statistic_increment(aborted_connects,&LOCK_status);
-    thread_scheduler.end_thread(thd, 0);
+    MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
     return 1;                                   // Error
   }
   return 0;
@@ -989,7 +990,7 @@ bool setup_connection_thread_globals(THD
 */
 
 
-static bool login_connection(THD *thd)
+bool login_connection(THD *thd)
 {
   NET *net= &thd->net;
   int error;
@@ -1027,7 +1028,7 @@ static bool login_connection(THD *thd)
     This mainly updates status variables
 */
 
-static void end_connection(THD *thd)
+void end_connection(THD *thd)
 {
   NET *net= &thd->net;
   plugin_thdvar_cleanup(thd);
@@ -1068,7 +1069,7 @@ static void end_connection(THD *thd)
   Initialize THD to handle queries
 */
 
-static void prepare_new_connection_state(THD* thd)
+void prepare_new_connection_state(THD* thd)
 {
   Security_context *sctx= thd->security_ctx;
 
@@ -1137,11 +1138,11 @@ void do_handle_one_connection(THD *thd_a
 
   thd->thr_create_utime= my_micro_time();
 
-  if (thread_scheduler.init_new_connection_thread())
+  if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0))
   {
     close_connection(thd, ER_OUT_OF_RESOURCES, 1);
     statistic_increment(aborted_connects,&LOCK_status);
-    thread_scheduler.end_thread(thd,0);
+    MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
     return;
   }
 
@@ -1195,7 +1196,7 @@ void do_handle_one_connection(THD *thd_a
    
 end_thread:
     close_connection(thd, 0, 1);
-    if (thread_scheduler.end_thread(thd,1))
+    if (MYSQL_CALLBACK_ELSE(thread_scheduler, end_thread, (thd, 1), 0))
       return;                                 // Probably no-threads
 
     /*

=== modified file 'sql/sql_connect.h'
--- a/sql/sql_connect.h	2010-07-02 02:58:51 +0000
+++ b/sql/sql_connect.h	2010-09-01 13:05:01 +0000
@@ -40,4 +40,8 @@ int check_user(THD *thd, enum enum_serve
 	       const char *passwd, uint passwd_len, const char *db,
 	       bool check_count);
 
+bool login_connection(THD *thd);
+void prepare_new_connection_state(THD* thd);
+void end_connection(THD *thd);
+
 #endif /* SQL_CONNECT_INCLUDED */

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2010-08-24 14:23:04 +0000
+++ b/sql/sql_insert.cc	2010-09-01 13:16:07 +0000
@@ -621,6 +621,32 @@ bool open_and_lock_for_insert_delayed(TH
 
 
 /**
+  Create a new query string for removing DELAYED keyword for
+  multi INSERT DEALAYED statement.
+
+  @param[in] thd                 Thread handler
+  @param[in] buf                 Query string
+
+  @return
+             0           ok
+             1           error
+*/
+static int
+create_insert_stmt_from_insert_delayed(THD *thd, String *buf)
+{
+  /* Append the part of thd->query before "DELAYED" keyword */
+  if (buf->append(thd->query(),
+                  thd->lex->keyword_delayed_begin - thd->query()))
+    return 1;
+  /* Append the part of thd->query after "DELAYED" keyword */
+  if (buf->append(thd->lex->keyword_delayed_begin + 7))
+    return 1;
+
+  return 0;
+}
+
+
+/**
   INSERT statement implementation
 
   @note Like implementations of other DDL/DML in MySQL, this function
@@ -999,13 +1025,28 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
 	such case the flag is ignored for constructing binlog event.
 	*/
 	DBUG_ASSERT(thd->killed != THD::KILL_BAD_DATA || error > 0);
-	if (thd->binlog_query(THD::ROW_QUERY_TYPE,
-			      thd->query(), thd->query_length(),
-			      transactional_table, FALSE, FALSE,
-                              errcode))
+        if (was_insert_delayed && table_list->lock_type ==  TL_WRITE)
         {
+          /* Binlog multi INSERT DELAYED as INSERT without DELAYED. */
+          String log_query;
+          if (create_insert_stmt_from_insert_delayed(thd, &log_query))
+          {
+            sql_print_error("Event Error: An error occurred while creating query string"
+                            "for INSERT DELAYED stmt, before writing it into binary log.");
+
+            error= 1;
+          }
+          else if (thd->binlog_query(THD::ROW_QUERY_TYPE,
+                                     log_query.c_ptr(), log_query.length(),
+                                     transactional_table, FALSE, FALSE,
+                                     errcode))
+            error= 1;
+        }
+        else if (thd->binlog_query(THD::ROW_QUERY_TYPE,
+			           thd->query(), thd->query_length(),
+			           transactional_table, FALSE, FALSE,
+                                   errcode))
 	  error= 1;
-	}
       }
     }
     DBUG_ASSERT(transactional_table || !changed || 
@@ -1797,7 +1838,7 @@ public:
   time_t start_time;
   ulong sql_mode;
   bool auto_increment_field_not_null;
-  bool query_start_used, ignore, log_query;
+  bool query_start_used, ignore, log_query, binlog_rows_query_log_events;
   bool stmt_depends_on_first_successful_insert_id_in_prev_stmt;
   ulonglong first_successful_insert_id_in_prev_stmt;
   ulonglong forced_insert_id;
@@ -1810,7 +1851,8 @@ public:
   delayed_row(LEX_STRING const query_arg, enum_duplicates dup_arg,
               bool ignore_arg, bool log_query_arg)
     : record(0), dup(dup_arg), ignore(ignore_arg), log_query(log_query_arg),
-      forced_insert_id(0), query(query_arg), time_zone(0)
+      forced_insert_id(0), query(query_arg), time_zone(0),
+      binlog_rows_query_log_events(FALSE)
     {}
   ~delayed_row()
   {
@@ -2374,6 +2416,7 @@ int write_delayed(THD *thd, TABLE *table
   row->auto_increment_offset=    thd->variables.auto_increment_offset;
   row->sql_mode=                 thd->variables.sql_mode;
   row->auto_increment_field_not_null= table->auto_increment_field_not_null;
+  row->binlog_rows_query_log_events= thd->variables.binlog_rows_query_log_events;
 
   /* Copy the next forced auto increment value, if any. */
   if ((forced_auto_inc= thd->auto_inc_intervals_forced.get_next()))
@@ -2813,6 +2856,16 @@ bool Delayed_insert::handle_inserts(void
                            (ulong) row->query.length));
     if (log_query)
     {
+      if (thd.is_current_stmt_binlog_format_row())
+      {
+        /* Flush rows of previous statement*/
+        if (thd.binlog_flush_pending_rows_event(TRUE, FALSE))
+          goto err;
+        /* Set query for Rows_query_log event in RBR*/
+        thd.set_query(row->query.str, row->query.length);
+        thd.variables.binlog_rows_query_log_events= row->binlog_rows_query_log_events;
+      }
+
       /*
         This is the first value of an INSERT statement.
         It is the right place to clear a forced insert_id.
@@ -2880,7 +2933,8 @@ bool Delayed_insert::handle_inserts(void
       table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
     }
 
-    if (log_query && mysql_bin_log.is_open())
+    if (log_query && mysql_bin_log.is_open() &&
+        !thd.is_current_stmt_binlog_format_row())
     {
       bool backup_time_zone_used = thd.time_zone_used;
       Time_zone *backup_time_zone = thd.variables.time_zone;
@@ -2895,16 +2949,12 @@ bool Delayed_insert::handle_inserts(void
       int errcode= 0;
       if (thd.killed == THD::NOT_KILLED)
         errcode= query_error_code(&thd, TRUE);
-      
+
       /*
-        If the query has several rows to insert, only the first row will come
-        here. In row-based binlogging, this means that the first row will be
-        written to binlog as one Table_map event and one Rows event (due to an
-        event flush done in binlog_query()), then all other rows of this query
-        will be binlogged together as one single Table_map event and one
-        single Rows event.
+        In SBR, only the query which has one single value
+        will be binlogged here.
       */
-      if (thd.binlog_query(THD::ROW_QUERY_TYPE,
+      if (thd.binlog_query(THD::STMT_QUERY_TYPE,
                            row->query.str, row->query.length,
                            FALSE, FALSE, FALSE, errcode))
         goto err;
@@ -2925,6 +2975,8 @@ bool Delayed_insert::handle_inserts(void
     */
     table->auto_increment_field_not_null= FALSE;
 
+    if (log_query && thd.is_current_stmt_binlog_format_row())
+      thd.set_query(NULL, 0);
     delete row;
     /*
       Let READ clients do something once in a while

=== modified file 'sql/sql_join_cache.cc'
--- a/sql/sql_join_cache.cc	2010-07-23 17:51:11 +0000
+++ b/sql/sql_join_cache.cc	2010-09-02 07:34:10 +0000
@@ -612,7 +612,12 @@ int JOIN_CACHE_BKA::init()
       copy_end= cache->field_descr+cache->fields;
       for (copy= cache->field_descr+cache->flag_fields; copy < copy_end; copy++)
       {
-        if (copy->field->table == tab->table &&
+        /*
+          (1) - when we store rowids for DuplicateWeedout, they have
+                copy->field==NULL
+        */
+        if (copy->field &&  // (1)
+            copy->field->table == tab->table &&
             bitmap_is_set(key_read_set, copy->field->field_index))
         {
           *copy_ptr++= copy; 

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

=== modified file 'sql/sql_plugin_services.h'
--- a/sql/sql_plugin_services.h	2010-07-02 02:58:51 +0000
+++ b/sql/sql_plugin_services.h	2010-09-01 13:05:01 +0000
@@ -36,9 +36,23 @@ static struct thd_alloc_service_st thd_a
   thd_make_lex_string
 };
 
+static struct thd_wait_service_st thd_wait_handler= {
+  thd_wait_begin,
+  thd_wait_end
+};
+
+static struct my_thread_scheduler_service my_thread_scheduler_handler= {
+  my_thread_scheduler_set,
+  my_thread_scheduler_reset,
+};
+
+
 static struct st_service_ref list_of_services[]=
 {
   { "my_snprintf_service", VERSION_my_snprintf, &my_snprintf_handler },
-  { "thd_alloc_service",   VERSION_thd_alloc,   &thd_alloc_handler }
+  { "thd_alloc_service",   VERSION_thd_alloc,   &thd_alloc_handler },
+  { "thd_wait_service",    VERSION_thd_wait,    &thd_wait_handler },
+  { "my_thread_scheduler_service",
+    VERSION_my_thread_scheduler, &my_thread_scheduler_handler },
 };
 

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-09-01 14:00:12 +0000
+++ b/sql/sql_select.cc	2010-09-06 17:56:05 +0000
@@ -1236,6 +1236,39 @@ static bool sj_table_is_included(JOIN *j
   return TRUE;
 }
 
+/**
+   Check if the optimizer might choose to use join buffering for this
+   join. If that is the case, and if duplicate weedout semijoin
+   strategy is used, the duplicate generating range must be extended
+   to the first non-const table. 
+
+   This function is called from setup_semijoin_dups_elimination()
+   before the final decision is made on whether or not buffering is
+   used. It is therefore only a rough test that covers all cases where
+   join buffering might be used, but potentially also some cases where
+   join buffering will not be used.
+
+   @param join_cache_level     The join cache level
+   @param sj_tab               Table that might be joined by BNL/BKA
+
+   @return                     
+      true if join buffering might be used, false otherwise
+
+ */
+bool might_do_join_buffering(uint join_cache_level, 
+                             const JOIN_TAB *sj_tab) 
+{
+  /* 
+     (1) sj_tab is not a const table
+  */
+  return (sj_tab-sj_tab->join->join_tab != sj_tab->join->const_tables && // (1)
+          sj_tab->use_quick != QS_DYNAMIC_RANGE && 
+          ((join_cache_level != 0 && sj_tab->type == JT_ALL) ||
+           (join_cache_level > 4 && 
+            (sj_tab->type == JT_REF || 
+             sj_tab->type == JT_EQ_REF || 
+             sj_tab->type == JT_CONST))));
+}
 
 /**
   Setup the strategies to eliminate semi-join duplicates.
@@ -1243,8 +1276,8 @@ static bool sj_table_is_included(JOIN *j
   @param join           Join to process
   @param options        Join options (needed to see if join buffering will be 
                         used or not)
-  @param no_jbuf_after  Another bit of information re where join buffering will
-                        be used.
+  @param no_jbuf_after  Do not use join buffering after the table with this 
+                        number
 
   @retval FALSE  OK 
   @retval TRUE   Out of memory error
@@ -1368,32 +1401,32 @@ static bool sj_table_is_included(JOIN *j
 int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
                                     uint no_jbuf_after)
 {
-  uint i;
+  uint tableno;
   THD *thd= join->thd;
   DBUG_ENTER("setup_semijoin_dups_elimination");
 
-  for (i= join->const_tables ; i < join->tables; )
+  for (tableno= join->const_tables ; tableno < join->tables; )
   {
-    JOIN_TAB *tab=join->join_tab + i;
-    POSITION *pos= join->best_positions + i;
+    JOIN_TAB *tab=join->join_tab + tableno;
+    POSITION *pos= join->best_positions + tableno;
     uint keylen, keyno;
     if (pos->sj_strategy == SJ_OPT_NONE)
     {
-      i++;  // nothing to do
+      tableno++;  // nothing to do
       continue;
     }
-    JOIN_TAB *tab_end= tab + pos->n_sj_tables - 1;
+    JOIN_TAB *last_sj_tab= tab + pos->n_sj_tables - 1;
     switch (pos->sj_strategy) {
       case SJ_OPT_MATERIALIZE_LOOKUP:
       case SJ_OPT_MATERIALIZE_SCAN:
         /* Do nothing */
-        i+= pos->n_sj_tables;
+        tableno+= pos->n_sj_tables;
         break;
       case SJ_OPT_LOOSE_SCAN:
       {
         DBUG_ASSERT(tab->emb_sj_nest != NULL); // First table must be inner
         /* We jump from the last table to the first one */
-        tab->loosescan_match_tab= tab_end;
+        tab->loosescan_match_tab= last_sj_tab;
 
         /* For LooseScan, duplicate elimination is based on rows being sorted 
            on key. We need to make sure that range select keep the sorted index
@@ -1415,22 +1448,100 @@ int setup_semijoin_dups_elimination(JOIN
 
         tab->loosescan_key_len= keylen;
         if (pos->n_sj_tables > 1) 
-          tab_end->do_firstmatch= tab;
-        i+= pos->n_sj_tables;
+          last_sj_tab->do_firstmatch= tab;
+        tableno+= pos->n_sj_tables;
         break;
       }
       case SJ_OPT_DUPS_WEEDOUT:
       {
         DBUG_ASSERT(tab->emb_sj_nest != NULL); // First table must be inner
         /*
-          Check for join buffering. If there is one, move the first table
-          forwards, but do not destroy other duplicate elimination methods.
+          Consider a semijoin of one outer and one inner table, both
+          with two rows. The inner table is assumed to be confluent
+          (See sj_opt_materialize_lookup)
+
+          If normal nested loop execution is used, we do not need to
+          include semi-join outer table rowids in the duplicate
+          weedout temp table since NL guarantees that outer table rows
+          are encountered only consecutively and because all rows in
+          the temp table are deleted for every new outer table
+          combination (example is with a confluent inner table):
+
+            ot1.row1|it1.row1 
+                 '-> temp table's have_confluent_row == FALSE 
+                   |-> output ot1.row1
+                   '-> set have_confluent_row= TRUE
+            ot1.row1|it1.row2
+                 |-> temp table's have_confluent_row == TRUE
+                 | '-> do not output ot1.row1
+                 '-> no more join matches - set have_confluent_row= FALSE
+            ot1.row2|it1.row1 
+                 '-> temp table's have_confluent_row == FALSE 
+                   |-> output ot1.row2
+                   '-> set have_confluent_row= TRUE
+              ...                 
+
+          Note: not having outer table rowids in the temp table and
+          then emptying the temp table when a new outer table row
+          combinition is encountered is an optimization. Including
+          outer table rowids in the temp table is not harmful but
+          wastes memory.
+
+          Now consider the join buffering algorithms (BNL/BKA). These
+          algorithms join each inner row with outer rows in "reverse"
+          order compared to NL. Effectively, this means that outer
+          table rows may be encountered multiple times in a
+          non-consecutive manner:
+
+            NL:                 BNL/BKA:
+            ot1.row1|it1.row1   ot1.row1|it1.row1
+            ot1.row1|it1.row2   ot1.row2|it1.row1
+            ot1.row2|it1.row1   ot1.row1|it1.row2
+            ot1.row2|it1.row2   ot1.row2|it1.row2
+
+          It is clear from the above that there is no place we can
+          empty the temp table like we do in NL to avoid storing outer
+          table rowids. 
+
+          Below we check if join buffering might be used. If so, set
+          first_table to the first non-constant table so that outer
+          table rowids are included in the temp table. Do not destroy
+          other duplicate elimination methods. 
         */
-        uint first_table= i;
-        for (uint j= i; j < i + pos->n_sj_tables; j++)
+        uint first_table= tableno;
+        uint join_cache_level= join->thd->variables.optimizer_join_cache_level;
+        for (uint sj_tableno= tableno; 
+             sj_tableno < tableno + pos->n_sj_tables; 
+             sj_tableno++)
         {
-          if (join->best_positions[j].use_join_buffer && j <= no_jbuf_after)
+          /*
+            The final decision on whether or not join buffering will
+            be used is taken in check_join_cache_usage(), which is
+            called from make_join_readinfo()'s main loop.
+            check_join_cache_usage() needs to know if duplicate
+            weedout is used, so moving
+            setup_semijoin_dups_elimination() from before the main
+            loop to after it is not possible. I.e.,
+            join->best_positions[sj_tableno].use_join_buffer is not
+            trustworthy at this point.
+          */
+          /**
+            @todo: merge make_join_readinfo() and
+            setup_semijoin_dups_elimination() loops and change the
+            following 'if' to
+
+            "if (join->best_positions[sj_tableno].use_join_buffer && 
+                 sj_tableno <= no_jbuf_after)".
+
+            For now, use a rough criteria:
+          */
+
+          if (sj_tableno <= no_jbuf_after &&
+              might_do_join_buffering(join_cache_level, 
+                                      join->join_tab + sj_tableno))
+
           {
+            /* Join buffering will probably be used */
             first_table= join->const_tables;
             break;
           }
@@ -1445,21 +1556,23 @@ int setup_semijoin_dups_elimination(JOIN
            - tables that need their rowids to be put into temptable
            - the last outer table
         */
-        for (JOIN_TAB *j=join->join_tab + first_table; j <= tab_end; j++)
+        for (JOIN_TAB *tab_in_range= join->join_tab + first_table; 
+             tab_in_range <= last_sj_tab; 
+             tab_in_range++)
         {
-          if (sj_table_is_included(join, j))
+          if (sj_table_is_included(join, tab_in_range))
           {
-            last_tab->join_tab= j;
+            last_tab->join_tab= tab_in_range;
             last_tab->rowid_offset= jt_rowid_offset;
-            jt_rowid_offset += j->table->file->ref_length;
-            if (j->table->maybe_null)
+            jt_rowid_offset += tab_in_range->table->file->ref_length;
+            if (tab_in_range->table->maybe_null)
             {
               last_tab->null_byte= jt_null_bits / 8;
               last_tab->null_bit= jt_null_bits++;
             }
             last_tab++;
-            j->table->prepare_for_position();
-            j->keep_current_rowid= TRUE;
+            tab_in_range->table->prepare_for_position();
+            tab_in_range->keep_current_rowid= TRUE;
           }
         }
 
@@ -1497,24 +1610,26 @@ int setup_semijoin_dups_elimination(JOIN
           sjtbl->have_confluent_row= FALSE;
         }
         join->join_tab[first_table].flush_weedout_table= sjtbl;
-        tab_end->check_weed_out_table= sjtbl;
+        last_sj_tab->check_weed_out_table= sjtbl;
 
-        i+= pos->n_sj_tables;
+        tableno+= pos->n_sj_tables;
         break;
       }
       case SJ_OPT_FIRST_MATCH:
       {
         JOIN_TAB *jump_to= tab - 1;
         DBUG_ASSERT(tab->emb_sj_nest != NULL); // First table must be inner
-        for (JOIN_TAB *j= tab; j <= tab_end; j++)
+        for (JOIN_TAB *tab_in_range= tab; 
+             tab_in_range <= last_sj_tab; 
+             tab_in_range++)
         {
-          if (!j->emb_sj_nest)
+          if (!tab_in_range->emb_sj_nest)
           {
             /*
               Let last non-correlated table be jump target for
               subsequent inner tables.
             */
-            jump_to= j;
+            jump_to= tab_in_range;
           }
           else
           {
@@ -1522,11 +1637,11 @@ int setup_semijoin_dups_elimination(JOIN
               Assign jump target for last table in a consecutive range of 
               inner tables.
             */
-            if (j == tab_end || !(j+1)->emb_sj_nest)
-              j->do_firstmatch= jump_to;
+            if (tab_in_range == last_sj_tab || !(tab_in_range+1)->emb_sj_nest)
+              tab_in_range->do_firstmatch= jump_to;
           }
         }
-        i+= pos->n_sj_tables;
+        tableno+= pos->n_sj_tables;
         break;
       }
     }
@@ -1537,11 +1652,13 @@ int setup_semijoin_dups_elimination(JOIN
     JOIN_TAB *last_sj_inner=
       (pos->sj_strategy == SJ_OPT_DUPS_WEEDOUT) ?
       /* Range may end with non-inner table so cannot set last_sj_inner_tab */
-      NULL : tab_end;
-    for (JOIN_TAB *j= tab; j <= tab_end; j++)
+      NULL : last_sj_tab;
+    for (JOIN_TAB *tab_in_range= tab; 
+         tab_in_range <= last_sj_tab; 
+         tab_in_range++)
     {
-      j->first_sj_inner_tab= tab;
-      j->last_sj_inner_tab=  last_sj_inner;
+      tab_in_range->first_sj_inner_tab= tab;
+      tab_in_range->last_sj_inner_tab=  last_sj_inner;
     }
   }
   DBUG_RETURN(FALSE);
@@ -8047,6 +8164,10 @@ void calc_used_field_length(THD *thd, JO
 			     (join_tab->table->s->reclength- rec_length));
     rec_length+=(uint) max(4,blob_length);
   }
+  /**
+    @todo why don't we count the rowids that we might need to store
+    when using DuplicateElimination?
+  */
   join_tab->used_fields=fields;
   join_tab->used_fieldlength=rec_length;
   join_tab->used_blobs=blobs;
@@ -9247,7 +9368,7 @@ static bool make_join_select(JOIN *join,
 	/* Range uses longer key;  Use this instead of ref on key */
 	tab->type=JT_ALL;
 	use_quick_range=1;
-	tab->use_quick=1;
+	tab->use_quick=QS_RANGE;
         tab->ref.key= -1;
 	tab->ref.key_parts=0;		// Don't use ref key.
 	join->best_positions[i].records_read= rows2double(tab->quick->records);
@@ -9440,10 +9561,10 @@ static bool make_join_select(JOIN *join,
 			     (sel->quick_keys.is_clear_all() ||
 			      (sel->quick &&
 			       (sel->quick->records >= 100L)))) ?
-	      2 : 1;
+	      QS_DYNAMIC_RANGE : QS_RANGE;
 	    sel->read_tables= used_tables & ~current_map;
 	  }
-	  if (i != join->const_tables && tab->use_quick != 2 &&
+	  if (i != join->const_tables && tab->use_quick != QS_DYNAMIC_RANGE &&
               !tab->first_inner)
 	  {					/* Read with cache */
 	    if (cond &&
@@ -10165,7 +10286,7 @@ uint check_join_cache_usage(JOIN_TAB *ta
     psergey-todo: why the below when execution code seems to handle the
     "range checked for each record" case?
   */
-  if (tab->use_quick == 2)
+  if (tab->use_quick == QS_DYNAMIC_RANGE)
     goto no_join_cache;
   
   /*
@@ -10235,6 +10356,7 @@ uint check_join_cache_usage(JOIN_TAB *ta
          !tab->cache->init()))
     {
       *icp_other_tables_ok= FALSE;
+      DBUG_ASSERT(might_do_join_buffering(cache_level, tab));
       return JOIN_CACHE::ALG_BNL | force_unlinked_cache;
     }
     goto no_join_cache;
@@ -10258,6 +10380,7 @@ uint check_join_cache_usage(JOIN_TAB *ta
             (tab->cache= new JOIN_CACHE_BKA_UNIQUE(join, tab, flags, prev_cache)))
            ) && !tab->cache->init())))
     {
+      DBUG_ASSERT(might_do_join_buffering(cache_level, tab));
       if (cache_level <= 6)
         return JOIN_CACHE::ALG_BKA | force_unlinked_cache;
       return JOIN_CACHE::ALG_BKA_UNIQUE | force_unlinked_cache;
@@ -10735,7 +10858,7 @@ make_join_readinfo(JOIN *join, ulonglong
         tab[-1].next_select=sub_select_cache;
       }
       /* These init changes read_record */
-      if (tab->use_quick == 2)
+      if (tab->use_quick == QS_DYNAMIC_RANGE)
       {
 	join->thd->server_status|=SERVER_QUERY_NO_GOOD_INDEX_USED;
 	tab->read_first_record= join_init_quick_read_record;
@@ -17856,7 +17979,8 @@ test_if_quick_select(JOIN_TAB *tab)
 static 
 bool test_if_use_dynamic_range_scan(JOIN_TAB *join_tab)
 {
-    return (join_tab->use_quick == 2 && test_if_quick_select(join_tab) > 0);
+    return (join_tab->use_quick == QS_DYNAMIC_RANGE && 
+            test_if_quick_select(join_tab) > 0);
 }
 
 int join_init_read_record(JOIN_TAB *tab)
@@ -18242,7 +18366,9 @@ end_write(JOIN *join, JOIN_TAB *join_tab
   if (!end_of_records)
   {
     copy_fields(&join->tmp_table_param);
-    copy_funcs(join->tmp_table_param.items_to_copy);
+    if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd))
+      DBUG_RETURN(NESTED_LOOP_ERROR);           /* purecov: inspected */
+
     if (!join->having || join->having->val_int())
     {
       int error;
@@ -18334,7 +18460,8 @@ end_update(JOIN *join, JOIN_TAB *join_ta
       memcpy(table->record[0]+key_part->offset, group->buff, 1);
   }
   init_tmptable_sum_functions(join->sum_funcs);
-  copy_funcs(join->tmp_table_param.items_to_copy);
+  if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd))
+    DBUG_RETURN(NESTED_LOOP_ERROR);           /* purecov: inspected */
   if ((error=table->file->ha_write_row(table->record[0])))
   {
     if (create_myisam_from_heap(join->thd, table,
@@ -18371,7 +18498,8 @@ end_unique_update(JOIN *join, JOIN_TAB *
 
   init_tmptable_sum_functions(join->sum_funcs);
   copy_fields(&join->tmp_table_param);		// Groups are copied twice.
-  copy_funcs(join->tmp_table_param.items_to_copy);
+  if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd))
+    DBUG_RETURN(NESTED_LOOP_ERROR);           /* purecov: inspected */
 
   if (!(error=table->file->ha_write_row(table->record[0])))
     join->send_records++;			// New group
@@ -18460,7 +18588,8 @@ end_write_group(JOIN *join, JOIN_TAB *jo
     if (idx < (int) join->send_group_parts)
     {
       copy_fields(&join->tmp_table_param);
-      copy_funcs(join->tmp_table_param.items_to_copy);
+      if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd))
+	DBUG_RETURN(NESTED_LOOP_ERROR);
       if (init_sum_functions(join->sum_funcs, join->sum_funcs_end[idx+1]))
 	DBUG_RETURN(NESTED_LOOP_ERROR);
       if (join->procedure)
@@ -19056,6 +19185,34 @@ ok:
 }
 
 
+/**
+  Find shortest key suitable for full table scan.
+
+  @param table                 Table to scan
+  @param usable_keys           Allowed keys
+
+  @note
+     As far as 
+     1) clustered primary key entry data set is a set of all record
+        fields (key fields and not key fields) and
+     2) secondary index entry data is a union of its key fields and
+        primary key fields (at least InnoDB and its derivatives don't
+        duplicate primary key fields there, even if the primary and
+        the secondary keys have a common subset of key fields),
+     then secondary index entry data is always a subset of primary key entry.
+     Unfortunately, key_info[nr].key_length doesn't show the length
+     of key/pointer pair but a sum of key field lengths only, thus
+     we can't estimate index IO volume comparing only this key_length
+     value of secondary keys and clustered PK.
+     So, try secondary keys first, and choose PK only if there are no
+     usable secondary covering keys or found best secondary key include
+     all table fields (i.e. same as PK):
+
+  @return
+    MAX_KEY     no suitable key found
+    key index   otherwise
+*/
+
 uint find_shortest_key(TABLE *table, const key_map *usable_keys)
 {
   uint best= MAX_KEY;
@@ -19068,23 +19225,6 @@ uint find_shortest_key(TABLE *table, con
     uint min_length= (uint) ~0;
     for (uint nr=0; nr < table->s->keys ; nr++)
     {
-      /*
-       As far as 
-       1) clustered primary key entry data set is a set of all record
-          fields (key fields and not key fields) and
-       2) secondary index entry data is a union of its key fields and
-          primary key fields (at least InnoDB and its derivatives don't
-          duplicate primary key fields there, even if the primary and
-          the secondary keys have a common subset of key fields),
-       then secondary index entry data is always a subset of primary key
-       entry, and the PK is always longer.
-       Unfortunately, key_info[nr].key_length doesn't show the length
-       of key/pointer pair but a sum of key field lengths only, thus
-       we can't estimate index IO volume comparing only this key_length
-       value of seconday keys and clustered PK.
-       So, try secondary keys first, and choose PK only if there are no
-       usable secondary covering keys:
-      */
       if (nr == usable_clustered_pk)
         continue;
       if (usable_keys->is_set(nr))
@@ -19097,7 +19237,20 @@ uint find_shortest_key(TABLE *table, con
       }
     }
   }
-  return best != MAX_KEY ? best : usable_clustered_pk;
+  if (usable_clustered_pk != MAX_KEY)
+  {
+    /*
+     If the primary key is clustered and found shorter key covers all table
+     fields then primary key scan normally would be faster because amount of
+     data to scan is the same but PK is clustered.
+     It's safe to compare key parts with table fields since duplicate key
+     parts aren't allowed.
+     */
+    if (best == MAX_KEY ||
+        table->key_info[best].key_parts >= table->s->fields)
+      best= usable_clustered_pk;
+  }
+  return best;
 }
 
 /**
@@ -19549,7 +19702,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
           */
           DBUG_ASSERT(tab->select->quick);
           tab->type=JT_ALL;
-          tab->use_quick=1;
+          tab->use_quick=QS_RANGE;
           tab->ref.key= -1;
           tab->ref.key_parts=0;		// Don't use ref key.
           tab->read_first_record= join_init_read_record;
@@ -21442,14 +21595,39 @@ update_sum_func(Item_sum **func_ptr)
   return 0;
 }
 
-/** Copy result of functions to record in tmp_table. */
+/** 
+  Copy result of functions to record in tmp_table. 
 
-void
-copy_funcs(Item **func_ptr)
+  Uses the thread pointer to check for errors in 
+  some of the val_xxx() methods called by the 
+  save_in_result_field() function.
+  TODO: make the Item::val_xxx() return error code
+
+  @param func_ptr  array of the function Items to copy to the tmp table
+  @param thd       pointer to the current thread for error checking
+  @retval
+    FALSE if OK
+  @retval
+    TRUE on error  
+*/
+
+bool
+copy_funcs(Item **func_ptr, const THD *thd)
 {
   Item *func;
   for (; (func = *func_ptr) ; func_ptr++)
+  {
     func->save_in_result_field(1);
+    /*
+      Need to check the THD error state because Item::val_xxx() don't
+      return error code, but can generate errors
+      TODO: change it for a real status check when Item::val_xxx()
+      are extended to return status code.
+    */  
+    if (thd->is_error())
+      return TRUE;
+  }
+  return FALSE;
 }
 
 
@@ -22043,7 +22221,7 @@ void select_describe(JOIN *join, bool ne
     {
       SELECT_LEX *last_select= join->unit->first_select()->last_select();
       // # characters needed to print select_number of last select
-      int last_length= log10((double)last_select->select_number)+1;
+      int last_length= (int)log10((double)last_select->select_number)+1;
 
       SELECT_LEX *sl= join->unit->first_select();
       uint len= 6, lastop= 0;
@@ -22360,7 +22538,7 @@ void select_describe(JOIN *join, bool ne
         }
         if (tab->select)
 	{
-	  if (tab->use_quick == 2)
+	  if (tab->use_quick == QS_DYNAMIC_RANGE)
 	  {
             /* 4 bits per 1 hex digit + terminating '\0' */
             char buf[MAX_KEY / 4 + 1];

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2010-08-19 07:10:58 +0000
+++ b/sql/sql_select.h	2010-09-06 17:56:05 +0000
@@ -179,6 +179,11 @@ inline bool sj_is_materialize_strategy(u
   return strategy >= SJ_OPT_MATERIALIZE_LOOKUP;
 }
 
+/** 
+    Bits describing quick select type
+*/
+enum quick_type { QS_NONE, QS_RANGE, QS_DYNAMIC_RANGE};
+
 typedef struct st_join_table : public Sql_alloc
 {
   st_join_table();
@@ -244,12 +249,13 @@ typedef struct st_join_table : public Sq
   ha_rows       read_time;
   
   table_map	dependent,key_dependent;
-  uint		use_quick,index;
+  uint		index;
   uint		status;				///< Save status for cache
   uint		used_fields,used_fieldlength,used_blobs;
   uint          used_null_fields;
   uint          used_rowid_fields;
   uint          used_uneven_bit_fields;
+  enum quick_type use_quick;
   enum join_type type;
   bool		cached_eq_ref_table,eq_ref_table,not_used_in_distinct;
   /* TRUE <=> index-based access method must return records in order */
@@ -417,7 +423,6 @@ st_join_table::st_join_table()
 
     dependent(0),
     key_dependent(0),
-    use_quick(0),
     index(0),
     status(0),
     used_fields(0),
@@ -426,6 +431,7 @@ st_join_table::st_join_table()
     used_null_fields(0),
     used_rowid_fields(0),
     used_uneven_bit_fields(0),
+    use_quick(QS_NONE),
     type(JT_UNKNOWN),
     cached_eq_ref_table(FALSE),
     eq_ref_table(FALSE),
@@ -1957,7 +1963,7 @@ bool setup_copy_fields(THD *thd, TMP_TAB
 		       List<Item> &new_list1, List<Item> &new_list2,
 		       uint elements, List<Item> &fields);
 void copy_fields(TMP_TABLE_PARAM *param);
-void copy_funcs(Item **func_ptr);
+bool copy_funcs(Item **func_ptr, const THD *thd);
 bool create_myisam_from_heap(THD *thd, TABLE *table,
                              MI_COLUMNDEF *start_recinfo,
                              MI_COLUMNDEF **recinfo, 

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2010-08-20 09:15:16 +0000
+++ b/sql/sql_show.cc	2010-09-01 13:06:14 +0000
@@ -1819,6 +1819,7 @@ void mysqld_list_processes(THD *thd,cons
         if ((thd_info->db=tmp->db))             // Safe test
           thd_info->db=thd->strdup(thd_info->db);
         thd_info->command=(int) tmp->command;
+        mysql_mutex_lock(&tmp->LOCK_thd_data);
         if ((mysys_var= tmp->mysys_var))
           mysql_mutex_lock(&mysys_var->mutex);
         thd_info->proc_info= (char*) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0);
@@ -1826,16 +1827,15 @@ void mysqld_list_processes(THD *thd,cons
         if (mysys_var)
           mysql_mutex_unlock(&mysys_var->mutex);
 
-        thd_info->start_time= tmp->start_time;
         thd_info->query=0;
         /* Lock THD mutex that protects its data when looking at it. */
-        mysql_mutex_lock(&tmp->LOCK_thd_data);
         if (tmp->query())
         {
           uint length= min(max_query_length, tmp->query_length());
           thd_info->query= (char*) thd->strmake(tmp->query(),length);
         }
         mysql_mutex_unlock(&tmp->LOCK_thd_data);
+        thd_info->start_time= tmp->start_time;
         thread_infos.append(thd_info);
       }
     }
@@ -1922,6 +1922,7 @@ int fill_schema_processlist(THD* thd, TA
         table->field[3]->set_notnull();
       }
 
+      mysql_mutex_lock(&tmp->LOCK_thd_data);
       if ((mysys_var= tmp->mysys_var))
         mysql_mutex_lock(&mysys_var->mutex);
       /* COMMAND */
@@ -1942,6 +1943,7 @@ int fill_schema_processlist(THD* thd, TA
 
       if (mysys_var)
         mysql_mutex_unlock(&mysys_var->mutex);
+      mysql_mutex_unlock(&tmp->LOCK_thd_data);
 
       /* INFO */
       /* Lock THD mutex that protects its data when looking at it. */
@@ -7495,13 +7497,16 @@ int finalize_schema_table(st_plugin_int 
   ST_SCHEMA_TABLE *schema_table= (ST_SCHEMA_TABLE *)plugin->data;
   DBUG_ENTER("finalize_schema_table");
 
-  if (schema_table && plugin->plugin->deinit)
+  if (schema_table)
   {
-    DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str));
-    if (plugin->plugin->deinit(NULL))
+    if (plugin->plugin->deinit)
     {
-      DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
-                             plugin->name.str));
+      DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str));
+      if (plugin->plugin->deinit(NULL))
+      {
+        DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
+                               plugin->name.str));
+      }
     }
     my_free(schema_table);
   }

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-08-24 12:59:07 +0000
+++ b/sql/sql_table.cc	2010-09-01 13:13:01 +0000
@@ -2365,9 +2365,16 @@ int mysql_rm_table_part2(THD *thd, TABLE
           . ./sql/datadict.cc +32 /Alfranio - TODO: We need to test this.
       */
       if (if_exists)
+      {
+        String tbl_name;
+        tbl_name.append(String(db,system_charset_info));
+        tbl_name.append('.');
+        tbl_name.append(String(table->table_name,system_charset_info));
+
 	push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
 			    ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
-			    table->table_name);
+			    tbl_name.c_ptr());
+      }
       else
       {
         non_tmp_error = (drop_temporary ? non_tmp_error : TRUE);
@@ -2425,6 +2432,9 @@ int mysql_rm_table_part2(THD *thd, TABLE
     {
       if (wrong_tables.length())
 	wrong_tables.append(',');
+
+      wrong_tables.append(String(db,system_charset_info));
+      wrong_tables.append('.');
       wrong_tables.append(String(table->table_name,system_charset_info));
     }
     DBUG_PRINT("table", ("table: 0x%lx  s: 0x%lx", (long) table->table,

=== modified file 'sql/sql_test.cc'
--- a/sql/sql_test.cc	2010-08-23 12:05:47 +0000
+++ b/sql/sql_test.cc	2010-09-02 07:34:10 +0000
@@ -215,7 +215,7 @@ TEST_join(JOIN *join)
     if (tab->select)
     {
       char buf[MAX_KEY/8+1];
-      if (tab->use_quick == 2)
+      if (tab->use_quick == QS_DYNAMIC_RANGE)
 	fprintf(DBUG_FILE,
 		"                  quick select checked for each record (keys: %s)\n",
 		tab->select->quick_keys.print(buf));

=== modified file 'sql/sql_view.cc'
--- a/sql/sql_view.cc	2010-08-20 09:15:16 +0000
+++ b/sql/sql_view.cc	2010-08-30 06:38:09 +0000
@@ -1660,13 +1660,15 @@ bool mysql_drop_view(THD *thd, TABLE_LIS
     if (access(path, F_OK) || 
         FRMTYPE_VIEW != (type= dd_frm_type(thd, path, &not_used)))
     {
-      char name[FN_REFLEN];
-      my_snprintf(name, sizeof(name), "%s.%s", view->db, view->table_name);
       if (thd->lex->drop_if_exists)
       {
+        String tbl_name;
+        tbl_name.append(String(view->db,system_charset_info));
+        tbl_name.append('.');
+        tbl_name.append(String(view->table_name,system_charset_info));
 	push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
 			    ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
-			    name);
+			    tbl_name.c_ptr());
 	continue;
       }
       if (type == FRMTYPE_TABLE)
@@ -1681,6 +1683,9 @@ bool mysql_drop_view(THD *thd, TABLE_LIS
       {
         if (non_existant_views.length())
           non_existant_views.append(',');
+
+        non_existant_views.append(String(view->db,system_charset_info));
+        non_existant_views.append('.');
         non_existant_views.append(String(view->table_name,system_charset_info));
       }
       continue;

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2010-08-24 10:52:32 +0000
+++ b/sql/sql_yacc.yy	2010-09-01 13:16:07 +0000
@@ -1430,6 +1430,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 
 %type <table>
         table_ident table_ident_nodb references xid
+        table_ident_opt_wild
 
 %type <simple_string>
         remember_name remember_end opt_db text_or_password
@@ -10527,7 +10528,7 @@ table_alias_ref_list:
         ;
 
 table_alias_ref:
-          table_ident
+          table_ident_opt_wild
           {
             if (!Select->add_table_to_list(YYTHD, $1, NULL,
                                            TL_OPTION_UPDATING | TL_OPTION_ALIAS,
@@ -10617,8 +10618,8 @@ insert_lock_option:
         | LOW_PRIORITY  { $$= TL_WRITE_LOW_PRIORITY; }
         | DELAYED_SYM
         {
+          Lex->keyword_delayed_begin= YYLIP->get_tok_start();
           $$= TL_WRITE_DELAYED;
-          Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_DELAYED);
         }
         | HIGH_PRIORITY { $$= TL_WRITE; }
         ;
@@ -10627,8 +10628,8 @@ replace_lock_option:
           opt_low_priority { $$= $1; }
         | DELAYED_SYM
         {
+          Lex->keyword_delayed_begin= YYLIP->get_tok_start();
           $$= TL_WRITE_DELAYED;
-          Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_DELAYED);
         }
         ;
 
@@ -12332,6 +12333,21 @@ table_ident:
           }
         ;
 
+table_ident_opt_wild:
+          ident opt_wild
+          {
+            $$= new Table_ident($1);
+            if ($$ == NULL)
+              MYSQL_YYABORT;
+          }
+        | ident '.' ident opt_wild
+          {
+            $$= new Table_ident(YYTHD, $1,$3,0);
+            if ($$ == NULL)
+              MYSQL_YYABORT;
+          }
+        ;
+
 table_ident_nodb:

           ident
           {

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2010-08-27 22:00:11 +0000
+++ b/sql/sys_vars.cc	2010-09-01 13:13:01 +0000
@@ -368,6 +368,12 @@ static Sys_var_mybool Sys_binlog_direct(
        CMD_LINE(OPT_ARG), DEFAULT(FALSE),
        NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(binlog_direct_check));
 
+static Sys_var_mybool Sys_binlog_rows_query(
+       "binlog_rows_query_log_events",
+       "Allow writing of Rows_query_log events into binary log.",
+       SESSION_VAR(binlog_rows_query_log_events),
+       CMD_LINE(OPT_ARG), DEFAULT(FALSE));
+
 static Sys_var_ulong Sys_bulk_insert_buff_size(
        "bulk_insert_buffer_size", "Size of tree cache used in bulk "
        "insert optimisation. Note that this is a limit per thread!",
@@ -1673,19 +1679,13 @@ static Sys_var_ulong Sys_trans_prealloc_
 
 static const char *thread_handling_names[]=
 {
-  "one-thread-per-connection", "no-threads",
-#if HAVE_POOL_OF_THREADS == 1
-  "pool-of-threads",
-#endif
+  "one-thread-per-connection", "no-threads", "loaded-dynamically",
   0
 };
 static Sys_var_enum Sys_thread_handling(
        "thread_handling",
        "Define threads usage for handling queries, one of "
-       "one-thread-per-connection, no-threads"
-#if HAVE_POOL_OF_THREADS == 1
-       ", pool-of-threads"
-#endif
+       "one-thread-per-connection, no-threads, loaded-dynamically"
        , READ_ONLY GLOBAL_VAR(thread_handling), CMD_LINE(REQUIRED_ARG),
        thread_handling_names, DEFAULT(0));
 

=== modified file 'sql/table.h'
--- a/sql/table.h	2010-08-23 12:05:47 +0000
+++ b/sql/table.h	2010-09-06 10:54:47 +0000
@@ -204,7 +204,6 @@ typedef struct st_order {
   struct st_order *next;
   Item	 **item;			/* Point at item in select fields */
   Item	 *item_ptr;			/* Storage for initial item */
-  Item   **item_copy;			/* For SPs; the original item ptr */
   int    counter;                       /* position in SELECT list, correct
                                            only if counter_used is true*/
   bool	 asc;				/* true if ascending */

=== modified file 'storage/innobase/buf/buf0flu.c'
--- a/storage/innobase/buf/buf0flu.c	2010-07-30 15:45:58 +0000
+++ b/storage/innobase/buf/buf0flu.c	2010-09-01 13:05:01 +0000
@@ -44,6 +44,8 @@ Created 11/11/1995 Heikki Tuuri
 #include "os0file.h"
 #include "trx0sys.h"
 #include "srv0mon.h"
+#include "mysql/plugin.h"
+#include "mysql/service_thd_wait.h"
 
 /**********************************************************************
 These statistics are generated for heuristics used in estimating the
@@ -1749,10 +1751,14 @@ buf_flush_wait_batch_end(
 
 			buf_pool = buf_pool_from_array(i);
 
+			thd_wait_begin(NULL, THD_WAIT_DISKIO);
 			os_event_wait(buf_pool->no_flush[type]);
+			thd_wait_end(NULL);
 		}
 	} else {
+		thd_wait_begin(NULL, THD_WAIT_DISKIO);
 		os_event_wait(buf_pool->no_flush[type]);
+		thd_wait_end(NULL);
 	}
 }
 

=== modified file 'storage/innobase/buf/buf0rea.c'
--- a/storage/innobase/buf/buf0rea.c	2010-07-23 16:29:41 +0000
+++ b/storage/innobase/buf/buf0rea.c	2010-09-01 13:05:01 +0000
@@ -37,6 +37,8 @@ Created 11/5/1995 Heikki Tuuri
 #include "os0file.h"
 #include "srv0start.h"
 #include "srv0srv.h"
+#include "mysql/plugin.h"
+#include "mysql/service_thd_wait.h"
 
 /** The linear read-ahead area size */
 #define	BUF_READ_AHEAD_LINEAR_AREA	BUF_READ_AHEAD_AREA
@@ -135,6 +137,7 @@ buf_read_page_low(
 
 	ut_ad(buf_page_in_file(bpage));
 
+	thd_wait_begin(NULL, THD_WAIT_DISKIO);
 	if (zip_size) {
 		*err = fil_io(OS_FILE_READ | wake_later,
 			      sync, space, zip_size, offset, 0, zip_size,
@@ -146,6 +149,7 @@ buf_read_page_low(
 			      sync, space, 0, offset, 0, UNIV_PAGE_SIZE,
 			      ((buf_block_t*) bpage)->frame, bpage);
 	}
+	thd_wait_end(NULL);
 	ut_a(*err == DB_SUCCESS);
 
 	if (sync) {

=== modified file 'storage/innobase/srv/srv0srv.c'
--- a/storage/innobase/srv/srv0srv.c	2010-08-18 07:49:26 +0000
+++ b/storage/innobase/srv/srv0srv.c	2010-09-01 13:05:01 +0000
@@ -85,6 +85,8 @@ Created 10/8/1995 Heikki Tuuri
 #include "trx0i_s.h"
 #include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */
 #include "srv0mon.h"
+#include "mysql/plugin.h"
+#include "mysql/service_thd_wait.h"
 
 /* This is set to TRUE if the MySQL user has set it in MySQL; currently
 affects only FOREIGN KEY definition parsing */
@@ -1235,7 +1237,9 @@ retry:
 
 	trx->op_info = "waiting in InnoDB queue";
 
+	thd_wait_begin(trx->mysql_thd, THD_WAIT_ROW_TABLE_LOCK);
 	os_event_wait(slot->event);
+	thd_wait_end(trx->mysql_thd);
 
 	trx->op_info = "";
 
@@ -1601,7 +1605,9 @@ srv_suspend_mysql_thread(
 
 	/* Suspend this thread and wait for the event. */
 
+	thd_wait_begin(trx->mysql_thd, THD_WAIT_ROW_TABLE_LOCK);
 	os_event_wait(event);
+	thd_wait_end(trx->mysql_thd);
 
 	/* After resuming, reacquire the data dictionary latch if
 	necessary. */

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

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

=== modified file 'vio/vio.c'
--- a/vio/vio.c	2010-07-08 21:20:08 +0000
+++ b/vio/vio.c	2010-08-16 12:50:27 +0000
@@ -44,6 +44,11 @@ static my_bool no_poll_read(Vio *vio __a
 
 #endif
 
+static my_bool has_no_data(Vio *vio __attribute__((unused)))
+{
+  return FALSE;
+}
+
 /*
  * Helper to fill most of the Vio* with defaults.
  */
@@ -83,6 +88,7 @@ static void vio_init(Vio* vio, enum enum
 
     vio->poll_read      =no_poll_read;
     vio->is_connected   =vio_is_connected_pipe;
+    vio->has_data       =has_no_data;
 
     vio->timeout=vio_win32_timeout;
     /* Set default timeout */
@@ -110,6 +116,7 @@ static void vio_init(Vio* vio, enum enum
 
     vio->poll_read      =no_poll_read;
     vio->is_connected   =vio_is_connected_shared_memory;
+    vio->has_data       =has_no_data;
 
     /* Currently, shared memory is on Windows only, hence the below is ok*/
     vio->timeout= vio_win32_timeout; 
@@ -137,6 +144,7 @@ static void vio_init(Vio* vio, enum enum
     vio->timeout	=vio_timeout;
     vio->poll_read      =vio_poll_read;
     vio->is_connected   =vio_is_connected;
+    vio->has_data       =vio_ssl_has_data;
     DBUG_VOID_RETURN;
   }
 #endif /* HAVE_OPENSSL */
@@ -155,6 +163,8 @@ static void vio_init(Vio* vio, enum enum
   vio->timeout          =vio_timeout;
   vio->poll_read        =vio_poll_read;
   vio->is_connected     =vio_is_connected;
+  vio->has_data=        (flags & VIO_BUFFERED_READ) ?
+                            vio_buff_has_data : has_no_data;
   DBUG_VOID_RETURN;
 }
 

=== modified file 'vio/vio_priv.h'
--- a/vio/vio_priv.h	2009-12-16 08:33:54 +0000
+++ b/vio/vio_priv.h	2010-06-07 14:01:39 +0000
@@ -49,6 +49,7 @@ int vio_close_shared_memory(Vio * vio);
 #endif
 
 void	vio_timeout(Vio *vio,uint which, uint timeout);
+my_bool vio_buff_has_data(Vio *vio);
 
 #ifdef HAVE_OPENSSL
 #include "my_net.h"			/* needed because of struct in_addr */
@@ -62,5 +63,7 @@ void vio_ssl_delete(Vio *vio);
 
 int vio_ssl_blocking(Vio *vio, my_bool set_blocking_mode, my_bool *old_mode);
 
+my_bool vio_ssl_has_data(Vio *vio);
+
 #endif /* HAVE_OPENSSL */
 #endif /* VIO_PRIV_INCLUDED */

=== modified file 'vio/viosocket.c'
--- a/vio/viosocket.c	2010-05-21 13:17:01 +0000

+++ b/vio/viosocket.c	2010-08-16 12:50:27 +0000
@@ -98,6 +98,10 @@ size_t vio_read_buff(Vio *vio, uchar* bu
 #undef VIO_UNBUFFERED_READ_MIN_SIZE
 }
 
+my_bool vio_buff_has_data(Vio *vio)
+{
+  return (vio->read_pos != vio->read_end);
+}
 
 size_t vio_write(Vio * vio, const uchar* buf, size_t size)
 {

=== modified file 'vio/viossl.c'
--- a/vio/viossl.c	2010-07-15 11:13:30 +0000
+++ b/vio/viossl.c	2010-08-16 12:50:27 +0000
@@ -244,6 +244,9 @@ int vio_ssl_blocking(Vio *vio __attribut
   return (set_blocking_mode ? 0 : 1);
 }
 
-
+my_bool vio_ssl_has_data(Vio *vio)
+{
+  return SSL_pending(vio->ssl_arg) > 0 ? TRUE : FALSE;
+}
 
 #endif /* HAVE_OPENSSL */

Attachment: [text/bzr-bundle] bzr/epotemkin@mysql.com-20100909105419-udrmg1xjqehvpnp7.bundle
Thread
bzr commit into mysql-next-mr-opt-team branch (epotemkin:3215)Evgeny Potemkin9 Sep