diff --git a/sql/field.h b/sql/field.h index fed2be5391b..aeed8ae5a64 100644 --- a/sql/field.h +++ b/sql/field.h @@ -4972,7 +4972,7 @@ public: /** structure with parsed options (for comparing fields in ALTER TABLE) */ ha_field_option_struct *option_struct; uint offset; - uint8 interval_id; // For rea_create_table + uint8 interval_id; bool create_if_not_exists; // Used in ALTER TABLE IF NOT EXISTS Create_field(): diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 6d12a0aa55a..9dcd57a5f82 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2828,6 +2828,8 @@ bool ha_partition::create_handler_file(const char *name) } } (void) mysql_file_close(file, MYF(0)); + if (result) + mysql_file_delete(key_file_partition, file_name, MYF(MY_WME)); } else result= TRUE; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f934ac44b77..34b03b952c0 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5031,9 +5031,22 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db, */ if (!file || thd->is_error()) goto err; - if (rea_create_table(thd, frm, path, db.str, table_name.str, create_info, - file, frm_only)) + + if (thd->variables.keep_files_on_create) + create_info->options|= HA_CREATE_KEEP_FILES; + + if (file->ha_create_partitioning_metadata(path, NULL, CHF_CREATE_FLAG)) goto err; + + if (!frm_only) + { + if (ha_create_table(thd, path, db.str, table_name.str, create_info, frm)) + { + file->ha_create_partitioning_metadata(path, NULL, CHF_DELETE_FLAG); + deletefrm(path); + goto err; + } + } } create_info->table= 0; diff --git a/sql/unireg.cc b/sql/unireg.cc index e56199e707d..1d6bb0cdfce 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -509,49 +509,6 @@ err: } -/** - Create a frm (table definition) file and the tables - - @param thd Thread handler - @param frm Binary frm image of the table to create - @param path Name of file (including database, without .frm) - @param db Data base name - @param table_name Table name - @param create_info create info parameters - @param file Handler to use or NULL if only frm needs to be created - - @retval 0 ok - @retval 1 error -*/ - -int rea_create_table(THD *thd, LEX_CUSTRING *frm, - const char *path, const char *db, const char *table_name, - HA_CREATE_INFO *create_info, handler *file, - bool no_ha_create_table) -{ - DBUG_ENTER("rea_create_table"); - - if (thd->variables.keep_files_on_create) - create_info->options|= HA_CREATE_KEEP_FILES; - - if (file->ha_create_partitioning_metadata(path, NULL, CHF_CREATE_FLAG)) - goto err_part; - - if (!no_ha_create_table) - { - if (ha_create_table(thd, path, db, table_name, create_info, frm)) - goto err_part; - } - - DBUG_RETURN(0); - -err_part: - file->ha_create_partitioning_metadata(path, NULL, CHF_DELETE_FLAG); - deletefrm(path); - DBUG_RETURN(1); -} /* rea_create_table */ - - /* Pack keyinfo and keynames to keybuff for save in form-file. */ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo, diff --git a/sql/unireg.h b/sql/unireg.h index 20cd4c292a6..d038de7a88f 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -183,10 +183,6 @@ enum extra2_field_flags { VERS_OPTIMIZED_UPDATE= 1 << INVISIBLE_MAX_BITS, }; -int rea_create_table(THD *thd, LEX_CUSTRING *frm, - const char *path, const char *db, const char *table_name, - HA_CREATE_INFO *create_info, handler *file, - bool no_ha_create_table); LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table, HA_CREATE_INFO *create_info, List &create_fields,