mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Avoid creating the .frm file twice in some cases
Other things: - Updated code comments & fixed indentation - Removed an old QQ (temporary) comment that does not apply anymore
This commit is contained in:
@ -549,8 +549,13 @@ uint build_table_filename(char *buff, size_t bufflen, const char *db,
|
||||
|
||||
(void) tablename_to_filename(db, dbbuff, sizeof(dbbuff));
|
||||
|
||||
/* Check if this is a temporary table name. Allow it if a corresponding .frm file exists */
|
||||
if (is_prefix(table_name, tmp_file_prefix) && strlen(table_name) < NAME_CHAR_LEN &&
|
||||
/*
|
||||
Check if this is a temporary table name. Allow it if a corresponding .frm
|
||||
file exists.
|
||||
*/
|
||||
if (!(flags & FN_IS_TMP) &&
|
||||
is_prefix(table_name, tmp_file_prefix) &&
|
||||
strlen(table_name) < NAME_CHAR_LEN &&
|
||||
check_if_frm_exists(tbbuff, dbbuff, table_name))
|
||||
flags|= FN_IS_TMP;
|
||||
|
||||
@ -3997,13 +4002,17 @@ err:
|
||||
the extension).
|
||||
@param create_info Create information (like MAX_ROWS)
|
||||
@param alter_info Description of fields and keys for new table
|
||||
@param create_table_mode C_ORDINARY_CREATE, C_ALTER_TABLE, C_ASSISTED_DISCOVERY
|
||||
@param create_table_mode C_ORDINARY_CREATE, C_ALTER_TABLE,
|
||||
C_ASSISTED_DISCOVERY or C_ALTER_TABLE_FRM_ONLY.
|
||||
or any positive number (for C_CREATE_SELECT).
|
||||
If set to C_ALTER_TABLE_FRM_ONY then no frm or
|
||||
table is created, only the frm image in memory.
|
||||
@param[out] is_trans Identifies the type of engine where the table
|
||||
was created: either trans or non-trans.
|
||||
@param[out] key_info Array of KEY objects describing keys in table
|
||||
which was created.
|
||||
@param[out] key_count Number of keys in table which was created.
|
||||
@param[out] frm The frm image.
|
||||
|
||||
If one creates a temporary table, its is automatically opened and its
|
||||
TABLE_SHARE is added to THD::all_temp_tables list.
|
||||
@ -4264,7 +4273,8 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
|
||||
|
||||
if (!frm_only)
|
||||
{
|
||||
if (ha_create_table(thd, path, db.str, table_name.str, create_info, frm))
|
||||
if (ha_create_table(thd, path, db.str, table_name.str, create_info,
|
||||
frm, 0))
|
||||
{
|
||||
file->ha_create_partitioning_metadata(path, NULL, CHF_DELETE_FLAG);
|
||||
deletefrm(path);
|
||||
@ -7083,18 +7093,14 @@ static bool mysql_inplace_alter_table(THD *thd,
|
||||
goto rollback;
|
||||
}
|
||||
if (trt.update(trx_start_id, trx_end_id))
|
||||
{
|
||||
goto rollback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (table->file->ha_commit_inplace_alter_table(altered_table,
|
||||
ha_alter_info,
|
||||
true))
|
||||
{
|
||||
goto rollback;
|
||||
}
|
||||
DEBUG_SYNC(thd, "alter_table_inplace_after_commit");
|
||||
}
|
||||
|
||||
@ -7197,7 +7203,6 @@ static bool mysql_inplace_alter_table(THD *thd,
|
||||
NULL);
|
||||
if (thd->locked_tables_list.reopen_tables(thd, false))
|
||||
thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0);
|
||||
/* QQ; do something about metadata locks ? */
|
||||
}
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
@ -8709,6 +8714,7 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list,
|
||||
{
|
||||
THD_STAGE_INFO(thd, stage_rename);
|
||||
handlerton *old_db_type= table->s->db_type();
|
||||
|
||||
/*
|
||||
Then do a 'simple' rename of the table. First we need to close all
|
||||
instances of 'source' table.
|
||||
@ -8878,7 +8884,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
|
||||
uint order_num, ORDER *order, bool ignore,
|
||||
bool if_exists)
|
||||
{
|
||||
bool engine_changed, error;
|
||||
bool engine_changed, error, frm_is_created= false;
|
||||
bool no_ha_table= true; /* We have not created table in storage engine yet */
|
||||
TABLE *table, *new_table;
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
@ -9633,6 +9639,11 @@ do_continue:;
|
||||
if (create_table_for_inplace_alter(thd, alter_ctx, &frm, &altered_share,
|
||||
&altered_table))
|
||||
goto err_new_table_cleanup;
|
||||
/*
|
||||
Avoid creating frm again in ha_create_table() if inline alter will not
|
||||
be used.
|
||||
*/
|
||||
frm_is_created= 1;
|
||||
|
||||
/* Set markers for fields in TABLE object for altered table. */
|
||||
update_altered_table(ha_alter_info, &altered_table);
|
||||
@ -9764,7 +9775,7 @@ do_continue:;
|
||||
|
||||
if (ha_create_table(thd, alter_ctx.get_tmp_path(),
|
||||
alter_ctx.new_db.str, alter_ctx.new_name.str,
|
||||
create_info, &frm))
|
||||
create_info, &frm, frm_is_created))
|
||||
goto err_new_table_cleanup;
|
||||
|
||||
/* Mark that we have created table in storage engine. */
|
||||
@ -9867,7 +9878,7 @@ do_continue:;
|
||||
|
||||
if (table->s->tmp_table != NO_TMP_TABLE)
|
||||
{
|
||||
/* Close lock if this is a transactional table */
|
||||
/* Release lock if this is a transactional temporary table */
|
||||
if (thd->lock)
|
||||
{
|
||||
if (thd->locked_tables_mode != LTM_LOCK_TABLES &&
|
||||
@ -9888,6 +9899,7 @@ do_continue:;
|
||||
goto err_new_table_cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
new_table->s->table_creation_was_logged=
|
||||
table->s->table_creation_was_logged;
|
||||
/* Remove link to old table and rename the new one */
|
||||
|
Reference in New Issue
Block a user