Commit 5d8ca989 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Get rid of rea_create_table()

Moved rea_create_table() to the sole caller.

Also ha_create_partitioning_metadata(CHF_CREATE_FLAG) does cleanup on
error now.

Part of MDEV-17805 - Remove InnoDB cache for temporary tables.
parent 38e151d1
...@@ -4972,7 +4972,7 @@ class Create_field :public Column_definition ...@@ -4972,7 +4972,7 @@ class Create_field :public Column_definition
/** structure with parsed options (for comparing fields in ALTER TABLE) */ /** structure with parsed options (for comparing fields in ALTER TABLE) */
ha_field_option_struct *option_struct; ha_field_option_struct *option_struct;
uint offset; uint offset;
uint8 interval_id; // For rea_create_table uint8 interval_id;
bool create_if_not_exists; // Used in ALTER TABLE IF NOT EXISTS bool create_if_not_exists; // Used in ALTER TABLE IF NOT EXISTS
Create_field(): Create_field():
......
...@@ -2828,6 +2828,8 @@ bool ha_partition::create_handler_file(const char *name) ...@@ -2828,6 +2828,8 @@ bool ha_partition::create_handler_file(const char *name)
} }
} }
(void) mysql_file_close(file, MYF(0)); (void) mysql_file_close(file, MYF(0));
if (result)
mysql_file_delete(key_file_partition, file_name, MYF(MY_WME));
} }
else else
result= TRUE; result= TRUE;
......
...@@ -5031,9 +5031,22 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db, ...@@ -5031,9 +5031,22 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
*/ */
if (!file || thd->is_error()) if (!file || thd->is_error())
goto err; 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; 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; create_info->table= 0;
......
...@@ -509,49 +509,6 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table, ...@@ -509,49 +509,6 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
} }
/**
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. */ /* Pack keyinfo and keynames to keybuff for save in form-file. */
static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo, static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
......
...@@ -183,10 +183,6 @@ enum extra2_field_flags { ...@@ -183,10 +183,6 @@ enum extra2_field_flags {
VERS_OPTIMIZED_UPDATE= 1 << INVISIBLE_MAX_BITS, 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, LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<Create_field> &create_fields, List<Create_field> &create_fields,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment