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) { - 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 - } + 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", diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc index c4eba8b4171..0134032351e 100644 --- a/storage/blackhole/ha_blackhole.cc +++ b/storage/blackhole/ha_blackhole.cc @@ -399,8 +399,8 @@ static int blackhole_init(void *p) blackhole_hton= (handlerton *)p; blackhole_hton->db_type= DB_TYPE_BLACKHOLE_DB; blackhole_hton->create= blackhole_create_handler; - blackhole_hton->drop_table= [](handlerton *, const char*) { return 0; }; - blackhole_hton->flags= HTON_CAN_RECREATE | HTON_AUTOMATIC_DELETE_TABLE; + blackhole_hton->drop_table= [](handlerton *, const char*) { return -1; }; + blackhole_hton->flags= HTON_CAN_RECREATE; mysql_mutex_init(bh_key_mutex_blackhole, &blackhole_mutex, MY_MUTEX_INIT_FAST); diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index c0e5c330edb..871a254f8c0 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -484,9 +484,8 @@ int federated_db_init(void *p) federated_hton->commit= federated_commit; federated_hton->rollback= federated_rollback; federated_hton->create= federated_create_handler; - federated_hton->drop_table= [](handlerton *, const char*) { return 0; }; - federated_hton->flags= (HTON_ALTER_NOT_SUPPORTED | HTON_NO_PARTITION | - HTON_AUTOMATIC_DELETE_TABLE); + federated_hton->drop_table= [](handlerton *, const char*) { return -1; }; + federated_hton->flags= HTON_ALTER_NOT_SUPPORTED | HTON_NO_PARTITION; /* Support for transactions disabled until WL#2952 fixes it. diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index 45029fdf17f..dfcbf156f88 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -438,9 +438,8 @@ int federatedx_db_init(void *p) federatedx_hton->rollback= ha_federatedx::rollback; federatedx_hton->discover_table_structure= ha_federatedx::discover_assisted; federatedx_hton->create= federatedx_create_handler; - federatedx_hton->drop_table= [](handlerton *, const char*) { return 0; }; - federatedx_hton->flags= (HTON_ALTER_NOT_SUPPORTED | - HTON_AUTOMATIC_DELETE_TABLE); + federatedx_hton->drop_table= [](handlerton *, const char*) { return -1; }; + federatedx_hton->flags= HTON_ALTER_NOT_SUPPORTED; federatedx_hton->create_derived= create_federatedx_derived_handler; federatedx_hton->create_select= create_federatedx_select_handler; diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 38996dd0c93..895b6edfcf2 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -43,7 +43,7 @@ static int heap_panic(handlerton *hton, ha_panic_function flag) static int heap_drop_table(handlerton *hton, const char *path) { int error= heap_delete_table(path); - return error == ENOENT ? 0 : error; + return error == ENOENT ? -1 : error; } int heap_init(void *p) diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc index 1509936fe53..f54d46ce979 100644 --- a/storage/perfschema/ha_perfschema.cc +++ b/storage/perfschema/ha_perfschema.cc @@ -94,13 +94,10 @@ static int pfs_init_func(void *p) pfs_hton= reinterpret_cast (p); pfs_hton->create= pfs_create_handler; - pfs_hton->drop_table= [](handlerton *, const char*) { return 0; }; + pfs_hton->drop_table= [](handlerton *, const char*) { return -1; }; pfs_hton->show_status= pfs_show_status; - pfs_hton->flags= (HTON_ALTER_NOT_SUPPORTED | - HTON_TEMPORARY_NOT_SUPPORTED | - HTON_NO_PARTITION | - HTON_NO_BINLOG_ROW_OPT | - HTON_AUTOMATIC_DELETE_TABLE); + pfs_hton->flags= HTON_ALTER_NOT_SUPPORTED | HTON_TEMPORARY_NOT_SUPPORTED | + HTON_NO_PARTITION | HTON_NO_BINLOG_ROW_OPT; /* As long as the server implementation keeps using legacy_db_type, diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc index 39e07290853..ca68a5feb60 100644 --- a/storage/sphinx/ha_sphinx.cc +++ b/storage/sphinx/ha_sphinx.cc @@ -749,8 +749,8 @@ static int sphinx_init_func ( void * p ) hton->close_connection = sphinx_close_connection; hton->show_status = sphinx_show_status; hton->panic = sphinx_panic; - hton->drop_table= [](handlerton *, const char*) { return 0; }; - hton->flags = HTON_CAN_RECREATE | HTON_AUTOMATIC_DELETE_TABLE; + hton->drop_table= [](handlerton *, const char*) { return -1; }; + hton->flags = HTON_CAN_RECREATE; #endif } SPH_RET(0); diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index f4b0177c794..e77e1a9261b 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -7249,7 +7249,7 @@ int spider_db_init( DBUG_ENTER("spider_db_init"); spider_hton_ptr = spider_hton; - spider_hton->flags = HTON_NO_FLAGS | HTON_AUTOMATIC_DELETE_TABLE; + spider_hton->flags = HTON_NO_FLAGS; #ifdef HTON_CAN_READ_CONNECT_STRING_IN_PARTITION spider_hton->flags |= HTON_CAN_READ_CONNECT_STRING_IN_PARTITION; #endif