replace HTON_AUTOMATIC_DELETE_TABLE with return -1 from drop_table()
This commit is contained in:
parent
4876651e0f
commit
6c52931680
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -94,13 +94,10 @@ static int pfs_init_func(void *p)
|
||||
pfs_hton= reinterpret_cast<handlerton *> (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,
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user