Skip to content

Commit 6034387

Browse files
committed
MDEV-8453 Alter table not returning engine errors
remove ~15 years old print_lock_error() function, use handler::print_error() instead Backport from 10.1
1 parent 3d20674 commit 6034387

File tree

4 files changed

+24
-34
lines changed

4 files changed

+24
-34
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
create table t1 (a int, b int);
2+
set debug_dbug='+d,external_lock_failure';
3+
alter table t1 add column c int;
4+
ERROR HY000: Got error 168 'KABOOM!' from MyISAM
5+
set debug_dbug='';
6+
drop table t1;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# MDEV-8453 Alter table not returning engine errors
3+
#
4+
--source include/have_debug.inc
5+
6+
create table t1 (a int, b int);
7+
set debug_dbug='+d,external_lock_failure';
8+
--error ER_GET_ERRMSG
9+
alter table t1 add column c int;
10+
set debug_dbug='';
11+
drop table t1;

sql/handler.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3650,6 +3650,8 @@ void handler::print_error(int error, myf errflag)
36503650
*/
36513651
bool handler::get_error_message(int error, String* buf)
36523652
{
3653+
DBUG_EXECUTE_IF("external_lock_failure",
3654+
buf->set_ascii(STRING_WITH_LEN("KABOOM!")););
36533655
return FALSE;
36543656
}
36553657

@@ -5944,6 +5946,8 @@ int handler::ha_external_lock(THD *thd, int lock_type)
59445946
MYSQL_TABLE_LOCK_WAIT(m_psi, PSI_TABLE_EXTERNAL_LOCK, lock_type,
59455947
{ error= external_lock(thd, lock_type); })
59465948

5949+
DBUG_EXECUTE_IF("external_lock_failure", error= HA_ERR_GENERIC;);
5950+
59475951
if (error == 0 || lock_type == F_UNLCK)
59485952
{
59495953
m_lock_type= lock_type;

sql/lock.cc

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ extern HASH open_cache;
9292

9393
static int lock_external(THD *thd, TABLE **table,uint count);
9494
static int unlock_external(THD *thd, TABLE **table,uint count);
95-
static void print_lock_error(int error, TABLE *);
9695

9796
/* Map the return value of thr_lock to an error from errmsg.txt */
9897
static int thr_lock_errno_to_mysql[]=
@@ -358,7 +357,7 @@ static int lock_external(THD *thd, TABLE **tables, uint count)
358357

359358
if ((error=(*tables)->file->ha_external_lock(thd,lock_type)))
360359
{
361-
print_lock_error(error, *tables);
360+
(*tables)->file->print_error(error, MYF(0));
362361
while (--i)
363362
{
364363
tables--;
@@ -675,8 +674,8 @@ static int unlock_external(THD *thd, TABLE **table,uint count)
675674
(*table)->current_lock = F_UNLCK;
676675
if ((error=(*table)->file->ha_external_lock(thd, F_UNLCK)))
677676
{
678-
error_code=error;
679-
print_lock_error(error_code, *table);
677+
error_code= error;
678+
(*table)->file->print_error(error, MYF(0));
680679
}
681680
}
682681
table++;
@@ -898,36 +897,6 @@ bool lock_object_name(THD *thd, MDL_key::enum_mdl_namespace mdl_type,
898897
}
899898

900899

901-
static void print_lock_error(int error, TABLE *table)
902-
{
903-
int textno;
904-
DBUG_ENTER("print_lock_error");
905-
906-
switch (error) {
907-
case HA_ERR_LOCK_WAIT_TIMEOUT:
908-
textno=ER_LOCK_WAIT_TIMEOUT;
909-
break;
910-
case HA_ERR_READ_ONLY_TRANSACTION:
911-
textno=ER_READ_ONLY_TRANSACTION;
912-
break;
913-
case HA_ERR_LOCK_DEADLOCK:
914-
textno=ER_LOCK_DEADLOCK;
915-
break;
916-
case HA_ERR_WRONG_COMMAND:
917-
my_error(ER_ILLEGAL_HA, MYF(0), table->file->table_type(),
918-
table->s->db.str, table->s->table_name.str);
919-
DBUG_VOID_RETURN;
920-
default:
921-
textno=ER_CANT_LOCK;
922-
break;
923-
}
924-
925-
my_error(textno, MYF(0), error);
926-
927-
DBUG_VOID_RETURN;
928-
}
929-
930-
931900
/****************************************************************************
932901
Handling of global read locks
933902

0 commit comments

Comments
 (0)