diff --git a/include/mysql/psi/mysql_table.h b/include/mysql/psi/mysql_table.h index 5bbe8cef929..a2124064510 100644 --- a/include/mysql/psi/mysql_table.h +++ b/include/mysql/psi/mysql_table.h @@ -43,7 +43,6 @@ #ifdef HAVE_PSI_TABLE_INTERFACE #define MYSQL_UNBIND_TABLE(handler) (handler)->unbind_psi() -#define MYSQL_REBIND_TABLE(handler) (handler)->rebind_psi() #define PSI_CALL_unbind_table PSI_TABLE_CALL(unbind_table) #define PSI_CALL_rebind_table PSI_TABLE_CALL(rebind_table) @@ -54,7 +53,6 @@ #define PSI_CALL_drop_table_share PSI_TABLE_CALL(drop_table_share) #else #define MYSQL_UNBIND_TABLE(handler) do { } while(0) -#define MYSQL_REBIND_TABLE(handler) do { } while(0) #define PSI_CALL_unbind_table(A1) do { } while(0) #define PSI_CALL_rebind_table(A1,A2,A3) NULL diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 2e5355580c7..b52c193ba13 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3715,18 +3715,25 @@ void ha_partition::unbind_psi() DBUG_VOID_RETURN; } -void ha_partition::rebind_psi() +int ha_partition::rebind() { uint i; - DBUG_ENTER("ha_partition::rebind_psi"); - handler::rebind_psi(); + DBUG_ENTER("ha_partition::rebind"); + if (int error= handler::rebind()) + DBUG_RETURN(error); for (i= 0; i < m_tot_parts; i++) { DBUG_ASSERT(m_file[i] != NULL); - m_file[i]->rebind_psi(); + if (int error= m_file[i]->rebind()) + { + while (i) + m_file[--i]->unbind_psi(); + handler::unbind_psi(); + DBUG_RETURN(error); + } } - DBUG_VOID_RETURN; + DBUG_RETURN(0); } #endif /* HAVE_M_PSI_PER_PARTITION */ diff --git a/sql/ha_partition.h b/sql/ha_partition.h index e50ed2aeef7..657eea4cbd5 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -685,7 +685,7 @@ public: Bind the table/handler thread to track table i/o. */ virtual void unbind_psi(); - virtual void rebind_psi(); + virtual int rebind(); #endif /* ------------------------------------------------------------------------- diff --git a/sql/ha_sequence.h b/sql/ha_sequence.h index 4360e9faa3d..bc799cca9e5 100644 --- a/sql/ha_sequence.h +++ b/sql/ha_sequence.h @@ -141,8 +141,8 @@ public: { return file->rename_table(from, to); } void unbind_psi() { return file->unbind_psi(); } - void rebind_psi() - { return file->rebind_psi(); } + int rebind() + { return file->rebind(); } bool auto_repair(int error) const { return file->auto_repair(error); } diff --git a/sql/handler.cc b/sql/handler.cc index 63800ce202e..2a92a041920 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2806,13 +2806,14 @@ void handler::unbind_psi() PSI_CALL_unbind_table(m_psi); } -void handler::rebind_psi() +int handler::rebind() { /* Notify the instrumentation that this table is now owned by this thread. */ m_psi= PSI_CALL_rebind_table(ha_table_share_psi(), this, m_psi); + return 0; } diff --git a/sql/handler.h b/sql/handler.h index 8674ccfd70e..b99d33874e9 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3160,7 +3160,7 @@ private: public: virtual void unbind_psi(); - virtual void rebind_psi(); + virtual int rebind(); /** Put the handler in 'batch' mode when collecting table io instrumented events. diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c41e08e4b8c..7a4926eb7c4 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2052,7 +2052,13 @@ retry_share: if (table) { DBUG_ASSERT(table->file != NULL); - MYSQL_REBIND_TABLE(table->file); + if (table->file->rebind() == HA_ERR_TABLE_DEF_CHANGED) + { + tc_release_table(table); + (void) ot_ctx->request_backoff_action(Open_table_context::OT_DISCOVER, + table_list); + DBUG_RETURN(TRUE); + } #ifdef WITH_PARTITION_STORAGE_ENGINE part_names_error= set_partitions_as_used(table_list, table); #endif diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 5cdf062922b..d2a83dffaaf 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -17023,34 +17023,39 @@ void ha_mroonga::unbind_psi() DBUG_VOID_RETURN; } -void ha_mroonga::wrapper_rebind_psi() +int ha_mroonga::wrapper_rebind() { MRN_DBUG_ENTER_METHOD(); MRN_SET_WRAP_SHARE_KEY(share, table->s); MRN_SET_WRAP_TABLE_KEY(this, table); - wrap_handler->rebind_psi(); + int error= wrap_handler->rebind(); MRN_SET_BASE_SHARE_KEY(share, table->s); MRN_SET_BASE_TABLE_KEY(this, table); - DBUG_VOID_RETURN; + DBUG_RETURN(error); } -void ha_mroonga::storage_rebind_psi() +void ha_mroonga::storage_rebind() { MRN_DBUG_ENTER_METHOD(); DBUG_VOID_RETURN; } -void ha_mroonga::rebind_psi() +int ha_mroonga::rebind() { MRN_DBUG_ENTER_METHOD(); - handler::rebind_psi(); + if (int error= handler::rebind()) + DBUG_RETURN(error); if (share->wrapper_mode) { - wrapper_rebind_psi(); + if (int error= wrapper_rebind()) + { + handler::unbind_psi(); + DBUG_RETURN(error); + } } else { - storage_rebind_psi(); + storage_rebind(); } - DBUG_VOID_RETURN; + DBUG_RETURN(0); } #endif diff --git a/storage/mroonga/ha_mroonga.hpp b/storage/mroonga/ha_mroonga.hpp index 4e3f4bec17c..632e45dab12 100644 --- a/storage/mroonga/ha_mroonga.hpp +++ b/storage/mroonga/ha_mroonga.hpp @@ -631,7 +631,7 @@ protected: void free_foreign_key_create_info(char* str) mrn_override; #ifdef MRN_HAVE_HA_REBIND_PSI void unbind_psi() mrn_override; - void rebind_psi() mrn_override; + int rebind() mrn_override; #endif my_bool register_query_cache_table(THD *thd, const char *table_key, @@ -1290,8 +1290,8 @@ private: #ifdef MRN_HAVE_HA_REBIND_PSI void wrapper_unbind_psi(); void storage_unbind_psi(); - void wrapper_rebind_psi(); - void storage_rebind_psi(); + int wrapper_rebind(); + void storage_rebind(); #endif my_bool wrapper_register_query_cache_table(THD *thd, const char *table_key,