]> git.pld-linux.org Git - packages/mysql.git/blob - mysql-control_online_alter_index.patch
5a921fbf660840d0d1166eb752abe27d51030bc3
[packages/mysql.git] / mysql-control_online_alter_index.patch
1 # name       : control_online_alter_index.patch
2 # introduced : 12
3 # maintainer : Yasufumi
4 #
5 #!!! notice !!!
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
8 --- a/sql/handler.h
9 +++ b/sql/handler.h
10 @@ -171,6 +171,19 @@
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*/
14 +
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)
27  /*
28    HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
29    supported at all.
30 --- a/sql/mysqld.cc
31 +++ b/sql/mysqld.cc
32 @@ -5914,6 +5914,7 @@
33    OPT_USERSTAT_RUNNING,
34    OPT_THREAD_STATISTICS,
35    OPT_OPTIMIZER_FIX,
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 @@
41     "from libc.so",
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},
54 --- a/sql/set_var.cc
55 +++ b/sql/set_var.cc
56 @@ -760,6 +760,11 @@
57  sys_engine_condition_pushdown(&vars, "engine_condition_pushdown",
58                               &SV::engine_condition_pushdown);
59  
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);
64 +
65  #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
66  /* ndb thread specific variable settings */
67  static sys_var_thd_ulong
68 --- a/sql/sql_class.h
69 +++ b/sql/sql_class.h
70 @@ -383,6 +383,8 @@
71    my_bool ndb_use_transactions;
72    my_bool ndb_index_stat_enable;
73  
74 +  my_bool online_alter_index;
75 +
76    my_bool old_alter_table;
77    my_bool old_passwords;
78  
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;
83        }
84      }
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)
88 +    {
89 +      flags&= ~((uint)HA_ONLINE_ALTER_INDEX_MASK);
90 +    }
91 +    if (!flags)
92      {
93        my_error(ER_PARTITION_FUNCTION_FAILURE, MYF(0));
94        DBUG_RETURN(1);
95 --- a/sql/sql_table.cc
96 +++ b/sql/sql_table.cc
97 @@ -7023,6 +7023,10 @@
98      uint  *idx_end_p;
99  
100      alter_flags= table->file->alter_table_flags(alter_info->flags);
101 +    if (!thd->variables.online_alter_index)
102 +    {
103 +      alter_flags&= ~((ulong)HA_ONLINE_ALTER_INDEX_MASK);
104 +    }
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;
This page took 0.05396 seconds and 2 git commands to generate.