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_ONLINE_DROP_UNIQUE_INDEX (1L << 9) /*drop uniq. online*/
13 #define HA_ONLINE_ADD_PK_INDEX (1L << 10)/*add prim. online*/
14 #define HA_ONLINE_DROP_PK_INDEX (1L << 11)/*drop prim. online*/
16 +#define HA_ONLINE_ALTER_INDEX_MASK (HA_ONLINE_ADD_INDEX_NO_WRITES \
17 + | HA_ONLINE_DROP_INDEX_NO_WRITES \
18 + | HA_ONLINE_ADD_UNIQUE_INDEX_NO_WRITES \
19 + | HA_ONLINE_DROP_UNIQUE_INDEX_NO_WRITES \
20 + | HA_ONLINE_ADD_PK_INDEX_NO_WRITES \
21 + | HA_ONLINE_DROP_PK_INDEX_NO_WRITES \
22 + | HA_ONLINE_ADD_INDEX \
23 + | HA_ONLINE_DROP_INDEX \
24 + | HA_ONLINE_ADD_UNIQUE_INDEX \
25 + | HA_ONLINE_DROP_UNIQUE_INDEX \
26 + | HA_ONLINE_ADD_PK_INDEX \
27 + | HA_ONLINE_DROP_PK_INDEX)
29 HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
31 diff -ruN a/sql/sql_class.h b/sql/sql_class.h
32 --- a/sql/sql_class.h 2010-12-02 20:31:56.200956501 +0900
33 +++ b/sql/sql_class.h 2010-12-03 13:51:04.744953174 +0900
35 my_bool engine_condition_pushdown;
36 my_bool keep_files_on_create;
38 + my_bool online_alter_index;
40 my_bool old_alter_table;
41 my_bool old_passwords;
43 diff -ruN a/sql/sql_partition.cc b/sql/sql_partition.cc
44 --- a/sql/sql_partition.cc 2010-11-03 07:01:14.000000000 +0900
45 +++ b/sql/sql_partition.cc 2010-12-03 13:59:56.444039002 +0900
46 @@ -4636,7 +4636,12 @@
47 alter_info->num_parts= curr_part_no - new_part_no;
50 - if (!(flags= new_table->file->alter_table_flags(alter_info->flags)))
51 + flags= new_table->file->alter_table_flags(alter_info->flags);
52 + if (!thd->variables.online_alter_index)
54 + flags&= ~((uint)HA_ONLINE_ALTER_INDEX_MASK);
58 my_error(ER_PARTITION_FUNCTION_FAILURE, MYF(0));
60 diff -ruN a/sql/sql_table.cc b/sql/sql_table.cc
61 --- a/sql/sql_table.cc 2010-11-03 07:01:14.000000000 +0900
62 +++ b/sql/sql_table.cc 2010-12-03 13:51:04.768955495 +0900
63 @@ -6117,6 +6117,10 @@
66 alter_flags= table->file->alter_table_flags(alter_info->flags);
67 + if (!thd->variables.online_alter_index)
69 + alter_flags&= ~((ulong)HA_ONLINE_ALTER_INDEX_MASK);
71 DBUG_PRINT("info", ("alter_flags: %lu", alter_flags));
72 /* Check dropped indexes. */
73 for (idx_p= index_drop_buffer, idx_end_p= idx_p + index_drop_count;
74 diff -ruN a/sql/sys_vars.cc b/sql/sys_vars.cc
75 --- a/sql/sys_vars.cc 2010-12-02 21:23:05.569356468 +0900
76 +++ b/sql/sys_vars.cc 2010-12-03 14:05:28.857356603 +0900
77 @@ -2140,6 +2140,13 @@
78 GLOBAL_VAR(opt_optimizer_fix),
79 NO_CMD_LINE, DEFAULT(TRUE));
81 +static Sys_var_mybool Sys_fast_index_creation(
82 + "fast_index_creation",
83 + "If disabled, suppresses online operations for indexes of ALTER TABLE "
84 + "(e.g. fast index creation of InnoDB Plugin) for the session.",
85 + SESSION_VAR(online_alter_index), NO_CMD_LINE,
88 /** propagates changes to the relevant flag of @@optimizer_switch */
89 static bool fix_engine_condition_pushdown(sys_var *self, THD *thd,