Commit a53200d4 authored by Sergei Golubchik's avatar Sergei Golubchik

remove HA_CREATE_INFO::frm_only - it's internal server flag,

not part of the SE API, and, again, mutually exclusive with
C_ORDINARY_CREATE and C_CREATE_SELECT.
parent 0c4cf3c7
......@@ -1389,7 +1389,6 @@ struct HA_CREATE_INFO
uint merge_insert_method;
uint extra_size; /* length of extra data segment */
enum ha_choice transactional;
bool frm_only; ///< 1 if no ha_create_table()
bool varchar; ///< 1 if table has a VARCHAR
enum ha_storage_media storage_media; ///< DEFAULT, DISK or MEMORY
enum ha_choice page_checksum; ///< If we have page_checksums
......
......@@ -4090,7 +4090,7 @@ handler *mysql_create_frm_image(THD *thd,
set_table_default_charset(thd, create_info, (char*) db);
db_options= create_info->table_options;
if (!create_info->frm_only &&
if (create_table_mode != C_ALTER_TABLE_FRM_ONLY &&
create_info->row_type != ROW_TYPE_FIXED &&
create_info->row_type != ROW_TYPE_DEFAULT)
db_options|= HA_OPTION_PACK_RECORD;
......@@ -4324,7 +4324,8 @@ bool mysql_create_table_no_lock(THD *thd,
handler *file;
LEX_CUSTRING frm= {0,0};
bool error= TRUE;
bool internal_tmp_table= create_table_mode == C_ALTER_TABLE;
bool internal_tmp_table= create_table_mode == C_ALTER_TABLE ||
create_table_mode == C_ALTER_TABLE_FRM_ONLY;
DBUG_ENTER("mysql_create_table_no_lock");
DBUG_PRINT("enter", ("db: '%s' table: '%s' tmp: %d",
db, table_name, internal_tmp_table));
......@@ -4385,7 +4386,8 @@ bool mysql_create_table_no_lock(THD *thd,
thd_proc_info(thd, "creating table");
if (rea_create_table(thd, &frm, path, db, table_name, create_info, file))
if (rea_create_table(thd, &frm, path, db, table_name, create_info,
create_table_mode == C_ALTER_TABLE_FRM_ONLY ? 0 : file))
goto err;
if (create_info->tmp_table())
......@@ -4409,7 +4411,7 @@ bool mysql_create_table_no_lock(THD *thd,
thd->thread_specific_used= TRUE;
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
else if (thd->work_part_info && create_info->frm_only)
else if (thd->work_part_info && create_table_mode == C_ALTER_TABLE_FRM_ONLY)
{
/*
For partitioned tables we can't find some problems with table
......@@ -5944,7 +5946,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
TABLE *table, *new_table= 0;
MDL_ticket *mdl_ticket;
MDL_request target_mdl_request;
int error= 0;
int error= 0, create_table_mode= C_ALTER_TABLE;
char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN + 1];
char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias;
char index_file[FN_REFLEN], data_file[FN_REFLEN];
......@@ -6615,10 +6617,11 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
char frm_name[FN_REFLEN+1];
strxmov(frm_name, path, reg_ext, NullS);
/*
frm_only can only be used if old frm exists.
C_ALTER_TABLE_FRM_ONLY can only be used if old frm exists.
discovering frm-less engines cannot enjoy this optimization.
*/
create_info->frm_only= !my_access(frm_name, F_OK);
if (!my_access(frm_name, F_OK))
create_table_mode= C_ALTER_TABLE_FRM_ONLY;
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
......@@ -6688,13 +6691,13 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
my_sleep(100000););
/*
Create a table with a temporary name.
With create_info->frm_only == 1 this creates a .frm file only and
With C_ALTER_TABLE_FRM_ONLY this creates a .frm file only and
we keep the original row format.
We don't log the statement, it will be logged later.
*/
if (need_copy_table == ALTER_TABLE_METADATA_ONLY)
{
DBUG_ASSERT(create_info->frm_only);
DBUG_ASSERT(create_table_mode == C_ALTER_TABLE_FRM_ONLY);
/* Ensure we keep the original table format */
create_info->table_options= ((create_info->table_options &
~HA_OPTION_PACK_RECORD) |
......@@ -6703,7 +6706,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
tmp_disable_binlog(thd);
error= mysql_create_table_no_lock(thd, new_db, tmp_name, create_info,
alter_info, NULL, C_ALTER_TABLE);
alter_info, NULL, create_table_mode);
reenable_binlog(thd);
if (error)
goto err;
......@@ -7224,7 +7227,8 @@ err_new_table_cleanup:
}
else
(void) quick_rm_table(new_db_type, new_db, tmp_name,
create_info->frm_only ? FN_IS_TMP | FRM_ONLY : FN_IS_TMP);
create_table_mode == C_ALTER_TABLE_FRM_ONLY ?
FN_IS_TMP | FRM_ONLY : FN_IS_TMP);
err:
#ifdef WITH_PARTITION_STORAGE_ENGINE
......
......@@ -156,6 +156,10 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
- ALTER TABLE, that creates a temporary table #sql-xxx, which will be later
renamed to replace the original table.
- ALTER TABLE as above, but which only modifies the frm file, it only
creates an frm file for the #sql-xxx, the table in the engine is not
created.
These situations are distinguished by the following "create table mode"
values, where a CREATE ... SELECT is denoted by any non-negative number
(which should be the number of fields in the SELECT ... part), and other
......@@ -164,6 +168,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
#define C_CREATE_SELECT(X) ((X) > 0 ? (X) : 0)
#define C_ORDINARY_CREATE 0
#define C_ALTER_TABLE -1
#define C_ALTER_TABLE_FRM_ONLY -2
bool mysql_create_table_no_lock(THD *thd, const char *db,
const char *table_name,
......
......@@ -361,7 +361,7 @@ err:
db Data base name
table_name Table name
create_info create info parameters
file Handler to use or NULL if only frm needs to be created
file Handler to use or NULL if only frm needs to be created
RETURN
0 ok
......@@ -374,21 +374,16 @@ int rea_create_table(THD *thd, LEX_CUSTRING *frm,
{
DBUG_ENTER("rea_create_table");
if (thd->variables.keep_files_on_create)
create_info->options|= HA_CREATE_KEEP_FILES;
if (create_info->frm_only)
{
if (writefrm(path, db, table_name, 1, frm->str, frm->length))
goto err_handler;
}
else
if (file)
{
// TODO don't write frm for temp tables
if (create_info->tmp_table() &&
writefrm(path, db, table_name, 0, frm->str, frm->length))
goto err_handler;
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,
create_info) ||
ha_create_table(thd, path, db, table_name, create_info, frm))
......@@ -398,6 +393,11 @@ int rea_create_table(THD *thd, LEX_CUSTRING *frm,
goto err_handler;
}
}
else
{
if (writefrm(path, db, table_name, 1, frm->str, frm->length))
goto err_handler;
}
DBUG_RETURN(0);
......
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