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!
8 diff -ruN a/sql/handler.h b/sql/handler.h
9 --- a/sql/handler.h 2010-11-03 07:01:14.000000000 +0900
10 +++ b/sql/handler.h 2010-12-03 13:51:04.727293058 +0900
12 #define HA_INPLACE_DROP_UNIQUE_INDEX_NO_WRITE (1L << 9)
13 #define HA_INPLACE_ADD_PK_INDEX_NO_WRITE (1L << 10)
14 #define HA_INPLACE_DROP_PK_INDEX_NO_WRITE (1L << 11)
16 +#define HA_INPLACE_ALTER_INDEX_MASK ((1L << 12) - 1)
18 HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
20 diff -ruN a/sql/sql_class.h b/sql/sql_class.h
21 --- a/sql/sql_class.h 2010-12-02 20:31:56.200956501 +0900
22 +++ b/sql/sql_class.h 2010-12-03 13:51:04.744953174 +0900
24 my_bool engine_condition_pushdown;
25 my_bool keep_files_on_create;
27 + my_bool online_alter_index;
29 my_bool old_alter_table;
30 my_bool old_passwords;
32 diff -ruN a/sql/sql_partition.cc b/sql/sql_partition.cc
33 --- a/sql/sql_partition.cc 2010-11-03 07:01:14.000000000 +0900
34 +++ b/sql/sql_partition.cc 2010-12-03 13:59:56.444039002 +0900
35 @@ -4636,7 +4636,12 @@
36 alter_info->num_parts= curr_part_no - new_part_no;
39 - if (!(flags= new_table->file->alter_table_flags(alter_info->flags)))
40 + flags= new_table->file->alter_table_flags(alter_info->flags);
41 + if (!thd->variables.online_alter_index)
43 + flags&= ~((uint)HA_INPLACE_ALTER_INDEX_MASK);
47 my_error(ER_PARTITION_FUNCTION_FAILURE, MYF(0));
49 diff -ruN a/sql/sql_table.cc b/sql/sql_table.cc
50 --- a/sql/sql_table.cc 2010-11-03 07:01:14.000000000 +0900
51 +++ b/sql/sql_table.cc 2010-12-03 13:51:04.768955495 +0900
52 @@ -6117,6 +6117,10 @@
55 alter_flags= table->file->alter_table_flags(alter_info->flags);
56 + if (!thd->variables.online_alter_index)
58 + alter_flags&= ~((ulong)HA_INPLACE_ALTER_INDEX_MASK);
60 DBUG_PRINT("info", ("alter_flags: %lu", alter_flags));
61 /* Check dropped indexes. */
62 for (idx_p= index_drop_buffer, idx_end_p= idx_p + index_drop_count;
63 diff -ruN a/sql/sys_vars.cc b/sql/sys_vars.cc
64 --- a/sql/sys_vars.cc 2010-12-02 21:23:05.569356468 +0900
65 +++ b/sql/sys_vars.cc 2010-12-03 14:05:28.857356603 +0900
66 @@ -2140,6 +2140,13 @@
67 GLOBAL_VAR(opt_optimizer_fix),
68 NO_CMD_LINE, DEFAULT(TRUE));
70 +static Sys_var_mybool Sys_fast_index_creation(
71 + "fast_index_creation",
72 + "If disabled, suppresses online operations for indexes of ALTER TABLE "
73 + "(e.g. fast index creation of InnoDB Plugin) for the session.",
74 + SESSION_VAR(online_alter_index), NO_CMD_LINE,
77 /** propagates changes to the relevant flag of @@optimizer_switch */
78 static bool fix_engine_condition_pushdown(sys_var *self, THD *thd,