diff options
author | dlenev@mysql.com <> | 2006-02-27 20:00:07 +0300 |
---|---|---|
committer | dlenev@mysql.com <> | 2006-02-27 20:00:07 +0300 |
commit | 8dbdf5237ecae0a8866195b1c12972fc1460b461 (patch) | |
tree | 0fde704b3ac2031c62de8957626945f2239d8343 /sql/sql_rename.cc | |
parent | 1f30b1525ad2f3d22d7373f5785691269be1db5c (diff) | |
parent | 3d6839d133e499dde697e180dc9ee48a129cf34b (diff) | |
download | mariadb-git-8dbdf5237ecae0a8866195b1c12972fc1460b461.tar.gz |
Merge mysql.com:/home/dlenev/src/mysql-5.0-bg13525
into mysql.com:/home/dlenev/src/mysql-5.1-merges2
Diffstat (limited to 'sql/sql_rename.cc')
-rw-r--r-- | sql/sql_rename.cc | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 5f20442cc84..e3468b2b5cf 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -19,6 +19,7 @@ */ #include "mysql_priv.h" +#include "sql_trigger.h" static TABLE_LIST *rename_tables(THD *thd, TABLE_LIST *table_list, @@ -173,9 +174,30 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error) if (table_type == DB_TYPE_UNKNOWN) my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno); else - rc= mysql_rename_table(ha_resolve_by_legacy_type(thd, table_type), - ren_table->db, old_alias, - new_table->db, new_alias); + { + if (!(rc= mysql_rename_table(ha_resolve_by_legacy_type(thd, + table_type), + ren_table->db, old_alias, + new_table->db, new_alias))) + { + if ((rc= Table_triggers_list::change_table_name(thd, ren_table->db, + old_alias, + new_table->db, + new_alias))) + { + /* + We've succeeded in renaming table's .frm and in updating + corresponding handler data, but have failed to update table's + triggers appropriately. So let us revert operations on .frm + and handler's data and report about failure to rename table. + */ + (void) mysql_rename_table(ha_resolve_by_legacy_type(thd, + table_type), + new_table->db, new_alias, + ren_table->db, old_alias); + } + } + } break; } case FRMTYPE_VIEW: |