From 762d2b96faaf9a55cbb97b8a350bd9c5780adb2e Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Thu, 16 May 2019 14:19:05 +0400 Subject: [PATCH] Fixed FederatedX to follow THD ha_data protocol Use thd_get_ha_data()/thd_set_ha_data() which protect against plugin removal until it has THD ha_data. Do not reset THD ha_data in ha_federatedx::disconnect(), cleaner approach is to let ha_close_connection() do it. Part of MDEV-19515 - Improve connect speed --- sql/handler.cc | 4 ---- sql/handler.h | 1 - storage/federatedx/ha_federatedx.cc | 12 +++++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 12a05aba90d..f9336dfca31 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2664,10 +2664,6 @@ double handler::keyread_time(uint index, uint ranges, ha_rows rows) return cost; } -void **handler::ha_data(THD *thd) const -{ - return thd_ha_data(thd, ht); -} THD *handler::ha_thd(void) const { diff --git a/sql/handler.h b/sql/handler.h index e34b308dd55..2d61249c58d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -4475,7 +4475,6 @@ public: TABLE_SHARE* get_table_share() { return table_share; } protected: /* Service methods for use by storage engines. */ - void **ha_data(THD *) const; THD *ha_thd(void) const; /** diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index b0a08a0d49a..932791c9d46 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -1746,10 +1746,13 @@ ha_rows ha_federatedx::records_in_range(uint inx, key_range *start_key, federatedx_txn *ha_federatedx::get_txn(THD *thd, bool no_create) { - federatedx_txn **txnp= (federatedx_txn **) ha_data(thd); - if (!*txnp && !no_create) - *txnp= new federatedx_txn(); - return *txnp; + federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, federatedx_hton); + if (!txn && !no_create) + { + txn= new federatedx_txn(); + thd_set_ha_data(thd, federatedx_hton, txn); + } + return txn; } @@ -1757,7 +1760,6 @@ int ha_federatedx::disconnect(handlerton *hton, MYSQL_THD thd) { federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, hton); delete txn; - *((federatedx_txn **) thd_ha_data(thd, hton))= 0; return 0; }