mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
mysql-5.5.33 merge
This commit is contained in:
@ -4655,6 +4655,8 @@ make_unique_key_name(const char *field_name,KEY *start,KEY *end)
|
||||
FN_TO_IS_TMP new_name is temporary.
|
||||
NO_FRM_RENAME Don't rename the FRM file
|
||||
but only the table in the storage engine.
|
||||
NO_FK_CHECKS Don't check FK constraints
|
||||
during rename.
|
||||
|
||||
RETURN
|
||||
FALSE OK
|
||||
@ -4673,9 +4675,14 @@ mysql_rename_table(handlerton *base, const char *old_db,
|
||||
char tmp_name[SAFE_NAME_LEN+1];
|
||||
handler *file;
|
||||
int error=0;
|
||||
ulonglong save_bits= thd->variables.option_bits;
|
||||
DBUG_ENTER("mysql_rename_table");
|
||||
DBUG_PRINT("enter", ("old: '%s'.'%s' new: '%s'.'%s'",
|
||||
old_db, old_name, new_db, new_name));
|
||||
|
||||
// Temporarily disable foreign key checks
|
||||
if (flags & NO_FK_CHECKS)
|
||||
thd->variables.option_bits|= OPTION_NO_FOREIGN_KEY_CHECKS;
|
||||
|
||||
file= (base == NULL ? 0 :
|
||||
get_new_handler((TABLE_SHARE*) 0, thd->mem_root, base));
|
||||
@ -4723,6 +4730,10 @@ mysql_rename_table(handlerton *base, const char *old_db,
|
||||
my_error(ER_ERROR_ON_RENAME, MYF(0), from, to, error);
|
||||
else if (!(flags & FN_IS_TMP))
|
||||
mysql_audit_rename_table(thd, old_db, old_name, new_db, new_name);
|
||||
|
||||
// Restore options bits to the original value
|
||||
thd->variables.option_bits= save_bits;
|
||||
|
||||
DBUG_RETURN(error != 0);
|
||||
}
|
||||
|
||||
@ -6327,7 +6338,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
new_db, new_alias))
|
||||
{
|
||||
(void) mysql_rename_table(old_db_type, new_db, new_alias, db,
|
||||
table_name, 0);
|
||||
table_name, NO_FK_CHECKS);
|
||||
error= -1;
|
||||
}
|
||||
}
|
||||
@ -7102,7 +7113,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
error= 1;
|
||||
(void) quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP);
|
||||
(void) mysql_rename_table(old_db_type, db, old_name, db, alias,
|
||||
FN_FROM_IS_TMP);
|
||||
FN_FROM_IS_TMP | NO_FK_CHECKS);
|
||||
}
|
||||
else if (new_name != table_name || new_db != db)
|
||||
{
|
||||
@ -7114,7 +7125,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
error= 1;
|
||||
(void) quick_rm_table(new_db_type, new_db, new_alias, 0);
|
||||
(void) mysql_rename_table(old_db_type, db, old_name, db, alias,
|
||||
FN_FROM_IS_TMP);
|
||||
FN_FROM_IS_TMP | NO_FK_CHECKS);
|
||||
}
|
||||
else if (Table_triggers_list::change_table_name(thd, db, alias,
|
||||
table_name, new_db,
|
||||
@ -7124,7 +7135,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
error= 1;
|
||||
(void) quick_rm_table(new_db_type, new_db, new_alias, 0);
|
||||
(void) mysql_rename_table(old_db_type, db, old_name, db,
|
||||
alias, FN_FROM_IS_TMP);
|
||||
alias, FN_FROM_IS_TMP | NO_FK_CHECKS);
|
||||
/*
|
||||
If we were performing "fast"/in-place ALTER TABLE we also need
|
||||
to restore old name of table in storage engine as a separate
|
||||
@ -7133,7 +7144,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
if (need_copy_table == ALTER_TABLE_METADATA_ONLY)
|
||||
{
|
||||
(void) mysql_rename_table(save_old_db_type, new_db, new_alias,
|
||||
db, table_name, NO_FRM_RENAME);
|
||||
db, table_name,
|
||||
NO_FRM_RENAME | NO_FK_CHECKS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user