Bug#20168
"Change in behavior --default-storage-engine=ndb or ndbcluster" Reduce use of legacy_db_type, some code cleanup (serg read my mind and implemented desired mysqld.cc changes)
This commit is contained in:
parent
acf3a19382
commit
62729fcdfe
@ -68,14 +68,14 @@ ulong total_ha_2pc= 0;
|
|||||||
/* size of savepoint storage area (see ha_init) */
|
/* size of savepoint storage area (see ha_init) */
|
||||||
ulong savepoint_alloc_size= 0;
|
ulong savepoint_alloc_size= 0;
|
||||||
|
|
||||||
struct show_table_alias_st sys_table_aliases[]=
|
static const LEX_STRING sys_table_aliases[]=
|
||||||
{
|
{
|
||||||
{"INNOBASE", DB_TYPE_INNODB},
|
{(char*)STRING_WITH_LEN("INNOBASE")}, {(char*)STRING_WITH_LEN("INNODB")},
|
||||||
{"NDB", DB_TYPE_NDBCLUSTER},
|
{(char*)STRING_WITH_LEN("NDB")}, {(char*)STRING_WITH_LEN("NDBCLUSTER")},
|
||||||
{"BDB", DB_TYPE_BERKELEY_DB},
|
{(char*)STRING_WITH_LEN("BDB")}, {(char*)STRING_WITH_LEN("BERKELEYDB")},
|
||||||
{"HEAP", DB_TYPE_HEAP},
|
{(char*)STRING_WITH_LEN("HEAP")}, {(char*)STRING_WITH_LEN("MEMORY")},
|
||||||
{"MERGE", DB_TYPE_MRG_MYISAM},
|
{(char*)STRING_WITH_LEN("MERGE")}, {(char*)STRING_WITH_LEN("MRG_MYISAM")},
|
||||||
{NullS, DB_TYPE_UNKNOWN}
|
{NullS, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *ha_row_type[] = {
|
const char *ha_row_type[] = {
|
||||||
@ -91,15 +91,50 @@ TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"",
|
|||||||
static TYPELIB known_extensions= {0,"known_exts", NULL, NULL};
|
static TYPELIB known_extensions= {0,"known_exts", NULL, NULL};
|
||||||
uint known_extensions_id= 0;
|
uint known_extensions_id= 0;
|
||||||
|
|
||||||
handlerton *ha_resolve_by_name(THD *thd, LEX_STRING *name)
|
|
||||||
|
/*
|
||||||
|
Return the default storage engine handlerton for thread
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
ha_default_handlerton(thd)
|
||||||
|
thd current thread
|
||||||
|
|
||||||
|
RETURN
|
||||||
|
pointer to handlerton
|
||||||
|
*/
|
||||||
|
|
||||||
|
handlerton *ha_default_handlerton(THD *thd)
|
||||||
{
|
{
|
||||||
show_table_alias_st *table_alias;
|
return (thd->variables.table_type != NULL) ?
|
||||||
|
thd->variables.table_type :
|
||||||
|
(global_system_variables.table_type != NULL ?
|
||||||
|
global_system_variables.table_type : &myisam_hton);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Return the storage engine handlerton for the supplied name
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
ha_resolve_by_name(thd, name)
|
||||||
|
thd current thread
|
||||||
|
name name of storage engine
|
||||||
|
|
||||||
|
RETURN
|
||||||
|
pointer to handlerton
|
||||||
|
*/
|
||||||
|
|
||||||
|
handlerton *ha_resolve_by_name(THD *thd, const LEX_STRING *name)
|
||||||
|
{
|
||||||
|
const LEX_STRING *table_alias;
|
||||||
st_plugin_int *plugin;
|
st_plugin_int *plugin;
|
||||||
|
|
||||||
if (thd && !my_strnncoll(&my_charset_latin1,
|
redo:
|
||||||
|
/* my_strnncoll is a macro and gcc doesn't do early expansion of macro */
|
||||||
|
if (thd && !my_charset_latin1.coll->strnncoll(&my_charset_latin1,
|
||||||
(const uchar *)name->str, name->length,
|
(const uchar *)name->str, name->length,
|
||||||
(const uchar *)"DEFAULT", 7))
|
(const uchar *)STRING_WITH_LEN("DEFAULT"), 0))
|
||||||
return ha_resolve_by_legacy_type(thd, DB_TYPE_DEFAULT);
|
return ha_default_handlerton(thd);
|
||||||
|
|
||||||
if ((plugin= plugin_lock(name, MYSQL_STORAGE_ENGINE_PLUGIN)))
|
if ((plugin= plugin_lock(name, MYSQL_STORAGE_ENGINE_PLUGIN)))
|
||||||
{
|
{
|
||||||
@ -112,13 +147,15 @@ handlerton *ha_resolve_by_name(THD *thd, LEX_STRING *name)
|
|||||||
/*
|
/*
|
||||||
We check for the historical aliases.
|
We check for the historical aliases.
|
||||||
*/
|
*/
|
||||||
for (table_alias= sys_table_aliases; table_alias->type; table_alias++)
|
for (table_alias= sys_table_aliases; table_alias->str; table_alias+= 2)
|
||||||
{
|
{
|
||||||
if (!my_strnncoll(&my_charset_latin1,
|
if (!my_strnncoll(&my_charset_latin1,
|
||||||
(const uchar *)name->str, name->length,
|
(const uchar *)name->str, name->length,
|
||||||
(const uchar *)table_alias->alias,
|
(const uchar *)table_alias->str, table_alias->length))
|
||||||
strlen(table_alias->alias)))
|
{
|
||||||
return ha_resolve_by_legacy_type(thd, table_alias->type);
|
name= table_alias + 1;
|
||||||
|
goto redo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -130,20 +167,20 @@ const char *ha_get_storage_engine(enum legacy_db_type db_type)
|
|||||||
switch (db_type) {
|
switch (db_type) {
|
||||||
case DB_TYPE_DEFAULT:
|
case DB_TYPE_DEFAULT:
|
||||||
return "DEFAULT";
|
return "DEFAULT";
|
||||||
case DB_TYPE_UNKNOWN:
|
|
||||||
return "UNKNOWN";
|
|
||||||
default:
|
default:
|
||||||
if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT &&
|
if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT &&
|
||||||
installed_htons[db_type])
|
installed_htons[db_type])
|
||||||
return hton2plugin[installed_htons[db_type]->slot]->name.str;
|
return hton2plugin[installed_htons[db_type]->slot]->name.str;
|
||||||
return "*NONE*";
|
/* fall through */
|
||||||
|
case DB_TYPE_UNKNOWN:
|
||||||
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static handler *create_default(TABLE_SHARE *table, MEM_ROOT *mem_root)
|
static handler *create_default(TABLE_SHARE *table, MEM_ROOT *mem_root)
|
||||||
{
|
{
|
||||||
handlerton *hton=ha_resolve_by_legacy_type(current_thd, DB_TYPE_DEFAULT);
|
handlerton *hton= ha_default_handlerton(current_thd);
|
||||||
return (hton && hton->create) ? hton->create(table, mem_root) : NULL;
|
return (hton && hton->create) ? hton->create(table, mem_root) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,10 +189,7 @@ handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type)
|
|||||||
{
|
{
|
||||||
switch (db_type) {
|
switch (db_type) {
|
||||||
case DB_TYPE_DEFAULT:
|
case DB_TYPE_DEFAULT:
|
||||||
return (thd->variables.table_type != NULL) ?
|
return ha_default_handlerton(thd);
|
||||||
thd->variables.table_type :
|
|
||||||
(global_system_variables.table_type != NULL ?
|
|
||||||
global_system_variables.table_type : &myisam_hton);
|
|
||||||
case DB_TYPE_UNKNOWN:
|
case DB_TYPE_UNKNOWN:
|
||||||
return NULL;
|
return NULL;
|
||||||
default:
|
default:
|
||||||
@ -196,7 +230,7 @@ handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ha_resolve_by_legacy_type(thd, DB_TYPE_DEFAULT);
|
return ha_default_handlerton(thd);
|
||||||
} /* ha_checktype */
|
} /* ha_checktype */
|
||||||
|
|
||||||
|
|
||||||
|
@ -667,10 +667,6 @@ struct handlerton
|
|||||||
struct handler_iterator *fill_this_in);
|
struct handler_iterator *fill_this_in);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct show_table_alias_st {
|
|
||||||
const char *alias;
|
|
||||||
enum legacy_db_type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Possible flags of a handlerton */
|
/* Possible flags of a handlerton */
|
||||||
#define HTON_NO_FLAGS 0
|
#define HTON_NO_FLAGS 0
|
||||||
@ -1545,7 +1541,8 @@ extern ulong total_ha, total_ha_2pc;
|
|||||||
#define ha_rollback(thd) (ha_rollback_trans((thd), TRUE))
|
#define ha_rollback(thd) (ha_rollback_trans((thd), TRUE))
|
||||||
|
|
||||||
/* lookups */
|
/* lookups */
|
||||||
handlerton *ha_resolve_by_name(THD *thd, LEX_STRING *name);
|
handlerton *ha_default_handlerton(THD *thd);
|
||||||
|
handlerton *ha_resolve_by_name(THD *thd, const LEX_STRING *name);
|
||||||
handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type);
|
handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type);
|
||||||
const char *ha_get_storage_engine(enum legacy_db_type db_type);
|
const char *ha_get_storage_engine(enum legacy_db_type db_type);
|
||||||
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
|
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
|
||||||
|
@ -23,7 +23,7 @@ extern struct st_mysql_plugin *mysqld_builtins[];
|
|||||||
|
|
||||||
char *opt_plugin_dir_ptr;
|
char *opt_plugin_dir_ptr;
|
||||||
char opt_plugin_dir[FN_REFLEN];
|
char opt_plugin_dir[FN_REFLEN];
|
||||||
LEX_STRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]=
|
const LEX_STRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]=
|
||||||
{
|
{
|
||||||
{ (char *)STRING_WITH_LEN("UDF") },
|
{ (char *)STRING_WITH_LEN("UDF") },
|
||||||
{ (char *)STRING_WITH_LEN("STORAGE ENGINE") },
|
{ (char *)STRING_WITH_LEN("STORAGE ENGINE") },
|
||||||
@ -63,7 +63,7 @@ static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM];
|
|||||||
static rw_lock_t THR_LOCK_plugin;
|
static rw_lock_t THR_LOCK_plugin;
|
||||||
static bool initialized= 0;
|
static bool initialized= 0;
|
||||||
|
|
||||||
static struct st_plugin_dl *plugin_dl_find(LEX_STRING *dl)
|
static struct st_plugin_dl *plugin_dl_find(const LEX_STRING *dl)
|
||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
DBUG_ENTER("plugin_dl_find");
|
DBUG_ENTER("plugin_dl_find");
|
||||||
@ -112,7 +112,7 @@ static inline void free_plugin_mem(struct st_plugin_dl *p)
|
|||||||
my_free((gptr)p->plugins, MYF(MY_ALLOW_ZERO_PTR));
|
my_free((gptr)p->plugins, MYF(MY_ALLOW_ZERO_PTR));
|
||||||
}
|
}
|
||||||
|
|
||||||
static st_plugin_dl *plugin_dl_add(LEX_STRING *dl, int report)
|
static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DLOPEN
|
#ifdef HAVE_DLOPEN
|
||||||
char dlpath[FN_REFLEN];
|
char dlpath[FN_REFLEN];
|
||||||
@ -294,7 +294,7 @@ static st_plugin_dl *plugin_dl_add(LEX_STRING *dl, int report)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void plugin_dl_del(LEX_STRING *dl)
|
static void plugin_dl_del(const LEX_STRING *dl)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DLOPEN
|
#ifdef HAVE_DLOPEN
|
||||||
uint i;
|
uint i;
|
||||||
@ -322,7 +322,7 @@ static void plugin_dl_del(LEX_STRING *dl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct st_plugin_int *plugin_find_internal(LEX_STRING *name, int type)
|
static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int type)
|
||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
DBUG_ENTER("plugin_find_internal");
|
DBUG_ENTER("plugin_find_internal");
|
||||||
@ -345,7 +345,7 @@ static struct st_plugin_int *plugin_find_internal(LEX_STRING *name, int type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my_bool plugin_is_ready(LEX_STRING *name, int type)
|
my_bool plugin_is_ready(const LEX_STRING *name, int type)
|
||||||
{
|
{
|
||||||
my_bool rc= FALSE;
|
my_bool rc= FALSE;
|
||||||
struct st_plugin_int *plugin;
|
struct st_plugin_int *plugin;
|
||||||
@ -359,7 +359,7 @@ my_bool plugin_is_ready(LEX_STRING *name, int type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct st_plugin_int *plugin_lock(LEX_STRING *name, int type)
|
struct st_plugin_int *plugin_lock(const LEX_STRING *name, int type)
|
||||||
{
|
{
|
||||||
struct st_plugin_int *rc;
|
struct st_plugin_int *rc;
|
||||||
DBUG_ENTER("plugin_lock");
|
DBUG_ENTER("plugin_lock");
|
||||||
@ -396,7 +396,7 @@ static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin)
|
|||||||
struct st_plugin_int *));
|
struct st_plugin_int *));
|
||||||
}
|
}
|
||||||
|
|
||||||
static my_bool plugin_add(LEX_STRING *name, LEX_STRING *dl, int report)
|
static my_bool plugin_add(const LEX_STRING *name, const LEX_STRING *dl, int report)
|
||||||
{
|
{
|
||||||
struct st_plugin_int tmp;
|
struct st_plugin_int tmp;
|
||||||
struct st_mysql_plugin *plugin;
|
struct st_mysql_plugin *plugin;
|
||||||
@ -479,7 +479,7 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void plugin_del(LEX_STRING *name)
|
static void plugin_del(const LEX_STRING *name)
|
||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
struct st_plugin_int *plugin;
|
struct st_plugin_int *plugin;
|
||||||
@ -811,7 +811,7 @@ void plugin_free(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my_bool mysql_install_plugin(THD *thd, LEX_STRING *name, LEX_STRING *dl)
|
my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl)
|
||||||
{
|
{
|
||||||
TABLE_LIST tables;
|
TABLE_LIST tables;
|
||||||
TABLE *table;
|
TABLE *table;
|
||||||
@ -866,7 +866,7 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my_bool mysql_uninstall_plugin(THD *thd, LEX_STRING *name)
|
my_bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name)
|
||||||
{
|
{
|
||||||
TABLE *table;
|
TABLE *table;
|
||||||
TABLE_LIST tables;
|
TABLE_LIST tables;
|
||||||
|
@ -66,15 +66,15 @@ typedef int (*plugin_type_init)(struct st_plugin_int *);
|
|||||||
|
|
||||||
extern char *opt_plugin_dir_ptr;
|
extern char *opt_plugin_dir_ptr;
|
||||||
extern char opt_plugin_dir[FN_REFLEN];
|
extern char opt_plugin_dir[FN_REFLEN];
|
||||||
extern LEX_STRING plugin_type_names[];
|
extern const LEX_STRING plugin_type_names[];
|
||||||
extern int plugin_init(void);
|
extern int plugin_init(void);
|
||||||
extern void plugin_load(void);
|
extern void plugin_load(void);
|
||||||
extern void plugin_free(void);
|
extern void plugin_free(void);
|
||||||
extern my_bool plugin_is_ready(LEX_STRING *name, int type);
|
extern my_bool plugin_is_ready(const LEX_STRING *name, int type);
|
||||||
extern st_plugin_int *plugin_lock(LEX_STRING *name, int type);
|
extern st_plugin_int *plugin_lock(const LEX_STRING *name, int type);
|
||||||
extern void plugin_unlock(struct st_plugin_int *plugin);
|
extern void plugin_unlock(struct st_plugin_int *plugin);
|
||||||
extern my_bool mysql_install_plugin(THD *thd, LEX_STRING *name, LEX_STRING *dl);
|
extern my_bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl);
|
||||||
extern my_bool mysql_uninstall_plugin(THD *thd, LEX_STRING *name);
|
extern my_bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name);
|
||||||
|
|
||||||
extern my_bool plugin_register_builtin(struct st_mysql_plugin *plugin);
|
extern my_bool plugin_register_builtin(struct st_mysql_plugin *plugin);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
|
|||||||
*/
|
*/
|
||||||
if (hton == NULL || hton->state != SHOW_OPTION_YES)
|
if (hton == NULL || hton->state != SHOW_OPTION_YES)
|
||||||
{
|
{
|
||||||
hton= ha_resolve_by_legacy_type(thd, DB_TYPE_DEFAULT);
|
hton= ha_default_handlerton(thd);
|
||||||
if (ts_info->storage_engine != 0)
|
if (ts_info->storage_engine != 0)
|
||||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
|
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
|
||||||
ER_WARN_USING_OTHER_HANDLER,
|
ER_WARN_USING_OTHER_HANDLER,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user