Commit e354005d authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#4870 hot alter row format on 5.5 refs #4870

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@45095 c7de825b-a66e-492c-adef-691d508d4ae1
parent bac333c3
...@@ -574,6 +574,7 @@ public: ...@@ -574,6 +574,7 @@ public:
bool is_alter_table_hot(); bool is_alter_table_hot();
void prepare_for_alter(); void prepare_for_alter();
int new_alter_table_frm_data(const uchar *frm_data, size_t frm_len); int new_alter_table_frm_data(const uchar *frm_data, size_t frm_len);
bool try_hot_alter_table();
#endif #endif
#if TOKU_INCLUDE_ALTER_51 #if TOKU_INCLUDE_ALTER_51
public: public:
......
...@@ -196,4 +196,10 @@ ha_tokudb::prepare_for_alter() { ...@@ -196,4 +196,10 @@ ha_tokudb::prepare_for_alter() {
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
bool
ha_tokudb::try_hot_alter_table() {
TOKUDB_DBUG_ENTER("try_hot_alter_table");
DBUG_RETURN(true);
}
#endif #endif
...@@ -705,6 +705,7 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_ ...@@ -705,6 +705,7 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_
THD *thd = ha_thd(); THD *thd = ha_thd();
enum_alter_inplace_result result = HA_ALTER_INPLACE_NOT_SUPPORTED; // default is NOT inplace enum_alter_inplace_result result = HA_ALTER_INPLACE_NOT_SUPPORTED; // default is NOT inplace
HA_CREATE_INFO *create_info = ha_alter_info->create_info;
// column rename // column rename
if ((ha_alter_info->handler_flags & ~(Alter_inplace_info::ALTER_COLUMN_NAME + Alter_inplace_info::ALTER_COLUMN_DEFAULT)) == 0) { if ((ha_alter_info->handler_flags & ~(Alter_inplace_info::ALTER_COLUMN_NAME + Alter_inplace_info::ALTER_COLUMN_DEFAULT)) == 0) {
...@@ -728,11 +729,13 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_ ...@@ -728,11 +729,13 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_
} }
} else } else
// alter auto_increment (and nothing else) // alter auto_increment (and nothing else)
if (ha_alter_info->handler_flags == Alter_inplace_info::CHANGE_CREATE_OPTION && ha_alter_info->create_info->used_fields == HA_CREATE_USED_AUTO) { 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_NO_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 && ha_alter_info->create_info->used_fields == HA_CREATE_USED_ROW_FORMAT) { 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_NO_LOCK;
} else } else
// add index (and nothing else) // add index (and nothing else)
...@@ -740,7 +743,8 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_ ...@@ -740,7 +743,8 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_
ha_alter_info->handler_flags == Alter_inplace_info::ADD_UNIQUE_INDEX) { // && tables_have_same_keys TODO??? ha_alter_info->handler_flags == Alter_inplace_info::ADD_UNIQUE_INDEX) { // && tables_have_same_keys TODO???
assert(ha_alter_info->index_drop_count == 0); assert(ha_alter_info->index_drop_count == 0);
result = HA_ALTER_INPLACE_SHARED_LOCK; result = HA_ALTER_INPLACE_SHARED_LOCK;
// TODO allow multiple hot indexes via alter table add key. don't forget to change the store_lock function.x // 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) 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_AFTER_PREPARE;
} else } else
...@@ -797,8 +801,11 @@ bool ...@@ -797,8 +801,11 @@ bool
ha_tokudb::prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { ha_tokudb::prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) {
TOKUDB_DBUG_ENTER("prepare_inplace_alter_table"); TOKUDB_DBUG_ENTER("prepare_inplace_alter_table");
bool result = false; // success #if MYSQL_VERSION_ID < 50600
assert(0); // not supported
#endif
bool result = false; // success
DBUG_RETURN(result); DBUG_RETURN(result);
} }
...@@ -807,6 +814,7 @@ ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alte ...@@ -807,6 +814,7 @@ ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alte
TOKUDB_DBUG_ENTER("inplace_alter_table"); TOKUDB_DBUG_ENTER("inplace_alter_table");
int error = 0; int error = 0;
HA_CREATE_INFO *create_info = ha_alter_info->create_info;
if (ha_alter_info->handler_flags == Alter_inplace_info::ADD_INDEX || if (ha_alter_info->handler_flags == Alter_inplace_info::ADD_INDEX ||
ha_alter_info->handler_flags == Alter_inplace_info::ADD_UNIQUE_INDEX) { ha_alter_info->handler_flags == Alter_inplace_info::ADD_UNIQUE_INDEX) {
...@@ -816,19 +824,29 @@ ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alte ...@@ -816,19 +824,29 @@ ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alte
ha_alter_info->handler_flags == Alter_inplace_info::DROP_UNIQUE_INDEX) { ha_alter_info->handler_flags == Alter_inplace_info::DROP_UNIQUE_INDEX) {
error = alter_table_drop_index(altered_table, ha_alter_info); error = alter_table_drop_index(altered_table, ha_alter_info);
} else } else
if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_COLUMN || if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_COLUMN) {
ha_alter_info->handler_flags & Alter_inplace_info::DROP_COLUMN) {
error = alter_table_add_or_drop_column(altered_table, ha_alter_info); error = alter_table_add_or_drop_column(altered_table, ha_alter_info);
} else } else
if (ha_alter_info->handler_flags == Alter_inplace_info::CHANGE_CREATE_OPTION) { if (ha_alter_info->handler_flags & Alter_inplace_info::DROP_COLUMN) {
HA_CREATE_INFO *create_info = ha_alter_info->create_info; error = alter_table_add_or_drop_column(altered_table, ha_alter_info);
if (create_info->used_fields == HA_CREATE_USED_AUTO) { } else
error = write_auto_inc_create(share->status_block, create_info->auto_increment_value, transaction); if (ha_alter_info->handler_flags == Alter_inplace_info::CHANGE_CREATE_OPTION &&
} create_info->used_fields == HA_CREATE_USED_AUTO) {
if (create_info->used_fields == HA_CREATE_USED_ROW_FORMAT) { error = write_auto_inc_create(share->status_block, create_info->auto_increment_value, transaction);
// TODO handle new row format } else
printf("TODO row_type=%u\n", (unsigned)create_info->row_type); if (ha_alter_info->handler_flags == Alter_inplace_info::CHANGE_CREATE_OPTION &&
error = EAGAIN; // DEBUG create_info->used_fields == HA_CREATE_USED_ROW_FORMAT) {
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)
break;
} }
} }
......
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