summaryrefslogtreecommitdiff
path: root/storage/maria/ha_maria.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/maria/ha_maria.cc')
-rw-r--r--storage/maria/ha_maria.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 1764f76c3d5..c180365f9e4 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -2072,13 +2072,19 @@ int ha_maria::enable_indexes(uint mode)
param->orig_sort_buffer_length= THDVAR(thd,sort_buffer_size);
param->stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
param->tmpdir= &mysql_tmpdir_list;
- if ((error= (repair(thd, param, 0) != HA_ADMIN_OK)) && param->retry_repair)
+
+ /*
+ Don't retry repair if we get duplicate key error if
+ create_unique_index_by_sort is enabled
+ This can be set when doing an ALTER TABLE and enabling unique keys
+ */
+ if ((error= (repair(thd, param, 0) != HA_ADMIN_OK)) && param->retry_repair &&
+ (my_errno != HA_ERR_FOUND_DUPP_KEY ||
+ !file->create_unique_index_by_sort))
{
sql_print_warning("Warning: Enabling keys got errno %d on %s.%s, "
"retrying",
my_errno, param->db_name, param->table_name);
- /* This should never fail normally */
- DBUG_ASSERT(thd->killed != 0);
/* Repairing by sort failed. Now try standard repair method. */
param->testflag &= ~T_REP_BY_SORT;
file->state->records= start_rows;