[packages/percona-server/v5.1.x: 6/21] - up to 5.1.11

glen glen at pld-linux.org
Wed Oct 21 16:08:39 CEST 2015


commit 74952c29c4cb9a91e7c19bf18e90a499400f59ab
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Feb 19 22:35:53 2011 +0000

    - up to 5.1.11
    
    Changed files:
        mysql-bug677407.patch -> 1.1.2.2
        mysql-error_pad.patch -> 1.1.2.2
        mysql-i_s_innodb_buffer_pool_pages.patch -> 1.1.2.2
        mysql-innodb_adjust_defaults.patch -> 1.1.2.2
        mysql-innodb_admin_command_base.patch -> 1.1.2.2
        mysql-innodb_deadlock_count.patch -> 1.1.2.2
        mysql-innodb_expand_import.patch -> 1.1.2.2
        mysql-innodb_expand_undo_slots.patch -> 1.1.2.2
        mysql-innodb_fast_checksum.patch -> 1.1.2.2
        mysql-innodb_files_extend.patch -> 1.1.2.2
        mysql-innodb_fix_misc.patch -> 1.1.2.2
        mysql-innodb_lru_dump_restore.patch -> 1.1.2.2
        mysql-innodb_overwrite_relay_log_info.patch -> 1.1.2.2
        mysql-innodb_pass_corrupt_table.patch -> 1.1.2.2
        mysql-innodb_purge_thread.patch -> 1.1.2.2
        mysql-innodb_separate_doublewrite.patch -> 1.1.2.2
        mysql-innodb_show_enhancements.patch -> 1.1.2.2
        mysql-innodb_show_lock_name.patch -> 1.1.2.2
        mysql-innodb_show_status.patch -> 1.1.2.2
        mysql-innodb_show_sys_tables.patch -> 1.1.2.2
        mysql-innodb_stats.patch -> 1.1.2.2
        mysql-innodb_swap_builtin_plugin.patch -> 1.1.2.2
        mysql-optimizer_fix.patch -> 1.1.2.2
        mysql-query_cache_enhance.patch -> 1.1.2.2
        mysql-show_temp_51.patch -> 1.1.2.2
        mysql-slow_extended.patch -> 1.1.2.2
        mysql-suppress_log_warning_1592.patch -> 1.1.2.2

 mysql-bug677407.patch                       |  11 +-
 mysql-error_pad.patch                       |   4 +-
 mysql-i_s_innodb_buffer_pool_pages.patch    |   2 +-
 mysql-innodb_adjust_defaults.patch          |  12 +-
 mysql-innodb_admin_command_base.patch       |   4 +-
 mysql-innodb_deadlock_count.patch           |   6 +-
 mysql-innodb_expand_import.patch            |  27 ++-
 mysql-innodb_expand_undo_slots.patch        |   2 +-
 mysql-innodb_fast_checksum.patch            |  12 +-
 mysql-innodb_files_extend.patch             | 218 ++++++++++++++++++++++---
 mysql-innodb_fix_misc.patch                 |  36 +++-
 mysql-innodb_lru_dump_restore.patch         |  79 +++++----
 mysql-innodb_overwrite_relay_log_info.patch |   2 +-
 mysql-innodb_pass_corrupt_table.patch       |  84 +++++-----
 mysql-innodb_purge_thread.patch             |  18 +-
 mysql-innodb_separate_doublewrite.patch     | 200 +++++++++++++++++++----
 mysql-innodb_show_enhancements.patch        |   4 +-
 mysql-innodb_show_lock_name.patch           | 100 ++++++++----
 mysql-innodb_show_status.patch              |  25 +--
 mysql-innodb_show_sys_tables.patch          |   4 +-
 mysql-innodb_stats.patch                    | 187 ++++++++++-----------
 mysql-innodb_swap_builtin_plugin.patch      | 120 +++++++++++++-
 mysql-optimizer_fix.patch                   |  12 +-
 mysql-query_cache_enhance.patch             |  22 +--
 mysql-show_temp_51.patch                    |  16 +-
 mysql-slow_extended.patch                   | 244 +++++++++++++++-------------
 mysql-suppress_log_warning_1592.patch       |  12 +-
 27 files changed, 991 insertions(+), 472 deletions(-)
---
diff --git a/mysql-bug677407.patch b/mysql-bug677407.patch
index 873a6a1..4c4f9aa 100644
--- a/mysql-bug677407.patch
+++ b/mysql-bug677407.patch
@@ -49,6 +49,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+diff -ruN a/storage/innodb_plugin/trx/trx0i_s.c b/storage/innodb_plugin/trx/trx0i_s.c
 --- a/storage/innodb_plugin/trx/trx0i_s.c	2010-11-03 16:39:54.000000000 +0300
 +++ b/storage/innodb_plugin/trx/trx0i_s.c	2010-11-30 13:57:03.000000000 +0300
 @@ -157,10 +157,6 @@
@@ -62,7 +63,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  	i_s_table_cache_t innodb_trx;	/*!< innodb_trx table */
  	i_s_table_cache_t innodb_locks;	/*!< innodb_locks table */
  	i_s_table_cache_t innodb_lock_waits;/*!< innodb_lock_waits table */
-@@ -1101,13 +1097,6 @@
+@@ -1142,13 +1138,6 @@
  {
  	ullint	now;
  
@@ -76,7 +77,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  #ifdef UNIV_SYNC_DEBUG
  	ut_a(rw_lock_own(&cache->rw_lock, RW_LOCK_EX));
  #endif
-@@ -1205,6 +1194,12 @@
+@@ -1246,6 +1235,12 @@
  /*===================================*/
  	trx_i_s_cache_t*	cache)	/*!< in/out: cache */
  {
@@ -89,7 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  	if (!can_cache_be_updated(cache)) {
  
  		return(1);
-@@ -1217,6 +1212,10 @@
+@@ -1258,6 +1253,10 @@
  
  	mutex_exit(&kernel_mutex);
  
@@ -100,7 +101,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  	return(0);
  }
  
-@@ -1247,16 +1246,12 @@
+@@ -1288,16 +1287,12 @@
  	release kernel_mutex
  	release trx_i_s_cache_t::rw_lock
  	acquire trx_i_s_cache_t::rw_lock, S
@@ -117,7 +118,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  	table_cache_init(&cache->innodb_trx, sizeof(i_s_trx_row_t));
  	table_cache_init(&cache->innodb_locks, sizeof(i_s_locks_row_t));
  	table_cache_init(&cache->innodb_lock_waits,
-@@ -1307,18 +1302,10 @@
+@@ -1348,18 +1343,10 @@
  /*===================*/
  	trx_i_s_cache_t*	cache)	/*!< in: cache */
  {
diff --git a/mysql-error_pad.patch b/mysql-error_pad.patch
index fa452c7..aa3e8fa 100644
--- a/mysql-error_pad.patch
+++ b/mysql-error_pad.patch
@@ -61,7 +61,7 @@ diff -ruN a/extra/comp_err.c b/extra/comp_err.c
 -	goto err;
 +        int padd_to= tmp_error->d_code;
 +        char* padd_message= tmp->text;
-+        while ((row_nr+er_offset) < padd_to)
++        while ((int) row_nr + er_offset < padd_to)
 +        {
 +          if (copy_rows(to, padd_message,row_nr,start_pos))
 +          {
@@ -177,7 +177,7 @@ diff -ruN a/extra/comp_err.c b/extra/comp_err.c
 +    fprintf(stderr, "Failed to parse the error padd string '%s' '%s' (d_code doesn't parse)!\n",er_name,str);
 +    DBUG_RETURN(0);
 +  }
-+  if (d_code < (er_offset + er_count))
++  if (d_code < (uint) er_offset + er_count)
 +  {
 +    fprintf(stderr, "Error to padding less current error number!\n");
 +    DBUG_RETURN(0);
diff --git a/mysql-i_s_innodb_buffer_pool_pages.patch b/mysql-i_s_innodb_buffer_pool_pages.patch
index 1adf1b5..d977f0c 100644
--- a/mysql-i_s_innodb_buffer_pool_pages.patch
+++ b/mysql-i_s_innodb_buffer_pool_pages.patch
@@ -26,7 +26,7 @@ diff -ruN a/storage/innodb_plugin/buf/buf0buf.c b/storage/innodb_plugin/buf/buf0
 diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 --- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-29 15:55:25.000000000 +0900
 +++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-29 16:04:05.000000000 +0900
-@@ -11173,6 +11173,9 @@
+@@ -11175,6 +11175,9 @@
    innobase_system_variables, /* system variables */
    NULL /* reserved */
  },
diff --git a/mysql-innodb_adjust_defaults.patch b/mysql-innodb_adjust_defaults.patch
index e08a02b..4f1b805 100644
--- a/mysql-innodb_adjust_defaults.patch
+++ b/mysql-innodb_adjust_defaults.patch
@@ -8,7 +8,7 @@
 diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 --- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-30 16:39:14.000000000 +0900
 +++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-30 16:43:26.000000000 +0900
-@@ -11178,7 +11178,7 @@
+@@ -11223,7 +11223,7 @@
  static MYSQL_SYSVAR_ULONG(use_purge_thread, srv_use_purge_thread,
    PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
    "Number of purge devoted threads. #### over 1 is EXPERIMENTAL ####",
@@ -17,7 +17,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  
  static MYSQL_SYSVAR_BOOL(overwrite_relay_log_info, innobase_overwrite_relay_log_info,
    PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
-@@ -11278,7 +11278,7 @@
+@@ -11323,7 +11323,7 @@
  static MYSQL_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
    PLUGIN_VAR_NOCMDARG,
    "Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
@@ -26,7 +26,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  
  static MYSQL_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
    PLUGIN_VAR_RQCMDARG,
-@@ -11523,7 +11523,7 @@
+@@ -11568,7 +11568,7 @@
  static MYSQL_SYSVAR_ULONG(ibuf_active_contract, srv_ibuf_active_contract,
    PLUGIN_VAR_RQCMDARG,
    "Enable/Disable active_contract of insert buffer. 0:disable 1:enable",
@@ -35,13 +35,13 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  
  static MYSQL_SYSVAR_ULONG(ibuf_accel_rate, srv_ibuf_accel_rate,
    PLUGIN_VAR_RQCMDARG,
-@@ -11601,8 +11601,8 @@
+@@ -11648,8 +11648,8 @@
  };
  static MYSQL_SYSVAR_ENUM(adaptive_checkpoint, srv_adaptive_checkpoint,
    PLUGIN_VAR_RQCMDARG,
--  "Enable/Disable flushing along modified age. ([none], reflex, estimate)",
+-  "Enable/Disable flushing along modified age. ([none], reflex, estimate, keep_average)",
 -  NULL, innodb_adaptive_checkpoint_update, 0, &adaptive_checkpoint_typelib);
-+  "Enable/Disable flushing along modified age. (none, reflex, [estimate])",
++  "Enable/Disable flushing along modified age. (none, reflex, [estimate], keep_average)",
 +  NULL, innodb_adaptive_checkpoint_update, 2, &adaptive_checkpoint_typelib);
  
  static MYSQL_SYSVAR_ULONG(enable_unsafe_group_commit, srv_enable_unsafe_group_commit,
diff --git a/mysql-innodb_admin_command_base.patch b/mysql-innodb_admin_command_base.patch
index 2619ed9..4a42d19 100644
--- a/mysql-innodb_admin_command_base.patch
+++ b/mysql-innodb_admin_command_base.patch
@@ -8,7 +8,7 @@
 diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 --- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:27:30.222410116 +0900
 +++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:27:44.073104773 +0900
-@@ -11532,6 +11532,7 @@
+@@ -11547,6 +11547,7 @@
  i_s_innodb_cmpmem_reset,
  i_s_innodb_table_stats,
  i_s_innodb_index_stats,
@@ -19,7 +19,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
 diff -ruN a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler/i_s.cc
 --- a/storage/innodb_plugin/handler/i_s.cc	2010-08-27 16:22:04.261021936 +0900
 +++ b/storage/innodb_plugin/handler/i_s.cc	2010-08-27 16:27:44.077058655 +0900
-@@ -2948,3 +2948,139 @@
+@@ -2947,3 +2947,139 @@
  	STRUCT_FLD(system_vars, NULL),
  	STRUCT_FLD(__reserved1, NULL)
  };
diff --git a/mysql-innodb_deadlock_count.patch b/mysql-innodb_deadlock_count.patch
index 7a33d6a..079e36b 100644
--- a/mysql-innodb_deadlock_count.patch
+++ b/mysql-innodb_deadlock_count.patch
@@ -8,7 +8,7 @@
 diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 --- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-10 15:32:14.468241191 +0400
 +++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-10 15:32:14.926992081 +0400
-@@ -546,6 +546,8 @@
+@@ -547,6 +547,8 @@
    (char*) &export_vars.innodb_data_written,		  SHOW_LONG},
    {"dblwr_pages_written",
    (char*) &export_vars.innodb_dblwr_pages_written,	  SHOW_LONG},
@@ -53,7 +53,7 @@ diff -ruN a/storage/innodb_plugin/lock/lock0lock.c b/storage/innodb_plugin/lock/
 diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c
 --- a/storage/innodb_plugin/srv/srv0srv.c	2010-08-10 15:32:14.478241628 +0400
 +++ b/storage/innodb_plugin/srv/srv0srv.c	2010-08-10 15:32:14.936991959 +0400
-@@ -435,7 +435,7 @@
+@@ -438,7 +438,7 @@
  static ulint	srv_n_rows_updated_old		= 0;
  static ulint	srv_n_rows_deleted_old		= 0;
  static ulint	srv_n_rows_read_old		= 0;
@@ -62,7 +62,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0
  UNIV_INTERN ulint		srv_n_lock_wait_count		= 0;
  UNIV_INTERN ulint		srv_n_lock_wait_current_count	= 0;
  UNIV_INTERN ib_int64_t	srv_n_lock_wait_time		= 0;
-@@ -2146,6 +2146,8 @@
+@@ -2149,6 +2149,8 @@
  		= UT_LIST_GET_LEN(buf_pool->flush_list);
  	export_vars.innodb_buffer_pool_pages_free
  		= UT_LIST_GET_LEN(buf_pool->free);
diff --git a/mysql-innodb_expand_import.patch b/mysql-innodb_expand_import.patch
index 98d9de2..ec08929 100644
--- a/mysql-innodb_expand_import.patch
+++ b/mysql-innodb_expand_import.patch
@@ -21,7 +21,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  #ifndef UNIV_HOTBACKUP
  # include "buf0lru.h"
  # include "ibuf0ibuf.h"
-@@ -2983,7 +2989,7 @@
+@@ -3029,7 +3035,7 @@
  	ut_a(!(flags & (~0UL << DICT_TF_BITS)));
  
  	file = os_file_create_simple_no_error_handling(
@@ -30,12 +30,12 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  	if (!success) {
  		/* The following call prints an error message */
  		os_file_get_last_error(TRUE);
-@@ -3030,6 +3036,464 @@
+@@ -3076,6 +3082,464 @@
  	space_id = fsp_header_get_space_id(page);
  	space_flags = fsp_header_get_flags(page);
  
-+	if (srv_expand_import
-+	    && (space_id != id || space_flags != (flags & ~(~0 << DICT_TF_BITS)))) {
++	if (srv_expand_import) {
++
 +		ibool		file_is_corrupt = FALSE;
 +		byte*		buf3;
 +		byte*		descr_page;
@@ -498,7 +498,22 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
 diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 --- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-29 16:54:08.000000000 +0900
 +++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-30 10:28:05.000000000 +0900
-@@ -11305,6 +11305,11 @@
+@@ -7106,6 +7106,14 @@
+ 		err = row_discard_tablespace_for_mysql(dict_table->name, trx);
+ 	} else {
+ 		err = row_import_tablespace_for_mysql(dict_table->name, trx);
++
++		/* in expanded import mode re-initialize auto_increment again */
++		if ((err == DB_SUCCESS) && srv_expand_import &&
++		    (table->found_next_number_field != NULL)) {
++			dict_table_autoinc_lock(dict_table);
++			innobase_initialize_autoinc();
++			dict_table_autoinc_unlock(dict_table);
++		}
+ 	}
+ 
+ 	err = convert_error_code_to_mysql(err, dict_table->flags, NULL);
+@@ -11307,6 +11315,11 @@
    "Enable/Disable unsafe group commit when support_xa=OFF and use with binlog or other XA storage engine.",
    NULL, NULL, 0, 0, 1, 0);
  
@@ -510,7 +525,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  static MYSQL_SYSVAR_ULONG(extra_rsegments, srv_extra_rsegments,
    PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
    "Number of extra user rollback segments when create new database.",
-@@ -11381,6 +11386,7 @@
+@@ -11383,6 +11396,7 @@
    MYSQL_SYSVAR(adaptive_checkpoint),
    MYSQL_SYSVAR(flush_log_at_trx_commit_session),
    MYSQL_SYSVAR(enable_unsafe_group_commit),
diff --git a/mysql-innodb_expand_undo_slots.patch b/mysql-innodb_expand_undo_slots.patch
index 29a07e8..7af0902 100644
--- a/mysql-innodb_expand_undo_slots.patch
+++ b/mysql-innodb_expand_undo_slots.patch
@@ -39,7 +39,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  static MYSQL_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
    PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
    "Enable InnoDB doublewrite buffer (enabled by default). "
-@@ -11095,6 +11105,7 @@
+@@ -11097,6 +11107,7 @@
    MYSQL_SYSVAR(data_file_path),
    MYSQL_SYSVAR(data_home_dir),
    MYSQL_SYSVAR(doublewrite),
diff --git a/mysql-innodb_fast_checksum.patch b/mysql-innodb_fast_checksum.patch
index 4d830c9..9a4418d 100644
--- a/mysql-innodb_fast_checksum.patch
+++ b/mysql-innodb_fast_checksum.patch
@@ -109,7 +109,7 @@ diff -ruN a/storage/innodb_plugin/buf/buf0flu.c b/storage/innodb_plugin/buf/buf0
 diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0fil.c
 --- a/storage/innodb_plugin/fil/fil0fil.c	2010-08-27 16:40:36.522990504 +0900
 +++ b/storage/innodb_plugin/fil/fil0fil.c	2010-08-27 16:42:03.602023484 +0900
-@@ -3096,7 +3096,9 @@
+@@ -3150,7 +3150,9 @@
  			mach_write_ull(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
  		mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
  				srv_use_checksums
@@ -120,7 +120,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  						: BUF_NO_CHECKSUM_MAGIC);
  		mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
  				srv_use_checksums
-@@ -3226,7 +3228,8 @@
+@@ -3280,7 +3282,8 @@
  					page_is_corrupt = TRUE;
  				}
  
@@ -130,7 +130,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  				    && checksum_field != BUF_NO_CHECKSUM_MAGIC
  				    && checksum_field
  				    != buf_calc_page_new_checksum(page)) {
-@@ -3234,6 +3237,17 @@
+@@ -3288,6 +3291,17 @@
  					page_is_corrupt = TRUE;
  				}
  
@@ -148,7 +148,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  				/* if it is free page, inconsistency is acceptable */
  				if (!offset) {
  					/* header page*/
-@@ -3379,7 +3393,9 @@
+@@ -3433,7 +3447,9 @@
  
  					mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
  							srv_use_checksums
@@ -178,7 +178,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  
  #ifdef HAVE_LARGE_PAGES
          if ((os_use_large_pages = (ibool) my_use_large_pages))
-@@ -11105,6 +11107,15 @@
+@@ -11118,6 +11120,15 @@
    "Disable with --skip-innodb-checksums.",
    NULL, NULL, TRUE);
  
@@ -194,7 +194,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  static MYSQL_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
    PLUGIN_VAR_READONLY,
    "The common part for InnoDB table spaces.",
-@@ -11595,6 +11606,7 @@
+@@ -11610,6 +11621,7 @@
    MYSQL_SYSVAR(autoextend_increment),
    MYSQL_SYSVAR(buffer_pool_size),
    MYSQL_SYSVAR(checksums),
diff --git a/mysql-innodb_files_extend.patch b/mysql-innodb_files_extend.patch
index 513a5d8..11f0fbc 100644
--- a/mysql-innodb_files_extend.patch
+++ b/mysql-innodb_files_extend.patch
@@ -20,7 +20,34 @@ diff -ruN a/storage/innodb_plugin/buf/buf0buddy.c b/storage/innodb_plugin/buf/bu
 diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0fil.c
 --- a/storage/innodb_plugin/fil/fil0fil.c	2010-08-27 16:43:11.941989968 +0900
 +++ b/storage/innodb_plugin/fil/fil0fil.c	2010-08-27 16:44:21.668058937 +0900
-@@ -4722,9 +4722,9 @@
+@@ -690,7 +690,7 @@
+ 		ut_a(space->purpose != FIL_LOG);
+ 		ut_a(!trx_sys_sys_space(space->id));
+ 
+-		if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
++		if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
+ 			fprintf(stderr,
+ 				"InnoDB: Error: the size of single-table"
+ 				" tablespace file %s\n"
+@@ -3778,7 +3778,7 @@
+ 
+ 	size = (((ib_int64_t)size_high) << 32) + (ib_int64_t)size_low;
+ #ifndef UNIV_HOTBACKUP
+-	if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
++	if (size < FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
+ 		fprintf(stderr,
+ 			"InnoDB: Error: the size of single-table tablespace"
+ 			" file %s\n"
+@@ -3798,7 +3798,7 @@
+ 	/* Align the memory for file i/o if we might have O_DIRECT set */
+ 	page = ut_align(buf2, UNIV_PAGE_SIZE);
+ 
+-	if (size >= FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
++	if (size >= FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
+ 		success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
+ 
+ 		/* We have to read the tablespace id from the file */
+@@ -4776,9 +4776,9 @@
  	ut_ad(ut_is_2pow(zip_size));
  	ut_ad(buf);
  	ut_ad(len > 0);
@@ -36,28 +63,36 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
 diff -ruN a/storage/innodb_plugin/fsp/fsp0fsp.c b/storage/innodb_plugin/fsp/fsp0fsp.c
 --- a/storage/innodb_plugin/fsp/fsp0fsp.c	2010-08-27 16:40:36.528021375 +0900
 +++ b/storage/innodb_plugin/fsp/fsp0fsp.c	2010-08-27 16:44:21.673058570 +0900
-@@ -658,15 +658,16 @@
+@@ -657,16 +657,18 @@
+ 				0 for uncompressed pages */
  	ulint	offset)		/*!< in: page offset */
  {
- #ifndef DOXYGEN /* Doxygen gets confused of these */
+-#ifndef DOXYGEN /* Doxygen gets confused of these */
 -# if UNIV_PAGE_SIZE <= XDES_ARR_OFFSET \
 -		+ (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
 -#  error
 -# endif
+-# if PAGE_ZIP_MIN_SIZE <= XDES_ARR_OFFSET \
+-		+ (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
+-#  error
+-# endif
+-#endif /* !DOXYGEN */
++//#ifndef DOXYGEN /* Doxygen gets confused of these */
 +//# if UNIV_PAGE_SIZE <= XDES_ARR_OFFSET
 +//		+ (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
 +//#  error
 +//# endif
- # if PAGE_ZIP_MIN_SIZE <= XDES_ARR_OFFSET \
- 		+ (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
- #  error
- # endif
- #endif /* !DOXYGEN */
++//# if PAGE_ZIP_MIN_SIZE <= XDES_ARR_OFFSET
++//		+ (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
++//#  error
++//# endif
++//#endif /* !DOXYGEN */
 +	ut_a(UNIV_PAGE_SIZE > XDES_ARR_OFFSET + (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE);
++	ut_a(PAGE_ZIP_MIN_SIZE > XDES_ARR_OFFSET + (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE);
  	ut_ad(ut_is_2pow(zip_size));
  
  	if (!zip_size) {
-@@ -1465,12 +1466,12 @@
+@@ -1465,12 +1467,12 @@
  							   mtr);
  		xdes_init(descr, mtr);
  
@@ -79,16 +114,17 @@ diff -ruN a/storage/innodb_plugin/fsp/fsp0fsp.c b/storage/innodb_plugin/fsp/fsp0
 diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 --- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:43:11.951020997 +0900
 +++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:44:21.682059132 +0900
-@@ -151,6 +151,8 @@
+@@ -151,6 +151,9 @@
  static ulong innobase_read_io_threads;
  static ulong innobase_write_io_threads;
  
 +static ulong innobase_page_size;
++static ulong innobase_log_block_size;
 +
  static my_bool innobase_thread_concurrency_timer_based;
  static long long innobase_buffer_pool_size, innobase_log_file_size;
  
-@@ -2084,6 +2086,36 @@
+@@ -2084,6 +2087,62 @@
  	}
  #endif /* UNIV_DEBUG */
  
@@ -122,10 +158,36 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
 +		goto error;
 +	}
 +
++	srv_log_block_size = 0;
++	if (innobase_log_block_size != (1 << 9)) { /*!=512*/
++		uint	n_shift;
++
++		fprintf(stderr,
++			"InnoDB: Warning: innodb_log_block_size has been changed from default value 512. (###EXPERIMENTAL### operation)\n");
++		for (n_shift = 9; n_shift <= UNIV_PAGE_SIZE_SHIFT_MAX; n_shift++) {
++			if (innobase_log_block_size == ((ulong)1 << n_shift)) {
++				srv_log_block_size = (1 << n_shift);
++				fprintf(stderr,
++					"InnoDB: The log block size is set to %lu.\n",
++					srv_log_block_size);
++				break;
++			}
++		}
++	} else {
++		srv_log_block_size = 512;
++	}
++
++	if (!srv_log_block_size) {
++		fprintf(stderr,
++			"InnoDB: Error: %lu is not valid value for innodb_log_block_size.\n",
++			innobase_log_block_size);
++		goto error;
++	}
++
  #ifndef MYSQL_SERVER
  	innodb_overwrite_relay_log_info = FALSE;
  #endif
-@@ -7006,9 +7038,9 @@
+@@ -7015,9 +7074,9 @@
  				| DICT_TF_COMPACT
  				| DICT_TF_FORMAT_ZIP
  				<< DICT_TF_FORMAT_SHIFT;
@@ -138,7 +200,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  		}
  	}
  
-@@ -11116,6 +11148,11 @@
+@@ -11129,6 +11188,16 @@
    "#### Attention: The checksum is not compatible for normal or disabled version! ####",
    NULL, NULL, FALSE);
  
@@ -147,14 +209,20 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
 +  "###EXPERIMENTAL###: The universal page size of the database. Changing for created database is not supported. Use on your own risk!",
 +  NULL, NULL, (1 << 14), (1 << 12), (1 << UNIV_PAGE_SIZE_SHIFT_MAX), 0);
 +
++static MYSQL_SYSVAR_ULONG(log_block_size, innobase_log_block_size,
++  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
++  "###EXPERIMENTAL###: The log block size of the transaction log file. Changing for created log file is not supported. Use on your own risk!",
++  NULL, NULL, (1 << 9)/*512*/, (1 << 9)/*512*/, (1 << UNIV_PAGE_SIZE_SHIFT_MAX), 0);
++
  static MYSQL_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
    PLUGIN_VAR_READONLY,
    "The common part for InnoDB table spaces.",
-@@ -11602,6 +11639,7 @@
+@@ -11617,6 +11686,8 @@
    NULL, NULL, 0, 0, 1, 0);
  
  static struct st_mysql_sys_var* innobase_system_variables[]= {
 +  MYSQL_SYSVAR(page_size),
++  MYSQL_SYSVAR(log_block_size),
    MYSQL_SYSVAR(additional_mem_pool_size),
    MYSQL_SYSVAR(autoextend_increment),
    MYSQL_SYSVAR(buffer_pool_size),
@@ -202,7 +270,7 @@ diff -ruN a/storage/innodb_plugin/include/buf0buf.h b/storage/innodb_plugin/incl
 diff -ruN a/storage/innodb_plugin/include/buf0types.h b/storage/innodb_plugin/include/buf0types.h
 --- a/storage/innodb_plugin/include/buf0types.h	2010-08-04 02:24:19.000000000 +0900
 +++ b/storage/innodb_plugin/include/buf0types.h	2010-08-27 16:44:21.692071229 +0900
-@@ -70,6 +70,7 @@
+@@ -70,12 +70,13 @@
  					buddy system; must be at least
  					sizeof(buf_page_t) */
  #define BUF_BUDDY_SIZES		(UNIV_PAGE_SIZE_SHIFT - BUF_BUDDY_LOW_SHIFT)
@@ -210,6 +278,38 @@ diff -ruN a/storage/innodb_plugin/include/buf0types.h b/storage/innodb_plugin/in
  					/*!< number of buddy sizes */
  
  /** twice the maximum block size of the buddy system;
+ the underlying memory is aligned by this amount:
+ this must be equal to UNIV_PAGE_SIZE */
+-#define BUF_BUDDY_HIGH	(BUF_BUDDY_LOW << BUF_BUDDY_SIZES)
++#define BUF_BUDDY_HIGH	((ulint)BUF_BUDDY_LOW << BUF_BUDDY_SIZES)
+ /* @} */
+ 
+ #endif
+diff -ruN a/storage/innodb_plugin/include/fsp0types.h b/storage/innodb_plugin/include/fsp0types.h
+--- a/storage/innodb_plugin/include/fsp0types.h	2010-11-29 19:38:03.000000000 +0900
++++ b/storage/innodb_plugin/include/fsp0types.h	2011-02-02 23:29:13.000000000 +0900
+@@ -42,7 +42,7 @@
+ /* @} */
+ 
+ /** File space extent size (one megabyte) in pages */
+-#define	FSP_EXTENT_SIZE		(1 << (20 - UNIV_PAGE_SIZE_SHIFT))
++#define	FSP_EXTENT_SIZE		((ulint)1 << (20 - UNIV_PAGE_SIZE_SHIFT))
+ 
+ /** On a page of any file segment, data may be put starting from this
+ offset */
+diff -ruN a/storage/innodb_plugin/include/log0log.h b/storage/innodb_plugin/include/log0log.h
+--- a/storage/innodb_plugin/include/log0log.h	2010-11-03 22:39:54.000000000 +0900
++++ b/storage/innodb_plugin/include/log0log.h	2010-12-13 20:17:00.600329611 +0900
+@@ -672,6 +672,9 @@
+ 					when mysqld is first time started
+ 					on the restored database, it can
+ 					print helpful info for the user */
++#define LOG_FILE_OS_FILE_LOG_BLOCK_SIZE 64
++					/* extend to record log_block_size
++					of XtraDB. 0 means default 512 */
+ #define	LOG_FILE_ARCH_COMPLETED	OS_FILE_LOG_BLOCK_SIZE
+ 					/* this 4-byte field is TRUE when
+ 					the writing of an archived log file
 diff -ruN a/storage/innodb_plugin/include/mtr0log.ic b/storage/innodb_plugin/include/mtr0log.ic
 --- a/storage/innodb_plugin/include/mtr0log.ic	2010-08-27 16:38:38.273059844 +0900
 +++ b/storage/innodb_plugin/include/mtr0log.ic	2010-08-27 16:44:21.693073476 +0900
@@ -222,6 +322,27 @@ diff -ruN a/storage/innodb_plugin/include/mtr0log.ic b/storage/innodb_plugin/inc
  		if (trx_doublewrite_buf_is_being_created) {
  			/* Do nothing: we only come to this branch in an
  			InnoDB database creation. We do not redo log
+diff -ruN a/storage/innodb_plugin/include/os0file.h b/storage/innodb_plugin/include/os0file.h
+--- a/storage/innodb_plugin/include/os0file.h	2010-12-13 20:14:59.101402758 +0900
++++ b/storage/innodb_plugin/include/os0file.h	2010-12-13 20:17:00.602329548 +0900
+@@ -107,7 +107,7 @@
+ if this fails for a log block, then it is equivalent to a media failure in the
+ log. */
+ 
+-#define OS_FILE_LOG_BLOCK_SIZE		512
++#define OS_FILE_LOG_BLOCK_SIZE		srv_log_block_size
+ 
+ /** Options for file_create @{ */
+ #define	OS_FILE_OPEN			51
+@@ -188,6 +188,8 @@
+ extern ulint	os_n_file_writes;
+ extern ulint	os_n_fsyncs;
+ 
++extern ulint	srv_log_block_size;
++
+ /* File types for directory entry data type */
+ 
+ enum os_file_type_enum{
 diff -ruN a/storage/innodb_plugin/include/page0types.h b/storage/innodb_plugin/include/page0types.h
 --- a/storage/innodb_plugin/include/page0types.h	2010-08-04 02:24:19.000000000 +0900
 +++ b/storage/innodb_plugin/include/page0types.h	2010-08-27 16:44:21.695063547 +0900
@@ -281,7 +402,7 @@ diff -ruN a/storage/innodb_plugin/include/univ.i b/storage/innodb_plugin/include
  
  /* Maximum number of parallel threads in a parallelized operation */
  #define UNIV_MAX_PARALLELISM	32
-@@ -384,7 +388,7 @@
+@@ -399,7 +403,7 @@
  stored part of the field in the tablespace. The length field then
  contains the sum of the following flag and the locally stored len. */
  
@@ -290,7 +411,7 @@ diff -ruN a/storage/innodb_plugin/include/univ.i b/storage/innodb_plugin/include
  
  /* Some macros to improve branch prediction and reduce cache misses */
  #if defined(__GNUC__) && (__GNUC__ > 2) && ! defined(__INTEL_COMPILER)
-@@ -487,4 +491,6 @@
+@@ -502,4 +506,6 @@
  	UNIV_MEM_ALLOC(addr, size);			\
  } while (0)
  
@@ -310,7 +431,28 @@ diff -ruN a/storage/innodb_plugin/log/log0log.c b/storage/innodb_plugin/log/log0
  
  	/* fprintf(stderr,
  	"Offset is %lu gr_lsn_offset is %lu difference is %lu\n",
-@@ -1791,6 +1793,7 @@
+@@ -1182,6 +1184,9 @@
+ 	/* Wipe over possible label of ibbackup --restore */
+ 	memcpy(buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, "    ", 4);
+ 
++	mach_write_to_4(buf + LOG_FILE_OS_FILE_LOG_BLOCK_SIZE,
++			srv_log_block_size);
++
+ 	dest_offset = nth_file * group->file_size;
+ 
+ #ifdef UNIV_DEBUG
+@@ -1775,9 +1780,7 @@
+ 	ulint		i;
+ 
+ 	ut_ad(mutex_own(&(log_sys->mutex)));
+-#if LOG_CHECKPOINT_SIZE > OS_FILE_LOG_BLOCK_SIZE
+-# error "LOG_CHECKPOINT_SIZE > OS_FILE_LOG_BLOCK_SIZE"
+-#endif
++	ut_a(LOG_CHECKPOINT_SIZE <= OS_FILE_LOG_BLOCK_SIZE);
+ 
+ 	buf = group->checkpoint_buf;
+ 
+@@ -1791,6 +1794,7 @@
  	mach_write_to_4(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, log_sys->buf_size);
  
  #ifdef UNIV_LOG_ARCHIVE
@@ -318,7 +460,7 @@ diff -ruN a/storage/innodb_plugin/log/log0log.c b/storage/innodb_plugin/log/log0
  	if (log_sys->archiving_state == LOG_ARCH_OFF) {
  		archived_lsn = IB_ULONGLONG_MAX;
  	} else {
-@@ -1804,7 +1807,9 @@
+@@ -1804,7 +1808,9 @@
  
  	mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, archived_lsn);
  #else /* UNIV_LOG_ARCHIVE */
@@ -355,6 +497,35 @@ diff -ruN a/storage/innodb_plugin/log/log0recv.c b/storage/innodb_plugin/log/log
  			checkpoint_no = mach_read_ull(
  				buf + LOG_CHECKPOINT_NO);
  
+@@ -2942,6 +2956,7 @@
+ 	log_group_t*	max_cp_group;
+ 	log_group_t*	up_to_date_group;
+ 	ulint		max_cp_field;
++	ulint		log_hdr_log_block_size;
+ 	ib_uint64_t	checkpoint_lsn;
+ 	ib_uint64_t	checkpoint_no;
+ 	ib_uint64_t	old_scanned_lsn;
+@@ -3043,6 +3058,20 @@
+ 		       log_hdr_buf, max_cp_group);
+ 	}
+ 
++	log_hdr_log_block_size
++		= mach_read_from_4(log_hdr_buf + LOG_FILE_OS_FILE_LOG_BLOCK_SIZE);
++	if (log_hdr_log_block_size == 0) {
++		/* 0 means default value */
++		log_hdr_log_block_size = 512;
++	}
++	if (log_hdr_log_block_size != srv_log_block_size) {
++		fprintf(stderr,
++			"InnoDB: Error: The block size of ib_logfile (%lu) "
++			"is not equal to innodb_log_block_size.\n",
++			log_hdr_log_block_size);
++		return(DB_ERROR);
++	}
++
+ #ifdef UNIV_LOG_ARCHIVE
+ 	group = UT_LIST_GET_FIRST(log_sys->log_groups);
+ 
 diff -ruN a/storage/innodb_plugin/page/page0zip.c b/storage/innodb_plugin/page/page0zip.c
 --- a/storage/innodb_plugin/page/page0zip.c	2010-08-27 16:40:36.584058988 +0900
 +++ b/storage/innodb_plugin/page/page0zip.c	2010-08-27 16:44:21.709058243 +0900
@@ -382,7 +553,7 @@ diff -ruN a/storage/innodb_plugin/row/row0merge.c b/storage/innodb_plugin/row/ro
 diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c
 --- a/storage/innodb_plugin/srv/srv0srv.c	2010-08-27 16:43:11.968059077 +0900
 +++ b/storage/innodb_plugin/srv/srv0srv.c	2010-08-27 16:44:21.716988122 +0900
-@@ -217,6 +217,10 @@
+@@ -217,6 +217,13 @@
  UNIV_INTERN ulint	srv_n_read_io_threads	= ULINT_MAX;
  UNIV_INTERN ulint	srv_n_write_io_threads	= ULINT_MAX;
  
@@ -390,13 +561,16 @@ diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0
 +UNIV_INTERN ulint	srv_page_size_shift	= 0;
 +UNIV_INTERN ulint	srv_page_size		= 0;
 +
++/* The log block size */
++UNIV_INTERN ulint	srv_log_block_size	= 0;
++
  /* User settable value of the number of pages that must be present
  in the buffer cache and accessed sequentially for InnoDB to trigger a
  readahead request. */
 diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/srv0start.c
 --- a/storage/innodb_plugin/srv/srv0start.c	2010-08-27 16:40:36.602058774 +0900
 +++ b/storage/innodb_plugin/srv/srv0start.c	2010-08-27 16:44:21.720021228 +0900
-@@ -1486,10 +1486,12 @@
+@@ -1506,10 +1506,12 @@
  	}
  #endif /* UNIV_LOG_ARCHIVE */
  
@@ -411,7 +585,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/sr
  
  		return(DB_ERROR);
  	}
-@@ -1498,7 +1500,7 @@
+@@ -1518,7 +1520,7 @@
  
  	for (i = 0; i < srv_n_data_files; i++) {
  #ifndef __WIN__
diff --git a/mysql-innodb_fix_misc.patch b/mysql-innodb_fix_misc.patch
index 1c78be2..d95d662 100644
--- a/mysql-innodb_fix_misc.patch
+++ b/mysql-innodb_fix_misc.patch
@@ -8,7 +8,7 @@
 diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 --- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:50:59.626327847 +0900
 +++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:55:20.281021252 +0900
-@@ -11735,7 +11735,7 @@
+@@ -11783,7 +11783,7 @@
    &innobase_storage_engine,
    innobase_hton_name,
    "Innobase Oy",
@@ -22,10 +22,10 @@ diff -ruN a/storage/innodb_plugin/include/univ.i b/storage/innodb_plugin/include
 +++ b/storage/innodb_plugin/include/univ.i	2010-04-30 16:41:46.000000000 +0900
 @@ -48,6 +48,11 @@
  #define INNODB_VERSION_MINOR	0
- #define INNODB_VERSION_BUGFIX	13
+ #define INNODB_VERSION_BUGFIX	15
  
 +#ifndef PERCONA_INNODB_VERSION
-+#define PERCONA_INNODB_VERSION 12.1
++#define PERCONA_INNODB_VERSION 12.5
 +#endif
 +
 +
@@ -51,10 +51,30 @@ diff -ruN a/storage/innodb_plugin/include/univ.i b/storage/innodb_plugin/include
  
  #define REFMAN "http://dev.mysql.com/doc/refman/5.1/en/"
  
+diff -ruN a/storage/innodb_plugin/mtr/mtr0log.c b/storage/innodb_plugin/mtr/mtr0log.c
+--- a/storage/innodb_plugin/mtr/mtr0log.c	2010-11-29 19:38:03.000000000 +0900
++++ b/storage/innodb_plugin/mtr/mtr0log.c	2011-02-02 23:31:34.000000000 +0900
+@@ -408,7 +408,7 @@
+ 	ptr += 2;
+ 
+ 	if (UNIV_UNLIKELY(offset >= UNIV_PAGE_SIZE)
+-			|| UNIV_UNLIKELY(len + offset) > UNIV_PAGE_SIZE) {
++			|| UNIV_UNLIKELY(len + offset > UNIV_PAGE_SIZE)) {
+ 		recv_sys->found_corrupt_log = TRUE;
+ 
+ 		return(NULL);
 diff -ruN a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/row0mysql.c
 --- a/storage/innodb_plugin/row/row0mysql.c	2010-07-20 16:33:04.097866666 +0900
 +++ b/storage/innodb_plugin/row/row0mysql.c	2010-07-20 16:33:53.995828763 +0900
-@@ -1134,6 +1134,13 @@
+@@ -51,6 +51,7 @@
+ #include "btr0sea.h"
+ #include "fil0fil.h"
+ #include "ibuf0ibuf.h"
++#include "ha_prototypes.h"
+ 
+ /** Provide optional 4.x backwards compatibility for 5.0 and above */
+ UNIV_INTERN ibool	row_rollback_on_timeout	= FALSE;
+@@ -1135,6 +1136,13 @@
  
  	thr = que_fork_get_first_thr(prebuilt->ins_graph);
  
@@ -71,7 +91,7 @@ diff -ruN a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/ro
 diff -ruN a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0sel.c
 --- a/storage/innodb_plugin/row/row0sel.c	2010-07-20 16:33:04.204866103 +0900
 +++ b/storage/innodb_plugin/row/row0sel.c	2010-07-20 16:33:53.998864025 +0900
-@@ -3362,6 +3362,7 @@
+@@ -3374,6 +3374,7 @@
  	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
  	ulint*		offsets				= offsets_;
  	ibool		table_lock_waited		= FALSE;
@@ -79,7 +99,7 @@ diff -ruN a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0
  
  	rec_offs_init(offsets_);
  
-@@ -3728,6 +3729,15 @@
+@@ -3740,6 +3741,15 @@
  
  	/* Do some start-of-statement preparations */
  
@@ -95,7 +115,7 @@ diff -ruN a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0
  	if (!prebuilt->sql_stat_start) {
  		/* No need to set an intention lock or assign a read view */
  
-@@ -3738,6 +3748,14 @@
+@@ -3750,6 +3760,14 @@
  			      " perform a consistent read\n"
  			      "InnoDB: but the read view is not assigned!\n",
  			      stderr);
@@ -113,7 +133,7 @@ diff -ruN a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0
 diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/srv0start.c
 --- a/storage/innodb_plugin/srv/srv0start.c	2010-04-30 16:37:05.000000000 +0900
 +++ b/storage/innodb_plugin/srv/srv0start.c	2010-04-30 16:41:46.000000000 +0900
-@@ -1967,7 +1967,7 @@
+@@ -2006,7 +2006,7 @@
  	if (srv_print_verbose_log) {
  		ut_print_timestamp(stderr);
  		fprintf(stderr,
diff --git a/mysql-innodb_lru_dump_restore.patch b/mysql-innodb_lru_dump_restore.patch
index f2222b4..e0efec9 100644
--- a/mysql-innodb_lru_dump_restore.patch
+++ b/mysql-innodb_lru_dump_restore.patch
@@ -5,10 +5,44 @@
 #!!! notice !!!
 # Any small change to this file in the main branch
 # should be done or reviewed by the maintainer!
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ b/mysql-test/suite/innodb_plugin/r/percona_bug692211.result	2010-12-22 20:48:19.000000000 +0300
+@@ -0,0 +1,7 @@
++#
++# LP bug #692211: innodb_auto_lru_dump crashes if ib_lru_dump doesn't 
++#                 exist
++#
++SELECT @@innodb_auto_lru_dump;
++@@innodb_auto_lru_dump
++300
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ b/mysql-test/suite/innodb_plugin/t/percona_bug692211-master.opt	2010-12-22 20:25:59.000000000 +0300
+@@ -0,0 +1 @@
++--innodb_auto_lru_dump=300
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ b/mysql-test/suite/innodb_plugin/t/percona_bug692211.test	2010-12-22 20:17:57.000000000 +0300
+@@ -0,0 +1,17 @@
++--source include/have_innodb_plugin.inc
++
++--echo #
++--echo # LP bug #692211: innodb_auto_lru_dump crashes if ib_lru_dump doesn't 
++--echo #                 exist
++--echo #
++
++SELECT @@innodb_auto_lru_dump;
++
++# We want to check that the server does not crash on startup when there is no 
++# ib_lru_dump in the datadir. If we are here, we have already started up
++# successfully. So we only have to check that there is no ib_lru_dump in the 
++# datadir.
++
++--let $MYSQLD_DATADIR= `SELECT @@datadir`
++--error 1
++--file_exists $MYSQLD_DATADIR/ib_lru_dump;
 diff -ruN a/storage/innodb_plugin/buf/buf0lru.c b/storage/innodb_plugin/buf/buf0lru.c
 --- a/storage/innodb_plugin/buf/buf0lru.c	2010-08-27 16:13:11.070058073 +0900
 +++ b/storage/innodb_plugin/buf/buf0lru.c	2010-08-27 16:34:33.860400549 +0900
-@@ -2122,6 +2122,278 @@
+@@ -2130,6 +2130,277 @@
  	memset(&buf_LRU_stat_cur, 0, sizeof buf_LRU_stat_cur);
  }
  
@@ -155,7 +189,7 @@ diff -ruN a/storage/innodb_plugin/buf/buf0lru.c b/storage/innodb_plugin/buf/buf0
 +	ulint		req = 0;
 +	ibool		terminated = FALSE;
 +	ibool		ret = FALSE;
-+	dump_record_t*	records;
++	dump_record_t*	records = NULL;
 +	ulint		size;
 +	ulint		size_high;
 +	ulint		length;
@@ -251,8 +285,7 @@ diff -ruN a/storage/innodb_plugin/buf/buf0lru.c b/storage/innodb_plugin/buf/buf0
 +			continue;
 +		}
 +
-+		if (fil_area_is_exist(space_id, zip_size, page_no, 0,
-+				      zip_size ? zip_size : UNIV_PAGE_SIZE)) {
++		if (fil_is_exist(space_id, page_no)) {
 +
 +			tablespace_version = fil_space_get_version(space_id);
 +
@@ -302,7 +335,7 @@ diff -ruN a/storage/innodb_plugin/buf/buf0rea.c b/storage/innodb_plugin/buf/buf0
 diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0fil.c
 --- a/storage/innodb_plugin/fil/fil0fil.c	2010-08-27 16:32:40.298411400 +0900
 +++ b/storage/innodb_plugin/fil/fil0fil.c	2010-08-27 16:34:33.868058362 +0900
-@@ -4869,6 +4869,78 @@
+@@ -4915,6 +4915,70 @@
  	return(DB_SUCCESS);
  }
  
@@ -310,18 +343,10 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
 +Confirm whether the parameters are valid or not */
 +UNIV_INTERN
 +ibool
-+fil_area_is_exist(
++fil_is_exist(
 +/*==============*/
 +	ulint	space_id,	/*!< in: space id */
-+	ulint	zip_size,	/*!< in: compressed page size in bytes;
-+				0 for uncompressed pages */
-+	ulint	block_offset,	/*!< in: offset in number of blocks */
-+	ulint	byte_offset,	/*!< in: remainder of offset in bytes; in
-+				aio this must be divisible by the OS block
-+				size */
-+	ulint	len)		/*!< in: how many bytes to read or write; this
-+				must not cross a file boundary; in aio this
-+				must be a block size multiple */
++	ulint	block_offset)	/*!< in: offset in number of blocks */
 +{
 +	fil_space_t*	space;
 +	fil_node_t*	node;
@@ -384,7 +409,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
 diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 --- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-10-01 09:57:56.486228425 +0900
 +++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-10-01 10:00:13.292228546 +0900
-@@ -11471,6 +11471,12 @@
+@@ -11486,6 +11486,12 @@
    "Limit the allocated memory for dictionary cache. (0: unlimited)",
    NULL, NULL, 0, 0, LONG_MAX, 0);
  
@@ -397,7 +422,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  static struct st_mysql_sys_var* innobase_system_variables[]= {
    MYSQL_SYSVAR(additional_mem_pool_size),
    MYSQL_SYSVAR(autoextend_increment),
-@@ -11553,6 +11559,7 @@
+@@ -11568,6 +11574,7 @@
  #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
    MYSQL_SYSVAR(read_ahead_threshold),
    MYSQL_SYSVAR(io_capacity),
@@ -416,7 +441,7 @@ diff -ruN a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler
  }
  
  static const char plugin_author[] = "Innobase Oy";
-@@ -3041,6 +3042,36 @@
+@@ -3040,6 +3041,36 @@
  			"Hello!");
  		goto end_func;
  	}
@@ -529,7 +554,7 @@ diff -ruN a/storage/innodb_plugin/include/buf0rea.h b/storage/innodb_plugin/incl
 diff -ruN a/storage/innodb_plugin/include/fil0fil.h b/storage/innodb_plugin/include/fil0fil.h
 --- a/storage/innodb_plugin/include/fil0fil.h	2010-08-27 16:32:40.315012507 +0900
 +++ b/storage/innodb_plugin/include/fil0fil.h	2010-08-27 16:34:33.878063455 +0900
-@@ -643,6 +643,22 @@
+@@ -643,6 +643,14 @@
  	void*	message,	/*!< in: message for aio handler if non-sync
  				aio used, else ignored */
  	trx_t*	trx);
@@ -537,18 +562,10 @@ diff -ruN a/storage/innodb_plugin/include/fil0fil.h b/storage/innodb_plugin/incl
 +Confirm whether the parameters are valid or not */
 +UNIV_INTERN
 +ibool
-+fil_area_is_exist(
++fil_is_exist(
 +/*==============*/
 +	ulint	space_id,	/*!< in: space id */
-+	ulint	zip_size,	/*!< in: compressed page size in bytes;
-+				0 for uncompressed pages */
-+	ulint	block_offset,	/*!< in: offset in number of blocks */
-+	ulint	byte_offset,	/*!< in: remainder of offset in bytes; in
-+				aio this must be divisible by the OS block
-+				size */
-+	ulint	len);		/*!< in: how many bytes to read or write; this
-+				must not cross a file boundary; in aio this
-+				must be a block size multiple */
++	ulint	block_offset);	/*!< in: offset in number of blocks */
  /**********************************************************************//**
  Waits for an aio operation to complete. This function is used to write the
  handler for completed requests. The aio array of pending requests is divided
@@ -667,7 +684,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/sr
  
  /** We use this mutex to test the return value of pthread_mutex_trylock
     on successful locking. HP-UX does NOT return 0, though Linux et al do. */
-@@ -1680,6 +1680,10 @@
+@@ -1700,6 +1700,10 @@
  	os_thread_create(&srv_monitor_thread, NULL,
  			 thread_ids + 4 + SRV_MAX_N_IO_THREADS);
  
@@ -678,7 +695,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/sr
  	srv_is_being_started = FALSE;
  
  	if (trx_doublewrite == NULL) {
-@@ -1704,13 +1708,13 @@
+@@ -1724,13 +1728,13 @@
  		ulint i;
  
  		os_thread_create(&srv_purge_thread, NULL, thread_ids
diff --git a/mysql-innodb_overwrite_relay_log_info.patch b/mysql-innodb_overwrite_relay_log_info.patch
index 2e79440..4346c98 100644
--- a/mysql-innodb_overwrite_relay_log_info.patch
+++ b/mysql-innodb_overwrite_relay_log_info.patch
@@ -256,7 +256,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  static MYSQL_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
    PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
    "Enable InnoDB doublewrite buffer (enabled by default). "
-@@ -11138,6 +11336,7 @@
+@@ -11140,6 +11338,7 @@
    MYSQL_SYSVAR(old_blocks_pct),
    MYSQL_SYSVAR(old_blocks_time),
    MYSQL_SYSVAR(open_files),
diff --git a/mysql-innodb_pass_corrupt_table.patch b/mysql-innodb_pass_corrupt_table.patch
index 5647416..3fce911 100644
--- a/mysql-innodb_pass_corrupt_table.patch
+++ b/mysql-innodb_pass_corrupt_table.patch
@@ -228,7 +228,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
  	page = buf_block_get_frame(block);
  	index = cursor->index;
  	zip_size = buf_block_get_zip_size(block);
-@@ -2904,6 +2979,11 @@
+@@ -2895,6 +2970,11 @@
  
  	block = btr_cur_get_block(cursor);
  
@@ -240,7 +240,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
  	ut_ad(page_is_leaf(buf_block_get_frame(block)));
  
  	rec = btr_cur_get_rec(cursor);
-@@ -3551,6 +3631,11 @@
+@@ -3540,6 +3620,11 @@
  
  		page = btr_cur_get_page(&cursor);
  
@@ -397,7 +397,7 @@ diff -ruN a/storage/innodb_plugin/buf/buf0buf.c b/storage/innodb_plugin/buf/buf0
  		to the 4 first bytes of the page end lsn field */
  
 @@ -3484,6 +3509,19 @@
- 			      REFMAN "forcing-recovery.html\n"
+ 			      REFMAN "forcing-innodb-recovery.html\n"
  			      "InnoDB: about forcing recovery.\n", stderr);
  
 +			if (srv_pass_corrupt_table && !trx_sys_sys_space(bpage->space)
@@ -471,16 +471,16 @@ diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/
  
  #include <ctype.h>
  
-@@ -704,7 +705,7 @@
+@@ -734,7 +735,7 @@
+ 
  	mutex_exit(&(dict_sys->mutex));
  
- 	if (table != NULL) {
--		if (!table->stat_initialized) {
-+		if (!table->stat_initialized && !table->is_corrupt) {
- 			/* If table->ibd_file_missing == TRUE, this will
- 			print an error message and return without doing
- 			anything. */
-@@ -1245,7 +1246,7 @@
+-	if (table != NULL) {
++	if (table != NULL && !table->is_corrupt) {
+ 		/* If table->ibd_file_missing == TRUE, this will
+ 		print an error message and return without doing
+ 		anything. */
+@@ -1275,7 +1276,7 @@
  		    + dict_sys->size) > srv_dict_size_limit ) {
  		prev_table = UT_LIST_GET_PREV(table_LRU, table);
  
@@ -489,8 +489,8 @@ diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/
  			goto next_loop;
  
  		cached_foreign_tables = 0;
-@@ -4556,6 +4557,11 @@
- 
+@@ -4593,6 +4594,11 @@
+ 	}
  
  	do {
 +		if (table->is_corrupt) {
@@ -501,8 +501,8 @@ diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/
  		if (UNIV_LIKELY
  		    (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE
  		     || (srv_force_recovery < SRV_FORCE_NO_LOG_REDO
-@@ -5292,4 +5298,42 @@
- 		mutex_free(&dict_index_stat_mutex[i]);
+@@ -5320,4 +5326,42 @@
+ 		rw_lock_free(&dict_table_stats_latches[i]);
  	}
  }
 +
@@ -567,7 +567,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  	UT_LIST_NODE_T(fil_space_t) space_list;
  				/*!< list of all spaces */
  	ulint		magic_n;/*!< FIL_SPACE_MAGIC_N */
-@@ -1242,6 +1243,8 @@
+@@ -1246,6 +1247,8 @@
  		    ut_fold_string(name), space);
  	space->is_in_unflushed_spaces = FALSE;
  
@@ -576,7 +576,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  	UT_LIST_ADD_LAST(space_list, fil_system->space_list, space);
  
  	mutex_exit(&fil_system->mutex);
-@@ -4839,6 +4842,22 @@
+@@ -4893,6 +4896,22 @@
  	ut_a(byte_offset % OS_FILE_LOG_BLOCK_SIZE == 0);
  	ut_a((len % OS_FILE_LOG_BLOCK_SIZE) == 0);
  
@@ -599,7 +599,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  #ifdef UNIV_HOTBACKUP
  	/* In ibbackup do normal i/o, not aio */
  	if (type == OS_FILE_READ) {
-@@ -4853,6 +4872,8 @@
+@@ -4907,6 +4926,8 @@
  	ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
  		     offset_low, offset_high, len, node, message, trx);
  #endif
@@ -608,7 +608,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  	ut_a(ret);
  
  	if (mode == OS_AIO_SYNC) {
-@@ -4999,7 +5020,7 @@
+@@ -5045,7 +5066,7 @@
  
  	if (fil_node->space->purpose == FIL_TABLESPACE) {
  		srv_set_io_thread_op_info(segment, "complete io for buf page");
@@ -617,7 +617,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  	} else {
  		srv_set_io_thread_op_info(segment, "complete io for log");
  		log_io_complete(message);
-@@ -5353,3 +5374,46 @@
+@@ -5399,3 +5420,46 @@
                 return 0;
         }
  }
@@ -738,7 +738,7 @@ diff -ruN a/storage/innodb_plugin/fsp/fsp0fsp.c b/storage/innodb_plugin/fsp/fsp0
  	return(inode);
  }
  
-@@ -3259,6 +3286,11 @@
+@@ -3309,6 +3336,11 @@
  
  	descr = xdes_get_descriptor(space, zip_size, page, mtr);
  
@@ -750,7 +750,7 @@ diff -ruN a/storage/innodb_plugin/fsp/fsp0fsp.c b/storage/innodb_plugin/fsp/fsp0
  	ut_a(descr);
  	if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) {
  		fputs("InnoDB: Dump of the tablespace extent descriptor: ",
-@@ -3511,6 +3543,11 @@
+@@ -3561,6 +3593,11 @@
  
  	descr = xdes_get_descriptor(space, zip_size, header_page, mtr);
  
@@ -762,7 +762,7 @@ diff -ruN a/storage/innodb_plugin/fsp/fsp0fsp.c b/storage/innodb_plugin/fsp/fsp0
  	/* Check that the header resides on a page which has not been
  	freed yet */
  
-@@ -3595,6 +3632,12 @@
+@@ -3645,6 +3682,12 @@
  
  	inode = fseg_inode_get(header, space, zip_size, mtr);
  
@@ -899,7 +899,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  	switch (ret) {
  	case DB_SUCCESS:
  		error = 0;
-@@ -5852,6 +5903,10 @@
+@@ -5857,6 +5908,10 @@
  {
  	DBUG_ENTER("change_active_index");
  
@@ -910,7 +910,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  	ut_ad(user_thd == ha_thd());
  	ut_a(prebuilt->trx == thd_to_trx(user_thd));
  
-@@ -5942,6 +5997,10 @@
+@@ -5947,6 +6002,10 @@
  
  	DBUG_ENTER("general_fetch");
  
@@ -921,7 +921,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  	ut_a(prebuilt->trx == thd_to_trx(user_thd));
  
  	innodb_srv_conc_enter_innodb(prebuilt->trx);
-@@ -5951,6 +6010,10 @@
+@@ -5956,6 +6015,10 @@
  
  	innodb_srv_conc_exit_innodb(prebuilt->trx);
  
@@ -932,7 +932,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  	switch (ret) {
  	case DB_SUCCESS:
  		error = 0;
-@@ -7204,6 +7267,10 @@
+@@ -7214,6 +7277,10 @@
  		DBUG_RETURN(my_errno=HA_ERR_WRONG_COMMAND);
  	}
  
@@ -943,7 +943,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  	/* Truncate the table in InnoDB */
  
  	error = row_truncate_table_for_mysql(prebuilt->table, prebuilt->trx);
-@@ -7212,6 +7279,10 @@
+@@ -7222,6 +7289,10 @@
  		goto fallback;
  	}
  
@@ -954,7 +954,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  	error = convert_error_code_to_mysql(error, prebuilt->table->flags,
  					    NULL);
  
-@@ -7721,6 +7792,16 @@
+@@ -7734,6 +7805,16 @@
  	return(ranges + (double) rows / (double) total_rows * time_for_scan);
  }
  
@@ -971,7 +971,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  /*********************************************************************//**
  Calculates the key number used inside MySQL for an Innobase index. We will
  first check the "index translation table" for a match of the index to get
-@@ -7842,7 +7923,7 @@
+@@ -7855,7 +7936,7 @@
  	ib_table = prebuilt->table;
  
  	if (flag & HA_STATUS_TIME) {
@@ -980,7 +980,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  			/* In sql_show we call with this flag: update
  			then statistics so that they are up-to-date */
  
-@@ -8133,10 +8214,18 @@
+@@ -8146,10 +8227,18 @@
  	THD*		thd,		/*!< in: connection thread handle */
  	HA_CHECK_OPT*	check_opt)	/*!< in: currently ignored */
  {
@@ -999,7 +999,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  	return(0);
  }
  
-@@ -8318,6 +8407,10 @@
+@@ -8331,6 +8420,10 @@
  		my_error(ER_QUERY_INTERRUPTED, MYF(0));
  	}
  
@@ -1010,7 +1010,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  	DBUG_RETURN(is_ok ? HA_ADMIN_OK : HA_ADMIN_CORRUPT);
  }
  
-@@ -9043,6 +9136,10 @@
+@@ -9056,6 +9149,10 @@
  
  	update_thd(thd);
  
@@ -1021,7 +1021,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  	if (prebuilt->table->ibd_file_missing && !thd_tablespace_op(thd)) {
  		ut_print_timestamp(stderr);
  		fprintf(stderr,
-@@ -11485,6 +11582,14 @@
+@@ -11500,6 +11597,14 @@
    "0 (the default) disables automatic dumps.",
    NULL, NULL, 0, 0, UINT_MAX32, 0);
  
@@ -1036,7 +1036,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  static struct st_mysql_sys_var* innobase_system_variables[]= {
    MYSQL_SYSVAR(additional_mem_pool_size),
    MYSQL_SYSVAR(autoextend_increment),
-@@ -11570,6 +11675,7 @@
+@@ -11585,6 +11690,7 @@
    MYSQL_SYSVAR(io_capacity),
    MYSQL_SYSVAR(auto_lru_dump),
    MYSQL_SYSVAR(use_purge_thread),
@@ -1085,9 +1085,9 @@ diff -ruN a/storage/innodb_plugin/include/btr0btr.ic b/storage/innodb_plugin/inc
  #define BTR_MAX_NODE_LEVEL	50	/*!< Maximum B-tree page level
  					(not really a hard limit).
  					Used in debug assertions
-@@ -52,7 +52,9 @@
- 
- 	block = buf_page_get(space, zip_size, page_no, mode, mtr);
+@@ -55,7 +55,9 @@
+ 	block = buf_page_get_gen(space, zip_size, page_no, mode,
+ 				 NULL, BUF_GET, file, line, mtr);
  
 -	if (mode != RW_NO_LATCH) {
 +	ut_a(srv_pass_corrupt_table || block);
@@ -1154,7 +1154,7 @@ diff -ruN a/storage/innodb_plugin/include/buf0buf.ic b/storage/innodb_plugin/inc
 diff -ruN a/storage/innodb_plugin/include/dict0dict.h b/storage/innodb_plugin/include/dict0dict.h
 --- a/storage/innodb_plugin/include/dict0dict.h	2010-08-27 16:22:04.264988090 +0900
 +++ b/storage/innodb_plugin/include/dict0dict.h	2010-08-27 16:39:03.011025333 +0900
-@@ -1201,6 +1201,15 @@
+@@ -1199,6 +1199,15 @@
  dict_close(void);
  /*============*/
  
@@ -1184,7 +1184,7 @@ diff -ruN a/storage/innodb_plugin/include/dict0mem.h b/storage/innodb_plugin/inc
 diff -ruN a/storage/innodb_plugin/include/fil0fil.h b/storage/innodb_plugin/include/fil0fil.h
 --- a/storage/innodb_plugin/include/fil0fil.h	2010-08-27 16:36:03.499987483 +0900
 +++ b/storage/innodb_plugin/include/fil0fil.h	2010-08-27 16:39:03.015021314 +0900
-@@ -747,6 +747,19 @@
+@@ -748,6 +748,19 @@
  fil_system_hash_nodes(void);
  /*========================*/
  
@@ -1326,7 +1326,7 @@ diff -ruN a/storage/innodb_plugin/row/row0merge.c b/storage/innodb_plugin/row/ro
 diff -ruN a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0sel.c
 --- a/storage/innodb_plugin/row/row0sel.c	2010-08-04 02:24:20.000000000 +0900
 +++ b/storage/innodb_plugin/row/row0sel.c	2010-08-27 16:39:03.045021567 +0900
-@@ -3844,6 +3844,13 @@
+@@ -3856,6 +3856,13 @@
  	/* PHASE 4: Look for matching records in a loop */
  
  	rec = btr_pcur_get_rec(pcur);
@@ -1354,7 +1354,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0
 diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/srv0start.c
 --- a/storage/innodb_plugin/srv/srv0start.c	2010-08-27 16:38:38.290021700 +0900
 +++ b/storage/innodb_plugin/srv/srv0start.c	2010-08-27 16:39:03.052021423 +0900
-@@ -1955,6 +1955,13 @@
+@@ -1994,6 +1994,13 @@
  
  	os_fast_mutex_free(&srv_os_test_mutex);
  
diff --git a/mysql-innodb_purge_thread.patch b/mysql-innodb_purge_thread.patch
index 91c860e..fcf951a 100644
--- a/mysql-innodb_purge_thread.patch
+++ b/mysql-innodb_purge_thread.patch
@@ -8,7 +8,7 @@
 diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 --- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:23:31.022060427 +0900
 +++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:25:49.004020662 +0900
-@@ -10974,6 +10974,11 @@
+@@ -10987,6 +10987,11 @@
    "Output statistics of recovery process after it.",
    NULL, NULL, FALSE);
  
@@ -20,7 +20,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  static MYSQL_SYSVAR_BOOL(overwrite_relay_log_info, innobase_overwrite_relay_log_info,
    PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
    "During InnoDB crash recovery on slave overwrite relay-log.info "
-@@ -11495,6 +11500,7 @@
+@@ -11510,6 +11515,7 @@
  #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
    MYSQL_SYSVAR(read_ahead_threshold),
    MYSQL_SYSVAR(io_capacity),
@@ -154,7 +154,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0
  /* if TRUE, then we auto-extend the last data file */
  UNIV_INTERN ibool	srv_auto_extend_last_data_file	= FALSE;
  /* if != 0, this tells the max size auto-extending may increase the
-@@ -2614,10 +2616,10 @@
+@@ -2626,10 +2628,10 @@
  	srv_main_thread_process_no = os_proc_get_number();
  	srv_main_thread_id = os_thread_pf(os_thread_get_curr_id());
  
@@ -166,7 +166,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0
  	srv_n_threads_active[SRV_MASTER]++;
  
  	mutex_exit(&kernel_mutex);
-@@ -2947,6 +2949,7 @@
+@@ -3087,6 +3089,7 @@
  	/* Flush logs if needed */
  	srv_sync_log_buffer_in_background();
  
@@ -174,7 +174,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0
  	/* We run a full purge every 10 seconds, even if the server
  	were active */
  	do {
-@@ -2963,6 +2966,7 @@
+@@ -3103,6 +3106,7 @@
  		srv_sync_log_buffer_in_background();
  
  	} while (n_pages_purged);
@@ -182,7 +182,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0
  
  	srv_main_thread_op_info = "flushing buffer pool pages";
  
-@@ -3031,6 +3035,7 @@
+@@ -3171,6 +3175,7 @@
  		os_thread_sleep(100000);
  	}
  
@@ -190,7 +190,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0
  	srv_main_thread_op_info = "purging";
  
  	/* Run a full purge */
-@@ -3047,6 +3052,7 @@
+@@ -3187,6 +3192,7 @@
  		srv_sync_log_buffer_in_background();
  
  	} while (n_pages_purged);
@@ -198,7 +198,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0
  
  	srv_main_thread_op_info = "reserving kernel mutex";
  
-@@ -3199,3 +3205,143 @@
+@@ -3339,3 +3345,143 @@
  
  	OS_THREAD_DUMMY_RETURN;	/* Not reached, avoid compiler warning */
  }
@@ -357,7 +357,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/sr
  
  /** We use this mutex to test the return value of pthread_mutex_trylock
     on successful locking. HP-UX does NOT return 0, though Linux et al do. */
-@@ -1699,6 +1699,20 @@
+@@ -1719,6 +1719,20 @@
  
  	os_thread_create(&srv_master_thread, NULL, thread_ids
  			 + (1 + SRV_MAX_N_IO_THREADS));
diff --git a/mysql-innodb_separate_doublewrite.patch b/mysql-innodb_separate_doublewrite.patch
index 3247166..4fe5f65 100644
--- a/mysql-innodb_separate_doublewrite.patch
+++ b/mysql-innodb_separate_doublewrite.patch
@@ -67,7 +67,15 @@ diff -ruN a/storage/innodb_plugin/buf/buf0rea.c b/storage/innodb_plugin/buf/buf0
 diff -ruN a/storage/innodb_plugin/dict/dict0load.c b/storage/innodb_plugin/dict/dict0load.c
 --- a/storage/innodb_plugin/dict/dict0load.c	2010-08-27 16:22:04.223059346 +0900
 +++ b/storage/innodb_plugin/dict/dict0load.c	2010-08-27 16:37:55.363104692 +0900
-@@ -395,7 +395,7 @@
+@@ -40,6 +40,7 @@
+ #include "rem0cmp.h"
+ #include "srv0start.h"
+ #include "srv0srv.h"
++#include "trx0sys.h"
+ 
+ /****************************************************************//**
+ Compare the name of an index column.
+@@ -396,7 +397,7 @@
  
  		mtr_commit(&mtr);
  
@@ -76,7 +84,7 @@ diff -ruN a/storage/innodb_plugin/dict/dict0load.c b/storage/innodb_plugin/dict/
  			/* The system tablespace always exists. */
  		} else if (in_crash_recovery) {
  			/* Check that the tablespace (the .ibd file) really
-@@ -903,7 +903,7 @@
+@@ -904,7 +905,7 @@
  	space = mach_read_from_4(field);
  
  	/* Check if the tablespace exists and has the right name */
@@ -85,7 +93,7 @@ diff -ruN a/storage/innodb_plugin/dict/dict0load.c b/storage/innodb_plugin/dict/
  		flags = dict_sys_tables_get_flags(rec);
  
  		if (UNIV_UNLIKELY(flags == ULINT_UNDEFINED)) {
-@@ -956,7 +956,7 @@
+@@ -957,7 +958,7 @@
  	}
  
  	/* See if the tablespace is available. */
@@ -97,7 +105,16 @@ diff -ruN a/storage/innodb_plugin/dict/dict0load.c b/storage/innodb_plugin/dict/
 diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0fil.c
 --- a/storage/innodb_plugin/fil/fil0fil.c	2010-08-27 16:36:03.494411641 +0900
 +++ b/storage/innodb_plugin/fil/fil0fil.c	2010-08-27 16:37:55.367990277 +0900
-@@ -679,14 +679,14 @@
+@@ -617,7 +617,7 @@
+ 
+ 	UT_LIST_ADD_LAST(chain, space->chain, node);
+ 
+-	if (id < SRV_LOG_SPACE_FIRST_ID && fil_system->max_assigned_id < id) {
++	if (id < SRV_EXTRA_SYS_SPACE_FIRST_ID && fil_system->max_assigned_id < id) {
+ 
+ 		fil_system->max_assigned_id = id;
+ 	}
+@@ -680,14 +680,14 @@
  		size_bytes = (((ib_int64_t)size_high) << 32)
  			+ (ib_int64_t)size_low;
  #ifdef UNIV_HOTBACKUP
@@ -114,7 +131,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  
  		if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
  			fprintf(stderr,
-@@ -732,7 +732,7 @@
+@@ -733,7 +733,7 @@
  		}
  
  		if (UNIV_UNLIKELY(space_id == ULINT_UNDEFINED
@@ -123,7 +140,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  			fprintf(stderr,
  				"InnoDB: Error: tablespace id %lu"
  				" in file %s is not sensible\n",
-@@ -794,7 +794,7 @@
+@@ -795,7 +795,7 @@
  
  	system->n_open++;
  
@@ -132,7 +149,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  		/* Put the node to the LRU list */
  		UT_LIST_ADD_FIRST(LRU, system->LRU, node);
  	}
-@@ -827,7 +827,7 @@
+@@ -828,7 +828,7 @@
  	ut_a(system->n_open > 0);
  	system->n_open--;
  
@@ -141,7 +158,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  		ut_a(UT_LIST_GET_LEN(system->LRU) > 0);
  
  		/* The node is in the LRU list, remove it */
-@@ -913,7 +913,7 @@
+@@ -914,7 +914,7 @@
  retry:
  	mutex_enter(&fil_system->mutex);
  
@@ -150,7 +167,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  		/* We keep log files and system tablespace files always open;
  		this is important in preventing deadlocks in this module, as
  		a page read completion often performs another read from the
-@@ -1143,7 +1143,7 @@
+@@ -1145,7 +1145,7 @@
  			" tablespace memory cache!\n",
  			(ulong) space->id);
  
@@ -159,7 +176,24 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  
  			mutex_exit(&fil_system->mutex);
  
-@@ -1552,6 +1552,8 @@
+@@ -1207,6 +1207,7 @@
+ 	space->mark = FALSE;
+ 
+ 	if (UNIV_LIKELY(purpose == FIL_TABLESPACE && !recv_recovery_on)
++	    && UNIV_UNLIKELY(id < SRV_EXTRA_SYS_SPACE_FIRST_ID)
+ 	    && UNIV_UNLIKELY(id > fil_system->max_assigned_id)) {
+ 		if (!fil_system->space_id_reuse_warned) {
+ 			fil_system->space_id_reuse_warned = TRUE;
+@@ -1290,7 +1291,7 @@
+ 			(ulong) SRV_LOG_SPACE_FIRST_ID);
+ 	}
+ 
+-	success = (id < SRV_LOG_SPACE_FIRST_ID);
++	success = (id < SRV_EXTRA_SYS_SPACE_FIRST_ID);
+ 
+ 	if (success) {
+ 		*space_id = fil_system->max_assigned_id = id;
+@@ -1552,6 +1553,8 @@
  	UT_LIST_INIT(fil_system->LRU);
  
  	fil_system->max_n_open = max_n_open;
@@ -168,7 +202,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  }
  
  /*******************************************************************//**
-@@ -1573,7 +1575,7 @@
+@@ -1573,7 +1576,7 @@
  	space = UT_LIST_GET_FIRST(fil_system->space_list);
  
  	while (space != NULL) {
@@ -177,7 +211,63 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  			node = UT_LIST_GET_FIRST(space->chain);
  
  			while (node != NULL) {
-@@ -3736,7 +3738,7 @@
+@@ -1663,6 +1666,10 @@
+ 		ut_error;
+ 	}
+ 
++	if (max_id >= SRV_EXTRA_SYS_SPACE_FIRST_ID) {
++		return;
++	}
++
+ 	mutex_enter(&fil_system->mutex);
+ 
+ 	if (fil_system->max_assigned_id < max_id) {
+@@ -1681,6 +1688,7 @@
+ ulint
+ fil_write_lsn_and_arch_no_to_file(
+ /*==============================*/
++	ulint		space_id,
+ 	ulint		sum_of_sizes,	/*!< in: combined size of previous files
+ 					in space, in database pages */
+ 	ib_uint64_t	lsn,		/*!< in: lsn to write */
+@@ -1690,14 +1698,16 @@
+ 	byte*	buf1;
+ 	byte*	buf;
+ 
++	ut_a(trx_sys_sys_space(space_id));
++
+ 	buf1 = mem_alloc(2 * UNIV_PAGE_SIZE);
+ 	buf = ut_align(buf1, UNIV_PAGE_SIZE);
+ 
+-	fil_read(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
++	fil_read(TRUE, space_id, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
+ 
+ 	mach_write_ull(buf + FIL_PAGE_FILE_FLUSH_LSN, lsn);
+ 
+-	fil_write(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
++	fil_write(TRUE, space_id, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
+ 
+ 	mem_free(buf1);
+ 
+@@ -1733,7 +1743,7 @@
+ 		always open. */
+ 
+ 		if (space->purpose == FIL_TABLESPACE
+-		    && space->id == 0) {
++		    && trx_sys_sys_space(space->id)) {
+ 			sum_of_sizes = 0;
+ 
+ 			node = UT_LIST_GET_FIRST(space->chain);
+@@ -1741,7 +1751,7 @@
+ 				mutex_exit(&fil_system->mutex);
+ 
+ 				err = fil_write_lsn_and_arch_no_to_file(
+-					sum_of_sizes, lsn, arch_log_no);
++					space->id, sum_of_sizes, lsn, arch_log_no);
+ 				if (err != DB_SUCCESS) {
+ 
+ 					return(err);
+@@ -3782,7 +3792,7 @@
  	}
  
  #ifndef UNIV_HOTBACKUP
@@ -186,7 +276,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  		fprintf(stderr,
  			"InnoDB: Error: tablespace id %lu in file %s"
  			" is not sensible\n",
-@@ -3745,7 +3747,7 @@
+@@ -3791,7 +3801,7 @@
  		goto func_exit;
  	}
  #else
@@ -195,7 +285,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  		char*	new_path;
  
  		fprintf(stderr,
-@@ -4566,7 +4568,7 @@
+@@ -4612,7 +4622,7 @@
  	}
  
  	if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
@@ -204,7 +294,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  		/* The node is in the LRU list, remove it */
  
  		ut_a(UT_LIST_GET_LEN(system->LRU) > 0);
-@@ -4612,7 +4614,7 @@
+@@ -4658,7 +4668,7 @@
  	}
  
  	if (node->n_pending == 0 && node->space->purpose == FIL_TABLESPACE
@@ -213,7 +303,7 @@ diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0
  		/* The node must be put back to the LRU list */
  		UT_LIST_ADD_FIRST(LRU, system->LRU, node);
  	}
-@@ -5225,7 +5227,7 @@
+@@ -5263,7 +5273,7 @@
  		ut_a(fil_node->n_pending == 0);
  		ut_a(fil_node->open);
  		ut_a(fil_node->space->purpose == FIL_TABLESPACE);
@@ -267,7 +357,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  	srv_extra_undoslots = (ibool) innobase_extra_undoslots;
  
  	srv_use_sys_stats_table = (ibool) innobase_use_sys_stats_table;
-@@ -11321,6 +11324,11 @@
+@@ -11334,6 +11337,11 @@
    "Path to individual files and their sizes.",
    NULL, NULL, NULL);
  
@@ -279,7 +369,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode,
    PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
    "The AUTOINC lock modes supported by InnoDB:               "
-@@ -11485,6 +11493,7 @@
+@@ -11500,6 +11508,7 @@
    MYSQL_SYSVAR(commit_concurrency),
    MYSQL_SYSVAR(concurrency_tickets),
    MYSQL_SYSVAR(data_file_path),
@@ -332,6 +422,17 @@ diff -ruN a/storage/innodb_plugin/include/srv0srv.h b/storage/innodb_plugin/incl
  extern ibool	srv_extra_undoslots;
  
  extern ibool	srv_recovery_stats;
+diff -ruN a/storage/innodb_plugin/include/srv0start.h b/storage/innodb_plugin/include/srv0start.h
+--- a/storage/innodb_plugin/include/srv0start.h	2010-11-03 22:39:54.000000000 +0900
++++ b/storage/innodb_plugin/include/srv0start.h	2010-12-08 16:16:32.858488565 +0900
+@@ -131,4 +131,7 @@
+ /** Log 'spaces' have id's >= this */
+ #define SRV_LOG_SPACE_FIRST_ID		0xFFFFFFF0UL
+ 
++/** reserved for extra system tables */
++#define SRV_EXTRA_SYS_SPACE_FIRST_ID	0xFFFFFFE0UL
++
+ #endif
 diff -ruN a/storage/innodb_plugin/include/trx0sys.h b/storage/innodb_plugin/include/trx0sys.h
 --- a/storage/innodb_plugin/include/trx0sys.h	2010-08-27 16:08:45.299059235 +0900
 +++ b/storage/innodb_plugin/include/trx0sys.h	2010-08-27 16:37:55.404990159 +0900
@@ -376,7 +477,7 @@ diff -ruN a/storage/innodb_plugin/include/trx0sys.h b/storage/innodb_plugin/incl
  
  /* Space id and page no where the trx system file copy resides */
  #define	TRX_SYS_SPACE	0	/* the SYSTEM tablespace */
-+#define	TRX_DOUBLEWRITE_SPACE	1	/* the doublewrite buffer tablespace if used */
++#define	TRX_DOUBLEWRITE_SPACE	0xFFFFFFE0UL	/* the doublewrite buffer tablespace if used */
 +#define	TRX_SYS_SPACE_MAX	9	/* reserved max space id for system tablespaces */
  #include "fsp0fsp.h"
  #define	TRX_SYS_PAGE_NO	FSP_TRX_SYS_PAGE_NO
@@ -398,7 +499,7 @@ diff -ruN a/storage/innodb_plugin/include/trx0sys.ic b/storage/innodb_plugin/inc
 +{
 +	if (srv_doublewrite_file) {
 +		/* several spaces are reserved */
-+		return((ibool)(space <= TRX_SYS_SPACE_MAX));
++		return((ibool)(space == TRX_SYS_SPACE || space == TRX_DOUBLEWRITE_SPACE));
 +	} else {
 +		return((ibool)(space == TRX_SYS_SPACE));
 +	}
@@ -428,7 +529,7 @@ diff -ruN a/storage/innodb_plugin/include/trx0sys.ic b/storage/innodb_plugin/inc
 diff -ruN a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/row0mysql.c
 --- a/storage/innodb_plugin/row/row0mysql.c	2010-08-27 16:22:04.287058274 +0900
 +++ b/storage/innodb_plugin/row/row0mysql.c	2010-08-27 16:37:55.410993060 +0900
-@@ -3363,7 +3363,7 @@
+@@ -3365,7 +3365,7 @@
  		/* Do not drop possible .ibd tablespace if something went
  		wrong: we do not want to delete valuable data of the user */
  
@@ -619,7 +720,7 @@ diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/sr
  	ibool		log_file_created;
  	ibool		log_created	= FALSE;
  	ibool		log_opened	= FALSE;
-@@ -1381,6 +1520,7 @@
+@@ -1401,6 +1540,7 @@
  	}
  
  	err = open_or_create_data_files(&create_new_db,
@@ -627,21 +728,54 @@ diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/sr
  #ifdef UNIV_LOG_ARCHIVE
  					&min_arch_log_no, &max_arch_log_no,
  #endif /* UNIV_LOG_ARCHIVE */
-@@ -1497,6 +1637,14 @@
+@@ -1524,6 +1664,15 @@
+ 		mtr_commit(&mtr);
  
- 	trx_sys_file_format_init();
+ 		trx_sys_create();
++
++		if (create_new_doublewrite_file) {
++			mtr_start(&mtr);
++			fsp_header_init(TRX_DOUBLEWRITE_SPACE, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, &mtr);
++			mtr_commit(&mtr);
++
++			trx_sys_dummy_create(TRX_DOUBLEWRITE_SPACE);
++		}
++
+ 		dict_create();
+ 		srv_startup_is_before_trx_rollback_phase = FALSE;
  
-+	if (create_new_doublewrite_file) {
-+		mtr_start(&mtr);
-+		fsp_header_init(TRX_DOUBLEWRITE_SPACE, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, &mtr);
-+		mtr_commit(&mtr);
+@@ -1561,6 +1710,13 @@
+ 		recv_recovery_from_archive_finish();
+ #endif /* UNIV_LOG_ARCHIVE */
+ 	} else {
++		char*	save_srv_doublewrite_file = NULL;
 +
-+		trx_sys_dummy_create(TRX_DOUBLEWRITE_SPACE);
-+	}
++		if (create_new_doublewrite_file) {
++			/* doublewrite_file cannot be used for recovery yet. */
++			save_srv_doublewrite_file = srv_doublewrite_file;
++			srv_doublewrite_file = NULL;
++		}
+ 
+ 		/* Check if we support the max format that is stamped
+ 		on the system tablespace. 
+@@ -1647,6 +1803,17 @@
+ 		we have finished the recovery process so that the
+ 		image of TRX_SYS_PAGE_NO is not stale. */
+ 		trx_sys_file_format_tag_init();
 +
- 	if (create_new_db) {
- 		mtr_start(&mtr);
- 		fsp_header_init(0, sum_of_new_sizes, &mtr);
++		if (create_new_doublewrite_file) {
++			/* restore the value */
++			srv_doublewrite_file = save_srv_doublewrite_file;
++
++			mtr_start(&mtr);
++			fsp_header_init(TRX_DOUBLEWRITE_SPACE, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, &mtr);
++			mtr_commit(&mtr);
++
++			trx_sys_dummy_create(TRX_DOUBLEWRITE_SPACE);
++		}
+ 	}
+ 
+ 	if (!create_new_db && sum_of_new_sizes > 0) {
 diff -ruN a/storage/innodb_plugin/trx/trx0sys.c b/storage/innodb_plugin/trx/trx0sys.c
 --- a/storage/innodb_plugin/trx/trx0sys.c	2010-08-27 16:23:31.045058700 +0900
 +++ b/storage/innodb_plugin/trx/trx0sys.c	2010-08-27 16:37:55.421992951 +0900
diff --git a/mysql-innodb_show_enhancements.patch b/mysql-innodb_show_enhancements.patch
index 7d7de8c..f1235b9 100644
--- a/mysql-innodb_show_enhancements.patch
+++ b/mysql-innodb_show_enhancements.patch
@@ -19,7 +19,7 @@ diff -ruN a/storage/innodb_plugin/Makefile.am b/storage/innodb_plugin/Makefile.a
 diff -ruN a/storage/innodb_plugin/Makefile.in b/storage/innodb_plugin/Makefile.in
 --- a/storage/innodb_plugin/Makefile.in	2010-04-06 23:12:58.000000000 +0900
 +++ b/storage/innodb_plugin/Makefile.in	2010-04-29 15:22:39.000000000 +0900
-@@ -786,6 +786,7 @@
+@@ -782,6 +782,7 @@
  			include/ut0vec.h	\
  			include/ut0vec.ic	\
  			include/ut0wqueue.h	\
@@ -220,7 +220,7 @@ diff -ruN a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler
  /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_trx */
  static ST_FIELD_INFO	innodb_trx_fields_info[] =
  {
-@@ -401,10 +564,6 @@
+@@ -409,10 +572,6 @@
  	DBUG_RETURN(0);
  }
  
diff --git a/mysql-innodb_show_lock_name.patch b/mysql-innodb_show_lock_name.patch
index 554d524..71a5d16 100644
--- a/mysql-innodb_show_lock_name.patch
+++ b/mysql-innodb_show_lock_name.patch
@@ -8,7 +8,7 @@
 diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 --- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:29:12.539982446 +0900
 +++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:29:24.322059309 +0900
-@@ -9233,8 +9233,8 @@
+@@ -9246,8 +9246,8 @@
  			rw_lock_wait_time += mutex->lspent_time;
  		}
  #else /* UNIV_DEBUG */
@@ -19,7 +19,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  		buf2len= (uint) my_snprintf(buf2, sizeof(buf2), "os_waits=%lu",
  				     (ulong) mutex->count_os_wait);
  
-@@ -9249,9 +9249,8 @@
+@@ -9262,9 +9262,8 @@
  
  	if (block_mutex) {
  		buf1len = (uint) my_snprintf(buf1, sizeof buf1,
@@ -31,7 +31,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  		buf2len = (uint) my_snprintf(buf2, sizeof buf2,
  					     "os_waits=%lu",
  					     (ulong) block_mutex_oswait_count);
-@@ -9280,8 +9279,8 @@
+@@ -9293,8 +9292,8 @@
  			continue;
  		}
  
@@ -42,7 +42,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  		buf2len = my_snprintf(buf2, sizeof buf2, "os_waits=%lu",
  				      (ulong) lock->count_os_wait);
  
-@@ -9295,9 +9294,8 @@
+@@ -9308,9 +9307,8 @@
  
  	if (block_lock) {
  		buf1len = (uint) my_snprintf(buf1, sizeof buf1,
@@ -67,25 +67,38 @@ diff -ruN a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_p
 diff -ruN a/storage/innodb_plugin/include/sync0rw.h b/storage/innodb_plugin/include/sync0rw.h
 --- a/storage/innodb_plugin/include/sync0rw.h	2010-08-04 02:24:19.000000000 +0900
 +++ b/storage/innodb_plugin/include/sync0rw.h	2010-08-27 16:29:24.325059383 +0900
-@@ -120,7 +120,7 @@
+@@ -113,14 +113,14 @@
+ #ifdef UNIV_DEBUG
+ # ifdef UNIV_SYNC_DEBUG
+ #  define rw_lock_create(L, level) 					\
+-	rw_lock_create_func((L), (level), #L, __FILE__, __LINE__)
++	rw_lock_create_func((L), (level), __FILE__, __LINE__, #L)
+ # else /* UNIV_SYNC_DEBUG */
+ #  define rw_lock_create(L, level) 					\
+-	rw_lock_create_func((L), #L, __FILE__, __LINE__)
++	rw_lock_create_func((L), __FILE__, __LINE__, #L)
  # endif /* UNIV_SYNC_DEBUG */
  #else /* UNIV_DEBUG */
  # define rw_lock_create(L, level) 					\
 -	rw_lock_create_func((L), __FILE__, __LINE__)
-+	rw_lock_create_func((L), #L, NULL, 0)
++	rw_lock_create_func((L), #L)
  #endif /* UNIV_DEBUG */
  
  /******************************************************************//**
-@@ -137,8 +137,8 @@
+@@ -137,10 +137,10 @@
  # ifdef UNIV_SYNC_DEBUG
  	ulint		level,		/*!< in: level */
  # endif /* UNIV_SYNC_DEBUG */
 -	const char*	cmutex_name, 	/*!< in: mutex name */
- #endif /* UNIV_DEBUG */
-+	const char*	cmutex_name, 	/*!< in: mutex name */
+-#endif /* UNIV_DEBUG */
  	const char*	cfile_name,	/*!< in: file name where created */
- 	ulint 		cline);		/*!< in: file line where created */
+-	ulint 		cline);		/*!< in: file line where created */
++	ulint		cline,		/*!< in: file line where created */
++#endif /* UNIV_DEBUG */
++	const char*	cmutex_name);	/*!< in: mutex name */
  /******************************************************************//**
+ Calling this function is obligatory only if the memory buffer containing
+ the rw-lock is freed. Removes an rw-lock object from the global list. The
 @@ -541,7 +541,8 @@
  	ulint	level;		/*!< Level in the global latching order. */
  #endif /* UNIV_SYNC_DEBUG */
@@ -108,25 +121,41 @@ diff -ruN a/storage/innodb_plugin/include/sync0rw.h b/storage/innodb_plugin/incl
 diff -ruN a/storage/innodb_plugin/include/sync0sync.h b/storage/innodb_plugin/include/sync0sync.h
 --- a/storage/innodb_plugin/include/sync0sync.h	2010-08-27 16:13:11.087074844 +0900
 +++ b/storage/innodb_plugin/include/sync0sync.h	2010-08-27 16:29:24.327059254 +0900
-@@ -80,7 +80,7 @@
+@@ -73,14 +73,14 @@
+ #ifdef UNIV_DEBUG
+ # ifdef UNIV_SYNC_DEBUG
+ #  define mutex_create(M, level)					\
+-	mutex_create_func((M), #M, (level), __FILE__, __LINE__)
++	mutex_create_func((M), (level), __FILE__, __LINE__, #M)
+ # else
+ #  define mutex_create(M, level)					\
+-	mutex_create_func((M), #M, __FILE__, __LINE__)
++	mutex_create_func((M), __FILE__, __LINE__, #M)
  # endif
  #else
  # define mutex_create(M, level)					\
 -	mutex_create_func((M), __FILE__, __LINE__)
-+	mutex_create_func((M), #M, NULL, 0)
++	mutex_create_func((M), #M)
  #endif
  
  /******************************************************************//**
-@@ -93,8 +93,8 @@
- mutex_create_func(
+@@ -94,13 +94,13 @@
  /*==============*/
  	mutex_t*	mutex,		/*!< in: pointer to memory */
--#ifdef UNIV_DEBUG
- 	const char*	cmutex_name,	/*!< in: mutex name */
-+#ifdef UNIV_DEBUG
+ #ifdef UNIV_DEBUG
+-	const char*	cmutex_name,	/*!< in: mutex name */
  # ifdef UNIV_SYNC_DEBUG
  	ulint		level,		/*!< in: level */
  # endif /* UNIV_SYNC_DEBUG */
+-#endif /* UNIV_DEBUG */
+ 	const char*	cfile_name,	/*!< in: file name where created */
+-	ulint		cline);		/*!< in: file line where created */
++	ulint		cline,		/*!< in: file line where created */
++#endif /* UNIV_DEBUG */
++	const char*	cmutex_name);	/*!< in: mutex name */
+ 
+ #undef mutex_free			/* Fix for MacOS X */
+ 
 @@ -536,9 +536,9 @@
  	ulint	line;		/*!< Line where the mutex was locked */
  	ulint	level;		/*!< Level in the global latching order */
@@ -182,16 +211,20 @@ diff -ruN a/storage/innodb_plugin/sync/sync0arr.c b/storage/innodb_plugin/sync/s
 diff -ruN a/storage/innodb_plugin/sync/sync0rw.c b/storage/innodb_plugin/sync/sync0rw.c
 --- a/storage/innodb_plugin/sync/sync0rw.c	2010-08-04 02:24:20.000000000 +0900
 +++ b/storage/innodb_plugin/sync/sync0rw.c	2010-08-27 16:29:24.331058289 +0900
-@@ -231,8 +231,8 @@
+@@ -231,10 +231,10 @@
  # ifdef UNIV_SYNC_DEBUG
  	ulint		level,		/*!< in: level */
  # endif /* UNIV_SYNC_DEBUG */
 -	const char*	cmutex_name, 	/*!< in: mutex name */
- #endif /* UNIV_DEBUG */
-+	const char*	cmutex_name, 	/*!< in: mutex name */
+-#endif /* UNIV_DEBUG */
  	const char*	cfile_name,	/*!< in: file name where created */
- 	ulint		cline)		/*!< in: file line where created */
+-	ulint		cline)		/*!< in: file line where created */
++	ulint		cline,		/*!< in: file line where created */
++#endif /* UNIV_DEBUG */
++	const char*	cmutex_name) 	/*!< in: mutex name */
  {
+ 	/* If this is the very first time a synchronization object is
+ 	created, then the following call initializes the sync system. */
 @@ -242,14 +242,15 @@
  #ifndef INNODB_RW_LOCKS_USE_ATOMICS
  	mutex_create(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
@@ -222,7 +255,7 @@ diff -ruN a/storage/innodb_plugin/sync/sync0rw.c b/storage/innodb_plugin/sync/sy
  
  	lock->count_os_wait = 0;
  	lock->last_s_file_name = "not yet reserved";
-@@ -387,10 +387,10 @@
+@@ -390,10 +390,10 @@
  	if (srv_print_latch_waits) {
  		fprintf(stderr,
  			"Thread %lu spin wait rw-s-lock at %p"
@@ -235,7 +268,7 @@ diff -ruN a/storage/innodb_plugin/sync/sync0rw.c b/storage/innodb_plugin/sync/sy
  	}
  
  	/* We try once again to obtain the lock */
-@@ -423,10 +423,9 @@
+@@ -426,10 +426,9 @@
  		if (srv_print_latch_waits) {
  			fprintf(stderr,
  				"Thread %lu OS wait rw-s-lock at %p"
@@ -248,7 +281,7 @@ diff -ruN a/storage/innodb_plugin/sync/sync0rw.c b/storage/innodb_plugin/sync/sy
  		}
  
  		/* these stats may not be accurate */
-@@ -645,9 +644,9 @@
+@@ -648,9 +647,9 @@
  	if (srv_print_latch_waits) {
  		fprintf(stderr,
  			"Thread %lu spin wait rw-x-lock at %p"
@@ -260,7 +293,7 @@ diff -ruN a/storage/innodb_plugin/sync/sync0rw.c b/storage/innodb_plugin/sync/sy
  	}
  
  	sync_array_reserve_cell(sync_primary_wait_array,
-@@ -668,9 +667,9 @@
+@@ -671,9 +670,9 @@
  	if (srv_print_latch_waits) {
  		fprintf(stderr,
  			"Thread %lu OS wait for rw-x-lock at %p"
@@ -275,16 +308,23 @@ diff -ruN a/storage/innodb_plugin/sync/sync0rw.c b/storage/innodb_plugin/sync/sy
 diff -ruN a/storage/innodb_plugin/sync/sync0sync.c b/storage/innodb_plugin/sync/sync0sync.c
 --- a/storage/innodb_plugin/sync/sync0sync.c	2010-08-27 16:13:11.113988290 +0900
 +++ b/storage/innodb_plugin/sync/sync0sync.c	2010-08-27 16:29:24.333058256 +0900
-@@ -238,8 +238,8 @@
- mutex_create_func(
+@@ -239,13 +239,13 @@
  /*==============*/
  	mutex_t*	mutex,		/*!< in: pointer to memory */
--#ifdef UNIV_DEBUG
- 	const char*	cmutex_name,	/*!< in: mutex name */
-+#ifdef UNIV_DEBUG
+ #ifdef UNIV_DEBUG
+-	const char*	cmutex_name,	/*!< in: mutex name */
  # ifdef UNIV_SYNC_DEBUG
  	ulint		level,		/*!< in: level */
  # endif /* UNIV_SYNC_DEBUG */
+-#endif /* UNIV_DEBUG */
+ 	const char*	cfile_name,	/*!< in: file name where created */
+-	ulint		cline)		/*!< in: file line where created */
++	ulint		cline,		/*!< in: file line where created */
++#endif /* UNIV_DEBUG */
++	const char*	cmutex_name)	/*!< in: mutex name */
+ {
+ #if defined(HAVE_ATOMIC_BUILTINS)
+ 	mutex_reset_lock_word(mutex);
 @@ -263,11 +263,13 @@
  	mutex->file_name = "not yet reserved";
  	mutex->level = level;
diff --git a/mysql-innodb_show_status.patch b/mysql-innodb_show_status.patch
index 51df296..2fbaf51 100644
--- a/mysql-innodb_show_status.patch
+++ b/mysql-innodb_show_status.patch
@@ -33,7 +33,7 @@ diff -ruN a/storage/innodb_plugin/buf/buf0buf.c b/storage/innodb_plugin/buf/buf0
 diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0fil.c
 --- a/storage/innodb_plugin/fil/fil0fil.c	2010-04-06 23:07:12.000000000 +0900
 +++ b/storage/innodb_plugin/fil/fil0fil.c	2010-04-29 15:28:56.000000000 +0900
-@@ -4787,3 +4787,30 @@
+@@ -4833,3 +4833,30 @@
  
  	fil_system = NULL;
  }
@@ -115,9 +115,9 @@ diff -ruN a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_p
 diff -ruN a/storage/innodb_plugin/include/fil0fil.h b/storage/innodb_plugin/include/fil0fil.h
 --- a/storage/innodb_plugin/include/fil0fil.h	2010-04-06 23:07:12.000000000 +0900
 +++ b/storage/innodb_plugin/include/fil0fil.h	2010-04-29 15:28:56.000000000 +0900
-@@ -716,6 +716,16 @@
- /*==============*/
- 	const byte*	page);	/*!< in: file page */
+@@ -725,6 +725,17 @@
+ /*============================*/
+ 	ulint		id);	/*!< in: space id */
  
 +/*************************************************************************
 +Return local hash table informations. */
@@ -129,9 +129,10 @@ diff -ruN a/storage/innodb_plugin/include/fil0fil.h b/storage/innodb_plugin/incl
 +ulint
 +fil_system_hash_nodes(void);
 +/*========================*/
- 
++
  typedef	struct fil_space_struct	fil_space_t;
  
+ #endif
 diff -ruN a/storage/innodb_plugin/include/srv0srv.h b/storage/innodb_plugin/include/srv0srv.h
 --- a/storage/innodb_plugin/include/srv0srv.h	2010-04-06 23:07:13.000000000 +0900
 +++ b/storage/innodb_plugin/include/srv0srv.h	2010-04-29 15:28:56.000000000 +0900
@@ -169,7 +170,7 @@ diff -ruN a/storage/innodb_plugin/include/thr0loc.h b/storage/innodb_plugin/incl
 diff -ruN a/storage/innodb_plugin/lock/lock0lock.c b/storage/innodb_plugin/lock/lock0lock.c
 --- a/storage/innodb_plugin/lock/lock0lock.c	2010-04-06 23:07:13.000000000 +0900
 +++ b/storage/innodb_plugin/lock/lock0lock.c	2010-04-29 15:33:51.000000000 +0900
-@@ -4307,6 +4307,7 @@
+@@ -4379,6 +4379,7 @@
  
  	putc('\n', file);
  
@@ -177,7 +178,7 @@ diff -ruN a/storage/innodb_plugin/lock/lock0lock.c b/storage/innodb_plugin/lock/
  	block = buf_page_try_get(space, page_no, &mtr);
  
  	for (i = 0; i < lock_rec_get_n_bits(lock); ++i) {
-@@ -4333,6 +4334,7 @@
+@@ -4405,6 +4406,7 @@
  
  		putc('\n', file);
  	}
@@ -185,7 +186,7 @@ diff -ruN a/storage/innodb_plugin/lock/lock0lock.c b/storage/innodb_plugin/lock/
  
  	mtr_commit(&mtr);
  	if (UNIV_LIKELY_NULL(heap)) {
-@@ -4518,7 +4520,7 @@
+@@ -4590,7 +4592,7 @@
  		}
  	}
  
@@ -194,7 +195,7 @@ diff -ruN a/storage/innodb_plugin/lock/lock0lock.c b/storage/innodb_plugin/lock/
  		nth_trx++;
  		goto loop;
  	}
-@@ -4590,8 +4592,8 @@
+@@ -4662,8 +4664,8 @@
  
  	nth_lock++;
  
@@ -408,7 +409,7 @@ diff -ruN a/storage/innodb_plugin/thr/thr0loc.c b/storage/innodb_plugin/thr/thr0
  
  /** Thread local data */
  typedef struct thr_local_struct thr_local_t;
-@@ -197,6 +198,7 @@
+@@ -216,6 +217,7 @@
  		    os_thread_pf(os_thread_get_curr_id()),
  		    local);
  
@@ -416,7 +417,7 @@ diff -ruN a/storage/innodb_plugin/thr/thr0loc.c b/storage/innodb_plugin/thr/thr0
  	mutex_exit(&thr_local_mutex);
  }
  
-@@ -224,6 +226,7 @@
+@@ -244,6 +246,7 @@
  
  	HASH_DELETE(thr_local_t, hash, thr_local_hash,
  		    os_thread_pf(id), local);
@@ -424,7 +425,7 @@ diff -ruN a/storage/innodb_plugin/thr/thr0loc.c b/storage/innodb_plugin/thr/thr0
  
  	mutex_exit(&thr_local_mutex);
  
-@@ -277,3 +280,29 @@
+@@ -299,3 +302,29 @@
  	hash_table_free(thr_local_hash);
  	thr_local_hash = NULL;
  }
diff --git a/mysql-innodb_show_sys_tables.patch b/mysql-innodb_show_sys_tables.patch
index ca51348..57f98b7 100644
--- a/mysql-innodb_show_sys_tables.patch
+++ b/mysql-innodb_show_sys_tables.patch
@@ -8,7 +8,7 @@
 diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
 --- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:45:46.194411503 +0900
 +++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:49:26.171990559 +0900
-@@ -11758,6 +11758,9 @@
+@@ -11806,6 +11806,9 @@
  i_s_innodb_table_stats,
  i_s_innodb_index_stats,
  i_s_innodb_admin_command,
@@ -29,7 +29,7 @@ diff -ruN a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler
  #include "buf0lru.h" /* for XTRA_LRU_[DUMP/RESTORE] */
  }
  
-@@ -3112,6 +3113,664 @@
+@@ -3111,6 +3112,664 @@
  	STRUCT_FLD(deinit, i_s_common_deinit),
  	STRUCT_FLD(version, 0x0100 /* 1.0 */),
  	STRUCT_FLD(status_vars, NULL),
diff --git a/mysql-innodb_stats.patch b/mysql-innodb_stats.patch
index d1b87d7..5122409 100644
--- a/mysql-innodb_stats.patch
+++ b/mysql-innodb_stats.patch
@@ -117,7 +117,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
  /*==================== B-TREE INSERT =========================*/
  
  /*************************************************************//**
-@@ -3210,6 +3312,154 @@
+@@ -3201,6 +3303,154 @@
  }
  
  /*******************************************************************//**
@@ -272,7 +272,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
  Estimates the number of different key values in a given index, for
  each n-column prefix of the index where n <= dict_index_get_n_unique(index).
  The estimates are stored in the array index->stat_n_diff_key_vals. */
-@@ -3238,18 +3488,40 @@
+@@ -3229,18 +3479,38 @@
  	ulint		offsets_next_rec_[REC_OFFS_NORMAL_SIZE];
  	ulint*		offsets_rec	= offsets_rec_;
  	ulint*		offsets_next_rec= offsets_next_rec_;
@@ -290,11 +290,9 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
 +		effective_pages = btr_estimate_n_pages_not_null(index, 1 /*k*/, first_rec_path);
 +
 +		if (!effective_pages) {
-+			dict_index_stat_mutex_enter(index);
 +			for (j = 0; j <= n_cols; j++) {
 +				index->stat_n_diff_key_vals[j] = (ib_int64_t)index->stat_n_leaf_pages;
 +			}
-+			dict_index_stat_mutex_exit(index);
 +			return;
 +		} else if (effective_pages > index->stat_n_leaf_pages) {
 +			effective_pages = index->stat_n_leaf_pages;
@@ -316,7 +314,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
  		} else {
  			n_sample_pages = 1;
  		}
-@@ -3261,9 +3533,15 @@
+@@ -3252,9 +3522,15 @@
  
  	for (i = 0; i < n_sample_pages; i++) {
  		rec_t*	supremum;
@@ -332,7 +330,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
  
  		/* Count the number of different key values for each prefix of
  		the key on this index page. If the prefix does not determine
-@@ -3274,7 +3552,13 @@
+@@ -3265,7 +3541,13 @@
  		page = btr_cur_get_page(&cursor);
  
  		supremum = page_get_supremum_rec(page);
@@ -346,7 +344,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
  
  		if (rec != supremum) {
  			not_empty_flag = 1;
-@@ -3283,7 +3567,8 @@
+@@ -3274,7 +3556,8 @@
  		}
  
  		while (rec != supremum) {
@@ -356,7 +354,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
  			if (next_rec == supremum) {
  				break;
  			}
-@@ -3297,7 +3582,10 @@
+@@ -3288,7 +3571,10 @@
  			cmp_rec_rec_with_match(rec, next_rec,
  					       offsets_rec, offsets_next_rec,
  					       index, &matched_fields,
@@ -368,7 +366,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
  
  			for (j = matched_fields + 1; j <= n_cols; j++) {
  				/* We add one if this index record has
-@@ -3360,7 +3648,7 @@
+@@ -3349,7 +3635,7 @@
  	for (j = 0; j <= n_cols; j++) {
  		index->stat_n_diff_key_vals[j]
  			= ((n_diff[j]
@@ -377,7 +375,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
  			    + n_sample_pages - 1
  			    + total_external_size
  			    + not_empty_flag)
-@@ -3375,7 +3663,7 @@
+@@ -3364,7 +3650,7 @@
  		different key values, or even more. Let us try to approximate
  		that: */
  
@@ -386,7 +384,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
  			/ (10 * (n_sample_pages
  				 + total_external_size));
  
-@@ -3384,6 +3672,15 @@
+@@ -3373,6 +3659,15 @@
  		}
  
  		index->stat_n_diff_key_vals[j] += add_on;
@@ -401,7 +399,7 @@ diff -ruN a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0
 +		}
  	}
  
- 	dict_index_stat_mutex_exit(index);
+ 	mem_free(n_diff);
 diff -ruN a/storage/innodb_plugin/dict/dict0boot.c b/storage/innodb_plugin/dict/dict0boot.c
 --- a/storage/innodb_plugin/dict/dict0boot.c	2010-08-27 16:11:12.152990021 +0900
 +++ b/storage/innodb_plugin/dict/dict0boot.c	2010-08-27 16:16:49.202982244 +0900
@@ -738,16 +736,16 @@ diff -ruN a/storage/innodb_plugin/dict/dict0crea.c b/storage/innodb_plugin/dict/
 diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/dict0dict.c
 --- a/storage/innodb_plugin/dict/dict0dict.c	2010-08-27 16:11:12.155144214 +0900
 +++ b/storage/innodb_plugin/dict/dict0dict.c	2010-08-27 16:16:49.213982476 +0900
-@@ -708,7 +708,7 @@
- 			/* If table->ibd_file_missing == TRUE, this will
- 			print an error message and return without doing
- 			anything. */
--			dict_update_statistics(table);
-+			dict_update_statistics(table, FALSE);
- 		}
+@@ -739,7 +739,7 @@
+ 		print an error message and return without doing
+ 		anything. */
+ 		dict_update_statistics(table, TRUE /* only update stats
+-				       if they have not been initialized */);
++				       if they have not been initialized */, FALSE);
  	}
  
-@@ -4246,6 +4246,259 @@
+ 	return(table);
+@@ -4276,6 +4276,255 @@
  }
  
  /*********************************************************************//**
@@ -870,11 +868,9 @@ diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/
 +	btr_pcur_close(&pcur);
 +	mtr_commit(&mtr);
 +
-+	dict_index_stat_mutex_enter(index);
 +	for (i = 0; i <= n_cols; i++) {
 +		index->stat_n_diff_key_vals[i] = stat_n_diff_key_vals_tmp[i];
 +	}
-+	dict_index_stat_mutex_exit(index);
 +}
 +/*===========================================*/
 +
@@ -928,11 +924,9 @@ diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/
 +	n_cols = dict_index_get_n_unique(index);
 +	stat_n_diff_key_vals_tmp = mem_heap_zalloc(heap, (n_cols + 1) * sizeof(ib_int64_t));
 +
-+	dict_index_stat_mutex_enter(index);
 +	for (i = 0; i <= n_cols; i++) {
 +		stat_n_diff_key_vals_tmp[i] = index->stat_n_diff_key_vals[i];
 +	}
-+	dict_index_stat_mutex_exit(index);
 +
 +	sys_stats = dict_sys->sys_stats;
 +	sys_index = UT_LIST_GET_FIRST(sys_stats->indexes);
@@ -959,8 +953,8 @@ diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/
 +		    || ut_dulint_cmp(mach_read_from_8(rec_get_nth_field_old(rec, 0, &len)),
 +				     index->id)) {
 +			/* not found */
-+			btr_pcur_close(&pcur);
-+			mtr_commit(&mtr);
++
++
 +			break;
 +		}
 +
@@ -1007,23 +1001,26 @@ diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/
  Calculates new estimates for table and index statistics. The statistics
  are used in query optimization. */
  UNIV_INTERN
-@@ -4253,9 +4506,10 @@
- dict_update_statistics_low(
- /*=======================*/
+@@ -4283,10 +4532,11 @@
+ dict_update_statistics(
+ /*===================*/
  	dict_table_t*	table,		/*!< in/out: table */
--	ibool		has_dict_mutex __attribute__((unused)))
-+	ibool		has_dict_mutex __attribute__((unused)),
- 					/*!< in: TRUE if the caller has the
- 					dictionary mutex */
+-	ibool		only_calc_if_missing_stats)/*!< in: only
++	ibool		only_calc_if_missing_stats,	/*!< in: only
+ 					update/recalc the stats if they have
+ 					not been initialized yet, otherwise
+ 					do nothing */
 +	ibool		sync)		/*!< in: TRUE if must update SYS_STATS */
  {
  	dict_index_t*	index;
  	ulint		sum_of_index_sizes	= 0;
-@@ -4272,6 +4526,23 @@
+@@ -4303,6 +4553,27 @@
  		return;
  	}
  
 +	if (srv_use_sys_stats_table && !((table->flags >> DICT_TF2_SHIFT) & DICT_TF2_TEMPORARY) && !sync) {
++		dict_table_stats_lock(table, RW_X_LATCH);
++
 +		/* reload statistics from SYS_STATS table */
 +		if (dict_reload_statistics(table, &sum_of_index_sizes)) {
 +			/* success */
@@ -1033,6 +1030,8 @@ diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/
 +#endif
 +			goto end;
 +		}
++
++		dict_table_stats_unlock(table, RW_X_LATCH);
 +	}
 +#ifdef UNIV_DEBUG
 +	fprintf(stderr, "InnoDB: DEBUG: update_statistics for %s.\n",
@@ -1043,7 +1042,7 @@ diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/
  	/* Find out the sizes of the indexes and how many different values
  	for the key they approximately have */
  
-@@ -4326,6 +4597,11 @@
+@@ -4363,6 +4634,11 @@
  		index = dict_table_get_next_index(index);
  	} while (index);
  
@@ -1054,41 +1053,25 @@ diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/
 +end:
  	index = dict_table_get_first_index(table);
  
- 	dict_index_stat_mutex_enter(index);
-@@ -4352,9 +4628,10 @@
- void
- dict_update_statistics(
- /*===================*/
--	dict_table_t*	table)	/*!< in/out: table */
-+	dict_table_t*	table,	/*!< in/out: table */
-+	ibool		sync)
- {
--	dict_update_statistics_low(table, FALSE);
-+	dict_update_statistics_low(table, FALSE, sync);
- }
- 
- /**********************************************************************//**
-@@ -4434,7 +4711,8 @@
+ 	table->stat_n_rows = index->stat_n_diff_key_vals[
+@@ -4457,7 +4733,7 @@
  
  	ut_ad(mutex_own(&(dict_sys->mutex)));
  
--	dict_update_statistics_low(table, TRUE);
-+	if (srv_stats_auto_update)
-+		dict_update_statistics_low(table, TRUE, FALSE);
+-	dict_update_statistics(table, FALSE /* update even if initialized */);
++	dict_update_statistics(table, FALSE /* update even if initialized */, FALSE);
+ 
+ 	dict_table_stats_lock(table, RW_S_LATCH);
  
- 	fprintf(stderr,
- 		"--------------------------------------\n"
 diff -ruN a/storage/innodb_plugin/dict/dict0load.c b/storage/innodb_plugin/dict/dict0load.c
 --- a/storage/innodb_plugin/dict/dict0load.c	2010-08-04 02:24:19.000000000 +0900
 +++ b/storage/innodb_plugin/dict/dict0load.c	2010-08-27 16:16:49.218982387 +0900
-@@ -221,8 +221,8 @@
- 			/* The table definition was corrupt if there
- 			is no index */
- 
--			if (dict_table_get_first_index(table)) {
--				dict_update_statistics_low(table, TRUE);
-+			if (srv_stats_auto_update && dict_table_get_first_index(table)) {
-+				dict_update_statistics_low(table, TRUE, FALSE);
+@@ -223,7 +223,7 @@
+ 
+ 			if (dict_table_get_first_index(table)) {
+ 				dict_update_statistics(table, FALSE /* update
+-						       even if initialized */);
++						       even if initialized */, FALSE);
  			}
  
  			dict_table_print_low(table);
@@ -1145,19 +1128,31 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  	innodb_srv_conc_exit_innodb(trx);
  
  	error = convert_error_code_to_mysql(
-@@ -5897,6 +5912,11 @@
+@@ -5688,6 +5703,11 @@
  	case DB_SUCCESS:
  		error = 0;
  		table->status = 0;
 +#ifdef EXTENDED_FOR_USERSTAT
 +		rows_read++;
-+		if (active_index >= 0 && active_index < MAX_KEY)
++		if (active_index < MAX_KEY)
++			index_rows_read[active_index]++;
++#endif
+ 		break;
+ 	case DB_RECORD_NOT_FOUND:
+ 		error = HA_ERR_KEY_NOT_FOUND;
+@@ -5897,6 +5917,11 @@
+ 	case DB_SUCCESS:
+ 		error = 0;
+ 		table->status = 0;
++#ifdef EXTENDED_FOR_USERSTAT
++		rows_read++;
++		if (active_index < MAX_KEY)
 +			index_rows_read[active_index]++;
 +#endif
  		break;
  	case DB_RECORD_NOT_FOUND:
  		error = HA_ERR_END_OF_FILE;
-@@ -7783,9 +7803,29 @@
+@@ -7791,11 +7816,31 @@
  			/* In sql_show we call with this flag: update
  			then statistics so that they are up-to-date */
  
@@ -1183,12 +1178,14 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
 +
  			prebuilt->trx->op_info = "updating table statistics";
  
--			dict_update_statistics(ib_table);
-+			dict_update_statistics(ib_table, called_from_analyze);
+ 			dict_update_statistics(ib_table,
+ 					       FALSE /* update even if stats
+-						     are initialized */);
++						     are initialized */, called_from_analyze);
  
  			prebuilt->trx->op_info = "returning various info to MySQL";
  		}
-@@ -7858,7 +7898,7 @@
+@@ -7873,7 +7918,7 @@
  		are asked by MySQL to avoid locking. Another reason to
  		avoid the call is that it uses quite a lot of CPU.
  		See Bug#38185. */
@@ -1197,7 +1194,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  			/* We do not update delete_length if no
  			locking is requested so the "old" value can
  			remain. delete_length is initialized to 0 in
-@@ -11045,6 +11085,45 @@
+@@ -11053,6 +11098,45 @@
    "The number of index pages to sample when calculating statistics (default 8)",
    NULL, NULL, 8, 1, ~0ULL, 0);
  
@@ -1243,7 +1240,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
  static MYSQL_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
    PLUGIN_VAR_OPCMDARG,
    "Enable InnoDB adaptive hash index (enabled by default).  "
-@@ -11361,6 +11440,10 @@
+@@ -11371,6 +11455,10 @@
    MYSQL_SYSVAR(overwrite_relay_log_info),
    MYSQL_SYSVAR(rollback_on_timeout),
    MYSQL_SYSVAR(stats_on_metadata),
@@ -1254,7 +1251,7 @@ diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/h
    MYSQL_SYSVAR(stats_sample_pages),
    MYSQL_SYSVAR(adaptive_hash_index),
    MYSQL_SYSVAR(replication_delay),
-@@ -11425,6 +11508,8 @@
+@@ -11435,6 +11523,8 @@
  i_s_innodb_cmp_reset,
  i_s_innodb_cmpmem,
  i_s_innodb_cmpmem_reset,
@@ -1274,7 +1271,7 @@ diff -ruN a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler
  }
  
  static const char plugin_author[] = "Innobase Oy";
-@@ -2603,3 +2604,347 @@
+@@ -2602,3 +2603,347 @@
  	/* void* */
  	STRUCT_FLD(__reserved1, NULL)
  };
@@ -1743,28 +1740,20 @@ diff -ruN a/storage/innodb_plugin/include/dict0crea.h b/storage/innodb_plugin/in
 diff -ruN a/storage/innodb_plugin/include/dict0dict.h b/storage/innodb_plugin/include/dict0dict.h
 --- a/storage/innodb_plugin/include/dict0dict.h	2010-08-27 16:11:12.177142545 +0900
 +++ b/storage/innodb_plugin/include/dict0dict.h	2010-08-27 16:16:49.263981911 +0900
-@@ -1056,8 +1056,9 @@
- dict_update_statistics_low(
- /*=======================*/
- 	dict_table_t*	table,		/*!< in/out: table */
--	ibool		has_dict_mutex);/*!< in: TRUE if the caller has the
-+	ibool		has_dict_mutex,	/*!< in: TRUE if the caller has the
- 					dictionary mutex */
-+	ibool		sync);
- /*********************************************************************//**
- Calculates new estimates for table and index statistics. The statistics
- are used in query optimization. */
-@@ -1065,7 +1066,8 @@
- void
+@@ -1057,10 +1057,11 @@
  dict_update_statistics(
  /*===================*/
--	dict_table_t*	table);	/*!< in/out: table */
-+	dict_table_t*	table,	/*!< in/out: table */
+ 	dict_table_t*	table,		/*!< in/out: table */
+-	ibool		only_calc_if_missing_stats);/*!< in: only
++	ibool		only_calc_if_missing_stats,	/*!< in: only
+ 					update/recalc the stats if they have
+ 					not been initialized yet, otherwise
+ 					do nothing */
 +	ibool		sync);
  /********************************************************************//**
  Reserves the dictionary system mutex for MySQL. */
  UNIV_INTERN
-@@ -1176,6 +1178,7 @@
+@@ -1175,6 +1176,7 @@
  	dict_table_t*	sys_columns;	/*!< SYS_COLUMNS table */
  	dict_table_t*	sys_indexes;	/*!< SYS_INDEXES table */
  	dict_table_t*	sys_fields;	/*!< SYS_FIELDS table */
@@ -2046,16 +2035,16 @@ diff -ruN a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/ro
  	/* Calculate new statistics if 1 / 16 of table has been modified
  	since the last time a statistics batch was run, or if
  	stat_modified_counter > 2 000 000 000 (to avoid wrap-around).
-@@ -871,7 +874,7 @@
- 	if (counter > 2000000000
+@@ -872,7 +875,7 @@
  	    || ((ib_int64_t)counter > 16 + table->stat_n_rows / 16)) {
  
--		dict_update_statistics(table);
-+		dict_update_statistics(table, TRUE);
+ 		dict_update_statistics(table, FALSE /* update even if stats
+-						    are initialized */);
++						    are initialized */, TRUE);
  	}
  }
  
-@@ -2045,6 +2048,45 @@
+@@ -2046,6 +2049,45 @@
  }
  
  /*********************************************************************//**
@@ -2101,16 +2090,16 @@ diff -ruN a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/ro
  Scans a table create SQL string and adds to the data dictionary
  the foreign key constraints declared in the string. This function
  should be called after the indexes for a table have been created.
-@@ -2964,7 +3006,7 @@
- 	dict_table_autoinc_lock(table);
+@@ -2966,7 +3008,7 @@
  	dict_table_autoinc_initialize(table, 1);
  	dict_table_autoinc_unlock(table);
--	dict_update_statistics(table);
-+	dict_update_statistics(table, TRUE);
+ 	dict_update_statistics(table, FALSE /* update even if stats are
+-					    initialized */);
++					    initialized */, TRUE);
  
  	trx_commit_for_mysql(trx);
  
-@@ -3266,6 +3308,8 @@
+@@ -3268,6 +3310,8 @@
  			   "       IF (SQL % NOTFOUND) THEN\n"
  			   "               found := 0;\n"
  			   "       ELSE\n"
diff --git a/mysql-innodb_swap_builtin_plugin.patch b/mysql-innodb_swap_builtin_plugin.patch
index d130fb7..efd83d4 100644
--- a/mysql-innodb_swap_builtin_plugin.patch
+++ b/mysql-innodb_swap_builtin_plugin.patch
@@ -6,6 +6,114 @@
 # Any small change to this file in the main branch
 # should be done or reviewed by the maintainer!
 diff -ruN a/configure b/configure
+--- a/configure	2010-04-06 23:13:20.000000000 +0900
++++ b/configure	2010-04-28 19:12:59.000000000 +0900
+@@ -2056,13 +2056,13 @@
+    === InnoDB Storage Engine ===
+   Plugin Name:      innobase
+   Description:      Transactional Tables using InnoDB
+-  Supports build:   static and dynamic
++  Supports build:   dynamic
+   Configurations:   max, max-no-ndb
+ 
+    === InnoDB Storage Engine ===
+   Plugin Name:      innodb_plugin
+   Description:      Transactional Tables using InnoDB
+-  Supports build:   dynamic
++  Supports build:   static and dynamic
+   Configurations:   max, max-no-ndb
+ 
+    === MyISAM Storage Engine ===
+@@ -41806,7 +41806,8 @@
+ 
+ 
+ 
+-      mysql_plugin_innobase=yes
++      { $as_echo "$as_me:$LINENO: WARNING: InnoDB Storage Engine can only be built as a plugin" >&5
++$as_echo "$as_me: WARNING: InnoDB Storage Engine can only be built as a plugin" >&2;}
+ 
+ 
+ 
+@@ -41818,8 +41819,7 @@
+ 
+ 
+ 
+-      { $as_echo "$as_me:$LINENO: WARNING: InnoDB Storage Engine can only be built as a plugin" >&5
+-$as_echo "$as_me: WARNING: InnoDB Storage Engine can only be built as a plugin" >&2;}
++      mysql_plugin_innodb_plugin=yes
+ 
+ 
+ 
+@@ -43107,7 +43107,7 @@
+     { $as_echo "$as_me:$LINENO: result: no" >&5
+ $as_echo "no" >&6; }
+   else
+-
++    with_plugin_innobase=''
+     if test "X$mysql_plugin_innobase" != Xyes -a \
+             "X$with_plugin_innobase" != Xyes; then
+ 
+@@ -43133,20 +43133,11 @@
+     else
+ 
+ 
+-
+-         mysql_use_plugin_dir="storage/innobase"
+-         mysql_plugin_libs="$mysql_plugin_libs \$(top_builddir)/storage/innobase/libinnobase.a"
+-
+-
+-
+-        cat >>confdefs.h <<\_ACEOF
+-#define WITH_INNOBASE_STORAGE_ENGINE 1
+-_ACEOF
+-
+-
+-       plugin_innobase_static_target="libinnobase.a"
+-
+-       plugin_innobase_shared_target=""
++        { $as_echo "$as_me:$LINENO: result: error" >&5
++$as_echo "error" >&6; }
++        { { $as_echo "$as_me:$LINENO: error: Plugin innobase does not support static linking" >&5
++$as_echo "$as_me: error: Plugin innobase does not support static linking" >&2;}
++   { (exit 1); exit 1; }; }
+ 
+ 
+       mysql_plugin_defs="$mysql_plugin_defs, builtin_innobase_plugin"
+@@ -43234,7 +43225,7 @@
+     { $as_echo "$as_me:$LINENO: result: no" >&5
+ $as_echo "no" >&6; }
+   else
+-    with_plugin_innodb_plugin=''
++
+     if test "X$mysql_plugin_innodb_plugin" != Xyes -a \
+             "X$with_plugin_innodb_plugin" != Xyes; then
+ 
+@@ -43260,11 +43251,20 @@
+     else
+ 
+ 
+-        { $as_echo "$as_me:$LINENO: result: error" >&5
+-$as_echo "error" >&6; }
+-        { { $as_echo "$as_me:$LINENO: error: Plugin innodb_plugin does not support static linking" >&5
+-$as_echo "$as_me: error: Plugin innodb_plugin does not support static linking" >&2;}
+-   { (exit 1); exit 1; }; }
++
++         mysql_use_plugin_dir="storage/innodb_plugin"
++         mysql_plugin_libs="$mysql_plugin_libs \$(top_builddir)/storage/innodb_plugin/libinnobase.a"
++
++
++
++        cat >>confdefs.h <<\_ACEOF
++#define WITH_INNODB_PLUGIN_STORAGE_ENGINE 1
++_ACEOF
++
++
++       plugin_innodb_plugin_static_target="libinnobase.a"
++
++       plugin_innodb_plugin_shared_target=""
+ 
+ 
+       mysql_plugin_defs="$mysql_plugin_defs, builtin_innodb_plugin_plugin"
 diff -ruN a/mysql-test/include/have_innodb_plugin.inc b/mysql-test/include/have_innodb_plugin.inc
 --- a/mysql-test/include/have_innodb_plugin.inc	2010-05-07 00:59:10.000000000 +0900
 +++ b/mysql-test/include/have_innodb_plugin.inc	2010-05-25 18:12:49.000000000 +0900
@@ -56,7 +164,7 @@ diff -ruN a/mysql-test/include/read_many_rows.inc b/mysql-test/include/read_many
 diff -ruN a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm
 --- a/mysql-test/lib/mtr_cases.pm	2010-07-09 21:34:53.000000000 +0900
 +++ b/mysql-test/lib/mtr_cases.pm	2010-07-26 21:23:05.378120605 +0900
-@@ -939,7 +939,7 @@
+@@ -944,7 +944,7 @@
      push(@{$tinfo->{'slave_opt'}}, "--loose-federated");
    }
  
@@ -65,7 +173,7 @@ diff -ruN a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm
    {
      # This is a test that needs innodb
      if ( $::mysqld_variables{'innodb'} eq "OFF" ||
-@@ -951,36 +951,6 @@
+@@ -956,36 +956,6 @@
        return $tinfo;
      }
    }
@@ -153,10 +261,10 @@ diff -ruN a/storage/innobase/plug.in b/storage/innobase/plug.in
 diff -ruN a/storage/innodb_plugin/plug.in b/storage/innodb_plugin/plug.in
 --- a/storage/innodb_plugin/plug.in	2010-04-06 23:07:14.000000000 +0900
 +++ b/storage/innodb_plugin/plug.in	2010-04-28 19:12:59.000000000 +0900
-@@ -17,6 +17,7 @@
- MYSQL_STORAGE_ENGINE(innodb_plugin,, [InnoDB Storage Engine],
-         [Transactional Tables using InnoDB], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(innodb_plugin, [storage/innodb_plugin])
+@@ -20,6 +20,6 @@
+ # Enable if you know what you are doing (trying to link both InnoDB and
+ # InnoDB Plugin statically into MySQL does not work).
+-#MYSQL_PLUGIN_STATIC(innodb_plugin, [libinnobase.a])
 +MYSQL_PLUGIN_STATIC(innodb_plugin,   [libinnobase.a])
  MYSQL_PLUGIN_DYNAMIC(innodb_plugin,  [ha_innodb_plugin.la])
  MYSQL_PLUGIN_ACTIONS(innodb_plugin,  [
diff --git a/mysql-optimizer_fix.patch b/mysql-optimizer_fix.patch
index 55e95c8..ea64000 100644
--- a/mysql-optimizer_fix.patch
+++ b/mysql-optimizer_fix.patch
@@ -20,7 +20,7 @@ diff -ruN /dev/null b/patch_info/optimizer_fix.info
 diff -ruN a/sql/mysql_priv.h b/sql/mysql_priv.h
 --- a/sql/mysql_priv.h	2010-07-26 18:29:12.224113574 +0900
 +++ b/sql/mysql_priv.h	2010-07-26 18:29:35.697144981 +0900
-@@ -2080,6 +2080,7 @@
+@@ -2105,6 +2105,7 @@
  extern ulong slave_exec_mode_options;
  extern my_bool opt_readonly, lower_case_file_system;
  extern my_bool opt_userstat_running, opt_thread_statistics;
@@ -31,7 +31,7 @@ diff -ruN a/sql/mysql_priv.h b/sql/mysql_priv.h
 diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
 --- a/sql/mysqld.cc	2010-07-26 18:29:12.238109757 +0900
 +++ b/sql/mysqld.cc	2010-07-26 18:29:35.687113582 +0900
-@@ -534,6 +534,7 @@
+@@ -532,6 +532,7 @@
  #endif /* defined(ENABLED_DEBUG_SYNC) */
  my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
  my_bool opt_userstat_running= 0, opt_thread_statistics= 0;
@@ -39,7 +39,7 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
  /*
    True if there is at least one per-hour limit for some user, so we should
    check them before each query (and possibly reset counters when hour is
-@@ -5833,6 +5834,7 @@
+@@ -5825,6 +5826,7 @@
    OPT_SLOW_QUERY_LOG_FILE,
    OPT_USERSTAT_RUNNING,
    OPT_THREAD_STATISTICS,
@@ -47,7 +47,7 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
    OPT_USE_GLOBAL_LONG_QUERY_TIME,
    OPT_USE_GLOBAL_LOG_SLOW_CONTROL,
    OPT_SLOW_QUERY_LOG_MICROSECONDS_TIMESTAMP,
-@@ -7333,6 +7335,10 @@
+@@ -7326,6 +7328,10 @@
     "Control TABLE_STATISTICS running, when userstat_running is enabled",
     (uchar**) &opt_thread_statistics, (uchar**) &opt_thread_statistics,
     0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
@@ -148,7 +148,7 @@ diff -ruN a/sql/opt_range.cc b/sql/opt_range.cc
 diff -ruN a/sql/set_var.cc b/sql/set_var.cc
 --- a/sql/set_var.cc	2010-07-26 18:29:12.250113584 +0900
 +++ b/sql/set_var.cc	2010-07-26 18:29:35.724113196 +0900
-@@ -560,6 +560,8 @@
+@@ -561,6 +561,8 @@
  						     &opt_userstat_running);
  static sys_var_bool_ptr		sys_thread_statistics(&vars, "thread_statistics",
  						      &opt_thread_statistics);
@@ -160,7 +160,7 @@ diff -ruN a/sql/set_var.cc b/sql/set_var.cc
 diff -ruN a/sql/sql_select.cc b/sql/sql_select.cc
 --- a/sql/sql_select.cc	2010-07-26 18:23:40.015145156 +0900
 +++ b/sql/sql_select.cc	2010-07-26 18:29:35.743144611 +0900
-@@ -2596,6 +2596,11 @@
+@@ -2597,6 +2597,11 @@
        table->reginfo.impossible_range=1;
        DBUG_RETURN(0);
      }
diff --git a/mysql-query_cache_enhance.patch b/mysql-query_cache_enhance.patch
index fcc79b3..82ee320 100644
--- a/mysql-query_cache_enhance.patch
+++ b/mysql-query_cache_enhance.patch
@@ -26,7 +26,7 @@ diff -ruN a/patch_info/query_cache_enhance.patch b/patch_info/query_cache_enhanc
 diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
 --- a/sql/mysqld.cc	2010-07-28 16:47:41.134069529 +0400
 +++ b/sql/mysqld.cc	2010-07-28 16:47:41.704071184 +0400
-@@ -527,6 +527,7 @@
+@@ -525,6 +525,7 @@
  my_bool opt_log_slow_slave_statements= 0;
  my_bool opt_log_slow_sp_statements= 0;
  my_bool opt_log_slow_timestamp_every= 0;
@@ -34,7 +34,7 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
  my_bool opt_use_global_long_query_time= 0;
  my_bool opt_slow_query_log_microseconds_timestamp= 0;
  my_bool lower_case_file_system= 0;
-@@ -5882,6 +5883,7 @@
+@@ -5874,6 +5875,7 @@
    OPT_THREAD_STATISTICS,
    OPT_OPTIMIZER_FIX,
    OPT_SUPPRESS_LOG_WARNING_1592,
@@ -42,7 +42,7 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
    OPT_USE_GLOBAL_LONG_QUERY_TIME,
    OPT_USE_GLOBAL_LOG_SLOW_CONTROL,
    OPT_SLOW_QUERY_LOG_MICROSECONDS_TIMESTAMP,
-@@ -6935,6 +6937,10 @@
+@@ -6928,6 +6930,10 @@
    {"use_global_log_slow_control", OPT_USE_GLOBAL_LOG_SLOW_CONTROL,
      "Choose flags, wich always use the global variables. Multiple flags allowed in a comma-separated string. [none, log_slow_filter, log_slow_rate_limit, log_slow_verbosity, long_query_time, min_examined_row_limit, all]",
     0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_UG_NONE, 0, 0},
@@ -56,7 +56,7 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
 diff -ruN a/sql/mysql_priv.h b/sql/mysql_priv.h
 --- a/sql/mysql_priv.h	2010-07-28 16:47:41.144071083 +0400
 +++ b/sql/mysql_priv.h	2010-07-28 16:47:41.714068826 +0400
-@@ -2088,6 +2088,7 @@
+@@ -2113,6 +2113,7 @@
  extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
  extern my_bool opt_log_slow_sp_statements;
  extern my_bool opt_log_slow_timestamp_every;
@@ -119,7 +119,7 @@ diff -ruN a/sql/set_var.cc b/sql/set_var.cc
  static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
  static void fix_max_binlog_size(THD *thd, enum_var_type type);
  static void fix_max_relay_log_size(THD *thd, enum_var_type type);
-@@ -570,9 +572,6 @@
+@@ -571,9 +573,6 @@
                                                &SV::div_precincrement);
  static sys_var_long_ptr	sys_rpl_recovery_rank(&vars, "rpl_recovery_rank",
  					      &rpl_recovery_rank);
@@ -129,7 +129,7 @@ diff -ruN a/sql/set_var.cc b/sql/set_var.cc
  
  static sys_var_thd_ulong	sys_range_alloc_block_size(&vars, "range_alloc_block_size",
  						   &SV::range_alloc_block_size);
-@@ -638,14 +637,20 @@
+@@ -639,14 +638,20 @@
                                              NULL);
  
  #ifdef HAVE_QUERY_CACHE
@@ -155,7 +155,7 @@ diff -ruN a/sql/set_var.cc b/sql/set_var.cc
  static sys_var_thd_bool
  sys_query_cache_wlock_invalidate(&vars, "query_cache_wlock_invalidate",
  				 &SV::query_cache_wlock_invalidate);
-@@ -929,6 +934,8 @@
+@@ -930,6 +935,8 @@
  #ifndef EMBEDDED_LIBRARY
  static sys_var_const_str_ptr    sys_repl_report_host(&vars, "report_host", &report_host);
  static sys_var_const_str_ptr    sys_repl_report_user(&vars, "report_user", &report_user);
@@ -164,7 +164,7 @@ diff -ruN a/sql/set_var.cc b/sql/set_var.cc
  static sys_var_const_str_ptr    sys_repl_report_password(&vars, "report_password", &report_password);
  
  static uchar *slave_get_report_port(THD *thd)
-@@ -1239,10 +1246,9 @@
+@@ -1240,10 +1247,9 @@
  {}
  #endif /* HAVE_REPLICATION */
  
@@ -176,7 +176,7 @@ diff -ruN a/sql/set_var.cc b/sql/set_var.cc
    ulong new_cache_size= query_cache.resize(query_cache_size);
  
    /*
-@@ -1256,11 +1262,35 @@
+@@ -1257,11 +1263,35 @@
  			query_cache_size, new_cache_size);
    
    query_cache_size= new_cache_size;
@@ -214,7 +214,7 @@ diff -ruN a/sql/set_var.cc b/sql/set_var.cc
  static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type)
  {
    query_cache_min_res_unit= 
-@@ -3634,6 +3664,16 @@
+@@ -3619,6 +3649,16 @@
    Functions to handle SET mysql_internal_variable=const_expr
  *****************************************************************************/
  
@@ -833,7 +833,7 @@ diff -ruN a/mysql-test/t/query_cache_disabled.test b/mysql-test/t/query_cache_di
 diff -ruN a/sql/set_var.h b/sql/set_var.h
 --- a/sql/set_var.h	2010-07-31 20:42:00.884030418 +0400
 +++ b/sql/set_var.h	2010-07-31 20:41:47.224016185 +0400
-@@ -519,10 +519,16 @@
+@@ -521,10 +521,16 @@
    { chain_sys_var(chain); }
    bool check(THD *thd, set_var *var)
    {
diff --git a/mysql-show_temp_51.patch b/mysql-show_temp_51.patch
index cef6796..3e67c02 100644
--- a/mysql-show_temp_51.patch
+++ b/mysql-show_temp_51.patch
@@ -8,7 +8,7 @@
 diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
 --- a/sql/mysqld.cc	2010-08-27 15:24:41.663411604 +0900
 +++ b/sql/mysqld.cc	2010-08-27 15:30:36.942106886 +0900
-@@ -3233,6 +3233,7 @@
+@@ -3225,6 +3225,7 @@
    {"show_table_status",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
    {"show_tables",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLES]), SHOW_LONG_STATUS},
    {"show_thread_statistics",(char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_THREAD_STATS]), SHOW_LONG_STATUS},
@@ -50,7 +50,7 @@ diff -ruN a/sql/sql_parse.cc b/sql/sql_parse.cc
    case SCH_VIEWS:
    case SCH_TRIGGERS:
    case SCH_EVENTS:
-@@ -2317,6 +2322,7 @@
+@@ -2318,6 +2323,7 @@
    }
    case SQLCOM_SHOW_DATABASES:
    case SQLCOM_SHOW_TABLES:
@@ -58,7 +58,7 @@ diff -ruN a/sql/sql_parse.cc b/sql/sql_parse.cc
    case SQLCOM_SHOW_TRIGGERS:
    case SQLCOM_SHOW_TABLE_STATUS:
    case SQLCOM_SHOW_OPEN_TABLES:
-@@ -5457,6 +5463,8 @@
+@@ -5472,6 +5478,8 @@
  
    case SCH_TABLE_NAMES:
    case SCH_TABLES:
@@ -70,7 +70,7 @@ diff -ruN a/sql/sql_parse.cc b/sql/sql_parse.cc
 diff -ruN a/sql/sql_show.cc b/sql/sql_show.cc
 --- a/sql/sql_show.cc	2010-08-27 15:19:09.955989654 +0900
 +++ b/sql/sql_show.cc	2010-08-27 15:30:36.959020753 +0900
-@@ -3038,6 +3038,7 @@
+@@ -3032,6 +3032,7 @@
      break;
    case SQLCOM_SHOW_TABLES:
    case SQLCOM_SHOW_TABLE_STATUS:
@@ -78,7 +78,7 @@ diff -ruN a/sql/sql_show.cc b/sql/sql_show.cc
    case SQLCOM_SHOW_TRIGGERS:
    case SQLCOM_SHOW_EVENTS:
      thd->make_lex_string(&lookup_field_values->db_value, 
-@@ -3514,6 +3515,228 @@
+@@ -3508,6 +3509,228 @@
    return (uint) OPEN_FULL_TABLE;
  }
  
@@ -307,7 +307,7 @@ diff -ruN a/sql/sql_show.cc b/sql/sql_show.cc
  
  /**
    @brief          Fill I_S table with data from FRM file only
-@@ -6595,6 +6818,25 @@
+@@ -6616,6 +6839,25 @@
    {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
  };
  
@@ -333,7 +333,7 @@ diff -ruN a/sql/sql_show.cc b/sql/sql_show.cc
  
  ST_FIELD_INFO columns_fields_info[]=
  {
-@@ -7255,6 +7497,9 @@
+@@ -7276,6 +7518,9 @@
     fill_schema_files, 0, 0, -1, -1, 0, 0},
    {"GLOBAL_STATUS", variables_fields_info, create_schema_table,
     fill_status, make_old_format, 0, 0, -1, 0, 0},
@@ -343,7 +343,7 @@ diff -ruN a/sql/sql_show.cc b/sql/sql_show.cc
    {"GLOBAL_VARIABLES", variables_fields_info, create_schema_table,
     fill_variables, make_old_format, 0, 0, -1, 0, 0},
    {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
-@@ -7298,6 +7543,9 @@
+@@ -7319,6 +7564,9 @@
     get_all_tables, make_table_names_old_format, 0, 1, 2, 1, 0},
    {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
     fill_schema_table_privileges, 0, 0, -1, -1, 0, 0},
diff --git a/mysql-slow_extended.patch b/mysql-slow_extended.patch
index 45622df..2d6f974 100644
--- a/mysql-slow_extended.patch
+++ b/mysql-slow_extended.patch
@@ -6,8 +6,8 @@
 # Any small change to this file in the main branch
 # should be done or reviewed by the maintainer!
 diff -ruN a/include/mysql/plugin.h b/include/mysql/plugin.h
---- a/include/mysql/plugin.h	2010-08-04 02:24:32.000000000 +0900
-+++ b/include/mysql/plugin.h	2010-08-27 14:30:34.805156443 +0900
+--- a/include/mysql/plugin.h	2010-11-29 13:38:00.000000000 +0300
++++ b/include/mysql/plugin.h	2010-12-24 13:57:45.000000000 +0300
 @@ -694,6 +694,17 @@
  /* Increments the row counter, see THD::row_count */
  void thd_inc_row_count(MYSQL_THD thd);
@@ -27,8 +27,8 @@ diff -ruN a/include/mysql/plugin.h b/include/mysql/plugin.h
    Create a temporary file.
  
 diff -ruN a/include/mysql/plugin.h.pp b/include/mysql/plugin.h.pp
---- a/include/mysql/plugin.h.pp	2010-08-04 02:24:22.000000000 +0900
-+++ b/include/mysql/plugin.h.pp	2010-08-27 14:30:34.805156443 +0900
+--- a/include/mysql/plugin.h.pp	2010-11-29 13:38:05.000000000 +0300
++++ b/include/mysql/plugin.h.pp	2010-12-24 13:57:45.000000000 +0300
 @@ -122,6 +122,16 @@
  char *thd_security_context(void* thd, char *buffer, unsigned int length,
                             unsigned int max_query_len);
@@ -47,8 +47,8 @@ diff -ruN a/include/mysql/plugin.h.pp b/include/mysql/plugin.h.pp
  int thd_killed(const void* thd);
  unsigned long thd_get_thread_id(const void* thd);
 diff -ruN /dev/null b/patch_info/slow_extended.info
---- /dev/null	1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/slow_extended.info	2010-08-27 14:30:34.806092638 +0900
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ b/patch_info/slow_extended.info	2010-12-24 13:57:45.000000000 +0300
 @@ -0,0 +1,24 @@
 +File=slow_extended.patch
 +Name=Extended statistics in slow.log (not InnoDB part)
@@ -75,33 +75,33 @@ diff -ruN /dev/null b/patch_info/slow_extended.info
 +6) Change variable types (system/command-line)
 +
 diff -ruN a/scripts/mysqldumpslow.sh b/scripts/mysqldumpslow.sh
---- a/scripts/mysqldumpslow.sh	2010-08-04 02:24:31.000000000 +0900
-+++ b/scripts/mysqldumpslow.sh	2010-08-27 14:30:34.807102514 +0900
-@@ -83,8 +83,8 @@
+--- a/scripts/mysqldumpslow.sh	2010-11-29 13:38:13.000000000 +0300
++++ b/scripts/mysqldumpslow.sh	2010-12-24 13:57:45.000000000 +0300
+@@ -101,8 +101,8 @@
      s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
      my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
  
 -    s/^# Query_time: ([0-9.]+)\s+Lock_time: ([0-9.]+)\s+Rows_sent: ([0-9.]+).*\n//;
 -    my ($t, $l, $r) = ($1, $2, $3);
 +    s/^# Query_time: (\d+(\.\d+)?)  Lock_time: (\d+(\.\d+)?)  Rows_sent: (\d+(\.\d+)?).*\n//;
-+    my ($t, $l, $r) = ($1, $3, $5);
++    my ($t, $l, $r)= ($1, $3, $5);
      $t -= $l unless $opt{l};
  
      # remove fluff that mysqld writes to log when it (re)starts:
 diff -ruN a/sql/event_scheduler.cc b/sql/event_scheduler.cc
---- a/sql/event_scheduler.cc	2010-08-04 02:24:26.000000000 +0900
-+++ b/sql/event_scheduler.cc	2010-08-27 14:30:34.809063761 +0900
+--- a/sql/event_scheduler.cc	2010-11-29 13:38:10.000000000 +0300
++++ b/sql/event_scheduler.cc	2010-12-24 13:57:45.000000000 +0300
 @@ -193,6 +193,7 @@
    thd->client_capabilities|= CLIENT_MULTI_RESULTS;
    pthread_mutex_lock(&LOCK_thread_count);
    thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
-+  thd->write_to_slow_log = TRUE;
++  thd->write_to_slow_log= TRUE;
    pthread_mutex_unlock(&LOCK_thread_count);
  
    /*
 diff -ruN a/sql/filesort.cc b/sql/filesort.cc
---- a/sql/filesort.cc	2010-08-04 02:24:26.000000000 +0900
-+++ b/sql/filesort.cc	2010-08-27 14:30:34.811058646 +0900
+--- a/sql/filesort.cc	2010-11-29 13:38:10.000000000 +0300
++++ b/sql/filesort.cc	2010-12-24 13:57:45.000000000 +0300
 @@ -190,6 +190,7 @@
    {
      status_var_increment(thd->status_var.filesort_scan_count);
@@ -127,8 +127,8 @@ diff -ruN a/sql/filesort.cc b/sql/filesort.cc
    {
      killed= &not_killable;
 diff -ruN a/sql/log.cc b/sql/log.cc
---- a/sql/log.cc	2010-08-04 02:24:19.000000000 +0900
-+++ b/sql/log.cc	2010-08-27 14:30:34.817058569 +0900
+--- a/sql/log.cc	2010-11-29 13:37:59.000000000 +0300
++++ b/sql/log.cc	2010-12-24 14:18:38.000000000 +0300
 @@ -524,11 +524,13 @@
  */
  
@@ -195,7 +195,7 @@ diff -ruN a/sql/log.cc b/sql/log.cc
      }
      else
      {
-@@ -1010,8 +1026,20 @@
+@@ -1010,8 +1026,21 @@
        query_length= command_name[thd->command].length;
      }
  
@@ -203,6 +203,7 @@ diff -ruN a/sql/log.cc b/sql/log.cc
 +    {
 +      thd->sent_row_count= thd->examined_row_count= 0;
 +      thd->row_count= 0;
++      thd->orig_row_count= 0;
 +      thd->bytes_sent_old= thd->status_var.bytes_sent;
 +      thd->tmp_tables_used= thd->tmp_tables_disk_used= 0;
 +      thd->tmp_tables_size= 0;
@@ -217,7 +218,7 @@ diff -ruN a/sql/log.cc b/sql/log.cc
                                              user_host_buff, user_host_len,
                                              query_utime, lock_utime, is_command,
                                              query, query_length) || error;
-@@ -2280,12 +2308,13 @@
+@@ -2282,12 +2311,13 @@
      TRUE - error occured
  */
  
@@ -232,7 +233,7 @@ diff -ruN a/sql/log.cc b/sql/log.cc
    bool error= 0;
    DBUG_ENTER("MYSQL_QUERY_LOG::write");
  
-@@ -2307,17 +2336,28 @@
+@@ -2309,17 +2339,28 @@
  
      if (!(specialflag & SPECIAL_SHORT_LOG_FORMAT))
      {
@@ -268,7 +269,7 @@ diff -ruN a/sql/log.cc b/sql/log.cc
  
          /* Note that my_b_write() assumes it knows the length for this */
          if (my_b_write(&log_file, (uchar*) buff, buff_len))
-@@ -2335,12 +2375,64 @@
+@@ -2337,12 +2378,64 @@
      sprintf(query_time_buff, "%.6f", ulonglong2double(query_utime)/1000000.0);
      sprintf(lock_time_buff,  "%.6f", ulonglong2double(lock_utime)/1000000.0);
      if (my_b_printf(&log_file,
@@ -284,7 +285,7 @@ diff -ruN a/sql/log.cc b/sql/log.cc
 -                    (ulong) thd->examined_row_count) == (uint) -1)
 +                    (ulong) thd->examined_row_count,
 +                    ((long) thd->row_count_func > 0 ) ? (ulong) thd->row_count_func : 0,
-+                    (ulong) thd->row_count,
++                    thd->row_count - thd->orig_row_count + 1,
 +                    (ulong) (thd->status_var.bytes_sent - thd->bytes_sent_old),
 +                    (ulong) thd->tmp_tables_used,
 +                    (ulong) thd->tmp_tables_disk_used,
@@ -325,20 +326,20 @@ diff -ruN a/sql/log.cc b/sql/log.cc
 +                      (ulong) thd->innodb_io_read,
 +                      buf[0], buf[1], buf[2],
 +                      (ulong) thd->innodb_page_access) == (uint) -1)
-+        tmp_errno=errno;
++        tmp_errno= errno;
 +    } 
 +    else
 +    {
 +      if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) &&
 +          my_b_printf(&log_file,"# No InnoDB statistics available for this query\n") == (uint) -1)
-+        tmp_errno=errno;
++        tmp_errno= errno;
 +    }
      if (thd->db && strcmp(thd->db, db))
      {						// Database changed
        if (my_b_printf(&log_file,"use %s;\n",thd->db) == (uint) -1)
 diff -ruN a/sql/log.h b/sql/log.h
---- a/sql/log.h	2010-08-04 02:24:19.000000000 +0900
-+++ b/sql/log.h	2010-08-27 14:30:34.847021911 +0900
+--- a/sql/log.h	2010-11-29 13:38:00.000000000 +0300
++++ b/sql/log.h	2010-12-24 13:57:45.000000000 +0300
 @@ -211,7 +211,7 @@
               uint user_host_len, int thread_id,
               const char *command_type, uint command_type_len,
@@ -376,17 +377,17 @@ diff -ruN a/sql/log.h b/sql/log.h
                          uint user_host_len, ulonglong query_utime,
                          ulonglong lock_utime, bool is_command,
 diff -ruN a/sql/log_event.cc b/sql/log_event.cc
---- a/sql/log_event.cc	2010-08-04 02:24:29.000000000 +0900
-+++ b/sql/log_event.cc	2010-08-27 14:30:34.826059575 +0900
-@@ -3085,6 +3085,7 @@
+--- a/sql/log_event.cc	2010-11-29 13:37:59.000000000 +0300
++++ b/sql/log_event.cc	2010-12-24 13:57:45.000000000 +0300
+@@ -3090,6 +3090,7 @@
    LEX_STRING new_db;
    int expected_error,actual_error= 0;
    HA_CREATE_INFO db_options;
-+  bool process_log_slow_statement = false;
++  bool process_log_slow_statement= false;
  
    /*
      Colleagues: please never free(thd->catalog) in MySQL. This would
-@@ -3266,19 +3267,7 @@
+@@ -3271,19 +3272,7 @@
        /* Execute the query (note that we bypass dispatch_command()) */
        const char* found_semicolon= NULL;
        mysql_parse(thd, thd->query(), thd->query_length(), &found_semicolon);
@@ -403,11 +404,11 @@ diff -ruN a/sql/log_event.cc b/sql/log_event.cc
 -        opt_log_slow_admin_statements).
 -      */
 -      thd->enable_slow_log= opt_log_slow_slave_statements;
-+      process_log_slow_statement = true;
++      process_log_slow_statement= true;
      }
      else
      {
-@@ -3422,11 +3411,27 @@
+@@ -3428,11 +3417,27 @@
      don't suffer from these assignments to 0 as DROP TEMPORARY
      TABLE uses the db.table syntax.
    */
@@ -437,9 +438,9 @@ diff -ruN a/sql/log_event.cc b/sql/log_event.cc
      As a disk space optimization, future masters will not log an event for
      LAST_INSERT_ID() if that function returned 0 (and thus they will be able
 diff -ruN a/sql/mysql_priv.h b/sql/mysql_priv.h
---- a/sql/mysql_priv.h	2010-08-27 14:29:26.012020936 +0900
-+++ b/sql/mysql_priv.h	2010-08-27 14:30:34.868059088 +0900
-@@ -613,6 +613,106 @@
+--- a/sql/mysql_priv.h	2010-12-24 13:57:33.000000000 +0300
++++ b/sql/mysql_priv.h	2010-12-24 13:57:45.000000000 +0300
+@@ -638,6 +638,106 @@
  
  #define STRING_BUFFER_USUAL_SIZE 80
  
@@ -452,12 +453,12 @@ diff -ruN a/sql/mysql_priv.h b/sql/mysql_priv.h
 +};
 +
 +/* use global log slow control */
-+#define SLOG_UG_NONE                        1 << 0
-+#define SLOG_UG_LOG_SLOW_FILTER             1 << 1
-+#define SLOG_UG_LOG_SLOW_RATE_LIMIT         1 << 2
-+#define SLOG_UG_LOG_SLOW_VERBOSITY          1 << 3
-+#define SLOG_UG_LONG_QUERY_TIME             1 << 4
-+#define SLOG_UG_MIN_EXAMINED_ROW_LIMIT      1 << 5
++#define SLOG_UG_NONE                        (1UL << 0)
++#define SLOG_UG_LOG_SLOW_FILTER             (1UL << 1)
++#define SLOG_UG_LOG_SLOW_RATE_LIMIT         (1UL << 2)
++#define SLOG_UG_LOG_SLOW_VERBOSITY          (1UL << 3)
++#define SLOG_UG_LONG_QUERY_TIME             (1UL << 4)
++#define SLOG_UG_MIN_EXAMINED_ROW_LIMIT      (1UL << 5)
 +#define SLOG_UG_ALL                         SLOG_UG_LOG_SLOW_FILTER | SLOG_UG_LOG_SLOW_RATE_LIMIT | SLOG_UG_LOG_SLOW_VERBOSITY | SLOG_UG_LONG_QUERY_TIME | SLOG_UG_MIN_EXAMINED_ROW_LIMIT
 +/* ... */
 +#define SLOG_UG_INVALID                     1##UL << 31
@@ -546,7 +547,7 @@ diff -ruN a/sql/mysql_priv.h b/sql/mysql_priv.h
  /*
    Some defines for exit codes for ::is_equal class functions.
  */
-@@ -1972,6 +2072,10 @@
+@@ -1997,6 +2097,10 @@
  extern my_bool opt_secure_auth;
  extern char* opt_secure_file_priv;
  extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
@@ -558,9 +559,9 @@ diff -ruN a/sql/mysql_priv.h b/sql/mysql_priv.h
  extern my_bool opt_old_style_user_limits, trust_function_creators;
  extern uint opt_crash_binlog_innodb;
 diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc	2010-08-27 14:29:26.019978397 +0900
-+++ b/sql/mysqld.cc	2010-08-27 14:30:34.855060182 +0900
-@@ -521,6 +521,10 @@
+--- a/sql/mysqld.cc	2010-12-24 13:57:33.000000000 +0300
++++ b/sql/mysqld.cc	2010-12-24 13:57:45.000000000 +0300
+@@ -519,6 +519,10 @@
  char* opt_secure_file_priv= 0;
  my_bool opt_log_slow_admin_statements= 0;
  my_bool opt_log_slow_slave_statements= 0;
@@ -571,7 +572,7 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
  my_bool lower_case_file_system= 0;
  my_bool opt_large_pages= 0;
  my_bool opt_myisam_use_mmap= 0;
-@@ -5782,6 +5786,11 @@
+@@ -5774,6 +5778,11 @@
    OPT_SECURE_FILE_PRIV,
    OPT_MIN_EXAMINED_ROW_LIMIT,
    OPT_LOG_SLOW_SLAVE_STATEMENTS,
@@ -583,7 +584,7 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
  #if defined(ENABLED_DEBUG_SYNC)
    OPT_DEBUG_SYNC_TIMEOUT,
  #endif /* defined(ENABLED_DEBUG_SYNC) */
-@@ -5789,6 +5798,9 @@
+@@ -5781,6 +5790,9 @@
    OPT_SLAVE_EXEC_MODE,
    OPT_GENERAL_LOG_FILE,
    OPT_SLOW_QUERY_LOG_FILE,
@@ -593,7 +594,7 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
    OPT_IGNORE_BUILTIN_INNODB,
    OPT_BINLOG_DIRECT_NON_TRANS_UPDATE,
    OPT_DEFAULT_CHARACTER_SET_OLD
-@@ -6807,6 +6819,36 @@
+@@ -6800,6 +6812,36 @@
     "microsecond precision.",
     &long_query_time, &long_query_time, 0, GET_DOUBLE,
     REQUIRED_ARG, 10, 0, LONG_TIMEOUT, 0, 0, 0},
@@ -611,37 +612,37 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
 +  {"log_slow_sp_statements", OPT_LOG_SLOW_SP_STATEMENTS,
 +   "Log slow statements executed by stored procedure to the slow log if it is open.",
 +   (uchar**) &opt_log_slow_sp_statements, (uchar**) &opt_log_slow_sp_statements,
-+   0, GET_BOOL, REQUIRED_ARG, 1, 0, 1, 0, 1, 0},
++   0, GET_BOOL, OPT_ARG, 1, 0, 1, 0, 1, 0},
 +  {"log_slow_timestamp_every", OPT_LOG_SLOW_TIMESTAMP_EVERY,
 +   "Timestamp is printed for all records of the slow log even if they are same time.",
 +   (uchar**) &opt_log_slow_timestamp_every, (uchar**) &opt_log_slow_timestamp_every,
-+   0, GET_BOOL, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
++   0, GET_BOOL, OPT_ARG, 0, 0, 1, 0, 1, 0},
 +  {"use_global_log_slow_control", OPT_USE_GLOBAL_LOG_SLOW_CONTROL,
 +    "Choose flags, wich always use the global variables. Multiple flags allowed in a comma-separated string. [none, log_slow_filter, log_slow_rate_limit, log_slow_verbosity, long_query_time, min_examined_row_limit, all]",
 +   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_UG_NONE, 0, 0},
 +  {"use_global_long_query_time", OPT_USE_GLOBAL_LONG_QUERY_TIME,
 +   "Control always use global long_query_time or local long_query_time.",
 +   (uchar**) &opt_use_global_long_query_time, (uchar**) &opt_use_global_long_query_time,
-+   0, GET_BOOL, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
++   0, GET_BOOL, OPT_ARG, 0, 0, 1, 0, 1, 0},
 +  {"slow_query_log_microseconds_timestamp", OPT_SLOW_QUERY_LOG_MICROSECONDS_TIMESTAMP,
 +   "Use microsecond time's precision in slow query log",
 +   (uchar**) &opt_slow_query_log_microseconds_timestamp, (uchar**) &opt_slow_query_log_microseconds_timestamp,
-+   0, GET_BOOL, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
++   0, GET_BOOL, OPT_ARG, 0, 0, 1, 0, 1, 0},
    {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
     "If set to 1, table names are stored in lowercase on disk and table names "
     "will be case-insensitive.  Should be set to 2 if you are using a case-"
-@@ -7957,6 +7999,10 @@
+@@ -7950,6 +7992,10 @@
    global_system_variables.old_passwords= 0;
    global_system_variables.old_alter_table= 0;
    global_system_variables.binlog_format= BINLOG_FORMAT_UNSPEC;
 +
 +  global_system_variables.log_slow_verbosity= SLOG_V_MICROTIME;
-+  global_system_variables.use_global_log_slow_control = SLOG_UG_NONE;
++  global_system_variables.use_global_log_slow_control= SLOG_UG_NONE;
 +  global_system_variables.log_slow_filter= SLOG_F_NONE;
    /*
      Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
      when collecting index statistics for MyISAM tables.
-@@ -8458,6 +8504,41 @@
+@@ -8451,6 +8497,44 @@
    case OPT_BOOTSTRAP:
      opt_noacl=opt_bootstrap=1;
      break;
@@ -663,43 +664,47 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
 +      exit(1);
 +    }
 +    break;
++  case OPT_USE_GLOBAL_LONG_QUERY_TIME:
++    use_global_long_query_time_update(opt_use_global_long_query_time);
++    break;
 +  case OPT_USE_GLOBAL_LOG_SLOW_CONTROL:
 +    {
-+      ulong &v = global_system_variables.use_global_log_slow_control;
-+      v =  msl_flag_resolve_by_name(slog_use_global, argument, SLOG_UG_NONE, SLOG_UG_INVALID);
++      ulong &v= global_system_variables.use_global_log_slow_control;
++      v= msl_flag_resolve_by_name(slog_use_global, argument, SLOG_UG_NONE, SLOG_UG_INVALID);
 +      if (v != SLOG_UG_NONE)
 +      {
-+	ulong mask = SLOG_UG_NONE;
-+	mask = ~mask;
-+	v = v & mask;
++        v&= ~SLOG_UG_NONE;
 +      }
 +      if (v == SLOG_UG_INVALID)
 +      {
-+	fprintf(stderr,"Invalid argument in use_global_log_slow_control: %s\n", argument);
-+	exit(1);
++        fprintf(stderr,"Invalid argument in use_global_log_slow_control: %s\n", argument);
++        exit(1);
 +      }
++      use_global_long_query_time_update
++        (global_system_variables.use_global_log_slow_control & SLOG_UG_LONG_QUERY_TIME);
 +      break;
 +    }
    case OPT_SERVER_ID:
      server_id_supplied = 1;
      break;
 diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc	2010-08-04 02:24:33.000000000 +0900
-+++ b/sql/set_var.cc	2010-08-27 14:30:34.873021323 +0900
-@@ -160,6 +160,73 @@
+--- a/sql/set_var.cc	2010-11-29 13:37:59.000000000 +0300
++++ b/sql/set_var.cc	2010-12-24 13:57:45.000000000 +0300
+@@ -160,6 +160,74 @@
  
  static sys_var_chain vars = { NULL, NULL };
  
 +void use_global_long_query_time_update(bool enable)
 +{
-+  ulong &log_slow_control        = global_system_variables.use_global_log_slow_control;
-+  opt_use_global_long_query_time = enable;
-+  if(enable)
-+    log_slow_control = log_slow_control | SLOG_UG_LONG_QUERY_TIME;
++  ulong &log_slow_control= global_system_variables.use_global_log_slow_control;
++  opt_use_global_long_query_time= enable;
++  if (enable)
++    log_slow_control|= SLOG_UG_LONG_QUERY_TIME;
 +  else
-+    log_slow_control = log_slow_control & (~(SLOG_UG_LONG_QUERY_TIME));
-+  if(0 == log_slow_control)
-+    log_slow_control = SLOG_UG_NONE;
++    log_slow_control&= ~SLOG_UG_LONG_QUERY_TIME;
++  log_slow_control&= ~SLOG_UG_NONE;
++  if (log_slow_control == 0)
++    log_slow_control= SLOG_UG_NONE;
 +}
 +
 +class sys_var_use_global_long_query_time : public sys_var_bool_ptr
@@ -752,7 +757,7 @@ diff -ruN a/sql/set_var.cc b/sql/set_var.cc
 +private:
 +  void sync()
 +  {
-+    ulong const &variable = global_system_variables.use_global_log_slow_control;
++    ulong const &variable= global_system_variables.use_global_log_slow_control;
 +    use_global_long_query_time_update((variable & SLOG_UG_LONG_QUERY_TIME));
 +  }
 +};
@@ -760,7 +765,7 @@ diff -ruN a/sql/set_var.cc b/sql/set_var.cc
  static sys_var_thd_ulong
  sys_auto_increment_increment(&vars, "auto_increment_increment",
                               &SV::auto_increment_increment, NULL, NULL,
-@@ -891,6 +958,30 @@
+@@ -891,6 +959,30 @@
                                        QUERY_LOG_GENERAL);
  static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
                                           QUERY_LOG_SLOW);
@@ -791,7 +796,7 @@ diff -ruN a/sql/set_var.cc b/sql/set_var.cc
  /* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
  static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
                                            &opt_slow_log, QUERY_LOG_SLOW);
-@@ -3717,6 +3808,203 @@
+@@ -3701,6 +3793,203 @@
  #endif
  }
  
@@ -996,12 +1001,14 @@ diff -ruN a/sql/set_var.cc b/sql/set_var.cc
   Functions to handle table_type
  ****************************************************************************/
 diff -ruN a/sql/set_var.h b/sql/set_var.h
---- a/sql/set_var.h	2010-08-04 02:24:33.000000000 +0900
-+++ b/sql/set_var.h	2010-08-27 14:30:34.877021194 +0900
-@@ -567,6 +567,80 @@
+--- a/sql/set_var.h	2010-11-29 13:38:17.000000000 +0300
++++ b/sql/set_var.h	2010-12-24 13:57:45.000000000 +0300
+@@ -569,6 +569,82 @@
  };
  
  
++extern void use_global_long_query_time_update(bool enable);
++
 +class sys_var_thd_msl_option :public sys_var_thd
 +{
 +protected:
@@ -1079,7 +1086,7 @@ diff -ruN a/sql/set_var.h b/sql/set_var.h
  class sys_var_thd_storage_engine :public sys_var_thd
  {
  protected:
-@@ -1466,3 +1540,10 @@
+@@ -1470,3 +1546,10 @@
  bool process_key_caches(process_key_cache_t func);
  void delete_elements(I_List<NAMED_LIST> *list,
  		     void (*free_element)(const char*, uchar*));
@@ -1091,8 +1098,8 @@ diff -ruN a/sql/set_var.h b/sql/set_var.h
 +const char *msl_option_get_name(const struct msl_opts *opts, ulong val);
 +char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val);
 diff -ruN a/sql/slave.cc b/sql/slave.cc
---- a/sql/slave.cc	2010-08-04 02:24:34.000000000 +0900
-+++ b/sql/slave.cc	2010-08-27 14:30:34.880987743 +0900
+--- a/sql/slave.cc	2010-11-29 13:38:02.000000000 +0300
++++ b/sql/slave.cc	2010-12-24 13:57:45.000000000 +0300
 @@ -1834,6 +1834,7 @@
      + MAX_LOG_EVENT_HEADER;  /* note, incr over the global not session var */
    thd->slave_thread = 1;
@@ -1102,8 +1109,8 @@ diff -ruN a/sql/slave.cc b/sql/slave.cc
    thd->client_capabilities = CLIENT_LOCAL_FILES;
    pthread_mutex_lock(&LOCK_thread_count);
 diff -ruN a/sql/sp_head.cc b/sql/sp_head.cc
---- a/sql/sp_head.cc	2010-08-27 14:29:26.028021359 +0900
-+++ b/sql/sp_head.cc	2010-08-27 14:30:34.885021875 +0900
+--- a/sql/sp_head.cc	2010-12-24 13:57:33.000000000 +0300
++++ b/sql/sp_head.cc	2010-12-24 13:57:45.000000000 +0300
 @@ -1987,7 +1987,7 @@
      DBUG_PRINT("info",(" %.*s: eval args done", (int) m_name.length, 
                         m_name.str));
@@ -1114,8 +1121,8 @@ diff -ruN a/sql/sp_head.cc b/sql/sp_head.cc
      DBUG_PRINT("info", ("Disabling slow log for the execution"));
      save_enable_slow_log= true;
 diff -ruN a/sql/sql_cache.cc b/sql/sql_cache.cc
---- a/sql/sql_cache.cc	2010-08-04 02:24:34.000000000 +0900
-+++ b/sql/sql_cache.cc	2010-08-27 14:32:37.630058141 +0900
+--- a/sql/sql_cache.cc	2010-11-29 13:37:59.000000000 +0300
++++ b/sql/sql_cache.cc	2010-12-24 13:57:45.000000000 +0300
 @@ -1704,6 +1704,7 @@
  
    thd->limit_found_rows = query->found_rows();
@@ -1133,8 +1140,8 @@ diff -ruN a/sql/sql_cache.cc b/sql/sql_cache.cc
  }
  
 diff -ruN a/sql/sql_class.cc b/sql/sql_class.cc
---- a/sql/sql_class.cc	2010-08-04 02:24:34.000000000 +0900
-+++ b/sql/sql_class.cc	2010-08-27 14:30:34.898058226 +0900
+--- a/sql/sql_class.cc	2010-11-29 13:37:59.000000000 +0300
++++ b/sql/sql_class.cc	2010-12-24 13:57:45.000000000 +0300
 @@ -341,6 +341,37 @@
    thd->row_count++;
  }
@@ -1224,8 +1231,8 @@ diff -ruN a/sql/sql_class.cc b/sql/sql_class.cc
  }
  
 diff -ruN a/sql/sql_class.h b/sql/sql_class.h
---- a/sql/sql_class.h	2010-08-04 02:24:34.000000000 +0900
-+++ b/sql/sql_class.h	2010-08-27 14:30:34.902033897 +0900
+--- a/sql/sql_class.h	2010-11-29 13:37:59.000000000 +0300
++++ b/sql/sql_class.h	2010-12-24 14:06:52.000000000 +0300
 @@ -402,6 +402,18 @@
    DATE_TIME_FORMAT *datetime_format;
    DATE_TIME_FORMAT *time_format;
@@ -1287,10 +1294,22 @@ diff -ruN a/sql/sql_class.h b/sql/sql_class.h
    /* <> 0 if we are inside of trigger or stored function. */
    uint in_sub_stmt;
    /* TRUE when the current top has SQL_LOG_BIN ON */
+@@ -1777,6 +1817,11 @@
+     create_sort_index(); may differ from examined_row_count.
+   */
+   ulong      row_count;
++  /*
++    Original row_count value at the start of query execution
++    (used by the slow_extended patch).
++  */
++  ulong      orig_row_count;
+   pthread_t  real_id;                           /* For debugging */
+   my_thread_id  thread_id;
+   uint	     tmp_table, global_read_lock;
 diff -ruN a/sql/sql_connect.cc b/sql/sql_connect.cc
---- a/sql/sql_connect.cc	2010-08-04 02:24:34.000000000 +0900
-+++ b/sql/sql_connect.cc	2010-08-27 14:30:34.905058444 +0900
-@@ -1130,6 +1130,15 @@
+--- a/sql/sql_connect.cc	2010-11-29 13:38:17.000000000 +0300
++++ b/sql/sql_connect.cc	2010-12-24 13:57:45.000000000 +0300
+@@ -1143,6 +1143,15 @@
  
      prepare_new_connection_state(thd);
  
@@ -1307,8 +1326,8 @@ diff -ruN a/sql/sql_connect.cc b/sql/sql_connect.cc
             !(thd->killed == THD::KILL_CONNECTION))
      {
 diff -ruN a/sql/sql_parse.cc b/sql/sql_parse.cc
---- a/sql/sql_parse.cc	2010-08-27 14:29:26.038021257 +0900
-+++ b/sql/sql_parse.cc	2010-08-27 14:30:34.911058889 +0900
+--- a/sql/sql_parse.cc	2010-12-24 13:57:33.000000000 +0300
++++ b/sql/sql_parse.cc	2010-12-24 14:06:17.000000000 +0300
 @@ -1685,7 +1685,10 @@
    free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
    DBUG_RETURN(error);
@@ -1343,9 +1362,9 @@ diff -ruN a/sql/sql_parse.cc b/sql/sql_parse.cc
 +
 +  /* use_global_log_slow_control */
 +  {
-+    system_variables const &g     = global_system_variables; // global                                                           
-+    system_variables       &s     = thd->variables;          // session                                                          
-+    ulong const            &value = g.use_global_log_slow_control;
++    system_variables const &g= global_system_variables; // global                                                           
++    system_variables       &s= thd->variables;          // session                                                          
++    ulong const            &value= g.use_global_log_slow_control;
 +    SLOG_UG_SETUP(s.log_slow_filter,           value, SLOG_UG_LOG_SLOW_FILTER,             g.log_slow_filter);
 +    SLOG_UG_SETUP(s.log_slow_rate_limit,       value, SLOG_UG_LOG_SLOW_RATE_LIMIT,         g.log_slow_rate_limit);
 +    SLOG_UG_SETUP(s.log_slow_verbosity,        value, SLOG_UG_LOG_SLOW_VERBOSITY,          g.log_slow_verbosity);
@@ -1362,16 +1381,17 @@ diff -ruN a/sql/sql_parse.cc b/sql/sql_parse.cc
    /*
      Do not log administrative statements unless the appropriate option is
      set.
-@@ -2085,6 +2122,8 @@
+@@ -2085,6 +2122,9 @@
      context.resolve_in_table_list_only(select_lex->
                                         table_list.first);
  
-+  /* Reset the counter at all cases for the extended slow query log */
-+  thd->row_count= 1;
++  /* Save the original row_count value for extended stats in slow query log */
++  thd->orig_row_count= thd->row_count;
++
    /*
      Reset warning count for each query that uses tables
      A better approach would be to reset this for any commands
-@@ -5800,6 +5839,21 @@
+@@ -5814,6 +5854,21 @@
    thd->rand_used= 0;
    thd->sent_row_count= thd->examined_row_count= 0;
  
@@ -1394,9 +1414,9 @@ diff -ruN a/sql/sql_parse.cc b/sql/sql_parse.cc
      Because we come here only for start of top-statements, binlog format is
      constant inside a complex statement (using stored functions) etc.
 diff -ruN a/sql/sql_select.cc b/sql/sql_select.cc
---- a/sql/sql_select.cc	2010-08-04 02:24:34.000000000 +0900
-+++ b/sql/sql_select.cc	2010-08-27 14:30:34.925058584 +0900
-@@ -6764,7 +6764,10 @@
+--- a/sql/sql_select.cc	2010-11-29 13:38:01.000000000 +0300
++++ b/sql/sql_select.cc	2010-12-24 13:57:45.000000000 +0300
+@@ -6768,7 +6768,10 @@
  	  {
  	    join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
  	    if (statistics)
@@ -1407,7 +1427,7 @@ diff -ruN a/sql/sql_select.cc b/sql/sql_select.cc
  	  }
  	}
  	else
-@@ -6778,7 +6781,10 @@
+@@ -6782,7 +6785,10 @@
  	  {
  	    join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
  	    if (statistics)
@@ -1418,7 +1438,7 @@ diff -ruN a/sql/sql_select.cc b/sql/sql_select.cc
  	  }
  	}
  	if (!table->no_keyread)
-@@ -9977,6 +9983,7 @@
+@@ -9986,6 +9992,7 @@
                (ulong) rows_limit,test(group)));
  
    status_var_increment(thd->status_var.created_tmp_tables);
@@ -1426,7 +1446,7 @@ diff -ruN a/sql/sql_select.cc b/sql/sql_select.cc
  
    if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
      temp_pool_slot = bitmap_lock_set_next(&temp_pool);
-@@ -10858,6 +10865,7 @@
+@@ -10867,6 +10874,7 @@
      goto err;
    }
    status_var_increment(table->in_use->status_var.created_tmp_disk_tables);
@@ -1434,7 +1454,7 @@ diff -ruN a/sql/sql_select.cc b/sql/sql_select.cc
    share->db_record_offset= 1;
    DBUG_RETURN(0);
   err:
-@@ -10876,6 +10884,14 @@
+@@ -10885,6 +10893,14 @@
    save_proc_info=thd->proc_info;
    thd_proc_info(thd, "removing tmp table");
  
@@ -1450,9 +1470,9 @@ diff -ruN a/sql/sql_select.cc b/sql/sql_select.cc
    ha_release_temporary_latches(thd);
  
 diff -ruN a/sql/sql_show.cc b/sql/sql_show.cc
---- a/sql/sql_show.cc	2010-08-27 14:29:26.049059262 +0900
-+++ b/sql/sql_show.cc	2010-08-27 14:30:34.941021211 +0900
-@@ -1977,8 +1977,17 @@
+--- a/sql/sql_show.cc	2010-12-24 13:57:33.000000000 +0300
++++ b/sql/sql_show.cc	2010-12-24 13:57:46.000000000 +0300
+@@ -1971,8 +1971,17 @@
          table->field[4]->store(command_name[tmp->command].str,
                                 command_name[tmp->command].length, cs);
        /* MYSQL_TIME */
diff --git a/mysql-suppress_log_warning_1592.patch b/mysql-suppress_log_warning_1592.patch
index 9eb4211..d431b78 100644
--- a/mysql-suppress_log_warning_1592.patch
+++ b/mysql-suppress_log_warning_1592.patch
@@ -1,6 +1,6 @@
 # name       : suppress_log_warning_1592.patch
 # introduced : 11 or before
-# maintainer : Yasufumi
+# maintainer : Oleg
 #
 #!!! notice !!!
 # Any small change to this file in the main branch
@@ -8,7 +8,7 @@
 diff -ruN a/sql/mysql_priv.h b/sql/mysql_priv.h
 --- a/sql/mysql_priv.h	2010-07-26 18:31:59.056061915 +0900
 +++ b/sql/mysql_priv.h	2010-07-26 18:34:10.205015964 +0900
-@@ -2081,6 +2081,7 @@
+@@ -2106,6 +2106,7 @@
  extern my_bool opt_readonly, lower_case_file_system;
  extern my_bool opt_userstat_running, opt_thread_statistics;
  extern my_bool opt_optimizer_fix;
@@ -19,7 +19,7 @@ diff -ruN a/sql/mysql_priv.h b/sql/mysql_priv.h
 diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
 --- a/sql/mysqld.cc	2010-07-26 18:33:52.988451388 +0900
 +++ b/sql/mysqld.cc	2010-07-26 18:34:10.203114167 +0900
-@@ -535,6 +535,7 @@
+@@ -533,6 +533,7 @@
  my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
  my_bool opt_userstat_running= 0, opt_thread_statistics= 0;
  my_bool opt_optimizer_fix= 0;
@@ -27,7 +27,7 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
  /*
    True if there is at least one per-hour limit for some user, so we should
    check them before each query (and possibly reset counters when hour is
-@@ -5836,6 +5837,7 @@
+@@ -5828,6 +5829,7 @@
    OPT_USERSTAT_RUNNING,
    OPT_THREAD_STATISTICS,
    OPT_OPTIMIZER_FIX,
@@ -35,7 +35,7 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
    OPT_USE_GLOBAL_LONG_QUERY_TIME,
    OPT_USE_GLOBAL_LOG_SLOW_CONTROL,
    OPT_SLOW_QUERY_LOG_MICROSECONDS_TIMESTAMP,
-@@ -7340,6 +7342,10 @@
+@@ -7333,6 +7335,10 @@
     "Enable unofficial optimizer fixes.",
     (uchar**) &opt_optimizer_fix, (uchar**) &opt_optimizer_fix,
     0, GET_BOOL, NO_ARG, 1, 0, 1, 0, 1, 0},
@@ -49,7 +49,7 @@ diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
 diff -ruN a/sql/set_var.cc b/sql/set_var.cc
 --- a/sql/set_var.cc	2010-07-26 18:31:59.093062279 +0900
 +++ b/sql/set_var.cc	2010-07-26 18:34:10.210061358 +0900
-@@ -562,6 +562,8 @@
+@@ -563,6 +563,8 @@
  						      &opt_thread_statistics);
  static sys_var_bool_ptr		sys_optimizer_fix(&vars, "optimizer_fix",
  						  &opt_optimizer_fix);
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/percona-server.git/commitdiff/bf636d07b36bfd2921b9ecf2033c78270355c98c



More information about the pld-cvs-commit mailing list