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_ONLINE_DROP_UNIQUE_INDEX (1L << 9) /*drop uniq. online*/
12 #define HA_ONLINE_ADD_PK_INDEX (1L << 10)/*add prim. online*/
13 #define HA_ONLINE_DROP_PK_INDEX (1L << 11)/*drop prim. online*/
15 +#define HA_ONLINE_ALTER_INDEX_MASK (HA_ONLINE_ADD_INDEX_NO_WRITES \
16 + | HA_ONLINE_DROP_INDEX_NO_WRITES \
17 + | HA_ONLINE_ADD_UNIQUE_INDEX_NO_WRITES \
18 + | HA_ONLINE_DROP_UNIQUE_INDEX_NO_WRITES \
19 + | HA_ONLINE_ADD_PK_INDEX_NO_WRITES \
20 + | HA_ONLINE_DROP_PK_INDEX_NO_WRITES \
21 + | HA_ONLINE_ADD_INDEX \
22 + | HA_ONLINE_DROP_INDEX \
23 + | HA_ONLINE_ADD_UNIQUE_INDEX \
24 + | HA_ONLINE_DROP_UNIQUE_INDEX \
25 + | HA_ONLINE_ADD_PK_INDEX \
26 + | HA_ONLINE_DROP_PK_INDEX)
28 HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
34 OPT_THREAD_STATISTICS,
36 + OPT_ONLINE_ALTER_INDEX,
37 OPT_SUPPRESS_LOG_WARNING_1592,
38 OPT_QUERY_CACHE_STRIP_COMMENTS,
39 OPT_USE_GLOBAL_LONG_QUERY_TIME,
40 @@ -5946,6 +5947,13 @@
42 &opt_allow_suspicious_udfs, &opt_allow_suspicious_udfs,
43 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
44 + {"fast_index_creation",
45 + OPT_ONLINE_ALTER_INDEX,
46 + "If disabled, suppresses online operations for indexes of ALTER TABLE "
47 + "(e.g. fast index creation of InnoDB Plugin) for the session.",
48 + (uchar**) &global_system_variables.online_alter_index,
49 + (uchar**) &global_system_variables.online_alter_index,
50 + 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
51 {"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax. This mode "
52 "will also set transaction isolation level 'serializable'.", 0, 0, 0,
53 GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
57 sys_engine_condition_pushdown(&vars, "engine_condition_pushdown",
58 &SV::engine_condition_pushdown);
60 +/* Control online operations of ALTER TABLE */
61 +static sys_var_thd_bool
62 +sys_online_alter_index(&vars, "fast_index_creation",
63 + &SV::online_alter_index);
65 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
66 /* ndb thread specific variable settings */
67 static sys_var_thd_ulong
71 my_bool ndb_use_transactions;
72 my_bool ndb_index_stat_enable;
74 + my_bool online_alter_index;
76 my_bool old_alter_table;
77 my_bool old_passwords;
79 --- a/sql/sql_partition.cc
80 +++ b/sql/sql_partition.cc
81 @@ -4381,7 +4381,12 @@
82 alter_info->no_parts= curr_part_no - new_part_no;
85 - if (!(flags= table->file->alter_table_flags(alter_info->flags)))
86 + flags= table->file->alter_table_flags(alter_info->flags);
87 + if (!thd->variables.online_alter_index)
89 + flags&= ~((uint)HA_ONLINE_ALTER_INDEX_MASK);
93 my_error(ER_PARTITION_FUNCTION_FAILURE, MYF(0));
95 --- a/sql/sql_table.cc
96 +++ b/sql/sql_table.cc
97 @@ -7023,6 +7023,10 @@
100 alter_flags= table->file->alter_table_flags(alter_info->flags);
101 + if (!thd->variables.online_alter_index)
103 + alter_flags&= ~((ulong)HA_ONLINE_ALTER_INDEX_MASK);
105 DBUG_PRINT("info", ("alter_flags: %lu", alter_flags));
106 /* Check dropped indexes. */
107 for (idx_p= index_drop_buffer, idx_end_p= idx_p + index_drop_count;