mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
#4505 implement hot alter table auto increment in mysql 5.6
git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@44944 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
78ff6d8517
commit
f643286a50
4 changed files with 43 additions and 11 deletions
|
@ -6,9 +6,20 @@
|
|||
#endif
|
||||
|
||||
#if 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
|
||||
#define TOKU_INCLUDE_ALTER_56 1
|
||||
#define TOKU_INCLUDE_ROW_TYPE_COMPRESSION 0
|
||||
#define TOKU_INCLUDE_XA 1
|
||||
#else
|
||||
#endif
|
||||
|
||||
#if 50500 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50599
|
||||
#define TOKU_INCLUDE_ALTER_56 0
|
||||
#define TOKU_INCLUDE_ALTER_55 1
|
||||
#define TOKU_INCLUDE_ROW_TYPE_COMPRESSION 1
|
||||
#define TOKU_INCLUDE_XA 1
|
||||
#endif
|
||||
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#define TOKU_INCLUDE_ALTER_51 1
|
||||
#define TOKU_INCLUDE_ROW_TYPE_COMPRESSION 1
|
||||
#define TOKU_INCLUDE_XA 1
|
||||
#endif
|
||||
|
@ -540,7 +551,7 @@ public:
|
|||
int cmp_ref(const uchar * ref1, const uchar * ref2);
|
||||
bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes);
|
||||
|
||||
#if 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
|
||||
#if TOKU_INCLUDE_ALTER_56
|
||||
public:
|
||||
enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
|
||||
bool prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
|
||||
|
@ -552,7 +563,8 @@ public:
|
|||
int alter_table_add_or_drop_column(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
|
||||
void print_alter_info(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
|
||||
public:
|
||||
#elif 50500 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50599
|
||||
#endif
|
||||
#if TOKU_INCLUDE_ALTER_55
|
||||
public:
|
||||
int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys, handler_add_index **add);
|
||||
int final_add_index(handler_add_index *add, bool commit);
|
||||
|
@ -562,7 +574,8 @@ public:
|
|||
bool is_alter_table_hot();
|
||||
void prepare_for_alter();
|
||||
int new_alter_table_frm_data(const uchar *frm_data, size_t frm_len);
|
||||
#else
|
||||
#endif
|
||||
#if TOKU_INCLUDE_ALTER_51
|
||||
public:
|
||||
int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys);
|
||||
int prepare_drop_index(TABLE *table_arg, uint *key_num, uint num_of_keys);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#if MYSQL_VERSION_ID < 50500
|
||||
#if TOKU_INCLUDE_ALTER_51
|
||||
|
||||
volatile int ha_tokudb_add_index_wait = 0;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#if 50500 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50599
|
||||
#if TOKU_INCLUDE_ALTER_55
|
||||
|
||||
class ha_tokudb_add_index : public handler_add_index {
|
||||
public:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#if 50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699
|
||||
#if TOKU_INCLUDE_ALTER_56
|
||||
|
||||
static bool
|
||||
tables_have_same_keys(TABLE* table, TABLE* altered_table, bool print_error, bool check_field_index) {
|
||||
|
@ -727,7 +727,15 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_
|
|||
result = HA_ALTER_INPLACE_NO_LOCK;
|
||||
}
|
||||
} else
|
||||
// add index
|
||||
// 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) {
|
||||
result = HA_ALTER_INPLACE_NO_LOCK;
|
||||
} 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) {
|
||||
result = HA_ALTER_INPLACE_NO_LOCK;
|
||||
} else
|
||||
// add index (and nothing else)
|
||||
if (ha_alter_info->handler_flags == Alter_inplace_info::ADD_INDEX ||
|
||||
ha_alter_info->handler_flags == Alter_inplace_info::ADD_UNIQUE_INDEX) { // && tables_have_same_keys TODO???
|
||||
assert(ha_alter_info->index_drop_count == 0);
|
||||
|
@ -736,13 +744,13 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_
|
|||
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;
|
||||
} else
|
||||
// drop index
|
||||
// drop index (and nothing else)
|
||||
if (ha_alter_info->handler_flags == Alter_inplace_info::DROP_INDEX ||
|
||||
ha_alter_info->handler_flags == Alter_inplace_info::DROP_UNIQUE_INDEX) { // && tables_have_same_keys TODO???
|
||||
assert(ha_alter_info->index_add_count == 0);
|
||||
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;;
|
||||
} else
|
||||
// add column
|
||||
// add column (and nothing else)
|
||||
if (ha_alter_info->handler_flags == Alter_inplace_info::ADD_COLUMN ||
|
||||
ha_alter_info->handler_flags == Alter_inplace_info::ADD_COLUMN + Alter_inplace_info::ALTER_COLUMN_ORDER) {
|
||||
u_int32_t added_columns[altered_table->s->fields];
|
||||
|
@ -759,7 +767,7 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_
|
|||
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
|
||||
}
|
||||
} else
|
||||
// drop column
|
||||
// drop column (and nothing else)
|
||||
if (ha_alter_info->handler_flags == Alter_inplace_info::DROP_COLUMN ||
|
||||
ha_alter_info->handler_flags == Alter_inplace_info::DROP_COLUMN + Alter_inplace_info::ALTER_COLUMN_ORDER) {
|
||||
u_int32_t dropped_columns[table->s->fields];
|
||||
|
@ -811,6 +819,17 @@ ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alte
|
|||
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);
|
||||
} else
|
||||
if (ha_alter_info->handler_flags == Alter_inplace_info::CHANGE_CREATE_OPTION) {
|
||||
HA_CREATE_INFO *create_info = ha_alter_info->create_info;
|
||||
if (create_info->used_fields == HA_CREATE_USED_AUTO) {
|
||||
error = write_auto_inc_create(share->status_block, create_info->auto_increment_value, transaction);
|
||||
}
|
||||
if (create_info->used_fields == HA_CREATE_USED_ROW_FORMAT) {
|
||||
// TODO handle new row format
|
||||
printf("TODO row_type=%u\n", (unsigned)create_info->row_type);
|
||||
error = EAGAIN; // DEBUG
|
||||
}
|
||||
}
|
||||
|
||||
bool result = false; // success
|
||||
|
|
Loading…
Add table
Reference in a new issue