diff options
author | Sergei Golubchik <serg@mariadb.org> | 2020-06-15 12:13:44 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2020-07-04 01:44:46 +0200 |
commit | 2bb5981c202f85c8399485d6a57a69d8c6f627af (patch) | |
tree | 9e0f32ea030da1aa62a05f849a0e1c66bc044324 /sql | |
parent | b014720b6c05c8f8c08ffad263aff3273ff3d253 (diff) | |
download | mariadb-git-2bb5981c202f85c8399485d6a57a69d8c6f627af.tar.gz |
MDEV-11412 Ensure that table is truly dropped when using DROP TABLE
minor post-review fixes
* remove duplicate tests
* first file indicates table existance even with discovery
* don't duplicate trigger dropping code
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.cc | 13 | ||||
-rw-r--r-- | sql/sql_table.cc | 40 |
2 files changed, 11 insertions, 42 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 8642c773007..28588235477 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4457,21 +4457,12 @@ int handler::delete_table(const char *name) // For discovery tables, it's ok if first file doesn't exists if (ht->discover_table) - { - abort_if_first_file_error= 0; saved_error= 0; - if (!bas_ext()) - { - DBUG_ASSERT(ht->flags & HTON_AUTOMATIC_DELETE_TABLE); - DBUG_RETURN(0); // Drop succeded - } - } for (const char **ext= bas_ext(); *ext ; ext++) { - int error; - if ((error= mysql_file_delete_with_symlink(key_file_misc, name, *ext, - MYF(0)))) + int err= mysql_file_delete_with_symlink(key_file_misc, name, *ext, MYF(0)); + if (err) { if (my_errno != ENOENT) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index de1ebb4f191..0d6e2c69695 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2308,7 +2308,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, for (table= tables; table; table= table->next_local) { bool is_trans= 0, frm_was_deleted= 0, temporary_table_was_dropped= 0; - bool table_creation_was_logged= 0, trigger_drop_executed= 0; + bool table_creation_was_logged= 0; bool local_non_tmp_error= 0, frm_exists= 0, wrong_drop_sequence= 0; bool table_dropped= 0; LEX_CSTRING db= table->db; @@ -2363,14 +2363,6 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, */ if (!dont_log_query && table_creation_was_logged) { - /* - DROP TEMPORARY succeded. For the moment when we only come - here on success (error == 0) - - If there is an error, we don't know the type of the engine - at this point. So, we keep it in the trx-cache. - */ - is_trans= error ? TRUE : is_trans; if (is_trans) trans_tmp_table_deleted= TRUE; else @@ -2416,7 +2408,6 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, } DEBUG_SYNC(thd, "rm_table_no_locks_before_delete_table"); - error= 0; if (drop_temporary) { /* "DROP TEMPORARY" but a temporary table was not found */ @@ -2551,16 +2542,6 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, table_dropped= 1; } } - if (likely(!error) || non_existing_table_error(error)) - { - trigger_drop_executed= 1; - - if (Table_triggers_list::drop_all_triggers(thd, &db, - &table->table_name, - MYF(MY_WME | - MY_IGNORE_ENOENT))) - error= error ? error : -1; - } local_non_tmp_error|= MY_TEST(error); } @@ -2568,14 +2549,9 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, If there was no .frm file and the table is not temporary, scan all engines try to drop the table from there. This is to ensure we don't have any partial table files left. - - We check for trigger_drop_executed to ensure we don't again try - to drop triggers when it failed above (after sucecssfully dropping - the table). */ if (non_existing_table_error(error) && !drop_temporary && - table_type != view_pseudo_hton && !trigger_drop_executed && - !wrong_drop_sequence) + table_type != view_pseudo_hton && !wrong_drop_sequence) { int ferror= 0; @@ -2601,16 +2577,18 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, MYF(MY_WME | MY_IGNORE_ENOENT))) ferror= my_errno; } - if (Table_triggers_list::drop_all_triggers(thd, &db, - &table->table_name, - MYF(MY_WME | - MY_IGNORE_ENOENT))) - ferror= -1; } if (!error) error= ferror; } + if (likely(!error) || non_existing_table_error(error)) + { + if (Table_triggers_list::drop_all_triggers(thd, &db, &table->table_name, + MYF(MY_WME | MY_IGNORE_ENOENT))) + error= error ? error : -1; + } + if (error) { char buff[FN_REFLEN]; |