Skip to content

Commit f7dab76

Browse files
committed
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.
1 parent ca7cf69 commit f7dab76

File tree

11 files changed

+44
-3
lines changed

11 files changed

+44
-3
lines changed

mysql-test/include/varchar.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a '
9090
--replace_regex /Duplicate entry '[^']+' for key/Duplicate entry '{ ' for key/
9191
--error ER_DUP_ENTRY
9292
alter table t1 add unique(v);
93+
show warnings;
9394
alter table t1 add key(v);
9495
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
9596
--replace_column 6 # 9 # 10 #

mysql-test/r/mix2_myisam.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,9 @@ id select_type table type possible_keys key key_len ref rows Extra
15491549
1 SIMPLE t1 ref v v 13 const # Using where; Using index
15501550
alter table t1 add unique(v);
15511551
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
1552+
show warnings;
1553+
Level Code Message
1554+
Error 1062 Duplicate entry 'a' for key 'v_2'
15521555
alter table t1 add key(v);
15531556
Warnings:
15541557
Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release

mysql-test/r/mrr_icp_extra.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ id select_type table type possible_keys key key_len ref rows Extra
350350
1 SIMPLE t1 ref v v 13 const # Using where; Using index
351351
alter table t1 add unique(v);
352352
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
353+
show warnings;
354+
Level Code Message
355+
Error 1062 Duplicate entry 'a' for key 'v_2'
353356
alter table t1 add key(v);
354357
Warnings:
355358
Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release

mysql-test/r/myisam.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,9 @@ id select_type table type possible_keys key key_len ref rows Extra
12551255
1 SIMPLE t1 ref v v 13 const # Using where; Using index
12561256
alter table t1 add unique(v);
12571257
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
1258+
show warnings;
1259+
Level Code Message
1260+
Error 1062 Duplicate entry 'a' for key 'v_2'
12581261
alter table t1 add key(v);
12591262
Warnings:
12601263
Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release

mysql-test/suite/innodb/r/innodb.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,9 @@ id select_type table type possible_keys key key_len ref rows Extra
19171917
1 SIMPLE t1 ref v v 13 const # Using where; Using index
19181918
alter table t1 add unique(v);
19191919
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
1920+
show warnings;
1921+
Level Code Message
1922+
Error 1062 Duplicate entry 'v' for key 'v_2'
19201923
alter table t1 add key(v);
19211924
Warnings:
19221925
Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release

mysql-test/suite/maria/maria.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,9 @@ id select_type table type possible_keys key key_len ref rows Extra
11451145
1 SIMPLE t1 ref v v 13 const # Using where; Using index
11461146
alter table t1 add unique(v);
11471147
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
1148+
show warnings;
1149+
Level Code Message
1150+
Error 1062 Duplicate entry 'a' for key 'v_2'
11481151
alter table t1 add key(v);
11491152
Warnings:
11501153
Note 1831 Duplicate index `v_2`. This is deprecated and will be disallowed in a future release

sql/sql_table.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9938,7 +9938,9 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
99389938
}
99399939
if (to->file->ha_end_bulk_insert() && error <= 0)
99409940
{
9941-
to->file->print_error(my_errno,MYF(0));
9941+
/* Give error, if not already given */
9942+
if (!thd->is_error())
9943+
to->file->print_error(my_errno,MYF(0));
99429944
error= 1;
99439945
}
99449946
to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);

storage/maria/ha_maria.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,10 @@ extern "C" {
834834

835835
int _ma_killed_ptr(HA_CHECK *param)
836836
{
837-
return thd_killed((THD*)param->thd);
837+
if (likely(thd_killed((THD*)param->thd)) == 0)
838+
return 0;
839+
my_errno= HA_ERR_ABORTED_BY_USER;
840+
return 1;
838841
}
839842

840843

@@ -1668,8 +1671,11 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
16681671
}
16691672
if (error && file->create_unique_index_by_sort &&
16701673
share->state.dupp_key != MAX_KEY)
1674+
{
1675+
my_errno= HA_ERR_FOUND_DUPP_KEY;
16711676
print_keydup_error(table, &table->key_info[share->state.dupp_key],
16721677
MYF(0));
1678+
}
16731679
}
16741680
else
16751681
{

storage/maria/ma_check.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend,
13641364
pos=block_info.filepos+block_info.block_len;
13651365
if (block_info.rec_len > (uint) share->base.max_pack_length)
13661366
{
1367+
my_errno= HA_ERR_WRONG_IN_RECORD;
13671368
_ma_check_print_error(param,"Found too long record (%lu) at %s",
13681369
(ulong) block_info.rec_len,
13691370
llstr(start_recpos,llbuff));
@@ -4995,6 +4996,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
49954996
param->error_printed=1;
49964997
param->retry_repair=1;
49974998
param->testflag|=T_RETRY_WITHOUT_QUICK;
4999+
my_errno= HA_ERR_WRONG_IN_RECORD;
49985000
DBUG_RETURN(1); /* Something wrong with data */
49995001
}
50005002
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)
52685270
param->error_printed=1;
52695271
param->retry_repair=1;
52705272
param->testflag|=T_RETRY_WITHOUT_QUICK;
5273+
my_errno= HA_ERR_WRONG_IN_RECORD;
52715274
DBUG_RETURN(1); /* Something wrong with data */
52725275
}
52735276
sort_param->start_recpos=sort_param->pos;

storage/myisam/ha_myisam.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,10 @@ extern "C" {
577577

578578
int killed_ptr(HA_CHECK *param)
579579
{
580-
return thd_killed((THD*)param->thd);
580+
if (likely(thd_killed((THD*)param->thd)) == 0)
581+
return 0;
582+
my_errno= HA_ERR_ABORTED_BY_USER;
583+
return 1;
581584
}
582585

583586
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)
12131216
if (remap)
12141217
mi_munmap_file(file);
12151218
#endif
1219+
/*
1220+
The following is to catch errors when my_errno is no set properly
1221+
during repairt
1222+
*/
1223+
my_errno= 0;
12161224
if (mi_test_if_sort_rep(file,file->state->records,tmp_key_map,0) &&
12171225
(local_testflag & T_REP_BY_SORT))
12181226
{
@@ -1235,8 +1243,11 @@ int ha_myisam::repair(THD *thd, HA_CHECK &param, bool do_optimize)
12351243
}
12361244
if (error && file->create_unique_index_by_sort &&
12371245
share->state.dupp_key != MAX_KEY)
1246+
{
1247+
my_errno= HA_ERR_FOUND_DUPP_KEY;
12381248
print_keydup_error(table, &table->key_info[share->state.dupp_key],
12391249
MYF(0));
1250+
}
12401251
}
12411252
else
12421253
{

0 commit comments

Comments
 (0)