diff --git a/storage/tokudb/ha_tokudb_alter_55.cc b/storage/tokudb/ha_tokudb_alter_55.cc index 9b3a9e4c800..c868231783e 100644 --- a/storage/tokudb/ha_tokudb_alter_55.cc +++ b/storage/tokudb/ha_tokudb_alter_55.cc @@ -199,7 +199,9 @@ ha_tokudb::prepare_for_alter() { bool ha_tokudb::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 diff --git a/storage/tokudb/ha_tokudb_alter_56.cc b/storage/tokudb/ha_tokudb_alter_56.cc index 263188ba003..e552ff1f6b3 100644 --- a/storage/tokudb/ha_tokudb_alter_56.cc +++ b/storage/tokudb/ha_tokudb_alter_56.cc @@ -731,12 +731,12 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_ // alter auto_increment (and nothing else) if (ha_alter_info->handler_flags == Alter_inplace_info::CHANGE_CREATE_OPTION && create_info->used_fields == HA_CREATE_USED_AUTO) { - result = HA_ALTER_INPLACE_NO_LOCK; + result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK; } else // alter row_format (and nothing else) if (ha_alter_info->handler_flags == Alter_inplace_info::CHANGE_CREATE_OPTION && create_info->used_fields == HA_CREATE_USED_ROW_FORMAT) { - result = HA_ALTER_INPLACE_NO_LOCK; + result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK; } else // add index (and nothing else) 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_ // 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 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 // drop index (and nothing else) if (ha_alter_info->handler_flags == Alter_inplace_info::DROP_INDEX || diff --git a/storage/tokudb/hatoku_hton.cc b/storage/tokudb/hatoku_hton.cc index 6456b06c92a..ced94062a91 100644 --- a/storage/tokudb/hatoku_hton.cc +++ b/storage/tokudb/hatoku_hton.cc @@ -77,6 +77,13 @@ static MYSQL_THDVAR_BOOL(disable_slow_alter, NULL, 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, 0, "if on, create index done online", @@ -692,6 +699,10 @@ bool get_disable_slow_alter(THD* thd) { 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) { return (THDVAR(thd, create_index_online) != 0); } @@ -1616,6 +1627,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = { MYSQL_SYSVAR(pk_insert_mode), MYSQL_SYSVAR(load_save_space), MYSQL_SYSVAR(disable_slow_alter), + MYSQL_SYSVAR(disable_hot_alter), MYSQL_SYSVAR(create_index_online), MYSQL_SYSVAR(disable_prefetching), MYSQL_SYSVAR(version), diff --git a/storage/tokudb/hatoku_hton.h b/storage/tokudb/hatoku_hton.h index 79d1bb388d0..ca61bc72005 100644 --- a/storage/tokudb/hatoku_hton.h +++ b/storage/tokudb/hatoku_hton.h @@ -24,6 +24,7 @@ typedef enum srv_row_format_enum srv_row_format_t; uint get_pk_insert_mode(THD* thd); bool get_load_save_space(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_disable_prefetching(THD* thd); bool get_prelock_empty(THD* thd);