summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-11-14 17:45:19 +0400
committerSergey Vojtovich <svoj@mariadb.org>2019-11-15 15:23:42 +0400
commit7740cb245720f2ecb92e0ca5d6ce8e39a6124679 (patch)
treedf21c1a27830819438fa01a060314cac2d81a76d
parentda6d7f72b0a933ccf10dd78f41b0c32a88c4eb56 (diff)
downloadmariadb-git-bb-10.5-robert.tar.gz
Don't use plugin->data for storage engine pluginsbb-10.5-robert
Use plugin->plugin->info->hton instead. plugin_data() replaced with plugin_hton(). plugin_hton() must never return NULL anymore and is only good to be called against plugins in PLUGIN_IS_READY state. Part of MDEV-20044 - Replace dynamic storage engine initialisation with declarative approach
-rw-r--r--sql/ha_partition.cc4
-rw-r--r--sql/handler.cc16
-rw-r--r--sql/handler.h3
-rw-r--r--sql/sql_plugin.cc2
-rw-r--r--sql/sql_show.cc3
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/table.cc2
-rw-r--r--sql/wsrep_xid.cc4
-rw-r--r--storage/mroonga/mrn_table.cpp6
9 files changed, 22 insertions, 20 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 66fcce893a8..645b17817e9 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -2864,13 +2864,13 @@ bool ha_partition::create_handlers(MEM_ROOT *mem_root)
bzero((char*) m_file, alloc_len);
for (i= 0; i < m_tot_parts; i++)
{
- handlerton *hton= plugin_data(m_engine_array[i], handlerton*);
+ handlerton *hton= plugin_hton(m_engine_array[i]);
if (!(m_file[i]= get_new_handler(table_share, mem_root, hton)))
DBUG_RETURN(TRUE);
DBUG_PRINT("info", ("engine_type: %u", hton->db_type));
}
/* For the moment we only support partition over the same table engine */
- hton0= plugin_data(m_engine_array[0], handlerton*);
+ hton0= plugin_hton(m_engine_array[0]);
if (hton0 == myisam_hton)
{
DBUG_PRINT("info", ("MyISAM"));
diff --git a/sql/handler.cc b/sql/handler.cc
index 9dda482dfc6..636c94bd92c 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -193,7 +193,7 @@ redo:
if ((plugin= my_plugin_lock_by_name(thd, name, MYSQL_STORAGE_ENGINE_PLUGIN)))
{
handlerton *hton= plugin_hton(plugin);
- if (hton && !(hton->flags & HTON_NOT_USER_SELECTABLE))
+ if (!(hton->flags & HTON_NOT_USER_SELECTABLE))
return plugin;
/*
@@ -477,11 +477,11 @@ static void update_discovery_counters(handlerton *hton, int val)
int ha_finalize_handlerton(st_plugin_int *plugin)
{
- handlerton *hton= (handlerton *)plugin->data;
+ handlerton *hton= plugin_hton(plugin_int_to_ref(plugin));
DBUG_ENTER("ha_finalize_handlerton");
- /* hton can be NULL here, if ha_initialize_handlerton() failed. */
- if (!hton)
+ /* data can be NULL here, if ha_initialize_handlerton() failed. */
+ if (!plugin->data)
goto end;
if (installed_htons[hton->db_type] == hton)
@@ -538,11 +538,8 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
DBUG_ENTER("ha_initialize_handlerton");
DBUG_PRINT("plugin", ("initialize plugin: '%s'", plugin->name.str));
- handlerton *hton=
- static_cast<st_mysql_storage_engine*>(plugin->plugin->info)->hton;
+ handlerton *hton= plugin_hton(plugin_int_to_ref(plugin));
- /* Historical Requirement */
- plugin->data= hton; // shortcut for the future
if (plugin->plugin->init && plugin->plugin->init(0))
{
sql_print_error("Plugin '%s' init function returned error.",
@@ -662,6 +659,8 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
resolve_sysvar_table_options(hton);
update_discovery_counters(hton, 1);
+ /* Signal ha_finalize_handlerton() that init succeeded. */
+ plugin->data= (void*) 1;
DBUG_RETURN(0);
err_deinit:
@@ -677,6 +676,7 @@ err:
if (hton->prepare)
failed_ha_2pc++;
#endif
+ /* Signal ha_finalize_handlerton() that init failed. */
plugin->data= NULL;
DBUG_RETURN(1);
}
diff --git a/sql/handler.h b/sql/handler.h
index 69b84657ad5..037c7763064 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1668,7 +1668,8 @@ static inline LEX_CSTRING *hton_name(const handlerton *hton)
static inline handlerton *plugin_hton(plugin_ref plugin)
{
- return plugin_data(plugin, handlerton *);
+ return
+ reinterpret_cast<st_mysql_storage_engine*>(plugin_decl(plugin)->info)->hton;
}
static inline sys_var *find_hton_sysvar(handlerton *hton, st_mysql_sys_var *var)
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 19ea6e31042..1f26187d12d 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1059,7 +1059,7 @@ plugin_ref plugin_lock_by_name(THD *thd, const LEX_CSTRING *name, int type)
DBUG_ENTER("plugin_lock_by_name");
mysql_mutex_lock(&LOCK_plugin);
if ((plugin= plugin_find_internal(name, type)))
- rc= intern_plugin_lock(lex, plugin_int_to_ref(plugin));
+ rc= intern_plugin_lock(lex, plugin_int_to_ref(plugin), PLUGIN_IS_READY);
mysql_mutex_unlock(&LOCK_plugin);
DBUG_RETURN(rc);
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 43914a0003d..471dac34a2c 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -6004,7 +6004,7 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin,
void *ptable)
{
TABLE *table= (TABLE *) ptable;
- handlerton *hton= plugin_hton(plugin);
+ handlerton *hton;
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
CHARSET_INFO *scs= system_charset_info;
handlerton *default_type= ha_default_handlerton(thd);
@@ -6029,6 +6029,7 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin,
DBUG_RETURN(0);
}
+ hton= plugin_hton(plugin);
if (!(hton->flags & HTON_HIDDEN))
{
LEX_CSTRING *name= plugin_name(plugin);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 1520cc7c705..237b0705b0d 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1139,7 +1139,7 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), ddl_log_entry->handler_name);
goto error;
}
- hton= plugin_data(plugin, handlerton*);
+ hton= plugin_hton(plugin);
file= get_new_handler((TABLE_SHARE*)0, &mem_root, hton);
if (unlikely(!file))
goto error;
diff --git a/sql/table.cc b/sql/table.cc
index 7ed5121a9c6..0640f80fd84 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1920,7 +1920,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
sql_print_warning("%s.frm is inconsistent: engine typecode %d, engine name %s (%d)",
share->normalized_path.str, legacy_db_type,
plugin_name(tmp_plugin)->str,
- ha_legacy_type(plugin_data(tmp_plugin, handlerton *)));
+ ha_legacy_type(plugin_hton(tmp_plugin)));
}
/*
tmp_plugin is locked with a local lock.
diff --git a/sql/wsrep_xid.cc b/sql/wsrep_xid.cc
index d8f6e013820..b7502ca2231 100644
--- a/sql/wsrep_xid.cc
+++ b/sql/wsrep_xid.cc
@@ -107,7 +107,7 @@ wsrep::seqno wsrep_xid_seqno(const XID& xid)
static my_bool set_SE_checkpoint(THD* unused, plugin_ref plugin, void* arg)
{
XID* xid= static_cast<XID*>(arg);
- handlerton* hton= plugin_data(plugin, handlerton *);
+ handlerton* hton= plugin_hton(plugin);
if (hton->set_checkpoint)
{
@@ -137,7 +137,7 @@ bool wsrep_set_SE_checkpoint(const wsrep::gtid& wsgtid)
static my_bool get_SE_checkpoint(THD* unused, plugin_ref plugin, void* arg)
{
XID* xid= reinterpret_cast<XID*>(arg);
- handlerton* hton= plugin_data(plugin, handlerton *);
+ handlerton* hton= plugin_hton(plugin);
if (hton->get_checkpoint)
{
diff --git a/storage/mroonga/mrn_table.cpp b/storage/mroonga/mrn_table.cpp
index b10668cfcce..5a7c57546c6 100644
--- a/storage/mroonga/mrn_table.cpp
+++ b/storage/mroonga/mrn_table.cpp
@@ -50,9 +50,9 @@
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
-# define MRN_PLUGIN_DATA(plugin, type) plugin_data<type>(plugin)
+# define MRN_PLUGIN_HTON(plugin) plugin_data<handlerton*>(plugin)
#else
-# define MRN_PLUGIN_DATA(plugin, type) plugin_data(plugin, type)
+# define MRN_PLUGIN_HTON(plugin) plugin_hton(plugin)
#endif
#define LEX_STRING_IS_EMPTY(string) \
@@ -503,7 +503,7 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table)
error = ER_UNKNOWN_STORAGE_ENGINE;
goto error;
}
- share->hton = MRN_PLUGIN_DATA(share->plugin, handlerton *);
+ share->hton = MRN_PLUGIN_HTON(share->plugin);
share->wrapper_mode = TRUE;
}
}