|
|
|
@ -14705,25 +14705,14 @@ ha_innobase::analyze( |
|
|
|
/*****************************************************************//**
|
|
|
|
Defragment table. |
|
|
|
@return error number */ |
|
|
|
UNIV_INTERN |
|
|
|
int |
|
|
|
ha_innobase::defragment_table( |
|
|
|
/*==========================*/ |
|
|
|
const char* name, /*!< in: table name */ |
|
|
|
const char* index_name, /*!< in: index name */ |
|
|
|
bool async) /*!< in: whether to wait until finish */ |
|
|
|
inline int ha_innobase::defragment_table(const char *name) |
|
|
|
{ |
|
|
|
char norm_name[FN_REFLEN]; |
|
|
|
dict_table_t* table = NULL; |
|
|
|
dict_index_t* index = NULL; |
|
|
|
ibool one_index = (index_name != 0); |
|
|
|
int ret = 0; |
|
|
|
dberr_t err = DB_SUCCESS; |
|
|
|
|
|
|
|
if (!srv_defragment) { |
|
|
|
return ER_FEATURE_DISABLED; |
|
|
|
} |
|
|
|
|
|
|
|
normalize_table_name(norm_name, name); |
|
|
|
|
|
|
|
table = dict_table_open_on_name(norm_name, FALSE, |
|
|
|
@ -14751,10 +14740,6 @@ ha_innobase::defragment_table( |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (one_index && strcasecmp(index_name, index->name) != 0) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (btr_defragment_find_index(index)) { |
|
|
|
// We borrow this error code. When the same index is
|
|
|
|
// already in the defragmentation queue, issue another
|
|
|
|
@ -14770,7 +14755,7 @@ ha_innobase::defragment_table( |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
os_event_t event = btr_defragment_add_index(index, async, &err); |
|
|
|
os_event_t event = btr_defragment_add_index(index, &err); |
|
|
|
|
|
|
|
if (err != DB_SUCCESS) { |
|
|
|
push_warning_printf( |
|
|
|
@ -14786,7 +14771,7 @@ ha_innobase::defragment_table( |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (!async && event) { |
|
|
|
if (event) { |
|
|
|
while(os_event_wait_time(event, 1000000)) { |
|
|
|
if (thd_killed(current_thd)) { |
|
|
|
btr_defragment_remove_index(index); |
|
|
|
@ -14800,19 +14785,9 @@ ha_innobase::defragment_table( |
|
|
|
if (ret) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (one_index) { |
|
|
|
one_index = FALSE; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
dict_table_close(table, FALSE, FALSE); |
|
|
|
|
|
|
|
if (ret == 0 && one_index) { |
|
|
|
ret = ER_NO_SUCH_INDEX; |
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
@ -14838,9 +14813,7 @@ ha_innobase::optimize( |
|
|
|
bool try_alter = true; |
|
|
|
|
|
|
|
if (!m_prebuilt->table->is_temporary() && srv_defragment) { |
|
|
|
int err; |
|
|
|
|
|
|
|
err = defragment_table(m_prebuilt->table->name.m_name, NULL, false); |
|
|
|
int err = defragment_table(m_prebuilt->table->name.m_name); |
|
|
|
|
|
|
|
if (err == 0) { |
|
|
|
try_alter = false; |
|
|
|
|