diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-09-18 13:07:31 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-09-18 13:07:31 +0200 |
commit | 4ec2e9d7eda78d409d1b017ef4d8928fe9055438 (patch) | |
tree | 6c3a74a740d3c1c5f3a7d1f8154d8a791b435b3f /sql/sql_table.cc | |
parent | 1a2a9d74fe1256554eceb09bbc6752a6376df87d (diff) | |
parent | 197bdbae4db78ba65f3668803bebd3c4a4509ae5 (diff) | |
download | mariadb-git-4ec2e9d7eda78d409d1b017ef4d8928fe9055438.tar.gz |
5.5 merge and fixes for compiler/test errors
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 438047d0ebb..2b1dbbd394f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4564,6 +4564,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 @@ -4582,9 +4584,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)); @@ -4636,6 +4643,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); } @@ -6559,7 +6570,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; } } @@ -7357,7 +7368,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) { @@ -7369,7 +7380,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, @@ -7379,7 +7390,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 @@ -7388,7 +7399,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); } } } @@ -7812,11 +7824,13 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to, AUTO_INCREMENT_FLAG)) err_msg= ER(ER_DUP_ENTRY_AUTOINCREMENT_CASE); to->file->print_keydup_error(key_nr, err_msg, MYF(0)); + error= 1; break; } } to->file->print_error(error,MYF(0)); + error= 1; break; } to->file->restore_auto_increment(prev_insert_id); |