# name : control_online_alter_index.patch # introduced : 12 # maintainer : Yasufumi # #!!! notice !!! # Any small change to this file in the main branch # should be done or reviewed by the maintainer! diff -ruN a/sql/handler.h b/sql/handler.h --- a/sql/handler.h 2010-11-03 07:01:14.000000000 +0900 +++ b/sql/handler.h 2010-12-03 13:51:04.727293058 +0900 @@ -194,6 +194,19 @@ #define HA_ONLINE_DROP_UNIQUE_INDEX (1L << 9) /*drop uniq. online*/ #define HA_ONLINE_ADD_PK_INDEX (1L << 10)/*add prim. online*/ #define HA_ONLINE_DROP_PK_INDEX (1L << 11)/*drop prim. online*/ + +#define HA_ONLINE_ALTER_INDEX_MASK (HA_ONLINE_ADD_INDEX_NO_WRITES \ + | HA_ONLINE_DROP_INDEX_NO_WRITES \ + | HA_ONLINE_ADD_UNIQUE_INDEX_NO_WRITES \ + | HA_ONLINE_DROP_UNIQUE_INDEX_NO_WRITES \ + | HA_ONLINE_ADD_PK_INDEX_NO_WRITES \ + | HA_ONLINE_DROP_PK_INDEX_NO_WRITES \ + | HA_ONLINE_ADD_INDEX \ + | HA_ONLINE_DROP_INDEX \ + | HA_ONLINE_ADD_UNIQUE_INDEX \ + | HA_ONLINE_DROP_UNIQUE_INDEX \ + | HA_ONLINE_ADD_PK_INDEX \ + | HA_ONLINE_DROP_PK_INDEX) /* HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is supported at all. diff -ruN a/sql/sql_class.h b/sql/sql_class.h --- a/sql/sql_class.h 2010-12-02 20:31:56.200956501 +0900 +++ b/sql/sql_class.h 2010-12-03 13:51:04.744953174 +0900 @@ -481,6 +481,8 @@ my_bool engine_condition_pushdown; my_bool keep_files_on_create; + my_bool online_alter_index; + my_bool old_alter_table; my_bool old_passwords; my_bool big_tables; diff -ruN a/sql/sql_partition.cc b/sql/sql_partition.cc --- a/sql/sql_partition.cc 2010-11-03 07:01:14.000000000 +0900 +++ b/sql/sql_partition.cc 2010-12-03 13:59:56.444039002 +0900 @@ -4636,7 +4636,12 @@ alter_info->num_parts= curr_part_no - new_part_no; } } - if (!(flags= new_table->file->alter_table_flags(alter_info->flags))) + flags= new_table->file->alter_table_flags(alter_info->flags); + if (!thd->variables.online_alter_index) + { + flags&= ~((uint)HA_ONLINE_ALTER_INDEX_MASK); + } + if (!flags) { my_error(ER_PARTITION_FUNCTION_FAILURE, MYF(0)); goto err; diff -ruN a/sql/sql_table.cc b/sql/sql_table.cc --- a/sql/sql_table.cc 2010-11-03 07:01:14.000000000 +0900 +++ b/sql/sql_table.cc 2010-12-03 13:51:04.768955495 +0900 @@ -6117,6 +6117,10 @@ uint *idx_end_p; alter_flags= table->file->alter_table_flags(alter_info->flags); + if (!thd->variables.online_alter_index) + { + alter_flags&= ~((ulong)HA_ONLINE_ALTER_INDEX_MASK); + } DBUG_PRINT("info", ("alter_flags: %lu", alter_flags)); /* Check dropped indexes. */ for (idx_p= index_drop_buffer, idx_end_p= idx_p + index_drop_count; diff -ruN a/sql/sys_vars.cc b/sql/sys_vars.cc --- a/sql/sys_vars.cc 2010-12-02 21:23:05.569356468 +0900 +++ b/sql/sys_vars.cc 2010-12-03 14:05:28.857356603 +0900 @@ -2140,6 +2140,13 @@ GLOBAL_VAR(opt_optimizer_fix), NO_CMD_LINE, DEFAULT(TRUE)); +static Sys_var_mybool Sys_fast_index_creation( + "fast_index_creation", + "If disabled, suppresses online operations for indexes of ALTER TABLE " + "(e.g. fast index creation of InnoDB Plugin) for the session.", + SESSION_VAR(online_alter_index), NO_CMD_LINE, + DEFAULT(TRUE)); + /** propagates changes to the relevant flag of @@optimizer_switch */ static bool fix_engine_condition_pushdown(sys_var *self, THD *thd, enum_var_type type)