diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_ndbcluster.cc | 61 | ||||
-rw-r--r-- | sql/ha_ndbcluster_binlog.cc | 8 | ||||
-rw-r--r-- | sql/ha_ndbcluster_binlog.h | 6 | ||||
-rw-r--r-- | sql/ha_partition.cc | 30 | ||||
-rw-r--r-- | sql/handler.cc | 35 | ||||
-rw-r--r-- | sql/item_sum.cc | 2 | ||||
-rw-r--r-- | sql/log.cc | 62 | ||||
-rw-r--r-- | sql/mysql_priv.h | 46 | ||||
-rw-r--r-- | sql/mysqld.cc | 51 | ||||
-rw-r--r-- | sql/partition_info.cc | 6 | ||||
-rw-r--r-- | sql/set_var.cc | 2 | ||||
-rw-r--r-- | sql/sql_cache.cc | 4 | ||||
-rw-r--r-- | sql/sql_insert.cc | 4 | ||||
-rw-r--r-- | sql/sql_partition.cc | 4 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 58 | ||||
-rw-r--r-- | sql/sql_select.cc | 16 | ||||
-rw-r--r-- | sql/sql_show.cc | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 8 | ||||
-rw-r--r-- | sql/table.cc | 2 |
19 files changed, 249 insertions, 158 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index e2232443e4f..fbbc53f77d2 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -74,13 +74,13 @@ static const int max_transactions= 3; // should really be 2 but there is a trans static uint ndbcluster_partition_flags(); static uint ndbcluster_alter_table_flags(uint flags); -static int ndbcluster_init(void); +static int ndbcluster_init(void *); static int ndbcluster_end(ha_panic_function flag); static bool ndbcluster_show_status(THD*,stat_print_fn *,enum ha_stat_type); static int ndbcluster_alter_tablespace(THD* thd, st_alter_tablespace *info); static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond); -handlerton ndbcluster_hton; +handlerton *ndbcluster_hton; static handler *ndbcluster_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) @@ -4012,7 +4012,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) thd_ndb->init_open_tables(); thd_ndb->stmt= trans; thd_ndb->query_state&= NDB_QUERY_NORMAL; - trans_register_ha(thd, FALSE, &ndbcluster_hton); + trans_register_ha(thd, FALSE, ndbcluster_hton); } else { @@ -4028,7 +4028,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) thd_ndb->init_open_tables(); thd_ndb->all= trans; thd_ndb->query_state&= NDB_QUERY_NORMAL; - trans_register_ha(thd, TRUE, &ndbcluster_hton); + trans_register_ha(thd, TRUE, ndbcluster_hton); /* If this is the start of a LOCK TABLE, a table look @@ -4182,7 +4182,7 @@ int ha_ndbcluster::start_stmt(THD *thd, thr_lock_type lock_type) ERR_RETURN(ndb->getNdbError()); no_uncommitted_rows_reset(thd); thd_ndb->stmt= trans; - trans_register_ha(thd, FALSE, &ndbcluster_hton); + trans_register_ha(thd, FALSE, ndbcluster_hton); } thd_ndb->query_state&= NDB_QUERY_NORMAL; m_active_trans= trans; @@ -5551,7 +5551,7 @@ void ha_ndbcluster::get_auto_increment(ulonglong offset, ulonglong increment, HA_HAS_RECORDS ha_ndbcluster::ha_ndbcluster(TABLE_SHARE *table_arg): - handler(&ndbcluster_hton, table_arg), + handler(ndbcluster_hton, table_arg), m_active_trans(NULL), m_active_cursor(NULL), m_table(NULL), @@ -6379,35 +6379,36 @@ static int connect_callback() extern int ndb_dictionary_is_mysqld; -static int ndbcluster_init() +static int ndbcluster_init(void *p) { int res; DBUG_ENTER("ndbcluster_init"); ndb_dictionary_is_mysqld= 1; - - { - handlerton &h= ndbcluster_hton; - h.state= have_ndbcluster; - h.db_type= DB_TYPE_NDBCLUSTER; - h.close_connection= ndbcluster_close_connection; - h.commit= ndbcluster_commit; - h.rollback= ndbcluster_rollback; - h.create= ndbcluster_create_handler; /* Create a new handler */ - h.drop_database= ndbcluster_drop_database; /* Drop a database */ - h.panic= ndbcluster_end; /* Panic call */ - h.show_status= ndbcluster_show_status; /* Show status */ - h.alter_tablespace= ndbcluster_alter_tablespace; /* Show status */ - h.partition_flags= ndbcluster_partition_flags; /* Partition flags */ - h.alter_table_flags=ndbcluster_alter_table_flags; /* Alter table flags */ - h.fill_files_table= ndbcluster_fill_files_table; + ndbcluster_hton= (handlerton *)p; + + { + handlerton *h= ndbcluster_hton; + h->state= have_ndbcluster; + h->db_type= DB_TYPE_NDBCLUSTER; + h->close_connection= ndbcluster_close_connection; + h->commit= ndbcluster_commit; + h->rollback= ndbcluster_rollback; + h->create= ndbcluster_create_handler; /* Create a new handler */ + h->drop_database= ndbcluster_drop_database; /* Drop a database */ + h->panic= ndbcluster_end; /* Panic call */ + h->show_status= ndbcluster_show_status; /* Show status */ + h->alter_tablespace= ndbcluster_alter_tablespace; /* Show status */ + h->partition_flags= ndbcluster_partition_flags; /* Partition flags */ + h->alter_table_flags=ndbcluster_alter_table_flags; /* Alter table flags */ + h->fill_files_table= ndbcluster_fill_files_table; #ifdef HAVE_NDB_BINLOG ndbcluster_binlog_init_handlerton(); #endif - h.flags= HTON_CAN_RECREATE | HTON_TEMPORARY_NOT_SUPPORTED; - h.discover= ndbcluster_discover; - h.find_files= ndbcluster_find_files; - h.table_exists_in_engine= ndbcluster_table_exists_in_engine; + h->flags= HTON_CAN_RECREATE | HTON_TEMPORARY_NOT_SUPPORTED; + h->discover= ndbcluster_discover; + h->find_files= ndbcluster_find_files; + h->table_exists_in_engine= ndbcluster_table_exists_in_engine; } if (have_ndbcluster != SHOW_OPTION_YES) @@ -6516,6 +6517,8 @@ ndbcluster_init_error: delete g_ndb_cluster_connection; g_ndb_cluster_connection= NULL; have_ndbcluster= SHOW_OPTION_DISABLED; // If we couldn't use handler + ndbcluster_hton->state= SHOW_OPTION_DISABLED; // If we couldn't use handler + DBUG_RETURN(TRUE); } @@ -8120,7 +8123,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) Wait for cluster to start */ pthread_mutex_lock(&LOCK_ndb_util_thread); - while (!ndb_cluster_node_id && (ndbcluster_hton.slot != ~(uint)0)) + while (!ndb_cluster_node_id && (ndbcluster_hton->slot != ~(uint)0)) { /* ndb not connected yet */ set_timespec(abstime, 1); @@ -10611,7 +10614,7 @@ SHOW_VAR ndb_status_variables_export[]= { }; struct st_mysql_storage_engine ndbcluster_storage_engine= -{ MYSQL_HANDLERTON_INTERFACE_VERSION, &ndbcluster_hton }; +{ MYSQL_HANDLERTON_INTERFACE_VERSION, ndbcluster_hton }; mysql_declare_plugin(ndbcluster) { diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 4e59e0ef22a..e699dd22899 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -662,9 +662,9 @@ static int ndbcluster_binlog_func(THD *thd, enum_binlog_func fn, void *arg) void ndbcluster_binlog_init_handlerton() { - handlerton &h= ndbcluster_hton; - h.binlog_func= ndbcluster_binlog_func; - h.binlog_log_query= ndbcluster_binlog_log_query; + handlerton *h= ndbcluster_hton; + h->binlog_func= ndbcluster_binlog_func; + h->binlog_log_query= ndbcluster_binlog_log_query; } @@ -3431,7 +3431,7 @@ restart: if (thd_ndb == NULL) { - DBUG_ASSERT(ndbcluster_hton.slot != ~(uint)0); + DBUG_ASSERT(ndbcluster_hton->slot != ~(uint)0); if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb())) { sql_print_error("Could not allocate Thd_ndb object"); diff --git a/sql/ha_ndbcluster_binlog.h b/sql/ha_ndbcluster_binlog.h index 4c3cd105d1d..c34d70cf69a 100644 --- a/sql/ha_ndbcluster_binlog.h +++ b/sql/ha_ndbcluster_binlog.h @@ -103,7 +103,7 @@ extern pthread_mutex_t injector_mutex; extern pthread_cond_t injector_cond; extern unsigned char g_node_id_map[max_ndb_nodes]; -extern handlerton ndbcluster_hton; +extern handlerton *ndbcluster_hton; extern pthread_t ndb_util_thread; extern pthread_mutex_t LOCK_ndb_util_thread; extern pthread_cond_t COND_ndb_util_thread; @@ -212,10 +212,10 @@ inline void real_free_share(NDB_SHARE **share) inline Thd_ndb * -get_thd_ndb(THD *thd) { return (Thd_ndb *) thd->ha_data[ndbcluster_hton.slot]; } +get_thd_ndb(THD *thd) { return (Thd_ndb *) thd->ha_data[ndbcluster_hton->slot]; } inline void -set_thd_ndb(THD *thd, Thd_ndb *thd_ndb) { thd->ha_data[ndbcluster_hton.slot]= thd_ndb; } +set_thd_ndb(THD *thd, Thd_ndb *thd_ndb) { thd->ha_data[ndbcluster_hton->slot]= thd_ndb; } Ndb* check_ndb_in_thd(THD* thd); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index bd8d604ef0d..e435b356def 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -74,16 +74,20 @@ static handler *partition_create_handler(TABLE_SHARE *share, static uint partition_flags(); static uint alter_table_flags(uint flags); -handlerton partition_hton; +handlerton *partition_hton; -static int partition_initialize() +static int partition_initialize(void *p) { - partition_hton.state= SHOW_OPTION_YES; - partition_hton.db_type= DB_TYPE_PARTITION_DB; - partition_hton.create= partition_create_handler; - partition_hton.partition_flags= partition_flags; - partition_hton.alter_table_flags= alter_table_flags; - partition_hton.flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN; + + partition_hton= (handlerton *)p; + + partition_hton->state= SHOW_OPTION_YES; + partition_hton->db_type= DB_TYPE_PARTITION_DB; + partition_hton->create= partition_create_handler; + partition_hton->partition_flags= partition_flags; + partition_hton->alter_table_flags= alter_table_flags; + partition_hton->flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN; + return 0; } @@ -152,7 +156,7 @@ static uint alter_table_flags(uint flags __attribute__((unused))) */ ha_partition::ha_partition(TABLE_SHARE *share) - :handler(&partition_hton, share), m_part_info(NULL), m_create_handler(FALSE), + :handler(partition_hton, share), m_part_info(NULL), m_create_handler(FALSE), m_is_sub_partitioned(0) { DBUG_ENTER("ha_partition::ha_partition(table)"); @@ -173,7 +177,7 @@ ha_partition::ha_partition(TABLE_SHARE *share) */ ha_partition::ha_partition(partition_info *part_info) - :handler(&partition_hton, NULL), m_part_info(part_info), + :handler(partition_hton, NULL), m_part_info(part_info), m_create_handler(TRUE), m_is_sub_partitioned(m_part_info->is_sub_partitioned()) @@ -2016,7 +2020,7 @@ bool ha_partition::create_handlers(MEM_ROOT *mem_root) DBUG_PRINT("info", ("engine_type: %u", m_engine_array[i])); } /* For the moment we only support partition over the same table engine */ - if (m_engine_array[0] == &myisam_hton) + if (m_engine_array[0] == myisam_hton) { DBUG_PRINT("info", ("MyISAM")); m_myisam= TRUE; @@ -2089,7 +2093,7 @@ bool ha_partition::new_handlers_from_part_info(MEM_ROOT *mem_root) (uint) ha_legacy_type(part_elem->engine_type))); } } while (++i < m_part_info->no_parts); - if (part_elem->engine_type == &myisam_hton) + if (part_elem->engine_type == myisam_hton) { DBUG_PRINT("info", ("MyISAM")); m_myisam= TRUE; @@ -5628,7 +5632,7 @@ static int free_share(PARTITION_SHARE *share) #endif /* NOT_USED */ struct st_mysql_storage_engine partition_storage_engine= -{ MYSQL_HANDLERTON_INTERFACE_VERSION, &partition_hton }; +{ MYSQL_HANDLERTON_INTERFACE_VERSION, partition_hton }; mysql_declare_plugin(partition) { diff --git a/sql/handler.cc b/sql/handler.cc index cf080a843c7..d9ccb20fefc 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -97,7 +97,7 @@ handlerton *ha_default_handlerton(THD *thd) return (thd->variables.table_type != NULL) ? thd->variables.table_type : (global_system_variables.table_type != NULL ? - global_system_variables.table_type : &myisam_hton); + global_system_variables.table_type : myisam_hton); } @@ -378,16 +378,45 @@ int ha_finalize_handlerton(st_plugin_int *plugin) DBUG_RETURN(1); break; }; + + if (plugin->plugin->deinit) + { + /* + Today we have no defined/special behavior for uninstalling + engine plugins. + */ + DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str)); + if (plugin->plugin->deinit(NULL)) + { + DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.", + plugin->name.str)); + } + } + + my_free((gptr)hton, MYF(0)); + DBUG_RETURN(0); } int ha_initialize_handlerton(st_plugin_int *plugin) { - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton; DBUG_ENTER("ha_initialize_handlerton"); + hton= (handlerton *)my_malloc(sizeof(handlerton), + MYF(MY_WME | MY_ZEROFILL)); + /* Historical Requirement */ plugin->data= hton; // shortcut for the future + if (plugin->plugin->init) + { + if (plugin->plugin->init(hton)) + { + sql_print_error("Plugin '%s' init function returned error.", + plugin->name.str); + goto err; + } + } /* the switch below and hton->state should be removed when @@ -435,6 +464,8 @@ int ha_initialize_handlerton(st_plugin_int *plugin) break; } DBUG_RETURN(0); +err: + DBUG_RETURN(1); } int ha_init() diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 7b6be33d715..cf122f565ff 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -2549,7 +2549,7 @@ bool Item_sum_count_distinct::setup(THD *thd) table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows table->no_rows=1; - if (table->s->db_type == &heap_hton) + if (table->s->db_type == heap_hton) { /* No blobs, otherwise it would have been MyISAM: set up a compare diff --git a/sql/log.cc b/sql/log.cc index 8a8262c174d..37f145bbecd 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -90,7 +90,7 @@ struct binlog_trx_data { #endif }; -handlerton binlog_hton; +handlerton *binlog_hton; /* Open log table of a given type (general or slow log) @@ -1155,30 +1155,30 @@ void Log_to_csv_event_handler:: should be moved here. */ -int binlog_init() +int binlog_init(void *p) { - - binlog_hton.state=opt_bin_log ? SHOW_OPTION_YES : SHOW_OPTION_NO; - binlog_hton.db_type=DB_TYPE_BINLOG; - binlog_hton.savepoint_offset= sizeof(my_off_t); - binlog_hton.close_connection= binlog_close_connection; - binlog_hton.savepoint_set= binlog_savepoint_set; - binlog_hton.savepoint_rollback= binlog_savepoint_rollback; - binlog_hton.commit= binlog_commit; - binlog_hton.rollback= binlog_rollback; - binlog_hton.prepare= binlog_prepare; - binlog_hton.flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN; + binlog_hton= (handlerton *)p; + binlog_hton->state=opt_bin_log ? SHOW_OPTION_YES : SHOW_OPTION_NO; + binlog_hton->db_type=DB_TYPE_BINLOG; + binlog_hton->savepoint_offset= sizeof(my_off_t); + binlog_hton->close_connection= binlog_close_connection; + binlog_hton->savepoint_set= binlog_savepoint_set; + binlog_hton->savepoint_rollback= binlog_savepoint_rollback; + binlog_hton->commit= binlog_commit; + binlog_hton->rollback= binlog_rollback; + binlog_hton->prepare= binlog_prepare; + binlog_hton->flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN; return 0; } static int binlog_close_connection(THD *thd) { binlog_trx_data *const trx_data= - (binlog_trx_data*) thd->ha_data[binlog_hton.slot]; + (binlog_trx_data*) thd->ha_data[binlog_hton->slot]; IO_CACHE *trans_log= &trx_data->trans_log; DBUG_ASSERT(mysql_bin_log.is_open() && trx_data->empty()); close_cached_file(trans_log); - thd->ha_data[binlog_hton.slot]= 0; + thd->ha_data[binlog_hton->slot]= 0; my_free((gptr)trx_data, MYF(0)); return 0; } @@ -1253,7 +1253,7 @@ static int binlog_commit(THD *thd, bool all) { DBUG_ENTER("binlog_commit"); binlog_trx_data *const trx_data= - (binlog_trx_data*) thd->ha_data[binlog_hton.slot]; + (binlog_trx_data*) thd->ha_data[binlog_hton->slot]; IO_CACHE *trans_log= &trx_data->trans_log; DBUG_ASSERT(mysql_bin_log.is_open() && (all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))); @@ -1278,7 +1278,7 @@ static int binlog_rollback(THD *thd, bool all) DBUG_ENTER("binlog_rollback"); int error=0; binlog_trx_data *const trx_data= - (binlog_trx_data*) thd->ha_data[binlog_hton.slot]; + (binlog_trx_data*) thd->ha_data[binlog_hton->slot]; IO_CACHE *trans_log= &trx_data->trans_log; /* First assert is guaranteed - see trans_register_ha() call below. @@ -1330,7 +1330,7 @@ static int binlog_savepoint_set(THD *thd, void *sv) { DBUG_ENTER("binlog_savepoint_set"); binlog_trx_data *const trx_data= - (binlog_trx_data*) thd->ha_data[binlog_hton.slot]; + (binlog_trx_data*) thd->ha_data[binlog_hton->slot]; DBUG_ASSERT(mysql_bin_log.is_open() && my_b_tell(&trx_data->trans_log)); *(my_off_t *)sv= my_b_tell(&trx_data->trans_log); @@ -1346,7 +1346,7 @@ static int binlog_savepoint_rollback(THD *thd, void *sv) { DBUG_ENTER("binlog_savepoint_rollback"); binlog_trx_data *const trx_data= - (binlog_trx_data*) thd->ha_data[binlog_hton.slot]; + (binlog_trx_data*) thd->ha_data[binlog_hton->slot]; IO_CACHE *trans_log= &trx_data->trans_log; DBUG_ASSERT(mysql_bin_log.is_open() && my_b_tell(trans_log)); @@ -3076,19 +3076,19 @@ int THD::binlog_setup_trx_data() { DBUG_ENTER("THD::binlog_setup_trx_data"); binlog_trx_data *trx_data= - (binlog_trx_data*) ha_data[binlog_hton.slot]; + (binlog_trx_data*) ha_data[binlog_hton->slot]; if (trx_data) DBUG_RETURN(0); // Already set up - ha_data[binlog_hton.slot]= trx_data= + ha_data[binlog_hton->slot]= trx_data= (binlog_trx_data*) my_malloc(sizeof(binlog_trx_data), MYF(MY_ZEROFILL)); if (!trx_data || open_cached_file(&trx_data->trans_log, mysql_tmpdir, LOG_PREFIX, binlog_cache_size, MYF(MY_WME))) { my_free((gptr)trx_data, MYF(MY_ALLOW_ZERO_PTR)); - ha_data[binlog_hton.slot]= 0; + ha_data[binlog_hton->slot]= 0; DBUG_RETURN(1); // Didn't manage to set it up } trx_data->trans_log.end_of_file= max_binlog_cache_size; @@ -3124,7 +3124,7 @@ int THD::binlog_write_table_map(TABLE *table, bool is_trans) if (is_trans) trans_register_ha(this, (options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) != 0, - &binlog_hton); + binlog_hton); if ((error= mysql_bin_log.write(&the_event))) DBUG_RETURN(error); @@ -3138,7 +3138,7 @@ Rows_log_event* THD::binlog_get_pending_rows_event() const { binlog_trx_data *const trx_data= - (binlog_trx_data*) ha_data[binlog_hton.slot]; + (binlog_trx_data*) ha_data[binlog_hton->slot]; /* This is less than ideal, but here's the story: If there is no trx_data, prepare_pending_rows_event() has never been called @@ -3151,11 +3151,11 @@ THD::binlog_get_pending_rows_event() const void THD::binlog_set_pending_rows_event(Rows_log_event* ev) { - if (ha_data[binlog_hton.slot] == NULL) + if (ha_data[binlog_hton->slot] == NULL) binlog_setup_trx_data(); binlog_trx_data *const trx_data= - (binlog_trx_data*) ha_data[binlog_hton.slot]; + (binlog_trx_data*) ha_data[binlog_hton->slot]; DBUG_ASSERT(trx_data); trx_data->pending= ev; @@ -3177,7 +3177,7 @@ int MYSQL_BIN_LOG:: int error= 0; binlog_trx_data *const trx_data= - (binlog_trx_data*) thd->ha_data[binlog_hton.slot]; + (binlog_trx_data*) thd->ha_data[binlog_hton->slot]; DBUG_ASSERT(trx_data); @@ -3331,14 +3331,14 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info) goto err; binlog_trx_data *const trx_data= - (binlog_trx_data*) thd->ha_data[binlog_hton.slot]; + (binlog_trx_data*) thd->ha_data[binlog_hton->slot]; IO_CACHE *trans_log= &trx_data->trans_log; bool trans_log_in_use= my_b_tell(trans_log) != 0; if (event_info->get_cache_stmt() && !trans_log_in_use) trans_register_ha(thd, (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) != 0, - &binlog_hton); + binlog_hton); if (event_info->get_cache_stmt() || trans_log_in_use) { DBUG_PRINT("info", ("Using trans_log")); @@ -4620,7 +4620,7 @@ int TC_LOG_BINLOG::log(THD *thd, my_xid xid) DBUG_ENTER("TC_LOG_BINLOG::log"); Xid_log_event xle(thd, xid); binlog_trx_data *trx_data= - (binlog_trx_data*) thd->ha_data[binlog_hton.slot]; + (binlog_trx_data*) thd->ha_data[binlog_hton->slot]; DBUG_RETURN(!binlog_end_trans(thd, trx_data, &xle)); // invert return value } @@ -4681,7 +4681,7 @@ err1: } struct st_mysql_storage_engine binlog_storage_engine= -{ MYSQL_HANDLERTON_INTERFACE_VERSION, &binlog_hton }; +{ MYSQL_HANDLERTON_INTERFACE_VERSION, binlog_hton }; mysql_declare_plugin(binlog) { diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index cc16beedd9e..9ee3c3e2e03 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1625,61 +1625,63 @@ extern TYPELIB log_output_typelib; /* optional things, have_* variables */ #ifdef WITH_INNOBASE_STORAGE_ENGINE -extern handlerton innobase_hton; -#define have_innodb innobase_hton.state +extern handlerton *innobase_hton; +extern SHOW_COMP_OPTION have_innodb; #else extern SHOW_COMP_OPTION have_innodb; #endif #ifdef WITH_EXAMPLE_STORAGE_ENGINE -extern handlerton example_hton; -#define have_example_db example_hton.state +extern handlerton *example_hton; +extern SHOW_COMP_OPTION have_example_db; #else extern SHOW_COMP_OPTION have_example_db; #endif #ifdef WITH_ARCHIVE_STORAGE_ENGINE -extern handlerton archive_hton; -#define have_archive_db archive_hton.state +extern handlerton *archive_hton; +extern SHOW_COMP_OPTION have_archive_db; #else extern SHOW_COMP_OPTION have_archive_db; #endif #ifdef WITH_CSV_STORAGE_ENGINE -extern handlerton tina_hton; -#define have_csv_db tina_hton.state +extern handlerton *tina_hton; +extern SHOW_COMP_OPTION have_csv_db; #else extern SHOW_COMP_OPTION have_csv_db; #endif #ifdef WITH_FEDERATED_STORAGE_ENGINE -extern handlerton federated_hton; -#define have_federated_db federated_hton.state +extern handlerton *federated_hton; +extern SHOW_COMP_OPTION have_federated_db; #else extern SHOW_COMP_OPTION have_federated_db; #endif #ifdef WITH_BLACKHOLE_STORAGE_ENGINE -extern handlerton blackhole_hton; -#define have_blackhole_db blackhole_hton.state +extern handlerton *blackhole_hton; +extern SHOW_COMP_OPTION have_blackhole_db; #else extern SHOW_COMP_OPTION have_blackhole_db; #endif #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE -extern handlerton ndbcluster_hton; -#define have_ndbcluster ndbcluster_hton.state +extern handlerton *ndbcluster_hton; +extern SHOW_COMP_OPTION have_ndbcluster; #else extern SHOW_COMP_OPTION have_ndbcluster; #endif #ifdef WITH_PARTITION_STORAGE_ENGINE -extern handlerton partition_hton; -#define have_partition_db partition_hton.state +extern handlerton *partition_hton; +extern SHOW_COMP_OPTION have_partition_db; #else extern SHOW_COMP_OPTION have_partition_db; #endif -extern handlerton myisammrg_hton; -/* MRG_MYISAM handler is always built, but may be skipped */ -#define have_merge_db myisammrg_hton.state +#ifdef WITH_MYISAMMRG_STORAGE_ENGINE +extern handlerton *myisammrg_hton; +extern SHOW_COMP_OPTION have_merge_db; +#else +extern SHOW_COMP_OPTION have_merge_db; +#endif -extern handlerton myisam_hton; -extern handlerton myisammrg_hton; -extern handlerton heap_hton; +extern handlerton *myisam_hton; +extern handlerton *heap_hton; extern SHOW_COMP_OPTION have_row_based_replication; extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_dlopen; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f099ff76720..5e31af95f45 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3247,7 +3247,7 @@ server."); default_storage_engine_str); unireg_abort(1); } - hton= &myisam_hton; + hton= myisam_hton; } global_system_variables.table_type= hton; } @@ -6964,7 +6964,7 @@ static void mysql_init_variables(void) /* Set default values for some option variables */ default_storage_engine_str= (char*) "MyISAM"; - global_system_variables.table_type= &myisam_hton; + global_system_variables.table_type= myisam_hton; global_system_variables.tx_isolation= ISO_REPEATABLE_READ; global_system_variables.select_limit= (ulonglong) HA_POS_ERROR; max_system_variables.select_limit= (ulonglong) HA_POS_ERROR; @@ -6985,6 +6985,51 @@ static void mysql_init_variables(void) "d:t:i:o,/tmp/mysqld.trace"); #endif opt_error_log= IF_WIN(1,0); +#ifdef WITH_MYISAMMRG_STORAGE_ENGINE + have_merge_db= SHOW_OPTION_YES; +#else + have_merge_db= SHOW_OPTION_NO; +#endif +#ifdef WITH_INNOBASE_STORAGE_ENGINE + have_innodb= SHOW_OPTION_YES; +#else + have_innodb= SHOW_OPTION_NO; +#endif +#ifdef WITH_EXAMPLE_STORAGE_ENGINE + have_example_db= SHOW_OPTION_YES; +#else + have_example_db= SHOW_OPTION_NO; +#endif +#ifdef WITH_ARCHIVE_STORAGE_ENGINE + have_archive_db= SHOW_OPTION_YES; +#else + have_archive_db= SHOW_OPTION_NO; +#endif +#ifdef WITH_BLACKHOLE_STORAGE_ENGINE + have_blackhole_db= SHOW_OPTION_YES; +#else + have_blackhole_db= SHOW_OPTION_NO; +#endif +#ifdef WITH_FEDERATED_STORAGE_ENGINE + have_federated_db= SHOW_OPTION_YES; +#else + have_federated_db= SHOW_OPTION_NO; +#endif +#ifdef WITH_CSV_STORAGE_ENGINE + have_csv_db= SHOW_OPTION_YES; +#else + have_csv_db= SHOW_OPTION_NO; +#endif +#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE + have_ndbcluster= SHOW_OPTION_DISABLED; +#else + have_ndbcluster= SHOW_OPTION_NO; +#endif +#ifdef WITH_PARTITION_STORAGE_ENGINE + have_partition_db= SHOW_OPTION_YES; +#else + have_partition_db= SHOW_OPTION_NO; +#endif #ifdef HAVE_ROW_BASED_REPLICATION have_row_based_replication= SHOW_OPTION_YES; #else @@ -8061,6 +8106,7 @@ void refresh_status(THD *thd) #undef have_federated_db #undef have_partition_db #undef have_blackhole_db +#undef have_merge_db SHOW_COMP_OPTION have_innodb= SHOW_OPTION_NO; SHOW_COMP_OPTION have_ndbcluster= SHOW_OPTION_NO; @@ -8070,6 +8116,7 @@ SHOW_COMP_OPTION have_csv_db= SHOW_OPTION_NO; SHOW_COMP_OPTION have_federated_db= SHOW_OPTION_NO; SHOW_COMP_OPTION have_partition_db= SHOW_OPTION_NO; SHOW_COMP_OPTION have_blackhole_db= SHOW_OPTION_NO; +SHOW_COMP_OPTION have_merge_db= SHOW_OPTION_NO; #ifndef WITH_INNOBASE_STORAGE_ENGINE uint innobase_flush_log_at_trx_commit; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 286637bd9aa..3e8ad9bb78b 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -443,11 +443,11 @@ bool partition_info::check_engine_mix(handlerton **engine_array, uint no_parts) DBUG_RETURN(TRUE); } } while (++i < no_parts); - if (engine_array[0] == &myisammrg_hton || - engine_array[0] == &tina_hton) + if (engine_array[0] == myisammrg_hton || + engine_array[0] == tina_hton) { my_error(ER_PARTITION_MERGE_ERROR, MYF(0), - engine_array[0] == &myisammrg_hton ? "MyISAM Merge" : "CSV"); + engine_array[0] == myisammrg_hton ? "MyISAM Merge" : "CSV"); DBUG_RETURN(TRUE); } DBUG_RETURN(FALSE); diff --git a/sql/set_var.cc b/sql/set_var.cc index e09c75573eb..5fb209b8b11 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3591,7 +3591,7 @@ byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type, void sys_var_thd_storage_engine::set_default(THD *thd, enum_var_type type) { if (type == OPT_GLOBAL) - global_system_variables.*offset= &myisam_hton; + global_system_variables.*offset= myisam_hton; else thd->variables.*offset= global_system_variables.*offset; } diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 75c2422edf9..e0831b0f8ee 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -2389,7 +2389,7 @@ Query_cache::register_tables_from_list(TABLE_LIST *tables_used, tables_used->engine_data)) DBUG_RETURN(0); - if (tables_used->table->s->db_type == &myisammrg_hton) + if (tables_used->table->s->db_type == myisammrg_hton) { ha_myisammrg *handler = (ha_myisammrg *) tables_used->table->file; MYRG_INFO *file = handler->myrg_info(); @@ -3013,7 +3013,7 @@ static TABLE_COUNTER_TYPE process_and_count_tables(TABLE_LIST *tables_used, "other non-cacheable table(s)")); DBUG_RETURN(0); } - if (tables_used->table->s->db_type == &myisammrg_hton) + if (tables_used->table->s->db_type == myisammrg_hton) { ha_myisammrg *handler = (ha_myisammrg *)tables_used->table->file; MYRG_INFO *file = handler->myrg_info(); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index d561fb19953..ce237899b3a 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2767,8 +2767,8 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, tmp_table.s->db_create_options=0; tmp_table.s->blob_ptr_size= portable_sizeof_char_ptr; tmp_table.s->db_low_byte_first= - test(create_info->db_type == &myisam_hton || - create_info->db_type == &heap_hton); + test(create_info->db_type == myisam_hton || + create_info->db_type == heap_hton); tmp_table.null_row=tmp_table.maybe_null=0; while ((item=it++)) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index af69c16c7e5..a5dc0ab0d15 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -4677,7 +4677,7 @@ the generated partition syntax in a correct manner. DBUG_PRINT("info", ("partition changed")); *partition_changed= TRUE; } - if (create_info->db_type == &partition_hton) + if (create_info->db_type == partition_hton) part_info->default_engine_type= table->part_info->default_engine_type; else part_info->default_engine_type= create_info->db_type; @@ -4689,7 +4689,7 @@ the generated partition syntax in a correct manner. if (!is_native_partitioned) { DBUG_ASSERT(create_info->db_type); - create_info->db_type= &partition_hton; + create_info->db_type= partition_hton; } } } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 84810fb3324..97c28dd1fa5 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -477,13 +477,6 @@ err: void plugin_deinitialize(struct st_plugin_int *plugin) { - if (plugin_type_deinitialize[plugin->plugin->type] && - (*plugin_type_deinitialize[plugin->plugin->type])(plugin)) - { - sql_print_error("Plugin '%s' of type %s failed deinitialization", - plugin->name.str, plugin_type_names[plugin->plugin->type]); - } - if (plugin->plugin->status_vars) { #ifdef FIX_LATER @@ -504,10 +497,18 @@ void plugin_deinitialize(struct st_plugin_int *plugin) #endif /* FIX_LATER */ } - if (plugin->plugin->deinit) + if (plugin_type_deinitialize[plugin->plugin->type]) + { + if ((*plugin_type_deinitialize[plugin->plugin->type])(plugin)) + { + sql_print_error("Plugin '%s' of type %s failed deinitialization", + plugin->name.str, plugin_type_names[plugin->plugin->type]); + } + } + else if (plugin->plugin->deinit) { DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str)); - if (plugin->plugin->deinit()) + if (plugin->plugin->deinit(NULL)) { DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.", plugin->name.str)); @@ -556,6 +557,27 @@ static int plugin_initialize(struct st_plugin_int *plugin) { DBUG_ENTER("plugin_initialize"); + if (plugin_type_initialize[plugin->plugin->type]) + { + if ((*plugin_type_initialize[plugin->plugin->type])(plugin)) + { + sql_print_error("Plugin '%s' registration as a %s failed.", + plugin->name.str, plugin_type_names[plugin->plugin->type]); + goto err; + } + } + else if (plugin->plugin->init) + { + if (plugin->plugin->init(NULL)) + { + sql_print_error("Plugin '%s' init function returned error.", + plugin->name.str); + goto err; + } + } + + plugin->state= PLUGIN_IS_READY; + if (plugin->plugin->status_vars) { #ifdef FIX_LATER @@ -576,24 +598,6 @@ static int plugin_initialize(struct st_plugin_int *plugin) add_status_vars(plugin->plugin->status_vars); // add_status_vars makes a copy #endif /* FIX_LATER */ } - if (plugin->plugin->init) - { - if (plugin->plugin->init()) - { - sql_print_error("Plugin '%s' init function returned error.", - plugin->name.str); - goto err; - } - } - if (plugin_type_initialize[plugin->plugin->type] && - (*plugin_type_initialize[plugin->plugin->type])(plugin)) - { - sql_print_error("Plugin '%s' registration as a %s failed.", - plugin->name.str, plugin_type_names[plugin->plugin->type]); - goto err; - } - - plugin->state= PLUGIN_IS_READY; DBUG_RETURN(0); err: diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b3e4bf39a8f..a280b290019 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8857,7 +8857,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, OPTION_BIG_TABLES || (select_options & TMP_TABLE_FORCE_MYISAM)) { table->file= get_new_handler(share, &table->mem_root, - share->db_type= &myisam_hton); + share->db_type= myisam_hton); if (group && (param->group_parts > table->file->max_key_parts() || param->group_length > table->file->max_key_length())) @@ -8866,7 +8866,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, else { table->file= get_new_handler(share, &table->mem_root, - share->db_type= &heap_hton); + share->db_type= heap_hton); } if (!table->file) goto err; @@ -9027,7 +9027,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, if (thd->variables.tmp_table_size == ~(ulong) 0) // No limit share->max_rows= ~(ha_rows) 0; else - share->max_rows= (((share->db_type == &heap_hton) ? + share->max_rows= (((share->db_type == heap_hton) ? min(thd->variables.tmp_table_size, thd->variables.max_heap_table_size) : thd->variables.tmp_table_size)/ share->reclength); @@ -9179,7 +9179,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, if (thd->is_fatal_error) // If end of memory goto err; /* purecov: inspected */ share->db_record_offset= 1; - if (share->db_type == &myisam_hton) + if (share->db_type == myisam_hton) { if (create_myisam_tmp_table(table,param,select_options)) goto err; @@ -9505,7 +9505,7 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, int write_err; DBUG_ENTER("create_myisam_from_heap"); - if (table->s->db_type != &heap_hton || + if (table->s->db_type != heap_hton || error != HA_ERR_RECORD_FILE_FULL) { table->file->print_error(error,MYF(0)); @@ -9514,9 +9514,9 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, new_table= *table; share= *table->s; new_table.s= &share; - new_table.s->db_type= &myisam_hton; + new_table.s->db_type= myisam_hton; if (!(new_table.file= get_new_handler(&share, &new_table.mem_root, - &myisam_hton))) + myisam_hton))) DBUG_RETURN(1); // End of memory save_proc_info=thd->proc_info; @@ -12127,7 +12127,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having) free_io_cache(entry); // Safety entry->file->info(HA_STATUS_VARIABLE); - if (entry->s->db_type == &heap_hton || + if (entry->s->db_type == heap_hton || (!entry->s->blob_fields && ((ALIGN_SIZE(reclength) + HASH_OVERHEAD) * entry->file->stats.records < thd->variables.sortbuff_size))) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index eddba067d3a..70863d01311 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2925,7 +2925,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables, ha_row_type[(uint) share->row_type], NullS); #ifdef WITH_PARTITION_STORAGE_ENGINE - if (show_table->s->db_type == &partition_hton && + if (show_table->s->db_type == partition_hton && show_table->part_info != NULL && show_table->part_info->no_parts > 0) ptr= strmov(ptr, " partitioned"); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 02de7abb674..610771724e1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3276,7 +3276,7 @@ bool mysql_create_table_internal(THD *thd, goto err; } } - if ((part_engine_type == &partition_hton) && + if ((part_engine_type == partition_hton) && part_info->default_engine_type) { /* @@ -3319,7 +3319,7 @@ bool mysql_create_table_internal(THD *thd, part_info->part_info_len= syntax_len; if ((!(engine_type->partition_flags && engine_type->partition_flags() & HA_CAN_PARTITION)) || - create_info->db_type == &partition_hton) + create_info->db_type == partition_hton) { /* The handler assigned to the table cannot handle partitioning. @@ -3328,7 +3328,7 @@ bool mysql_create_table_internal(THD *thd, DBUG_PRINT("info", ("db_type: %d", ha_legacy_type(create_info->db_type))); delete file; - create_info->db_type= &partition_hton; + create_info->db_type= partition_hton; if (!(file= get_ha_partition(part_info))) { DBUG_RETURN(TRUE); @@ -6779,7 +6779,7 @@ static bool check_engine(THD *thd, const char *table_name, *new_engine= 0; return TRUE; } - *new_engine= &myisam_hton; + *new_engine= myisam_hton; } return FALSE; } diff --git a/sql/table.cc b/sql/table.cc index f1845fdedb3..834c2ed9c82 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -632,7 +632,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, if (!strncmp(next_chunk + 2, "partition", str_db_type_length)) { /* Use partition handler */ - share->db_type= &partition_hton; + share->db_type= partition_hton; DBUG_PRINT("info", ("setting dbtype to '%.*s' (%d)", str_db_type_length, next_chunk + 2, ha_legacy_type(share->db_type))); |