Commit 033ed51a authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#4505 merge 5.5 hot alter table to main refs #4505

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@45183 c7de825b-a66e-492c-adef-691d508d4ae1
parent cfa3d6c3
...@@ -199,7 +199,9 @@ ha_tokudb::prepare_for_alter() { ...@@ -199,7 +199,9 @@ ha_tokudb::prepare_for_alter() {
bool bool
ha_tokudb::try_hot_alter_table() { ha_tokudb::try_hot_alter_table() {
TOKUDB_DBUG_ENTER("try_hot_alter_table"); TOKUDB_DBUG_ENTER("try_hot_alter_table");
DBUG_RETURN(true); THD *thd = ha_thd();
bool disable_hot_alter = get_disable_hot_alter(thd);
DBUG_RETURN(!disable_hot_alter);
} }
#endif #endif
...@@ -731,12 +731,12 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_ ...@@ -731,12 +731,12 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_
// alter auto_increment (and nothing else) // alter auto_increment (and nothing else)
if (ha_alter_info->handler_flags == Alter_inplace_info::CHANGE_CREATE_OPTION && if (ha_alter_info->handler_flags == Alter_inplace_info::CHANGE_CREATE_OPTION &&
create_info->used_fields == HA_CREATE_USED_AUTO) { create_info->used_fields == HA_CREATE_USED_AUTO) {
result = HA_ALTER_INPLACE_NO_LOCK; result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
} else } else
// alter row_format (and nothing else) // alter row_format (and nothing else)
if (ha_alter_info->handler_flags == Alter_inplace_info::CHANGE_CREATE_OPTION && if (ha_alter_info->handler_flags == Alter_inplace_info::CHANGE_CREATE_OPTION &&
create_info->used_fields == HA_CREATE_USED_ROW_FORMAT) { create_info->used_fields == HA_CREATE_USED_ROW_FORMAT) {
result = HA_ALTER_INPLACE_NO_LOCK; result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
} else } else
// add index (and nothing else) // add index (and nothing else)
if (ha_alter_info->handler_flags == Alter_inplace_info::ADD_INDEX || if (ha_alter_info->handler_flags == Alter_inplace_info::ADD_INDEX ||
...@@ -746,7 +746,7 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_ ...@@ -746,7 +746,7 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_
// someday, allow multiple hot indexes via alter table add key. don't forget to change the store_lock function. // someday, allow multiple hot indexes via alter table add key. don't forget to change the store_lock function.
// for now, hot indexing is only supported via session variable with the create index sql command // for now, hot indexing is only supported via session variable with the create index sql command
if (get_create_index_online(thd) && ha_alter_info->index_add_count == 1 && thd_sql_command(thd) == SQLCOM_CREATE_INDEX) if (get_create_index_online(thd) && ha_alter_info->index_add_count == 1 && thd_sql_command(thd) == SQLCOM_CREATE_INDEX)
result = HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE; result = HA_ALTER_INPLACE_NO_LOCK;
} else } else
// drop index (and nothing else) // drop index (and nothing else)
if (ha_alter_info->handler_flags == Alter_inplace_info::DROP_INDEX || if (ha_alter_info->handler_flags == Alter_inplace_info::DROP_INDEX ||
......
...@@ -77,6 +77,13 @@ static MYSQL_THDVAR_BOOL(disable_slow_alter, ...@@ -77,6 +77,13 @@ static MYSQL_THDVAR_BOOL(disable_slow_alter,
NULL, NULL,
FALSE FALSE
); );
static MYSQL_THDVAR_BOOL(disable_hot_alter,
0,
"if on, hot alter table is disabled",
NULL,
NULL,
FALSE
);
static MYSQL_THDVAR_BOOL(create_index_online, static MYSQL_THDVAR_BOOL(create_index_online,
0, 0,
"if on, create index done online", "if on, create index done online",
...@@ -692,6 +699,10 @@ bool get_disable_slow_alter(THD* thd) { ...@@ -692,6 +699,10 @@ bool get_disable_slow_alter(THD* thd) {
return (THDVAR(thd, disable_slow_alter) != 0); return (THDVAR(thd, disable_slow_alter) != 0);
} }
bool get_disable_hot_alter(THD* thd) {
return THDVAR(thd, disable_hot_alter) != 0;
}
bool get_create_index_online(THD* thd) { bool get_create_index_online(THD* thd) {
return (THDVAR(thd, create_index_online) != 0); return (THDVAR(thd, create_index_online) != 0);
} }
...@@ -1616,6 +1627,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = { ...@@ -1616,6 +1627,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = {
MYSQL_SYSVAR(pk_insert_mode), MYSQL_SYSVAR(pk_insert_mode),
MYSQL_SYSVAR(load_save_space), MYSQL_SYSVAR(load_save_space),
MYSQL_SYSVAR(disable_slow_alter), MYSQL_SYSVAR(disable_slow_alter),
MYSQL_SYSVAR(disable_hot_alter),
MYSQL_SYSVAR(create_index_online), MYSQL_SYSVAR(create_index_online),
MYSQL_SYSVAR(disable_prefetching), MYSQL_SYSVAR(disable_prefetching),
MYSQL_SYSVAR(version), MYSQL_SYSVAR(version),
......
...@@ -24,6 +24,7 @@ typedef enum srv_row_format_enum srv_row_format_t; ...@@ -24,6 +24,7 @@ typedef enum srv_row_format_enum srv_row_format_t;
uint get_pk_insert_mode(THD* thd); uint get_pk_insert_mode(THD* thd);
bool get_load_save_space(THD* thd); bool get_load_save_space(THD* thd);
bool get_disable_slow_alter(THD* thd); bool get_disable_slow_alter(THD* thd);
bool get_disable_hot_alter(THD* thd);
bool get_create_index_online(THD* thd); bool get_create_index_online(THD* thd);
bool get_disable_prefetching(THD* thd); bool get_disable_prefetching(THD* thd);
bool get_prelock_empty(THD* thd); bool get_prelock_empty(THD* thd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment