summaryrefslogtreecommitdiff
path: root/sql/sql_rename.cc
diff options
context:
space:
mode:
authorunknown <dlenev@mysql.com>2006-02-27 20:00:07 +0300
committerunknown <dlenev@mysql.com>2006-02-27 20:00:07 +0300
commite54ecf09beca168cc7fba6d0a21b440be4f2783d (patch)
tree0fde704b3ac2031c62de8957626945f2239d8343 /sql/sql_rename.cc
parente2393aa24a02505688aabc73fa4ebf79aeff17d9 (diff)
parent475eb3e9179fa4c1af3e0daa980dc6f30025ac28 (diff)
downloadmariadb-git-e54ecf09beca168cc7fba6d0a21b440be4f2783d.tar.gz
Merge mysql.com:/home/dlenev/src/mysql-5.0-bg13525
into mysql.com:/home/dlenev/src/mysql-5.1-merges2 client/mysqltest.c: Auto merged include/my_global.h: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/heap.result: Auto merged mysql-test/r/merge.result: Auto merged mysql-test/r/ps.result: Auto merged mysql-test/r/trigger.result: Auto merged mysql-test/r/view.result: Auto merged mysql-test/t/ps.test: Auto merged mysql-test/t/trigger.test: Auto merged mysql-test/t/view.test: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/ha_myisammrg.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged storage/myisammrg/myrg_queue.c: Auto merged sql/sql_rename.cc: Manual merge. sql/sql_trigger.cc: Manual merge. sql/sql_yacc.yy: Manual merge.
Diffstat (limited to 'sql/sql_rename.cc')
-rw-r--r--sql/sql_rename.cc28
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: