1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

replace HTON_AUTOMATIC_DELETE_TABLE with return -1 from drop_table()

This commit is contained in:
Sergei Golubchik
2020-06-22 22:14:25 +02:00
parent 4876651e0f
commit 6c52931680
11 changed files with 30 additions and 50 deletions

View File

@@ -2758,14 +2758,14 @@ int ha_delete_table(THD *thd, handlerton *hton, const char *path,
if (hton == NULL || hton == view_pseudo_hton) if (hton == NULL || hton == view_pseudo_hton)
DBUG_RETURN(0); 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. It's not an error if the table doesn't exist in the engine.
warn the user, but still report DROP being a success warn the user, but still report DROP being a success
*/ */
bool intercept= non_existing_table_error(error); bool intercept= non_existing_table_error(error);
DBUG_ASSERT(error > 0);
if ((!intercept || generate_warning) && ! thd->is_error()) 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); handlerton *hton = plugin_hton(plugin);
st_force_drop_table_params *param = (st_force_drop_table_params *)arg; st_force_drop_table_params *param = (st_force_drop_table_params *)arg;
/* int error;
We have to ignore HEAP tables as these may not have been created yet error= ha_delete_table(thd, hton, param->path, param->db, param->alias, 0);
We also remove engines marked with if (error > 0 && !non_existing_table_error(error))
HTON_AUTOMATIC_DELETE_TABLE as for these we can't check if the table param->error= error;
ever existed. if (error == 0)
*/
if (hton->db_type != DB_TYPE_HEAP &&
!(hton->flags & HTON_AUTOMATIC_DELETE_TABLE))
{ {
int error; param->error= 0;
error= ha_delete_table(thd, hton, param->path, param->db, param->alias, 0); return TRUE; // Table was deleted
if (error > 0 && !non_existing_table_error(error))
param->error= error;
if (error == 0)
{
param->error= 0;
return TRUE; // Table was deleted
}
} }
return FALSE; return FALSE;
} }

View File

@@ -1484,6 +1484,11 @@ struct handlerton
void (*close_cursor_read_view)(handlerton *hton, THD *thd, void *read_view); void (*close_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root); handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
void (*drop_database)(handlerton *hton, char* path); 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 (*drop_table)(handlerton *hton, const char* path);
int (*panic)(handlerton *hton, enum ha_panic_function flag); int (*panic)(handlerton *hton, enum ha_panic_function flag);
int (*start_consistent_snapshot)(handlerton *hton, THD *thd); 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) #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; class Ha_trx_info;
struct THD_TRANS struct THD_TRANS

View File

@@ -1692,7 +1692,7 @@ int binlog_init(void *p)
binlog_savepoint_rollback_can_release_mdl; binlog_savepoint_rollback_can_release_mdl;
binlog_hton->commit= binlog_commit; binlog_hton->commit= binlog_commit;
binlog_hton->rollback= binlog_rollback; 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) if (WSREP_ON || opt_bin_log)
{ {
binlog_hton->prepare= binlog_prepare; 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 // recover needs to be set to make xa{commit,rollback}_handlerton effective
binlog_hton->recover= binlog_xa_recover_dummy; binlog_hton->recover= binlog_xa_recover_dummy;
} }
binlog_hton->flags= (HTON_NOT_USER_SELECTABLE | binlog_hton->flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN | HTON_NO_ROLLBACK;
HTON_HIDDEN |
HTON_NO_ROLLBACK |
HTON_AUTOMATIC_DELETE_TABLE);
return 0; return 0;
} }

View File

@@ -700,7 +700,7 @@ bool THD::rm_temporary_table(handlerton *base, const char *path)
if (mysql_file_delete(key_file_frm, frm_path, if (mysql_file_delete(key_file_frm, frm_path,
MYF(MY_WME | MY_IGNORE_ENOENT))) MYF(MY_WME | MY_IGNORE_ENOENT)))
error= true; error= true;
if (base->drop_table(base, path)) if (base->drop_table(base, path) > 0)
{ {
error= true; error= true;
sql_print_warning("Could not remove temporary table: '%s', error: %d", sql_print_warning("Could not remove temporary table: '%s', error: %d",

View File

@@ -399,8 +399,8 @@ static int blackhole_init(void *p)
blackhole_hton= (handlerton *)p; blackhole_hton= (handlerton *)p;
blackhole_hton->db_type= DB_TYPE_BLACKHOLE_DB; blackhole_hton->db_type= DB_TYPE_BLACKHOLE_DB;
blackhole_hton->create= blackhole_create_handler; blackhole_hton->create= blackhole_create_handler;
blackhole_hton->drop_table= [](handlerton *, const char*) { return 0; }; blackhole_hton->drop_table= [](handlerton *, const char*) { return -1; };
blackhole_hton->flags= HTON_CAN_RECREATE | HTON_AUTOMATIC_DELETE_TABLE; blackhole_hton->flags= HTON_CAN_RECREATE;
mysql_mutex_init(bh_key_mutex_blackhole, mysql_mutex_init(bh_key_mutex_blackhole,
&blackhole_mutex, MY_MUTEX_INIT_FAST); &blackhole_mutex, MY_MUTEX_INIT_FAST);

View File

@@ -484,9 +484,8 @@ int federated_db_init(void *p)
federated_hton->commit= federated_commit; federated_hton->commit= federated_commit;
federated_hton->rollback= federated_rollback; federated_hton->rollback= federated_rollback;
federated_hton->create= federated_create_handler; federated_hton->create= federated_create_handler;
federated_hton->drop_table= [](handlerton *, const char*) { return 0; }; federated_hton->drop_table= [](handlerton *, const char*) { return -1; };
federated_hton->flags= (HTON_ALTER_NOT_SUPPORTED | HTON_NO_PARTITION | federated_hton->flags= HTON_ALTER_NOT_SUPPORTED | HTON_NO_PARTITION;
HTON_AUTOMATIC_DELETE_TABLE);
/* /*
Support for transactions disabled until WL#2952 fixes it. Support for transactions disabled until WL#2952 fixes it.

View File

@@ -438,9 +438,8 @@ int federatedx_db_init(void *p)
federatedx_hton->rollback= ha_federatedx::rollback; federatedx_hton->rollback= ha_federatedx::rollback;
federatedx_hton->discover_table_structure= ha_federatedx::discover_assisted; federatedx_hton->discover_table_structure= ha_federatedx::discover_assisted;
federatedx_hton->create= federatedx_create_handler; federatedx_hton->create= federatedx_create_handler;
federatedx_hton->drop_table= [](handlerton *, const char*) { return 0; }; federatedx_hton->drop_table= [](handlerton *, const char*) { return -1; };
federatedx_hton->flags= (HTON_ALTER_NOT_SUPPORTED | federatedx_hton->flags= HTON_ALTER_NOT_SUPPORTED;
HTON_AUTOMATIC_DELETE_TABLE);
federatedx_hton->create_derived= create_federatedx_derived_handler; federatedx_hton->create_derived= create_federatedx_derived_handler;
federatedx_hton->create_select= create_federatedx_select_handler; federatedx_hton->create_select= create_federatedx_select_handler;

View File

@@ -43,7 +43,7 @@ static int heap_panic(handlerton *hton, ha_panic_function flag)
static int heap_drop_table(handlerton *hton, const char *path) static int heap_drop_table(handlerton *hton, const char *path)
{ {
int error= heap_delete_table(path); int error= heap_delete_table(path);
return error == ENOENT ? 0 : error; return error == ENOENT ? -1 : error;
} }
int heap_init(void *p) int heap_init(void *p)

View File

@@ -94,13 +94,10 @@ static int pfs_init_func(void *p)
pfs_hton= reinterpret_cast<handlerton *> (p); pfs_hton= reinterpret_cast<handlerton *> (p);
pfs_hton->create= pfs_create_handler; 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->show_status= pfs_show_status;
pfs_hton->flags= (HTON_ALTER_NOT_SUPPORTED | pfs_hton->flags= HTON_ALTER_NOT_SUPPORTED | HTON_TEMPORARY_NOT_SUPPORTED |
HTON_TEMPORARY_NOT_SUPPORTED | HTON_NO_PARTITION | HTON_NO_BINLOG_ROW_OPT;
HTON_NO_PARTITION |
HTON_NO_BINLOG_ROW_OPT |
HTON_AUTOMATIC_DELETE_TABLE);
/* /*
As long as the server implementation keeps using legacy_db_type, As long as the server implementation keeps using legacy_db_type,

View File

@@ -749,8 +749,8 @@ static int sphinx_init_func ( void * p )
hton->close_connection = sphinx_close_connection; hton->close_connection = sphinx_close_connection;
hton->show_status = sphinx_show_status; hton->show_status = sphinx_show_status;
hton->panic = sphinx_panic; hton->panic = sphinx_panic;
hton->drop_table= [](handlerton *, const char*) { return 0; }; hton->drop_table= [](handlerton *, const char*) { return -1; };
hton->flags = HTON_CAN_RECREATE | HTON_AUTOMATIC_DELETE_TABLE; hton->flags = HTON_CAN_RECREATE;
#endif #endif
} }
SPH_RET(0); SPH_RET(0);

View File

@@ -7249,7 +7249,7 @@ int spider_db_init(
DBUG_ENTER("spider_db_init"); DBUG_ENTER("spider_db_init");
spider_hton_ptr = spider_hton; 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 #ifdef HTON_CAN_READ_CONNECT_STRING_IN_PARTITION
spider_hton->flags |= HTON_CAN_READ_CONNECT_STRING_IN_PARTITION; spider_hton->flags |= HTON_CAN_READ_CONNECT_STRING_IN_PARTITION;
#endif #endif