summaryrefslogtreecommitdiff
path: root/sql/sql_rename.cc
diff options
context:
space:
mode:
authordlenev@mysql.com <>2006-02-24 23:50:36 +0300
committerdlenev@mysql.com <>2006-02-24 23:50:36 +0300
commit0c15039e74c02371eb931c9db6ebed1b1df8f380 (patch)
treecd355e9fb3c3537be6b3aae48e6d5eb5276fe04c /sql/sql_rename.cc
parent2f1614a9c198ab4b3f96c01a26d3ca76e245410c (diff)
downloadmariadb-git-0c15039e74c02371eb931c9db6ebed1b1df8f380.tar.gz
Fix for bug #13525 "Rename table does not keep info of triggers".
Let us transfer triggers associated with table when we rename it (but only if we are not changing database to which table belongs, in the latter case we will emit error).
Diffstat (limited to 'sql/sql_rename.cc')
-rw-r--r--sql/sql_rename.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index 80fcb973028..74951029de9 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,
@@ -176,8 +177,26 @@ 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(table_type, ren_table->db, old_alias,
- new_table->db, new_alias);
+ {
+ if (!(rc= mysql_rename_table(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(table_type, new_table->db, new_alias,
+ ren_table->db, old_alias);
+ }
+ }
+ }
break;
}
case FRMTYPE_VIEW: