Commit 3458cf8a authored by Christian Rober's avatar Christian Rober Committed by Yoni Fogel

refs #4870 MySQL 5.1 handlerton changes for allowing row format changes to be hot.

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@44946 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5ced96de
...@@ -542,10 +542,16 @@ ha_tokudb::check_if_supported_alter(TABLE *altered_table, ...@@ -542,10 +542,16 @@ ha_tokudb::check_if_supported_alter(TABLE *altered_table,
alter_flags->is_set(HA_DROP_UNIQUE_INDEX) || alter_flags->is_set(HA_DROP_UNIQUE_INDEX) ||
alter_flags->is_set(HA_ADD_INDEX) || alter_flags->is_set(HA_ADD_INDEX) ||
alter_flags->is_set(HA_ADD_UNIQUE_INDEX); alter_flags->is_set(HA_ADD_UNIQUE_INDEX);
// Check if the row format (read: compression) has
// changed as part of this alter statment.
bool has_row_format_changes = alter_flags->is_set(HA_ALTER_ROW_FORMAT);
bool has_non_indexing_changes = false; bool has_non_indexing_changes = false;
bool has_non_dropped_changes = false; bool has_non_dropped_changes = false;
bool has_non_added_changes = false; bool has_non_added_changes = false;
bool has_non_column_rename_changes = false; bool has_non_column_rename_changes = false;
bool has_non_row_format_changes = false;
bool has_non_auto_inc_change = alter_has_other_flag_set(alter_flags, HA_CHANGE_AUTOINCREMENT_VALUE); bool has_non_auto_inc_change = alter_has_other_flag_set(alter_flags, HA_CHANGE_AUTOINCREMENT_VALUE);
for (uint i = 0; i < HA_MAX_ALTER_FLAGS; i++) { for (uint i = 0; i < HA_MAX_ALTER_FLAGS; i++) {
...@@ -598,6 +604,16 @@ ha_tokudb::check_if_supported_alter(TABLE *altered_table, ...@@ -598,6 +604,16 @@ ha_tokudb::check_if_supported_alter(TABLE *altered_table,
break; break;
} }
} }
// See if any flags other than row format have been set.
for (uint i = 0; i < HA_MAX_ALTER_FLAGS; i++) {
if (i == HA_ALTER_ROW_FORMAT) {
continue;
}
if (alter_flags->is_set(i)) {
has_non_row_format_changes = true;
break;
}
}
if (tokudb_debug & TOKUDB_DEBUG_ALTER_TABLE_INFO) { if (tokudb_debug & TOKUDB_DEBUG_ALTER_TABLE_INFO) {
printf("has indexing changes %d, has non indexing changes %d\n", has_indexing_changes, has_non_indexing_changes); printf("has indexing changes %d, has non indexing changes %d\n", has_indexing_changes, has_non_indexing_changes);
...@@ -683,6 +699,9 @@ ha_tokudb::check_if_supported_alter(TABLE *altered_table, ...@@ -683,6 +699,9 @@ ha_tokudb::check_if_supported_alter(TABLE *altered_table,
else if (has_added_columns && !has_non_added_changes) { else if (has_added_columns && !has_non_added_changes) {
retval = HA_ALTER_SUPPORTED_WAIT_LOCK; retval = HA_ALTER_SUPPORTED_WAIT_LOCK;
} }
else if (has_row_format_changes && !has_non_row_format_changes) {
retval = HA_ALTER_SUPPORTED_WAIT_LOCK;
}
else if (has_auto_inc_change && !has_non_auto_inc_change) { else if (has_auto_inc_change && !has_non_auto_inc_change) {
retval = HA_ALTER_SUPPORTED_WAIT_LOCK; retval = HA_ALTER_SUPPORTED_WAIT_LOCK;
} }
...@@ -1131,6 +1150,7 @@ ha_tokudb::alter_table_phase2( ...@@ -1131,6 +1150,7 @@ ha_tokudb::alter_table_phase2(
bool modified_DBs = false; bool modified_DBs = false;
bool has_dropped_columns = alter_flags->is_set(HA_DROP_COLUMN); bool has_dropped_columns = alter_flags->is_set(HA_DROP_COLUMN);
bool has_added_columns = alter_flags->is_set(HA_ADD_COLUMN); bool has_added_columns = alter_flags->is_set(HA_ADD_COLUMN);
bool has_row_format_changes = alter_flags->is_set(HA_ALTER_ROW_FORMAT);
KEY_AND_COL_INFO altered_kc_info; KEY_AND_COL_INFO altered_kc_info;
memset(&altered_kc_info, 0, sizeof(altered_kc_info)); memset(&altered_kc_info, 0, sizeof(altered_kc_info));
u_int32_t max_new_desc_size = 0; u_int32_t max_new_desc_size = 0;
...@@ -1329,6 +1349,23 @@ ha_tokudb::alter_table_phase2( ...@@ -1329,6 +1349,23 @@ ha_tokudb::alter_table_phase2(
} }
} }
} }
// Check if compression type has been altered.
if (has_row_format_changes) {
// Determine the new compression type.
enum toku_compression_method method = TOKU_NO_COMPRESSION;
method = row_type_to_compression_method(create_info->row_type);
// Set the new type.
u_int32_t curr_num_DBs = table->s->keys + test(hidden_primary_key);
for (u_int32_t i = 0; i < curr_num_DBs; ++i) {
DB *db = share->key_file[i];
error = db->change_compression_method(db, method);
if (error) {
goto cleanup;
}
}
}
// update frm file // update frm file
// only for tables that are not partitioned // only for tables that are not partitioned
......
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