summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/engine_error_in_alter-8453.result6
-rw-r--r--mysql-test/t/engine_error_in_alter-8453.test11
-rw-r--r--sql/handler.cc4
-rw-r--r--sql/lock.cc37
-rw-r--r--storage/connect/mysql-test/connect/r/grant2.result2
5 files changed, 25 insertions, 35 deletions
diff --git a/mysql-test/r/engine_error_in_alter-8453.result b/mysql-test/r/engine_error_in_alter-8453.result
new file mode 100644
index 00000000000..c5a3375f33c
--- /dev/null
+++ b/mysql-test/r/engine_error_in_alter-8453.result
@@ -0,0 +1,6 @@
+create table t1 (a int, b int);
+set debug_dbug='+d,external_lock_failure';
+alter table t1 add column c int;
+ERROR HY000: Got error 168 'KABOOM!' from MyISAM
+set debug_dbug='';
+drop table t1;
diff --git a/mysql-test/t/engine_error_in_alter-8453.test b/mysql-test/t/engine_error_in_alter-8453.test
new file mode 100644
index 00000000000..c4600ec07fe
--- /dev/null
+++ b/mysql-test/t/engine_error_in_alter-8453.test
@@ -0,0 +1,11 @@
+#
+# MDEV-8453 Alter table not returning engine errors
+#
+--source include/have_debug.inc
+
+create table t1 (a int, b int);
+set debug_dbug='+d,external_lock_failure';
+--error ER_GET_ERRMSG
+alter table t1 add column c int;
+set debug_dbug='';
+drop table t1;
diff --git a/sql/handler.cc b/sql/handler.cc
index 1d1dae75164..0f341a0ccc5 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3631,6 +3631,8 @@ void handler::print_error(int error, myf errflag)
*/
bool handler::get_error_message(int error, String* buf)
{
+ DBUG_EXECUTE_IF("external_lock_failure",
+ buf->set_ascii(STRING_WITH_LEN("KABOOM!")););
return FALSE;
}
@@ -5802,6 +5804,8 @@ int handler::ha_external_lock(THD *thd, int lock_type)
MYSQL_TABLE_LOCK_WAIT(m_psi, PSI_TABLE_EXTERNAL_LOCK, lock_type,
{ error= external_lock(thd, lock_type); })
+ DBUG_EXECUTE_IF("external_lock_failure", error= HA_ERR_GENERIC;);
+
if (error == 0)
{
m_lock_type= lock_type;
diff --git a/sql/lock.cc b/sql/lock.cc
index 946a089fadc..7e7b378bfb4 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -90,7 +90,6 @@ extern HASH open_cache;
static int lock_external(THD *thd, TABLE **table,uint count);
static int unlock_external(THD *thd, TABLE **table,uint count);
-static void print_lock_error(int error, TABLE *);
/* Map the return value of thr_lock to an error from errmsg.txt */
static int thr_lock_errno_to_mysql[]=
@@ -365,7 +364,7 @@ static int lock_external(THD *thd, TABLE **tables, uint count)
if ((error=(*tables)->file->ha_external_lock(thd,lock_type)))
{
- print_lock_error(error, *tables);
+ (*tables)->file->print_error(error, MYF(0));
while (--i)
{
tables--;
@@ -687,8 +686,8 @@ static int unlock_external(THD *thd, TABLE **table,uint count)
(*table)->current_lock = F_UNLCK;
if ((error=(*table)->file->ha_external_lock(thd, F_UNLCK)))
{
- error_code=error;
- print_lock_error(error_code, *table);
+ error_code= error;
+ (*table)->file->print_error(error, MYF(0));
}
}
table++;
@@ -910,36 +909,6 @@ bool lock_object_name(THD *thd, MDL_key::enum_mdl_namespace mdl_type,
}
-static void print_lock_error(int error, TABLE *table)
-{
- int textno;
- DBUG_ENTER("print_lock_error");
-
- switch (error) {
- case HA_ERR_LOCK_WAIT_TIMEOUT:
- textno=ER_LOCK_WAIT_TIMEOUT;
- break;
- case HA_ERR_READ_ONLY_TRANSACTION:
- textno=ER_READ_ONLY_TRANSACTION;
- break;
- case HA_ERR_LOCK_DEADLOCK:
- textno=ER_LOCK_DEADLOCK;
- break;
- case HA_ERR_WRONG_COMMAND:
- my_error(ER_ILLEGAL_HA, MYF(0), table->file->table_type(),
- table->s->db.str, table->s->table_name.str);
- DBUG_VOID_RETURN;
- default:
- textno=ER_CANT_LOCK;
- break;
- }
-
- my_error(textno, MYF(0), error);
-
- DBUG_VOID_RETURN;
-}
-
-
/****************************************************************************
Handling of global read locks
diff --git a/storage/connect/mysql-test/connect/r/grant2.result b/storage/connect/mysql-test/connect/r/grant2.result
index acefe6df659..0259dd74cdc 100644
--- a/storage/connect/mysql-test/connect/r/grant2.result
+++ b/storage/connect/mysql-test/connect/r/grant2.result
@@ -622,7 +622,7 @@ test.t1 optimize status OK
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize Error Access denied for user 'user'@'localhost' (using password: NO)
-test.t1 optimize Error Can't lock file (errno: 122 "Internal (unspecified) error in handler")
+test.t1 optimize Error Got error 122 'This operation requires the FILE privilege' from CONNECT
test.t1 optimize error Corrupt
DROP TABLE t1;
# Testing SQLCOM_ALTER_TABLE (adding columns)