1 # name : control_online_alter_index.patch
3 # maintainer : Yasufumi
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
11 #define HA_INPLACE_DROP_UNIQUE_INDEX_NO_WRITE (1L << 9)
12 #define HA_INPLACE_ADD_PK_INDEX_NO_WRITE (1L << 10)
13 #define HA_INPLACE_DROP_PK_INDEX_NO_WRITE (1L << 11)
15 +#define HA_INPLACE_ALTER_INDEX_MASK ((1L << 12) - 1)
17 HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
22 my_bool engine_condition_pushdown;
23 my_bool keep_files_on_create;
25 + my_bool online_alter_index;
27 my_bool old_alter_table;
28 my_bool old_passwords;
30 --- a/sql/sql_partition.cc
31 +++ b/sql/sql_partition.cc
32 @@ -4637,7 +4637,12 @@
33 alter_info->num_parts= curr_part_no - new_part_no;
36 - if (!(flags= new_table->file->alter_table_flags(alter_info->flags)))
37 + flags= new_table->file->alter_table_flags(alter_info->flags);
38 + if (!thd->variables.online_alter_index)
40 + flags&= ~((uint)HA_INPLACE_ALTER_INDEX_MASK);
44 my_error(ER_PARTITION_FUNCTION_FAILURE, MYF(0));
46 --- a/sql/sql_table.cc
47 +++ b/sql/sql_table.cc
48 @@ -6146,6 +6146,10 @@
51 alter_flags= table->file->alter_table_flags(alter_info->flags);
52 + if (!thd->variables.online_alter_index)
54 + alter_flags&= ~((ulong)HA_INPLACE_ALTER_INDEX_MASK);
56 DBUG_PRINT("info", ("alter_flags: %lu", alter_flags));
57 /* Check dropped indexes. */
58 for (idx_p= index_drop_buffer, idx_end_p= idx_p + index_drop_count;
61 @@ -2265,6 +2265,13 @@
62 GLOBAL_VAR(opt_optimizer_fix),
63 NO_CMD_LINE, DEFAULT(TRUE));
65 +static Sys_var_mybool Sys_fast_index_creation(
66 + "fast_index_creation",
67 + "If disabled, suppresses online operations for indexes of ALTER TABLE "
68 + "(e.g. fast index creation of InnoDB Plugin) for the session.",
69 + SESSION_VAR(online_alter_index), NO_CMD_LINE,
72 /** propagates changes to the relevant flag of @@optimizer_switch */
73 static bool fix_engine_condition_pushdown(sys_var *self, THD *thd,