Commit f7dab76a authored by Monty's avatar Monty

MDEV-12756 rpl.rpl_killed_ddl fails in buildbot with 'Can't find record'

The issue was that my_errno was not set properly when a repair was killed,
which confused the rpl_killed_ddl script.

I also added an extra test line in varchar.inc to ensure we don't give
duplicate error rows.
parent ca7cf69c
...@@ -90,6 +90,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' ...@@ -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/ --replace_regex /Duplicate entry '[^']+' for key/Duplicate entry '{ ' for key/
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
alter table t1 add unique(v); alter table t1 add unique(v);
show warnings;
alter table t1 add key(v); alter table t1 add key(v);
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
--replace_column 6 # 9 # 10 # --replace_column 6 # 9 # 10 #
......
...@@ -1549,6 +1549,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -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 1 SIMPLE t1 ref v v 13 const # Using where; Using index
alter table t1 add unique(v); alter table t1 add unique(v);
ERROR 23000: Duplicate entry '{ ' for key 'v_2' 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); alter table t1 add key(v);
Warnings: Warnings:
Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release
......
...@@ -350,6 +350,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -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 1 SIMPLE t1 ref v v 13 const # Using where; Using index
alter table t1 add unique(v); alter table t1 add unique(v);
ERROR 23000: Duplicate entry '{ ' for key 'v_2' 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); alter table t1 add key(v);
Warnings: Warnings:
Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release
......
...@@ -1255,6 +1255,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -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 1 SIMPLE t1 ref v v 13 const # Using where; Using index
alter table t1 add unique(v); alter table t1 add unique(v);
ERROR 23000: Duplicate entry '{ ' for key 'v_2' 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); alter table t1 add key(v);
Warnings: Warnings:
Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release
......
...@@ -1917,6 +1917,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -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 1 SIMPLE t1 ref v v 13 const # Using where; Using index
alter table t1 add unique(v); alter table t1 add unique(v);
ERROR 23000: Duplicate entry '{ ' for key 'v_2' 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); alter table t1 add key(v);
Warnings: Warnings:
Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release
......
...@@ -1145,6 +1145,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -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 1 SIMPLE t1 ref v v 13 const # Using where; Using index
alter table t1 add unique(v); alter table t1 add unique(v);
ERROR 23000: Duplicate entry '{ ' for key 'v_2' 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); alter table t1 add key(v);
Warnings: Warnings:
Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release
......
...@@ -9938,7 +9938,9 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, ...@@ -9938,7 +9938,9 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
} }
if (to->file->ha_end_bulk_insert() && error <= 0) 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; error= 1;
} }
to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
......
...@@ -834,7 +834,10 @@ extern "C" { ...@@ -834,7 +834,10 @@ extern "C" {
int _ma_killed_ptr(HA_CHECK *param) 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) ...@@ -1668,8 +1671,11 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
} }
if (error && file->create_unique_index_by_sort && if (error && file->create_unique_index_by_sort &&
share->state.dupp_key != MAX_KEY) share->state.dupp_key != MAX_KEY)
{
my_errno= HA_ERR_FOUND_DUPP_KEY;
print_keydup_error(table, &table->key_info[share->state.dupp_key], print_keydup_error(table, &table->key_info[share->state.dupp_key],
MYF(0)); MYF(0));
}
} }
else else
{ {
......
...@@ -1364,6 +1364,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend, ...@@ -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; pos=block_info.filepos+block_info.block_len;
if (block_info.rec_len > (uint) share->base.max_pack_length) 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", _ma_check_print_error(param,"Found too long record (%lu) at %s",
(ulong) block_info.rec_len, (ulong) block_info.rec_len,
llstr(start_recpos,llbuff)); llstr(start_recpos,llbuff));
...@@ -4995,6 +4996,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param) ...@@ -4995,6 +4996,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
param->error_printed=1; param->error_printed=1;
param->retry_repair=1; param->retry_repair=1;
param->testflag|=T_RETRY_WITHOUT_QUICK; param->testflag|=T_RETRY_WITHOUT_QUICK;
my_errno= HA_ERR_WRONG_IN_RECORD;
DBUG_RETURN(1); /* Something wrong with data */ DBUG_RETURN(1); /* Something wrong with data */
} }
b_type= _ma_get_block_info(info, &block_info,-1,pos); 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) ...@@ -5268,6 +5270,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
param->error_printed=1; param->error_printed=1;
param->retry_repair=1; param->retry_repair=1;
param->testflag|=T_RETRY_WITHOUT_QUICK; param->testflag|=T_RETRY_WITHOUT_QUICK;
my_errno= HA_ERR_WRONG_IN_RECORD;
DBUG_RETURN(1); /* Something wrong with data */ DBUG_RETURN(1); /* Something wrong with data */
} }
sort_param->start_recpos=sort_param->pos; sort_param->start_recpos=sort_param->pos;
......
...@@ -577,7 +577,10 @@ extern "C" { ...@@ -577,7 +577,10 @@ extern "C" {
int killed_ptr(HA_CHECK *param) 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,...) void mi_check_print_error(HA_CHECK *param, const char *fmt,...)
...@@ -1213,6 +1216,11 @@ int ha_myisam::repair(THD *thd, HA_CHECK &param, bool do_optimize) ...@@ -1213,6 +1216,11 @@ int ha_myisam::repair(THD *thd, HA_CHECK &param, bool do_optimize)
if (remap) if (remap)
mi_munmap_file(file); mi_munmap_file(file);
#endif #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) && if (mi_test_if_sort_rep(file,file->state->records,tmp_key_map,0) &&
(local_testflag & T_REP_BY_SORT)) (local_testflag & T_REP_BY_SORT))
{ {
...@@ -1235,8 +1243,11 @@ int ha_myisam::repair(THD *thd, HA_CHECK &param, bool do_optimize) ...@@ -1235,8 +1243,11 @@ int ha_myisam::repair(THD *thd, HA_CHECK &param, bool do_optimize)
} }
if (error && file->create_unique_index_by_sort && if (error && file->create_unique_index_by_sort &&
share->state.dupp_key != MAX_KEY) share->state.dupp_key != MAX_KEY)
{
my_errno= HA_ERR_FOUND_DUPP_KEY;
print_keydup_error(table, &table->key_info[share->state.dupp_key], print_keydup_error(table, &table->key_info[share->state.dupp_key],
MYF(0)); MYF(0));
}
} }
else else
{ {
......
...@@ -3126,6 +3126,7 @@ static int sort_key_read(MI_SORT_PARAM *sort_param, void *key) ...@@ -3126,6 +3126,7 @@ static int sort_key_read(MI_SORT_PARAM *sort_param, void *key)
} }
if (info->state->records == sort_info->max_records) if (info->state->records == sort_info->max_records)
{ {
my_errno= HA_ERR_WRONG_IN_RECORD;
mi_check_print_error(sort_info->param, mi_check_print_error(sort_info->param,
"Key %d - Found too many records; Can't continue", "Key %d - Found too many records; Can't continue",
sort_param->key+1); sort_param->key+1);
...@@ -3332,6 +3333,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) ...@@ -3332,6 +3333,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
param->error_printed=1; param->error_printed=1;
param->retry_repair=1; param->retry_repair=1;
param->testflag|=T_RETRY_WITHOUT_QUICK; param->testflag|=T_RETRY_WITHOUT_QUICK;
my_errno= HA_ERR_WRONG_IN_RECORD;
DBUG_RETURN(1); /* Something wrong with data */ DBUG_RETURN(1); /* Something wrong with data */
} }
b_type=_mi_get_block_info(&block_info,-1,pos); 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) ...@@ -3590,6 +3592,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
param->error_printed=1; param->error_printed=1;
param->retry_repair=1; param->retry_repair=1;
param->testflag|=T_RETRY_WITHOUT_QUICK; param->testflag|=T_RETRY_WITHOUT_QUICK;
my_errno= HA_ERR_WRONG_IN_RECORD;
DBUG_RETURN(1); /* Something wrong with data */ DBUG_RETURN(1); /* Something wrong with data */
} }
sort_param->start_recpos=sort_param->pos; sort_param->start_recpos=sort_param->pos;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment