bug #3452506 [edit] Unable to move tables with triggers

This commit is contained in:
Madhura Jayaratne
2011-12-07 08:33:28 +05:30
parent 5f78897bc8
commit 6e0a10494f
2 changed files with 19 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ phpMyAdmin - ChangeLog
- bug #3398788 [session] No feedback when result is empty (signon auth_type) - bug #3398788 [session] No feedback when result is empty (signon auth_type)
- bug #3384035 [display] Problems regarding ShowTooltipAliasTB - bug #3384035 [display] Problems regarding ShowTooltipAliasTB
- bug #3306875 [edit] Can't rename a database that contains views - bug #3306875 [edit] Can't rename a database that contains views
- bug #3452506 [edit] Unable to move tables with triggers
3.4.8.0 (2011-12-01) 3.4.8.0 (2011-12-01)
- bug #3425230 [interface] enum data split at space char (more space to edit) - bug #3425230 [interface] enum data split at space char (more space to edit)

View File

@@ -1033,6 +1033,17 @@ class PMA_Table
return false; return false;
} }
// If the table is moved to a different database drop its triggers first
$triggers = PMA_DBI_get_triggers($this->getDbName(), $this->getName(), '');
$handle_triggers = $this->getDbName() != $new_db && $triggers;
if ($handle_triggers) {
foreach ($triggers as $trigger) {
$sql = 'DROP TRIGGER IF EXISTS ' . PMA_backquote($this->getDbName()) . '.'
. PMA_backquote($trigger['name']) . ';';
PMA_DBI_query($sql);
}
}
/* /*
* tested also for a view, in MySQL 5.0.92, 5.1.55 and 5.5.13 * tested also for a view, in MySQL 5.0.92, 5.1.55 and 5.5.13
*/ */
@@ -1041,6 +1052,13 @@ class PMA_Table
TO ' . $new_table->getFullName(true) . ';'; TO ' . $new_table->getFullName(true) . ';';
// I don't think a specific error message for views is necessary // I don't think a specific error message for views is necessary
if (! PMA_DBI_query($GLOBALS['sql_query'])) { if (! PMA_DBI_query($GLOBALS['sql_query'])) {
// Restore triggers in the old database
if ($handle_triggers) {
PMA_DBI_select_db($this->getDbName());
foreach ($triggers as $trigger) {
PMA_DBI_query($trigger['create']);
}
}
$this->errors[] = sprintf(__('Error renaming table %1$s to %2$s'), $this->getFullName(), $new_table->getFullName()); $this->errors[] = sprintf(__('Error renaming table %1$s to %2$s'), $this->getFullName(), $new_table->getFullName());
return false; return false;
} }