Skip to content

Commit

Permalink
Get rid of rea_create_table()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
svoj committed Apr 3, 2019
1 parent 38e151d commit 5d8ca98
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 50 deletions.
2 changes: 1 addition & 1 deletion sql/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -4972,7 +4972,7 @@ class Create_field :public Column_definition
/** 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():
Expand Down
2 changes: 2 additions & 0 deletions sql/ha_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 15 additions & 2 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
43 changes: 0 additions & 43 deletions sql/unireg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
Expand Down
4 changes: 0 additions & 4 deletions sql/unireg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_field> &create_fields,
Expand Down

0 comments on commit 5d8ca98

Please sign in to comment.