diff options
-rw-r--r-- | mysql-test/t/disabled.def | 1 | ||||
-rw-r--r-- | sql/handler.cc | 77 | ||||
-rw-r--r-- | sql/handler.h | 4 | ||||
-rw-r--r-- | sql/set_var.cc | 2 | ||||
-rw-r--r-- | sql/sql_partition.cc | 10 | ||||
-rw-r--r-- | sql/sql_plugin.h | 3 | ||||
-rw-r--r-- | sql/sql_show.cc | 14 | ||||
-rw-r--r-- | sql/sql_table.cc | 2 | ||||
-rw-r--r-- | sql/sql_tablespace.cc | 4 |
9 files changed, 58 insertions, 59 deletions
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 552827c47f9..d6083ab8bfe 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -38,4 +38,3 @@ rpl_sp : BUG#16456 2006-02-16 jmiller # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open #ndb_binlog_ddl_multi : BUG#18976 2006-04-10 kent CRBR: multiple binlog, second binlog may miss schema log events -ndb_dd_backuprestore : Nikolay: removed partitions from the test. Review pending. diff --git a/sql/handler.cc b/sql/handler.cc index ebfcc8f7a13..261925a3a60 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -48,7 +48,7 @@ check for dups and to find handlerton from legacy_db_type. Remove when legacy_db_type is finally gone */ static handlerton *installed_htons[128]; -st_mysql_plugin *hton2plugin[MAX_HA]; +st_plugin_int *hton2plugin[MAX_HA]; #define BITMAP_STACKBUF_SIZE (128/8) @@ -102,7 +102,7 @@ handlerton *ha_resolve_by_name(THD *thd, LEX_STRING *name) if ((plugin= plugin_lock(name, MYSQL_STORAGE_ENGINE_PLUGIN))) { - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if (!(hton->flags & HTON_NOT_USER_SELECTABLE)) return hton; plugin_unlock(plugin); @@ -135,7 +135,7 @@ const char *ha_get_storage_engine(enum legacy_db_type db_type) default: if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT && installed_htons[db_type]) - return hton2plugin[installed_htons[db_type]->slot]->name; + return hton2plugin[installed_htons[db_type]->slot]->name.str; return "*NONE*"; } } @@ -351,22 +351,19 @@ static int ha_finish_errors(void) int ha_finalize_handlerton(st_plugin_int *plugin) { - handlerton *hton; + handlerton *hton= (handlerton *)plugin->data; DBUG_ENTER("ha_finalize_handlerton"); - if (!(hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton)) - DBUG_RETURN(1); - switch (hton->state) { case SHOW_OPTION_NO: case SHOW_OPTION_DISABLED: break; case SHOW_OPTION_YES: - if (hton->panic && hton->panic(HA_PANIC_CLOSE)) - DBUG_RETURN(1); if (installed_htons[hton->db_type] == hton) installed_htons[hton->db_type]= NULL; + if (hton->panic && hton->panic(HA_PANIC_CLOSE)) + DBUG_RETURN(1); break; }; DBUG_RETURN(0); @@ -376,9 +373,10 @@ int ha_finalize_handlerton(st_plugin_int *plugin) int ha_initialize_handlerton(st_plugin_int *plugin) { handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; - DBUG_ENTER("ha_initialize_handlerton"); + plugin->data= hton; // shortcut for the future + /* the switch below and hton->state should be removed when command-line options for plugins will be implemented @@ -388,6 +386,7 @@ int ha_initialize_handlerton(st_plugin_int *plugin) break; case SHOW_OPTION_YES: { + uint tmp; /* now check the db_type for conflict */ if (hton->db_type <= DB_TYPE_UNKNOWN || hton->db_type >= DB_TYPE_DEFAULT || @@ -409,11 +408,11 @@ int ha_initialize_handlerton(st_plugin_int *plugin) hton->db_type= (enum legacy_db_type) idx; } installed_htons[hton->db_type]= hton; - uint tmp= hton->savepoint_offset; + tmp= hton->savepoint_offset; hton->savepoint_offset= savepoint_alloc_size; savepoint_alloc_size+= tmp; hton->slot= total_ha++; - hton2plugin[hton->slot]=plugin->plugin; + hton2plugin[hton->slot]=plugin; if (hton->prepare) total_ha_2pc++; break; @@ -445,16 +444,14 @@ int ha_init() DBUG_RETURN(error); } +/* + close, flush or restart databases + Ignore this for other databases than ours +*/ - - - /* close, flush or restart databases */ - /* Ignore this for other databases than ours */ - -static my_bool panic_handlerton(THD *unused1, st_plugin_int *plugin, - void *arg) +static my_bool panic_handlerton(THD *unused1, st_plugin_int *plugin, void *arg) { - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if (hton->state == SHOW_OPTION_YES && hton->panic) ((int*)arg)[0]|= hton->panic((enum ha_panic_function)((int*)arg)[1]); return FALSE; @@ -476,7 +473,7 @@ int ha_panic(enum ha_panic_function flag) static my_bool dropdb_handlerton(THD *unused1, st_plugin_int *plugin, void *path) { - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if (hton->state == SHOW_OPTION_YES && hton->drop_database) hton->drop_database((char *)path); return FALSE; @@ -492,9 +489,11 @@ void ha_drop_database(char* path) static my_bool closecon_handlerton(THD *thd, st_plugin_int *plugin, void *unused) { - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; - /* there's no need to rollback here as all transactions must - be rolled back already */ + handlerton *hton= (handlerton *)plugin->data; + /* + there's no need to rollback here as all transactions must + be rolled back already + */ if (hton->state == SHOW_OPTION_YES && hton->close_connection && thd->ha_data[hton->slot]) hton->close_connection(thd); @@ -585,7 +584,7 @@ int ha_prepare(THD *thd) { push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), - hton2plugin[(*ht)->slot]->name); + hton2plugin[(*ht)->slot]->name.str); } } } @@ -824,7 +823,7 @@ struct xahton_st { static my_bool xacommit_handlerton(THD *unused1, st_plugin_int *plugin, void *arg) { - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if (hton->state == SHOW_OPTION_YES && hton->recover) { hton->commit_by_xid(((struct xahton_st *)arg)->xid); @@ -836,7 +835,7 @@ static my_bool xacommit_handlerton(THD *unused1, st_plugin_int *plugin, static my_bool xarollback_handlerton(THD *unused1, st_plugin_int *plugin, void *arg) { - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if (hton->state == SHOW_OPTION_YES && hton->recover) { hton->rollback_by_xid(((struct xahton_st *)arg)->xid); @@ -851,7 +850,7 @@ int ha_commit_or_rollback_by_xid(XID *xid, bool commit) struct xahton_st xaop; xaop.xid= xid; xaop.result= 1; - + plugin_foreach(NULL, commit ? xacommit_handlerton : xarollback_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, &xaop); @@ -943,7 +942,7 @@ struct xarecover_st static my_bool xarecover_handlerton(THD *unused, st_plugin_int *plugin, void *arg) { - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; struct xarecover_st *info= (struct xarecover_st *) arg; int got; @@ -952,7 +951,7 @@ static my_bool xarecover_handlerton(THD *unused, st_plugin_int *plugin, while ((got= hton->recover(info->list, info->len)) > 0 ) { sql_print_information("Found %d prepared transaction(s) in %s", - got, hton2plugin[hton->slot]->name); + got, hton2plugin[hton->slot]->name.str); for (int i=0; i < got; i ++) { my_xid x=info->list[i].get_my_xid(); @@ -1132,7 +1131,7 @@ bool mysql_xa_recover(THD *thd) static my_bool release_temporary_latches(THD *thd, st_plugin_int *plugin, void *unused) { - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if (hton->state == SHOW_OPTION_YES && hton->release_temporary_latches) hton->release_temporary_latches(thd); @@ -1257,7 +1256,7 @@ int ha_release_savepoint(THD *thd, SAVEPOINT *sv) static my_bool snapshot_handlerton(THD *thd, st_plugin_int *plugin, void *arg) { - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if (hton->state == SHOW_OPTION_YES && hton->start_consistent_snapshot) { @@ -1288,7 +1287,7 @@ int ha_start_consistent_snapshot(THD *thd) static my_bool flush_handlerton(THD *thd, st_plugin_int *plugin, void *arg) { - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if (hton->state == SHOW_OPTION_YES && hton->flush_logs && hton->flush_logs()) return TRUE; return FALSE; @@ -2599,7 +2598,7 @@ struct binlog_func_st static my_bool binlog_func_list(THD *thd, st_plugin_int *plugin, void *arg) { hton_list_st *hton_list= (hton_list_st *)arg; - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if (hton->state == SHOW_OPTION_YES && hton->binlog_func) { uint sz= hton_list->sz; @@ -2689,7 +2688,7 @@ static my_bool binlog_log_query_handlerton(THD *thd, st_plugin_int *plugin, void *args) { - return binlog_log_query_handlerton2(thd, (const handlerton *) plugin->plugin->info, args); + return binlog_log_query_handlerton2(thd, (const handlerton *)plugin->data, args); } void ha_binlog_log_query(THD *thd, const handlerton *hton, @@ -2984,7 +2983,7 @@ static my_bool exts_handlerton(THD *unused, st_plugin_int *plugin, void *arg) { List<char> *found_exts= (List<char> *) arg; - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; handler *file; if (hton->state == SHOW_OPTION_YES && hton->create && (file= hton->create((TABLE_SHARE*) 0))) @@ -3060,7 +3059,7 @@ static my_bool showstat_handlerton(THD *thd, st_plugin_int *plugin, void *arg) { enum ha_stat_type stat= *(enum ha_stat_type *) arg; - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if (hton->state == SHOW_OPTION_YES && hton->show_status && hton->show_status(thd, stat_print, stat)) return TRUE; @@ -3090,8 +3089,8 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat) { if (db_type->state != SHOW_OPTION_YES) { - const char *name=hton2plugin[db_type->slot]->name; - result= stat_print(thd, name, strlen(name), + const LEX_STRING *name=&hton2plugin[db_type->slot]->name; + result= stat_print(thd, name->str, name->length, "", 0, "DISABLED", 8) ? 1 : 0; } else diff --git a/sql/handler.h b/sql/handler.h index ba5344b19c7..564f391ce2d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -461,7 +461,7 @@ typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len, const char *file, uint file_len, const char *status, uint status_len); enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX }; -extern st_mysql_plugin *hton2plugin[MAX_HA]; +extern st_plugin_int *hton2plugin[MAX_HA]; /* handlerton is a singleton structure - one instance per storage engine - @@ -1530,7 +1530,7 @@ static inline enum legacy_db_type ha_legacy_type(const handlerton *db_type) static inline const char *ha_resolve_storage_engine_name(const handlerton *db_type) { - return db_type == NULL ? "UNKNOWN" : hton2plugin[db_type->slot]->name; + return db_type == NULL ? "UNKNOWN" : hton2plugin[db_type->slot]->name.str; } static inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32 flag) diff --git a/sql/set_var.cc b/sql/set_var.cc index e53d94d635a..3dbbd243ee4 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3307,7 +3307,7 @@ byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type, handlerton *val; val= (type == OPT_GLOBAL) ? global_system_variables.*offset : thd->variables.*offset; - return (byte *) hton2plugin[val->slot]->name; + return (byte *) hton2plugin[val->slot]->name.str; } diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 03dfe378ec2..733287f8359 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1665,8 +1665,8 @@ static int add_keyword_int(File fptr, const char *keyword, longlong num) static int add_engine(File fptr, handlerton *engine_type) { - const char *engine_str= hton2plugin[engine_type->slot]->name; - DBUG_PRINT("info", ("ENGINE = %s", engine_str)); + const char *engine_str= hton2plugin[engine_type->slot]->name.str; + DBUG_PRINT("info", ("ENGINE: %s", engine_str)); int err= add_string(fptr, "ENGINE = "); return err + add_string(fptr, engine_str); } @@ -1676,7 +1676,7 @@ static int add_partition_options(File fptr, partition_element *p_elem) int err= 0; if (p_elem->tablespace_name) - err+= add_keyword_string(fptr,"TABLESPACE", FALSE, + err+= add_keyword_string(fptr,"TABLESPACE", FALSE, p_elem->tablespace_name); if (p_elem->nodegroup_id != UNDEF_NODEGROUP) err+= add_keyword_int(fptr,"NODEGROUP",(longlong)p_elem->nodegroup_id); @@ -4515,8 +4515,8 @@ the generated partition syntax in a correct manner. DBUG_PRINT("info", ("No explicit engine used")); create_info->db_type= table->part_info->default_engine_type; } - DBUG_PRINT("info", ("New engine type = %s", - hton2plugin[create_info->db_type->slot]->name)); + DBUG_PRINT("info", ("New engine type: %s", + hton2plugin[create_info->db_type->slot]->name.str)); thd->work_part_info= NULL; *partition_changed= TRUE; } diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index 8459346fb53..b013beaba1f 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -58,7 +58,8 @@ struct st_plugin_int struct st_mysql_plugin *plugin; struct st_plugin_dl *plugin_dl; enum enum_plugin_state state; - uint ref_count; /* number of threads using the plugin */ + uint ref_count; /* number of threads using the plugin */ + void *data; /* plugin type specific, e.g. handlerton */ }; typedef int (*plugin_type_init)(struct st_plugin_int *); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 8693e805826..8c492e9457b 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -55,12 +55,13 @@ static my_bool show_handlerton(THD *thd, st_plugin_int *plugin, { handlerton *default_type= (handlerton *) arg; Protocol *protocol= thd->protocol; - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if (!(hton->flags & HTON_HIDDEN)) { protocol->prepare_for_resend(); - protocol->store(plugin->plugin->name, system_charset_info); + protocol->store(plugin->name.str, plugin->name.length, + system_charset_info); const char *option_name= show_comp_option_name[(int) hton->state]; if (hton->state == SHOW_OPTION_YES && default_type == hton) @@ -3091,7 +3092,7 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin, void *ptable) { TABLE *table= (TABLE *) ptable; - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; CHARSET_INFO *scs= system_charset_info; DBUG_ENTER("iter_schema_engines"); @@ -3099,7 +3100,7 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin, if (!(hton->flags & HTON_HIDDEN)) { if (!(wild && wild[0] && - wild_case_compare(scs, plugin->plugin->name,wild))) + wild_case_compare(scs, plugin->name.str,wild))) { LEX_STRING state[2]={{STRING_WITH_LEN("ENABLED")}, {STRING_WITH_LEN("DISABLED")}}; @@ -3107,8 +3108,7 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin, LEX_STRING *tmp; restore_record(table, s->default_values); - table->field[0]->store(plugin->plugin->name, - strlen(plugin->plugin->name), scs); + table->field[0]->store(plugin->name.str, plugin->name.length, scs); tmp= &state[test(hton->state)]; table->field[1]->store(tmp->str, tmp->length, scs); table->field[2]->store(plugin->plugin->descr, @@ -5008,7 +5008,7 @@ static my_bool run_hton_fill_schema_files(THD *thd, st_plugin_int *plugin, { struct run_hton_fill_schema_files_args *args= (run_hton_fill_schema_files_args *) arg; - handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton; + handlerton *hton= (handlerton *)plugin->data; if(hton->fill_files_table) hton->fill_files_table(thd, args->tables, args->cond); return false; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3975d5724c4..21dee4d3f2f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6465,7 +6465,7 @@ static bool check_engine(THD *thd, const char *table_name, if (create_info->used_fields & HA_CREATE_USED_ENGINE) { my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0), - hton2plugin[(*new_engine)->slot]->name, "TEMPORARY"); + hton2plugin[(*new_engine)->slot]->name.str, "TEMPORARY"); *new_engine= 0; return TRUE; } diff --git a/sql/sql_tablespace.cc b/sql/sql_tablespace.cc index 84e2b9c7d04..94318a67575 100644 --- a/sql/sql_tablespace.cc +++ b/sql/sql_tablespace.cc @@ -35,7 +35,7 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info) push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, ER_WARN_USING_OTHER_HANDLER, ER(ER_WARN_USING_OTHER_HANDLER), - hton2plugin[hton->slot]->name, + hton2plugin[hton->slot]->name.str, ts_info->tablespace_name ? ts_info->tablespace_name : ts_info->logfile_group_name); } @@ -64,7 +64,7 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info) push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, ER_ILLEGAL_HA_CREATE_OPTION, ER(ER_ILLEGAL_HA_CREATE_OPTION), - hton2plugin[hton->slot]->name, + hton2plugin[hton->slot]->name.str, "TABLESPACE or LOGFILE GROUP"); } if (mysql_bin_log.is_open()) |