From 6c52931680a4a24da04d7de7b74321d9ff507745 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 22 Jun 2020 22:14:25 +0200 Subject: replace HTON_AUTOMATIC_DELETE_TABLE with return -1 from drop_table() --- sql/handler.cc | 30 ++++++++++-------------------- sql/handler.h | 12 +++++------- sql/log.cc | 7 ++----- sql/temporary_tables.cc | 2 +- 4 files changed, 18 insertions(+), 33 deletions(-) (limited to 'sql') diff --git a/sql/handler.cc b/sql/handler.cc index e3ce0436a79..d601bbb8c87 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2758,14 +2758,14 @@ int ha_delete_table(THD *thd, handlerton *hton, const char *path, if (hton == NULL || hton == view_pseudo_hton) DBUG_RETURN(0); - if (unlikely((error= hton->drop_table(hton, path)))) + error= hton->drop_table(hton, path); + if (error > 0) { /* It's not an error if the table doesn't exist in the engine. warn the user, but still report DROP being a success */ bool intercept= non_existing_table_error(error); - DBUG_ASSERT(error > 0); if ((!intercept || generate_warning) && ! thd->is_error()) { @@ -5001,24 +5001,14 @@ static my_bool delete_table_force(THD *thd, plugin_ref plugin, void *arg) handlerton *hton = plugin_hton(plugin); st_force_drop_table_params *param = (st_force_drop_table_params *)arg; - /* - We have to ignore HEAP tables as these may not have been created yet - We also remove engines marked with - HTON_AUTOMATIC_DELETE_TABLE as for these we can't check if the table - ever existed. - */ - if (hton->db_type != DB_TYPE_HEAP && - !(hton->flags & HTON_AUTOMATIC_DELETE_TABLE)) - { - int error; - error= ha_delete_table(thd, hton, param->path, param->db, param->alias, 0); - if (error > 0 && !non_existing_table_error(error)) - param->error= error; - if (error == 0) - { - param->error= 0; - return TRUE; // Table was deleted - } + int error; + error= ha_delete_table(thd, hton, param->path, param->db, param->alias, 0); + if (error > 0 && !non_existing_table_error(error)) + param->error= error; + if (error == 0) + { + param->error= 0; + return TRUE; // Table was deleted } return FALSE; } diff --git a/sql/handler.h b/sql/handler.h index 4d9f92d3126..e8315b6ad9a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1484,6 +1484,11 @@ struct handlerton void (*close_cursor_read_view)(handlerton *hton, THD *thd, void *read_view); handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root); void (*drop_database)(handlerton *hton, char* path); + /* + return 0 if dropped successfully, + -1 if nothing was done by design (as in e.g. blackhole) + an error code (e.g. HA_ERR_NO_SUCH_TABLE) otherwise + */ int (*drop_table)(handlerton *hton, const char* path); int (*panic)(handlerton *hton, enum ha_panic_function flag); int (*start_consistent_snapshot)(handlerton *hton, THD *thd); @@ -1791,13 +1796,6 @@ handlerton *ha_default_tmp_handlerton(THD *thd); */ #define HTON_TRANSACTIONAL_AND_NON_TRANSACTIONAL (1 << 17) -/* - The engine doesn't keep track of tables, delete_table() is not - needed and delete_table() always returns 0 (table deleted). This flag - mainly used to skip storage engines in case of ha_delete_table_force() -*/ -#define HTON_AUTOMATIC_DELETE_TABLE (1 << 18) - class Ha_trx_info; struct THD_TRANS diff --git a/sql/log.cc b/sql/log.cc index b6778f34768..5f4fd6bbcab 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1692,7 +1692,7 @@ int binlog_init(void *p) binlog_savepoint_rollback_can_release_mdl; binlog_hton->commit= binlog_commit; binlog_hton->rollback= binlog_rollback; - binlog_hton->drop_table= [](handlerton *, const char*) { return 0; }; + binlog_hton->drop_table= [](handlerton *, const char*) { return -1; }; if (WSREP_ON || opt_bin_log) { binlog_hton->prepare= binlog_prepare; @@ -1702,10 +1702,7 @@ int binlog_init(void *p) // recover needs to be set to make xa{commit,rollback}_handlerton effective binlog_hton->recover= binlog_xa_recover_dummy; } - binlog_hton->flags= (HTON_NOT_USER_SELECTABLE | - HTON_HIDDEN | - HTON_NO_ROLLBACK | - HTON_AUTOMATIC_DELETE_TABLE); + binlog_hton->flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN | HTON_NO_ROLLBACK; return 0; } diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index 6a507b99ef6..1a8b5c471bd 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -700,7 +700,7 @@ bool THD::rm_temporary_table(handlerton *base, const char *path) if (mysql_file_delete(key_file_frm, frm_path, MYF(MY_WME | MY_IGNORE_ENOENT))) error= true; - if (base->drop_table(base, path)) + if (base->drop_table(base, path) > 0) { error= true; sql_print_warning("Could not remove temporary table: '%s', error: %d", -- cgit v1.2.1