69
69
bool error_if_not_empty);
71
71
static bool prepare_blob_field(THD *thd, Create_field *sql_field);
72
static bool check_engine(THD *, const char *, HA_CREATE_INFO *);
72
static bool check_engine(THD *thd, const char *db_name,
73
const char *table_name,
74
HA_CREATE_INFO *create_info);
74
77
mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
75
78
Alter_info *alter_info,
3941
3944
DBUG_RETURN(TRUE);
3943
if (check_engine(thd, table_name, create_info))
3946
if (check_engine(thd, db, table_name, create_info))
3944
3947
DBUG_RETURN(TRUE);
3946
3949
set_table_default_charset(thd, create_info, (char*) db);
5923
5926
create_info->db_type= old_db_type;
5926
if (check_engine(thd, new_name, create_info))
5929
if (check_engine(thd, new_db, new_name, create_info))
5928
5931
new_db_type= create_info->db_type;
7342
7345
DBUG_RETURN(TRUE);
7345
static bool check_engine(THD *thd, const char *table_name,
7346
HA_CREATE_INFO *create_info)
7349
@brief Check if the table can be created in the specified storage engine.
7351
Checks if the storage engine is enabled and supports the given table
7352
type (e.g. normal, temporary, system). May do engine substitution
7353
if the requested engine is disabled.
7355
@param thd Thread descriptor.
7356
@param db_name Database name.
7357
@param table_name Name of table to be created.
7358
@param create_info Create info from parser, including engine.
7360
@retval true Engine not available/supported, error has been reported.
7361
@retval false Engine available/supported.
7363
static bool check_engine(THD *thd, const char *db_name,
7364
const char *table_name, HA_CREATE_INFO *create_info)
7366
DBUG_ENTER("check_engine");
7348
7367
handlerton **new_engine= &create_info->db_type;
7349
7368
handlerton *req_engine= *new_engine;
7350
7369
bool no_substitution=
7351
7370
test(thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION);
7352
7371
if (!(*new_engine= ha_checktype(thd, ha_legacy_type(req_engine),
7353
7372
no_substitution, 1)))
7356
7375
if (req_engine && req_engine != *new_engine)
7369
7388
my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
7370
7389
ha_resolve_storage_engine_name(*new_engine), "TEMPORARY");
7371
7390
*new_engine= 0;
7374
7393
*new_engine= myisam_hton;
7397
Check, if the given table name is system table, and if the storage engine
7400
if ((create_info->used_fields & HA_CREATE_USED_ENGINE) &&
7401
!ha_check_if_supported_system_table(*new_engine, db_name, table_name))
7403
my_error(ER_UNSUPPORTED_ENGINE, MYF(0),
7404
ha_resolve_storage_engine_name(*new_engine), db_name, table_name);