cleanup: put db/table_name into Alter_info

also, prefer Lex_table_name and Lex_ident over LEX_CSTRING
This commit is contained in:
Sergei Golubchik 2023-06-29 16:24:50 +02:00
parent 2f6d464fec
commit b8233b38da
9 changed files with 68 additions and 77 deletions

View File

@ -5234,7 +5234,7 @@ class Column_definition: public Sql_alloc,
const Type_handler *field_type() const; // Prevent using this const Type_handler *field_type() const; // Prevent using this
Compression_method *compression_method_ptr; Compression_method *compression_method_ptr;
public: public:
LEX_CSTRING field_name; Lex_ident field_name;
LEX_CSTRING comment; // Comment for field LEX_CSTRING comment; // Comment for field
enum enum_column_versioning enum enum_column_versioning
{ {

View File

@ -3332,17 +3332,17 @@ protected:
updated during fix_fields() to values from Field object and life-time updated during fix_fields() to values from Field object and life-time
of those is shorter than life-time of Item_field. of those is shorter than life-time of Item_field.
*/ */
LEX_CSTRING orig_db_name; Lex_table_name orig_db_name;
LEX_CSTRING orig_table_name; Lex_table_name orig_table_name;
LEX_CSTRING orig_field_name; Lex_ident orig_field_name;
void undeclared_spvar_error() const; void undeclared_spvar_error() const;
public: public:
Name_resolution_context *context; Name_resolution_context *context;
LEX_CSTRING db_name; Lex_table_name db_name;
LEX_CSTRING table_name; Lex_table_name table_name;
LEX_CSTRING field_name; Lex_ident field_name;
/* /*
NOTE: came from TABLE::alias_name_used and this is only a hint! NOTE: came from TABLE::alias_name_used and this is only a hint!
See comment for TABLE::alias_name_used. See comment for TABLE::alias_name_used.

View File

@ -84,6 +84,7 @@ public:
ALTER_TABLE_LOCK_EXCLUSIVE ALTER_TABLE_LOCK_EXCLUSIVE
}; };
Lex_table_name db, table_name;
// Columns and keys to be dropped. // Columns and keys to be dropped.
List<Alter_drop> drop_list; List<Alter_drop> drop_list;

View File

@ -313,7 +313,7 @@ typedef struct st_copy_info {
class Key_part_spec :public Sql_alloc { class Key_part_spec :public Sql_alloc {
public: public:
LEX_CSTRING field_name; Lex_ident field_name;
uint length; uint length;
bool generated; bool generated;
Key_part_spec(const LEX_CSTRING *name, uint len, bool gen= false) Key_part_spec(const LEX_CSTRING *name, uint len, bool gen= false)

View File

@ -6032,7 +6032,8 @@ static bool mysql_change_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
THD *thd= lpt->thd; THD *thd= lpt->thd;
DBUG_ENTER("mysql_change_partitions"); DBUG_ENTER("mysql_change_partitions");
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0); build_table_filename(path, sizeof(path) - 1, lpt->alter_info->db.str,
lpt->alter_info->table_name.str, "", 0);
if(mysql_trans_prepare_alter_copy_data(thd)) if(mysql_trans_prepare_alter_copy_data(thd))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
@ -6080,7 +6081,8 @@ static bool mysql_rename_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
int error; int error;
DBUG_ENTER("mysql_rename_partitions"); DBUG_ENTER("mysql_rename_partitions");
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0); build_table_filename(path, sizeof(path) - 1, lpt->alter_info->db.str,
lpt->alter_info->table_name.str, "", 0);
if (unlikely((error= lpt->table->file->ha_rename_partitions(path)))) if (unlikely((error= lpt->table->file->ha_rename_partitions(path))))
{ {
if (error != 1) if (error != 1)
@ -6124,7 +6126,8 @@ static bool mysql_drop_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
lpt->table->s->table_name.str, lpt->table->s->table_name.str,
MDL_EXCLUSIVE)); MDL_EXCLUSIVE));
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0); build_table_filename(path, sizeof(path) - 1, lpt->alter_info->db.str,
lpt->alter_info->table_name.str, "", 0);
if ((error= lpt->table->file->ha_drop_partitions(path))) if ((error= lpt->table->file->ha_drop_partitions(path)))
{ {
lpt->table->file->print_error(error, MYF(0)); lpt->table->file->print_error(error, MYF(0));
@ -6511,7 +6514,8 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt)
DBUG_ENTER("write_log_rename_frm"); DBUG_ENTER("write_log_rename_frm");
part_info->first_log_entry= NULL; part_info->first_log_entry= NULL;
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0); build_table_filename(path, sizeof(path) - 1, lpt->alter_info->db.str,
lpt->alter_info->table_name.str, "", 0);
build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt); build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
mysql_mutex_lock(&LOCK_gdl); mysql_mutex_lock(&LOCK_gdl);
if (write_log_replace_delete_frm(lpt, 0UL, shadow_path, path, TRUE)) if (write_log_replace_delete_frm(lpt, 0UL, shadow_path, path, TRUE))
@ -6562,7 +6566,8 @@ static bool write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
DBUG_ENTER("write_log_drop_partition"); DBUG_ENTER("write_log_drop_partition");
part_info->first_log_entry= NULL; part_info->first_log_entry= NULL;
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0); build_table_filename(path, sizeof(path) - 1, lpt->alter_info->db.str,
lpt->alter_info->table_name.str, "", 0);
build_table_shadow_filename(tmp_path, sizeof(tmp_path) - 1, lpt); build_table_shadow_filename(tmp_path, sizeof(tmp_path) - 1, lpt);
mysql_mutex_lock(&LOCK_gdl); mysql_mutex_lock(&LOCK_gdl);
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path, if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
@ -6620,7 +6625,8 @@ static bool write_log_add_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
DBUG_ASSERT(old_first_log_entry); DBUG_ASSERT(old_first_log_entry);
DBUG_ENTER("write_log_add_change_partition"); DBUG_ENTER("write_log_add_change_partition");
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0); build_table_filename(path, sizeof(path) - 1, lpt->alter_info->db.str,
lpt->alter_info->table_name.str, "", 0);
build_table_shadow_filename(tmp_path, sizeof(tmp_path) - 1, lpt); build_table_shadow_filename(tmp_path, sizeof(tmp_path) - 1, lpt);
mysql_mutex_lock(&LOCK_gdl); mysql_mutex_lock(&LOCK_gdl);
@ -6688,7 +6694,8 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
Replace the revert operations with forced retry operations. Replace the revert operations with forced retry operations.
*/ */
part_info->first_log_entry= NULL; part_info->first_log_entry= NULL;
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0); build_table_filename(path, sizeof(path) - 1, lpt->alter_info->db.str,
lpt->alter_info->table_name.str, "", 0);
build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt); build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
mysql_mutex_lock(&LOCK_gdl); mysql_mutex_lock(&LOCK_gdl);
if (write_log_changed_partitions(lpt, &next_entry, (const char*)path)) if (write_log_changed_partitions(lpt, &next_entry, (const char*)path))
@ -6874,8 +6881,8 @@ static void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt,
Better to do that here, than leave the cleaning up to others. Better to do that here, than leave the cleaning up to others.
Acquire EXCLUSIVE mdl lock if not already acquired. Acquire EXCLUSIVE mdl lock if not already acquired.
*/ */
if (!thd->mdl_context.is_lock_owner(MDL_key::TABLE, lpt->db.str, if (!thd->mdl_context.is_lock_owner(MDL_key::TABLE, lpt->alter_info->db.str,
lpt->table_name.str, lpt->alter_info->table_name.str,
MDL_EXCLUSIVE) && MDL_EXCLUSIVE) &&
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN)) wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN))
{ {
@ -7069,14 +7076,11 @@ static void downgrade_mdl_if_lock_tables_mode(THD *thd, MDL_ticket *ticket,
uint fast_alter_partition_table(THD *thd, TABLE *table, uint fast_alter_partition_table(THD *thd, TABLE *table,
Alter_info *alter_info, Alter_info *alter_info,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
TABLE_LIST *table_list, TABLE_LIST *table_list)
const LEX_CSTRING *db,
const LEX_CSTRING *table_name)
{ {
/* Set-up struct used to write frm files */ /* Set-up struct used to write frm files */
partition_info *part_info; partition_info *part_info;
ALTER_PARTITION_PARAM_TYPE lpt_obj; ALTER_PARTITION_PARAM_TYPE lpt_obj, *lpt= &lpt_obj;
ALTER_PARTITION_PARAM_TYPE *lpt= &lpt_obj;
bool action_completed= FALSE; bool action_completed= FALSE;
bool frm_install= FALSE; bool frm_install= FALSE;
MDL_ticket *mdl_ticket= table->mdl_ticket; MDL_ticket *mdl_ticket= table->mdl_ticket;
@ -7095,8 +7099,6 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
lpt->table= table; lpt->table= table;
lpt->key_info_buffer= 0; lpt->key_info_buffer= 0;
lpt->key_count= 0; lpt->key_count= 0;
lpt->db= *db;
lpt->table_name= *table_name;
lpt->copied= 0; lpt->copied= 0;
lpt->deleted= 0; lpt->deleted= 0;
lpt->pack_frm_data= NULL; lpt->pack_frm_data= NULL;

View File

@ -57,8 +57,6 @@ typedef struct st_lock_param_type
Alter_info *alter_info; Alter_info *alter_info;
TABLE *table; TABLE *table;
KEY *key_info_buffer; KEY *key_info_buffer;
LEX_CSTRING db;
LEX_CSTRING table_name;
uchar *pack_frm_data; uchar *pack_frm_data;
uint key_count; uint key_count;
uint db_options; uint db_options;
@ -255,9 +253,7 @@ typedef int (*get_partitions_in_range_iter)(partition_info *part_info,
uint fast_alter_partition_table(THD *thd, TABLE *table, uint fast_alter_partition_table(THD *thd, TABLE *table,
Alter_info *alter_info, Alter_info *alter_info,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
TABLE_LIST *table_list, TABLE_LIST *table_list);
const LEX_CSTRING *db,
const LEX_CSTRING *table_name);
bool set_part_state(Alter_info *alter_info, partition_info *tab_part_info, bool set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
enum partition_state part_state); enum partition_state part_state);
uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,

View File

@ -79,9 +79,7 @@ static int copy_data_between_tables(THD *, TABLE *,TABLE *,
Alter_table_ctx *); Alter_table_ctx *);
static int append_system_key_parts(THD *, HA_CREATE_INFO *, Key *); static int append_system_key_parts(THD *, HA_CREATE_INFO *, Key *);
static int mysql_prepare_create_table(THD *, HA_CREATE_INFO *, Alter_info *, static int mysql_prepare_create_table(THD *, HA_CREATE_INFO *, Alter_info *,
uint *, handler *, KEY **, uint *, int, uint *, handler *, KEY **, uint *, int);
const LEX_CSTRING db,
const LEX_CSTRING table_name);
static uint blob_length_by_type(enum_field_types type); static uint blob_length_by_type(enum_field_types type);
static bool fix_constraints_names(THD *, List<Virtual_column_info> *, static bool fix_constraints_names(THD *, List<Virtual_column_info> *,
const HA_CREATE_INFO *); const HA_CREATE_INFO *);
@ -1765,9 +1763,9 @@ uint build_table_shadow_filename(char *buff, size_t bufflen,
{ {
char tmp_name[FN_REFLEN]; char tmp_name[FN_REFLEN];
my_snprintf(tmp_name, sizeof (tmp_name), "%s-shadow-%lx-%s", tmp_file_prefix, my_snprintf(tmp_name, sizeof (tmp_name), "%s-shadow-%lx-%s", tmp_file_prefix,
(ulong) current_thd->thread_id, lpt->table_name.str); (ulong) current_thd->thread_id, lpt->alter_info->table_name.str);
return build_table_filename(buff, bufflen, lpt->db.str, tmp_name, "", return build_table_filename(buff, bufflen, lpt->alter_info->db.str, tmp_name,
FN_IS_TMP); "", FN_IS_TMP);
} }
@ -1826,7 +1824,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
if (mysql_prepare_create_table(lpt->thd, lpt->create_info, lpt->alter_info, if (mysql_prepare_create_table(lpt->thd, lpt->create_info, lpt->alter_info,
&lpt->db_options, lpt->table->file, &lpt->db_options, lpt->table->file,
&lpt->key_info_buffer, &lpt->key_count, &lpt->key_info_buffer, &lpt->key_count,
C_ALTER_TABLE, lpt->db, lpt->table_name)) C_ALTER_TABLE))
{ {
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -1846,7 +1844,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
#endif #endif
/* Write shadow frm file */ /* Write shadow frm file */
lpt->create_info->table_options= lpt->db_options; lpt->create_info->table_options= lpt->db_options;
LEX_CUSTRING frm= build_frm_image(lpt->thd, lpt->table_name, LEX_CUSTRING frm= build_frm_image(lpt->thd, lpt->alter_info->table_name,
lpt->create_info, lpt->create_info,
lpt->alter_info->create_list, lpt->alter_info->create_list,
lpt->key_count, lpt->key_info_buffer, lpt->key_count, lpt->key_info_buffer,
@ -1857,7 +1855,8 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
goto end; goto end;
} }
int error= writefile(shadow_frm_name, lpt->db.str, lpt->table_name.str, int error= writefile(shadow_frm_name, lpt->alter_info->db.str,
lpt->alter_info->table_name.str,
lpt->create_info->tmp_table(), frm.str, frm.length); lpt->create_info->tmp_table(), frm.str, frm.length);
my_free(const_cast<uchar*>(frm.str)); my_free(const_cast<uchar*>(frm.str));
@ -1879,8 +1878,8 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
/* /*
Build frm file name Build frm file name
*/ */
build_table_filename(path, sizeof(path) - 1, lpt->db.str, build_table_filename(path, sizeof(path) - 1, lpt->alter_info->db.str,
lpt->table_name.str, "", 0); lpt->alter_info->table_name.str, "", 0);
strxnmov(frm_name, sizeof(frm_name), path, reg_ext, NullS); strxnmov(frm_name, sizeof(frm_name), path, reg_ext, NullS);
/* /*
When we are changing to use new frm file we need to ensure that we When we are changing to use new frm file we need to ensure that we
@ -3556,8 +3555,7 @@ static int
mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
Alter_info *alter_info, uint *db_options, Alter_info *alter_info, uint *db_options,
handler *file, KEY **key_info_buffer, handler *file, KEY **key_info_buffer,
uint *key_count, int create_table_mode, uint *key_count, int create_table_mode)
const LEX_CSTRING db, const LEX_CSTRING table_name)
{ {
const char *key_name; const char *key_name;
Create_field *sql_field,*dup_field; Create_field *sql_field,*dup_field;
@ -4454,7 +4452,7 @@ without_overlaps_err:
create_info->null_bits= null_fields; create_info->null_bits= null_fields;
/* Check fields. */ /* Check fields. */
Item::Check_table_name_prm walk_prm(db, table_name); Item::Check_table_name_prm walk_prm(alter_info->db, alter_info->table_name);
it.rewind(); it.rewind();
while ((sql_field=it++)) while ((sql_field=it++))
{ {
@ -4858,9 +4856,7 @@ static int append_system_key_parts(THD *thd, HA_CREATE_INFO *create_info,
return result; return result;
} }
handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db, handler *mysql_create_frm_image(THD *thd, HA_CREATE_INFO *create_info,
const LEX_CSTRING &table_name,
HA_CREATE_INFO *create_info,
Alter_info *alter_info, int create_table_mode, Alter_info *alter_info, int create_table_mode,
KEY **key_info, uint *key_count, KEY **key_info, uint *key_count,
LEX_CUSTRING *frm) LEX_CUSTRING *frm)
@ -4875,7 +4871,7 @@ handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db,
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
set_table_default_charset(thd, create_info, db); set_table_default_charset(thd, create_info, alter_info->db);
db_options= create_info->table_options_with_row_type(); db_options= create_info->table_options_with_row_type();
@ -4996,7 +4992,7 @@ handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db,
if (part_info->vers_info && !create_info->versioned()) if (part_info->vers_info && !create_info->versioned())
{ {
my_error(ER_VERS_NOT_VERSIONED, MYF(0), table_name.str); my_error(ER_VERS_NOT_VERSIONED, MYF(0), alter_info->table_name.str);
goto err; goto err;
} }
@ -5094,14 +5090,12 @@ handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db,
#endif #endif
if (mysql_prepare_create_table(thd, create_info, alter_info, &db_options, if (mysql_prepare_create_table(thd, create_info, alter_info, &db_options,
file, key_info, key_count, file, key_info, key_count, create_table_mode))
create_table_mode, db, table_name))
goto err; goto err;
create_info->table_options=db_options; create_info->table_options=db_options;
*frm= build_frm_image(thd, table_name, create_info, *frm= build_frm_image(thd, alter_info->table_name, create_info,
alter_info->create_list, *key_count, alter_info->create_list, *key_count, *key_info, file);
*key_info, file);
if (frm->str) if (frm->str)
DBUG_RETURN(file); DBUG_RETURN(file);
@ -5373,9 +5367,10 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
} }
else else
{ {
file= mysql_create_frm_image(thd, orig_db, orig_table_name, create_info, alter_info->db= orig_db;
alter_info, create_table_mode, key_info, alter_info->table_name= orig_table_name;
key_count, frm); file= mysql_create_frm_image(thd, create_info, alter_info,
create_table_mode, key_info, key_count, frm);
/* /*
TODO: remove this check of thd->is_error() (now it intercept TODO: remove this check of thd->is_error() (now it intercept
errors in some val_*() methoids and bring some single place to errors in some val_*() methoids and bring some single place to
@ -7725,13 +7720,15 @@ bool mysql_compare_tables(TABLE *table, Alter_info *alter_info,
uint db_options= 0; /* not used */ uint db_options= 0; /* not used */
KEY *key_info_buffer= NULL; KEY *key_info_buffer= NULL;
tmp_alter_info.db= table->s->db;
tmp_alter_info.table_name= table->s->table_name;
/* Create the prepared information. */ /* Create the prepared information. */
int create_table_mode= table->s->tmp_table == NO_TMP_TABLE ? int create_table_mode= table->s->tmp_table == NO_TMP_TABLE ?
C_ORDINARY_CREATE : C_ALTER_TABLE; C_ORDINARY_CREATE : C_ALTER_TABLE;
if (mysql_prepare_create_table(thd, create_info, &tmp_alter_info, if (mysql_prepare_create_table(thd, create_info, &tmp_alter_info,
&db_options, table->file, &key_info_buffer, &db_options, table->file, &key_info_buffer,
&key_count, create_table_mode, &key_count, create_table_mode))
table->s->db, table->s->table_name))
DBUG_RETURN(1); DBUG_RETURN(1);
/* Some very basic checks. */ /* Some very basic checks. */
@ -10640,10 +10637,10 @@ do_continue:;
} }
// In-place execution of ALTER TABLE for partitioning. // In-place execution of ALTER TABLE for partitioning.
alter_info->db= alter_ctx.db;
alter_info->table_name= alter_ctx.table_name;
DBUG_RETURN(fast_alter_partition_table(thd, table, alter_info, DBUG_RETURN(fast_alter_partition_table(thd, table, alter_info,
create_info, table_list, create_info, table_list));
&alter_ctx.db,
&alter_ctx.table_name));
} }
#endif #endif

View File

@ -198,18 +198,12 @@ int mysql_create_table_no_lock(THD *thd, Table_specification_st *create_info,
Alter_info *alter_info, bool *is_trans, Alter_info *alter_info, bool *is_trans,
int create_table_mode, TABLE_LIST *table); int create_table_mode, TABLE_LIST *table);
handler *mysql_create_frm_image(THD *thd, handler *mysql_create_frm_image(THD *thd, HA_CREATE_INFO *create_info,
const LEX_CSTRING &db, Alter_info *alter_info, int create_table_mode,
const LEX_CSTRING &table_name, KEY **key_info, uint *key_count,
HA_CREATE_INFO *create_info,
Alter_info *alter_info,
int create_table_mode,
KEY **key_info,
uint *key_count,
LEX_CUSTRING *frm); LEX_CUSTRING *frm);
int mysql_discard_or_import_tablespace(THD *thd, int mysql_discard_or_import_tablespace(THD *thd, TABLE_LIST *table_list,
TABLE_LIST *table_list,
bool discard); bool discard);
bool mysql_prepare_alter_table(THD *thd, TABLE *table, bool mysql_prepare_alter_table(THD *thd, TABLE *table,

View File

@ -3411,17 +3411,18 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
sql_unusable_for_discovery(thd, hton, sql_copy)))) sql_unusable_for_discovery(thd, hton, sql_copy))))
goto ret; goto ret;
thd->lex->create_info.db_type= hton; tmp_lex.create_info.db_type= hton;
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
thd->work_part_info= 0; // For partitioning thd->work_part_info= 0; // For partitioning
#endif #endif
if (tabledef_version.str) if (tabledef_version.str)
thd->lex->create_info.tabledef_version= tabledef_version; tmp_lex.create_info.tabledef_version= tabledef_version;
promote_first_timestamp_column(&thd->lex->alter_info.create_list); tmp_lex.alter_info.db= db;
file= mysql_create_frm_image(thd, db, table_name, tmp_lex.alter_info.table_name= table_name;
&thd->lex->create_info, &thd->lex->alter_info, promote_first_timestamp_column(&tmp_lex.alter_info.create_list);
file= mysql_create_frm_image(thd, &tmp_lex.create_info, &tmp_lex.alter_info,
C_ORDINARY_CREATE, &unused1, &unused2, &frm); C_ORDINARY_CREATE, &unused1, &unused2, &frm);
error|= file == 0; error|= file == 0;
delete file; delete file;
@ -3435,7 +3436,7 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
ret: ret:
my_free(const_cast<uchar*>(frm.str)); my_free(const_cast<uchar*>(frm.str));
lex_end(thd->lex); lex_end(&tmp_lex);
thd->reset_db(&db_backup); thd->reset_db(&db_backup);
thd->lex= old_lex; thd->lex= old_lex;
reenable_binlog(thd); reenable_binlog(thd);