diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index b798b49dd34..42739b10d50 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -121,3 +121,17 @@ ERROR 42000: Incorrect table name '#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa use test; drop database mysqltestbug26703; End of 5.1 tests + +# -- +# -- Bug#37431 (DROP TABLE does not report errors correctly). +# -- +DROP TABLE IF EXISTS t1; +DROP TABLE t1; +ERROR 42S02: Unknown table 't1' +SHOW WARNINGS; +Level Code Message +Error 1051 Unknown table 't1' + +# -- +# -- End of Bug#37431. +# -- diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index bb4dd3e11f9..6be4ea25007 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -202,3 +202,24 @@ use test; drop database mysqltestbug26703; --echo End of 5.1 tests + +########################################################################### + +--echo +--echo # -- +--echo # -- Bug#37431 (DROP TABLE does not report errors correctly). +--echo # -- + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--error ER_BAD_TABLE_ERROR +DROP TABLE t1; + +SHOW WARNINGS; + +--echo +--echo # -- +--echo # -- End of Bug#37431. +--echo # -- diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 456ff0cb3c5..1c586415ce9 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -390,7 +390,7 @@ char *thd_security_context(THD *thd, char *buffer, unsigned int length, /** - Implementation of Drop_table_error_handler::handle_error(). + Implementation of Drop_table_error_handler::handle_condition(). The reason in having this implementation is to silence technical low-level warnings during DROP TABLE operation. Currently we don't want to expose the following warnings during DROP TABLE: diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e6f9bb9e5e3..2d7f85384a1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2054,6 +2054,12 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, } DBUG_PRINT("table", ("table: 0x%lx s: 0x%lx", (long) table->table, table->table ? (long) table->table->s : (long) -1)); + + DBUG_EXECUTE_IF("bug43138", + my_printf_error(ER_BAD_TABLE_ERROR, + ER(ER_BAD_TABLE_ERROR), MYF(0), + table->table_name);); + } /* It's safe to unlock LOCK_open: we have an exclusive lock