Commit 8bc6aed4 authored by Sergei Golubchik's avatar Sergei Golubchik

plugin_hton helper

parent 935817e9
...@@ -124,7 +124,7 @@ handlerton *ha_default_handlerton(THD *thd) ...@@ -124,7 +124,7 @@ handlerton *ha_default_handlerton(THD *thd)
{ {
plugin_ref plugin= ha_default_plugin(thd); plugin_ref plugin= ha_default_plugin(thd);
DBUG_ASSERT(plugin); DBUG_ASSERT(plugin);
handlerton *hton= plugin_data(plugin, handlerton*); handlerton *hton= plugin_hton(plugin);
DBUG_ASSERT(hton); DBUG_ASSERT(hton);
return hton; return hton;
} }
...@@ -155,7 +155,7 @@ redo: ...@@ -155,7 +155,7 @@ redo:
if ((plugin= my_plugin_lock_by_name(thd, name, MYSQL_STORAGE_ENGINE_PLUGIN))) if ((plugin= my_plugin_lock_by_name(thd, name, MYSQL_STORAGE_ENGINE_PLUGIN)))
{ {
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton && !(hton->flags & HTON_NOT_USER_SELECTABLE)) if (hton && !(hton->flags & HTON_NOT_USER_SELECTABLE))
return plugin; return plugin;
...@@ -203,7 +203,7 @@ handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type) ...@@ -203,7 +203,7 @@ handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type)
default: default:
if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT && if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT &&
(plugin= ha_lock_engine(thd, installed_htons[db_type]))) (plugin= ha_lock_engine(thd, installed_htons[db_type])))
return plugin_data(plugin, handlerton*); return plugin_hton(plugin);
/* fall through */ /* fall through */
case DB_TYPE_UNKNOWN: case DB_TYPE_UNKNOWN:
return NULL; return NULL;
...@@ -662,7 +662,7 @@ int ha_end() ...@@ -662,7 +662,7 @@ int ha_end()
static my_bool dropdb_handlerton(THD *unused1, plugin_ref plugin, static my_bool dropdb_handlerton(THD *unused1, plugin_ref plugin,
void *path) void *path)
{ {
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->state == SHOW_OPTION_YES && hton->drop_database) if (hton->state == SHOW_OPTION_YES && hton->drop_database)
hton->drop_database(hton, (char *)path); hton->drop_database(hton, (char *)path);
return FALSE; return FALSE;
...@@ -678,7 +678,7 @@ void ha_drop_database(char* path) ...@@ -678,7 +678,7 @@ void ha_drop_database(char* path)
static my_bool checkpoint_state_handlerton(THD *unused1, plugin_ref plugin, static my_bool checkpoint_state_handlerton(THD *unused1, plugin_ref plugin,
void *disable) void *disable)
{ {
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->state == SHOW_OPTION_YES && hton->checkpoint_state) if (hton->state == SHOW_OPTION_YES && hton->checkpoint_state)
hton->checkpoint_state(hton, (int) *(bool*) disable); hton->checkpoint_state(hton, (int) *(bool*) disable);
return FALSE; return FALSE;
...@@ -700,7 +700,7 @@ static my_bool commit_checkpoint_request_handlerton(THD *unused1, plugin_ref plu ...@@ -700,7 +700,7 @@ static my_bool commit_checkpoint_request_handlerton(THD *unused1, plugin_ref plu
void *data) void *data)
{ {
st_commit_checkpoint_request *st= (st_commit_checkpoint_request *)data; st_commit_checkpoint_request *st= (st_commit_checkpoint_request *)data;
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->state == SHOW_OPTION_YES && hton->commit_checkpoint_request) if (hton->state == SHOW_OPTION_YES && hton->commit_checkpoint_request)
{ {
void *cookie= st->cookie; void *cookie= st->cookie;
...@@ -732,7 +732,7 @@ ha_commit_checkpoint_request(void *cookie, void (*pre_hook)(void *)) ...@@ -732,7 +732,7 @@ ha_commit_checkpoint_request(void *cookie, void (*pre_hook)(void *))
static my_bool closecon_handlerton(THD *thd, plugin_ref plugin, static my_bool closecon_handlerton(THD *thd, plugin_ref plugin,
void *unused) void *unused)
{ {
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
/* /*
there's no need to rollback here as all transactions must there's no need to rollback here as all transactions must
be rolled back already be rolled back already
...@@ -759,7 +759,7 @@ void ha_close_connection(THD* thd) ...@@ -759,7 +759,7 @@ void ha_close_connection(THD* thd)
static my_bool kill_handlerton(THD *thd, plugin_ref plugin, static my_bool kill_handlerton(THD *thd, plugin_ref plugin,
void *level) void *level)
{ {
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->state == SHOW_OPTION_YES && hton->kill_query && if (hton->state == SHOW_OPTION_YES && hton->kill_query &&
thd_get_ha_data(thd, hton)) thd_get_ha_data(thd, hton))
...@@ -1604,7 +1604,7 @@ struct xahton_st { ...@@ -1604,7 +1604,7 @@ struct xahton_st {
static my_bool xacommit_handlerton(THD *unused1, plugin_ref plugin, static my_bool xacommit_handlerton(THD *unused1, plugin_ref plugin,
void *arg) void *arg)
{ {
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->state == SHOW_OPTION_YES && hton->recover) if (hton->state == SHOW_OPTION_YES && hton->recover)
{ {
hton->commit_by_xid(hton, ((struct xahton_st *)arg)->xid); hton->commit_by_xid(hton, ((struct xahton_st *)arg)->xid);
...@@ -1616,7 +1616,7 @@ static my_bool xacommit_handlerton(THD *unused1, plugin_ref plugin, ...@@ -1616,7 +1616,7 @@ static my_bool xacommit_handlerton(THD *unused1, plugin_ref plugin,
static my_bool xarollback_handlerton(THD *unused1, plugin_ref plugin, static my_bool xarollback_handlerton(THD *unused1, plugin_ref plugin,
void *arg) void *arg)
{ {
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->state == SHOW_OPTION_YES && hton->recover) if (hton->state == SHOW_OPTION_YES && hton->recover)
{ {
hton->rollback_by_xid(hton, ((struct xahton_st *)arg)->xid); hton->rollback_by_xid(hton, ((struct xahton_st *)arg)->xid);
...@@ -1722,7 +1722,7 @@ struct xarecover_st ...@@ -1722,7 +1722,7 @@ struct xarecover_st
static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin,
void *arg) void *arg)
{ {
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
struct xarecover_st *info= (struct xarecover_st *) arg; struct xarecover_st *info= (struct xarecover_st *) arg;
int got; int got;
...@@ -2051,7 +2051,7 @@ int ha_release_savepoint(THD *thd, SAVEPOINT *sv) ...@@ -2051,7 +2051,7 @@ int ha_release_savepoint(THD *thd, SAVEPOINT *sv)
static my_bool snapshot_handlerton(THD *thd, plugin_ref plugin, static my_bool snapshot_handlerton(THD *thd, plugin_ref plugin,
void *arg) void *arg)
{ {
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->state == SHOW_OPTION_YES && if (hton->state == SHOW_OPTION_YES &&
hton->start_consistent_snapshot) hton->start_consistent_snapshot)
{ {
...@@ -2091,7 +2091,7 @@ int ha_start_consistent_snapshot(THD *thd) ...@@ -2091,7 +2091,7 @@ int ha_start_consistent_snapshot(THD *thd)
static my_bool flush_handlerton(THD *thd, plugin_ref plugin, static my_bool flush_handlerton(THD *thd, plugin_ref plugin,
void *arg) void *arg)
{ {
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->state == SHOW_OPTION_YES && hton->flush_logs && if (hton->state == SHOW_OPTION_YES && hton->flush_logs &&
hton->flush_logs(hton)) hton->flush_logs(hton))
return TRUE; return TRUE;
...@@ -4327,7 +4327,7 @@ static my_bool discover_handlerton(THD *thd, plugin_ref plugin, ...@@ -4327,7 +4327,7 @@ static my_bool discover_handlerton(THD *thd, plugin_ref plugin,
void *arg) void *arg)
{ {
TABLE_SHARE *share= (TABLE_SHARE *)arg; TABLE_SHARE *share= (TABLE_SHARE *)arg;
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->state == SHOW_OPTION_YES && hton->discover_table) if (hton->state == SHOW_OPTION_YES && hton->discover_table)
{ {
share->db_plugin= plugin; share->db_plugin= plugin;
...@@ -4390,7 +4390,7 @@ static my_bool discover_existence(THD *thd, plugin_ref plugin, ...@@ -4390,7 +4390,7 @@ static my_bool discover_existence(THD *thd, plugin_ref plugin,
void *arg) void *arg)
{ {
st_discover_existence_args *args= (st_discover_existence_args*)arg; st_discover_existence_args *args= (st_discover_existence_args*)arg;
handlerton *ht= plugin_data(plugin, handlerton *); handlerton *ht= plugin_hton(plugin);
if (ht->state != SHOW_OPTION_YES || !ht->discover_table_existence) if (ht->state != SHOW_OPTION_YES || !ht->discover_table_existence)
return FALSE; return FALSE;
...@@ -4614,7 +4614,7 @@ static my_bool discover_names(THD *thd, plugin_ref plugin, ...@@ -4614,7 +4614,7 @@ static my_bool discover_names(THD *thd, plugin_ref plugin,
void *arg) void *arg)
{ {
st_discover_names_args *args= (st_discover_names_args *)arg; st_discover_names_args *args= (st_discover_names_args *)arg;
handlerton *ht= plugin_data(plugin, handlerton *); handlerton *ht= plugin_hton(plugin);
if (ht->state == SHOW_OPTION_YES && ht->discover_table_names) if (ht->state == SHOW_OPTION_YES && ht->discover_table_names)
{ {
...@@ -4691,7 +4691,7 @@ struct binlog_func_st ...@@ -4691,7 +4691,7 @@ struct binlog_func_st
static my_bool binlog_func_list(THD *thd, plugin_ref plugin, void *arg) static my_bool binlog_func_list(THD *thd, plugin_ref plugin, void *arg)
{ {
hton_list_st *hton_list= (hton_list_st *)arg; hton_list_st *hton_list= (hton_list_st *)arg;
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->state == SHOW_OPTION_YES && hton->binlog_func) if (hton->state == SHOW_OPTION_YES && hton->binlog_func)
{ {
uint sz= hton_list->sz; uint sz= hton_list->sz;
...@@ -4781,7 +4781,7 @@ static my_bool binlog_log_query_handlerton(THD *thd, ...@@ -4781,7 +4781,7 @@ static my_bool binlog_log_query_handlerton(THD *thd,
plugin_ref plugin, plugin_ref plugin,
void *args) void *args)
{ {
return binlog_log_query_handlerton2(thd, plugin_data(plugin, handlerton *), args); return binlog_log_query_handlerton2(thd, plugin_hton(plugin), args);
} }
void ha_binlog_log_query(THD *thd, handlerton *hton, void ha_binlog_log_query(THD *thd, handlerton *hton,
...@@ -5012,7 +5012,7 @@ static my_bool exts_handlerton(THD *unused, plugin_ref plugin, ...@@ -5012,7 +5012,7 @@ static my_bool exts_handlerton(THD *unused, plugin_ref plugin,
void *arg) void *arg)
{ {
List<char> *found_exts= (List<char> *) arg; List<char> *found_exts= (List<char> *) arg;
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
List_iterator_fast<char> it(*found_exts); List_iterator_fast<char> it(*found_exts);
const char **ext, *old_ext; const char **ext, *old_ext;
...@@ -5081,7 +5081,7 @@ static my_bool showstat_handlerton(THD *thd, plugin_ref plugin, ...@@ -5081,7 +5081,7 @@ static my_bool showstat_handlerton(THD *thd, plugin_ref plugin,
void *arg) void *arg)
{ {
enum ha_stat_type stat= *(enum ha_stat_type *) arg; enum ha_stat_type stat= *(enum ha_stat_type *) arg;
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->state == SHOW_OPTION_YES && hton->show_status && if (hton->state == SHOW_OPTION_YES && hton->show_status &&
hton->show_status(hton, thd, stat_print, stat)) hton->show_status(hton, thd, stat_print, stat))
return TRUE; return TRUE;
......
...@@ -1210,6 +1210,11 @@ static inline LEX_STRING *hton_name(const handlerton *hton) ...@@ -1210,6 +1210,11 @@ static inline LEX_STRING *hton_name(const handlerton *hton)
return &(hton2plugin[hton->slot]->name); return &(hton2plugin[hton->slot]->name);
} }
static inline handlerton *plugin_hton(plugin_ref plugin)
{
return plugin_data(plugin, handlerton *);
}
static inline sys_var *find_hton_sysvar(handlerton *hton, st_mysql_sys_var *var) static inline sys_var *find_hton_sysvar(handlerton *hton, st_mysql_sys_var *var)
{ {
return find_plugin_sysvar(hton2plugin[hton->slot], var); return find_plugin_sysvar(hton2plugin[hton->slot], var);
......
...@@ -4582,7 +4582,7 @@ a file name for --log-bin-index option", opt_binlog_index_name); ...@@ -4582,7 +4582,7 @@ a file name for --log-bin-index option", opt_binlog_index_name);
plugin_ref plugin; plugin_ref plugin;
handlerton *hton; handlerton *hton;
if ((plugin= ha_resolve_by_name(0, &name))) if ((plugin= ha_resolve_by_name(0, &name)))
hton= plugin_data(plugin, handlerton*); hton= plugin_hton(plugin);
else else
{ {
sql_print_error("Unknown/unsupported storage engine: %s", sql_print_error("Unknown/unsupported storage engine: %s",
......
...@@ -5395,7 +5395,7 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin, ...@@ -5395,7 +5395,7 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin,
void *ptable) void *ptable)
{ {
TABLE *table= (TABLE *) ptable; TABLE *table= (TABLE *) ptable;
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
CHARSET_INFO *scs= system_charset_info; CHARSET_INFO *scs= system_charset_info;
handlerton *default_type= ha_default_handlerton(thd); handlerton *default_type= ha_default_handlerton(thd);
...@@ -8052,7 +8052,7 @@ static my_bool run_hton_fill_schema_table(THD *thd, plugin_ref plugin, ...@@ -8052,7 +8052,7 @@ static my_bool run_hton_fill_schema_table(THD *thd, plugin_ref plugin,
{ {
struct run_hton_fill_schema_table_args *args= struct run_hton_fill_schema_table_args *args=
(run_hton_fill_schema_table_args *) arg; (run_hton_fill_schema_table_args *) arg;
handlerton *hton= plugin_data(plugin, handlerton *); handlerton *hton= plugin_hton(plugin);
if (hton->fill_is_table && hton->state == SHOW_OPTION_YES) if (hton->fill_is_table && hton->state == SHOW_OPTION_YES)
hton->fill_is_table(hton, thd, args->tables, args->cond, hton->fill_is_table(hton, thd, args->tables, args->cond,
get_schema_table_idx(args->tables->schema_table)); get_schema_table_idx(args->tables->schema_table));
......
...@@ -950,7 +950,7 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry) ...@@ -950,7 +950,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); my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), ddl_log_entry->handler_name);
goto error; goto error;
} }
hton= plugin_data(plugin, handlerton*); hton= plugin_hton(plugin);
file= get_new_handler((TABLE_SHARE*)0, &mem_root, hton); file= get_new_handler((TABLE_SHARE*)0, &mem_root, hton);
if (!file) if (!file)
{ {
......
...@@ -5376,7 +5376,7 @@ storage_engines: ...@@ -5376,7 +5376,7 @@ storage_engines:
plugin_ref plugin= ha_resolve_by_name(YYTHD, &$1); plugin_ref plugin= ha_resolve_by_name(YYTHD, &$1);
if (plugin) if (plugin)
$$= plugin_data(plugin, handlerton*); $$= plugin_hton(plugin);
else else
{ {
if (YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION) if (YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION)
...@@ -5398,7 +5398,7 @@ known_storage_engines: ...@@ -5398,7 +5398,7 @@ known_storage_engines:
{ {
plugin_ref plugin; plugin_ref plugin;
if ((plugin= ha_resolve_by_name(YYTHD, &$1))) if ((plugin= ha_resolve_by_name(YYTHD, &$1)))
$$= plugin_data(plugin, handlerton*); $$= plugin_hton(plugin);
else else
{ {
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str); my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
......
...@@ -1333,7 +1333,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, ...@@ -1333,7 +1333,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
/* Allocate handler */ /* Allocate handler */
if (!(handler_file= get_new_handler(share, thd->mem_root, if (!(handler_file= get_new_handler(share, thd->mem_root,
plugin_data(se_plugin, handlerton *)))) plugin_hton(se_plugin))))
goto err; goto err;
record= share->default_values-1; /* Fieldstart = 1 */ record= share->default_values-1; /* Fieldstart = 1 */
...@@ -2081,7 +2081,7 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write, ...@@ -2081,7 +2081,7 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
goto ret; goto ret;
} }
thd->lex->create_info.db_type= plugin_data(db_plugin, handlerton *); thd->lex->create_info.db_type= plugin_hton(db_plugin);
if (tabledef_version.str) if (tabledef_version.str)
thd->lex->create_info.tabledef_version= tabledef_version; thd->lex->create_info.tabledef_version= tabledef_version;
......
...@@ -672,8 +672,7 @@ struct TABLE_SHARE ...@@ -672,8 +672,7 @@ struct TABLE_SHARE
inline handlerton *db_type() const /* table_type for handler */ inline handlerton *db_type() const /* table_type for handler */
{ {
return is_view ? view_pseudo_hton : return is_view ? view_pseudo_hton :
db_plugin ? plugin_data(db_plugin, handlerton*) db_plugin ? plugin_hton(db_plugin) : NULL;
: NULL;
} }
enum row_type row_type; /* How rows are stored */ enum row_type row_type; /* How rows are stored */
enum tmp_table_type tmp_table; enum tmp_table_type tmp_table;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment