diff options
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r-- | sql/ha_partition.cc | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 603e0bf59dc..cd15fa8b20f 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1488,7 +1488,8 @@ bool ha_partition::is_crashed() const int ha_partition::prepare_new_partition(TABLE *tbl, HA_CREATE_INFO *create_info, handler *file, const char *part_name, - partition_element *p_elem) + partition_element *p_elem, + uint disable_non_uniq_indexes) { int error; DBUG_ENTER("prepare_new_partition"); @@ -1531,6 +1532,7 @@ int ha_partition::prepare_new_partition(TABLE *tbl, m_open_test_lock | HA_OPEN_NO_PSI_CALL))) goto error_open; DBUG_PRINT("info", ("partition %s opened", part_name)); + /* Note: if you plan to add another call that may return failure, better to do it before external_lock() as cleanup_new_partition() @@ -1541,6 +1543,9 @@ int ha_partition::prepare_new_partition(TABLE *tbl, goto error_external_lock; DBUG_PRINT("info", ("partition %s external locked", part_name)); + if (disable_non_uniq_indexes) + file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + DBUG_RETURN(0); error_external_lock: (void) file->ha_close(); @@ -1836,6 +1841,14 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, on them to prepare them for copy phase and also for later close calls */ + + /* + Before creating new partitions check whether indexes are disabled + in the partitions. + */ + + uint disable_non_uniq_indexes = indexes_are_disabled(); + i= 0; part_count= 0; part_it.rewind(); @@ -1870,11 +1883,13 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, if ((error= prepare_new_partition(table, create_info, new_file_array[part], (const char *)part_name_buff, - sub_elem))) + sub_elem, + disable_non_uniq_indexes))) { cleanup_new_partition(part_count); DBUG_RETURN(error); } + m_added_file[part_count++]= new_file_array[part]; } while (++j < num_subparts); } @@ -1887,11 +1902,13 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, if ((error= prepare_new_partition(table, create_info, new_file_array[i], (const char *)part_name_buff, - part_elem))) + part_elem, + disable_non_uniq_indexes))) { cleanup_new_partition(part_count); DBUG_RETURN(error); } + m_added_file[part_count++]= new_file_array[i]; } } @@ -7870,7 +7887,7 @@ void ha_partition::print_error(int error, myf errflag) if ((error == HA_ERR_NO_PARTITION_FOUND) && ! (thd->lex->alter_info.flags & Alter_info::ALTER_TRUNCATE_PARTITION)) - m_part_info->print_no_partition_found(table); + m_part_info->print_no_partition_found(table, errflag); else if (error == HA_ERR_ROW_IN_WRONG_PARTITION) { /* Should only happen on DELETE or UPDATE! */ |