diff --git a/mysql-test/include/varchar.inc b/mysql-test/include/varchar.inc index 50741130895..7add7113b8d 100644 --- a/mysql-test/include/varchar.inc +++ b/mysql-test/include/varchar.inc @@ -90,6 +90,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' --replace_regex /Duplicate entry '[^']+' for key/Duplicate entry '{ ' for key/ --error ER_DUP_ENTRY alter table t1 add unique(v); +show warnings; alter table t1 add key(v); select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; --replace_column 6 # 9 # 10 # diff --git a/mysql-test/r/mix2_myisam.result b/mysql-test/r/mix2_myisam.result index b282be15a56..34764466d2a 100644 --- a/mysql-test/r/mix2_myisam.result +++ b/mysql-test/r/mix2_myisam.result @@ -1549,6 +1549,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const # Using where; Using index alter table t1 add unique(v); ERROR 23000: Duplicate entry '{ ' for key 'v_2' +show warnings; +Level Code Message +Error 1062 Duplicate entry 'a' for key 'v_2' alter table t1 add key(v); Warnings: Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release diff --git a/mysql-test/r/mrr_icp_extra.result b/mysql-test/r/mrr_icp_extra.result index 5706bf21895..95788b393dd 100644 --- a/mysql-test/r/mrr_icp_extra.result +++ b/mysql-test/r/mrr_icp_extra.result @@ -350,6 +350,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const # Using where; Using index alter table t1 add unique(v); ERROR 23000: Duplicate entry '{ ' for key 'v_2' +show warnings; +Level Code Message +Error 1062 Duplicate entry 'a' for key 'v_2' alter table t1 add key(v); Warnings: Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index f7eb5db6468..5b41b35c1ba 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1255,6 +1255,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const # Using where; Using index alter table t1 add unique(v); ERROR 23000: Duplicate entry '{ ' for key 'v_2' +show warnings; +Level Code Message +Error 1062 Duplicate entry 'a' for key 'v_2' alter table t1 add key(v); Warnings: Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result index 2ce73304281..8e0e6d5b512 100644 --- a/mysql-test/suite/innodb/r/innodb.result +++ b/mysql-test/suite/innodb/r/innodb.result @@ -1917,6 +1917,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const # Using where; Using index alter table t1 add unique(v); ERROR 23000: Duplicate entry '{ ' for key 'v_2' +show warnings; +Level Code Message +Error 1062 Duplicate entry 'v' for key 'v_2' alter table t1 add key(v); Warnings: Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release diff --git a/mysql-test/suite/maria/maria.result b/mysql-test/suite/maria/maria.result index 04b042059fb..88f39827f27 100644 --- a/mysql-test/suite/maria/maria.result +++ b/mysql-test/suite/maria/maria.result @@ -1145,6 +1145,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const # Using where; Using index alter table t1 add unique(v); ERROR 23000: Duplicate entry '{ ' for key 'v_2' +show warnings; +Level Code Message +Error 1062 Duplicate entry 'a' for key 'v_2' alter table t1 add key(v); Warnings: Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 84e4018c3d8..f66aff1c516 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9938,7 +9938,9 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, } if (to->file->ha_end_bulk_insert() && error <= 0) { - to->file->print_error(my_errno,MYF(0)); + /* Give error, if not already given */ + if (!thd->is_error()) + to->file->print_error(my_errno,MYF(0)); error= 1; } to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index b3fbc15c1a3..119a002a11a 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -834,7 +834,10 @@ extern "C" { int _ma_killed_ptr(HA_CHECK *param) { - return thd_killed((THD*)param->thd); + if (likely(thd_killed((THD*)param->thd)) == 0) + return 0; + my_errno= HA_ERR_ABORTED_BY_USER; + return 1; } @@ -1668,8 +1671,11 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) } if (error && file->create_unique_index_by_sort && share->state.dupp_key != MAX_KEY) + { + my_errno= HA_ERR_FOUND_DUPP_KEY; print_keydup_error(table, &table->key_info[share->state.dupp_key], MYF(0)); + } } else { diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index f92774a0321..9787877420d 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -1364,6 +1364,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend, pos=block_info.filepos+block_info.block_len; if (block_info.rec_len > (uint) share->base.max_pack_length) { + my_errno= HA_ERR_WRONG_IN_RECORD; _ma_check_print_error(param,"Found too long record (%lu) at %s", (ulong) block_info.rec_len, llstr(start_recpos,llbuff)); @@ -4995,6 +4996,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param) param->error_printed=1; param->retry_repair=1; param->testflag|=T_RETRY_WITHOUT_QUICK; + my_errno= HA_ERR_WRONG_IN_RECORD; DBUG_RETURN(1); /* Something wrong with data */ } b_type= _ma_get_block_info(info, &block_info,-1,pos); @@ -5268,6 +5270,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param) param->error_printed=1; param->retry_repair=1; param->testflag|=T_RETRY_WITHOUT_QUICK; + my_errno= HA_ERR_WRONG_IN_RECORD; DBUG_RETURN(1); /* Something wrong with data */ } sort_param->start_recpos=sort_param->pos; diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 2b5536a9ce5..0a8fe2c78e6 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -577,7 +577,10 @@ extern "C" { int killed_ptr(HA_CHECK *param) { - return thd_killed((THD*)param->thd); + if (likely(thd_killed((THD*)param->thd)) == 0) + return 0; + my_errno= HA_ERR_ABORTED_BY_USER; + return 1; } void mi_check_print_error(HA_CHECK *param, const char *fmt,...) @@ -1213,6 +1216,11 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) if (remap) mi_munmap_file(file); #endif + /* + The following is to catch errors when my_errno is no set properly + during repairt + */ + my_errno= 0; if (mi_test_if_sort_rep(file,file->state->records,tmp_key_map,0) && (local_testflag & T_REP_BY_SORT)) { @@ -1235,8 +1243,11 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) } if (error && file->create_unique_index_by_sort && share->state.dupp_key != MAX_KEY) + { + my_errno= HA_ERR_FOUND_DUPP_KEY; print_keydup_error(table, &table->key_info[share->state.dupp_key], MYF(0)); + } } else { diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index e0016eca43f..b65bb8b78bd 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -3126,6 +3126,7 @@ static int sort_key_read(MI_SORT_PARAM *sort_param, void *key) } if (info->state->records == sort_info->max_records) { + my_errno= HA_ERR_WRONG_IN_RECORD; mi_check_print_error(sort_info->param, "Key %d - Found too many records; Can't continue", sort_param->key+1); @@ -3332,6 +3333,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) param->error_printed=1; param->retry_repair=1; param->testflag|=T_RETRY_WITHOUT_QUICK; + my_errno= HA_ERR_WRONG_IN_RECORD; DBUG_RETURN(1); /* Something wrong with data */ } b_type=_mi_get_block_info(&block_info,-1,pos); @@ -3590,6 +3592,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) param->error_printed=1; param->retry_repair=1; param->testflag|=T_RETRY_WITHOUT_QUICK; + my_errno= HA_ERR_WRONG_IN_RECORD; DBUG_RETURN(1); /* Something wrong with data */ } sort_param->start_recpos=sort_param->pos;