diff --git a/ChangeLog b/ChangeLog index 5c05c34ee..58b21724d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -48,6 +48,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA thanks to Thomas Pulickal - jemajoign - bug #2832600 [export] Slow export when having lots of databases - bug #2537766 [import] Comments are stripped when editing store procedures +- bug #2852370 [operations] Renaming database deletes triggers 3.2.2.0 (2009-09-13) - bug #2825293 [structure] Default value for a BIT column diff --git a/db_operations.php b/db_operations.php index 50b91320f..b89a9ef07 100644 --- a/db_operations.php +++ b/db_operations.php @@ -97,6 +97,11 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { } if ($this_what != 'nocopy') { + // keep the triggers from the original db+table + // (third param is empty because delimiters are only intended + // for importing via the mysql client or our Import feature) + $triggers = PMA_DBI_get_triggers($db, $each_table, ''); + if (! PMA_Table::moveCopy($db, $each_table, $newname, $each_table, isset($this_what) ? $this_what : 'data', $move, 'db_copy')) { @@ -105,6 +110,16 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { $sql_query = $back . $sql_query; break; } + // apply the triggers to the destination db+table + if ($triggers) { + PMA_DBI_select_db($newname); + foreach ($triggers as $trigger) { + PMA_DBI_query($trigger['create']); + } + unset($trigger); + } + unset($triggers); + if (isset($GLOBALS['add_constraints'])) { $GLOBALS['sql_constraints_query_full_db'] .= $GLOBALS['sql_constraints_query']; unset($GLOBALS['sql_constraints_query']); diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index dc5b8b2fe..2466f5ff5 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -1389,10 +1389,11 @@ function PMA_DBI_get_definition($db, $which, $name, $link = null) * @uses PMA_DBI_fetch_result() * @param string $db db name * @param string $table table name + * @param string $delimiter the delimiter to use (may be empty) * * @return array information about triggers (may be empty) */ -function PMA_DBI_get_triggers($db, $table) +function PMA_DBI_get_triggers($db, $table, $delimiter = '//') { $result = array(); @@ -1406,7 +1407,6 @@ function PMA_DBI_get_triggers($db, $table) } if ($triggers) { - $delimiter = '//'; foreach ($triggers as $trigger) { if ($GLOBALS['cfg']['Server']['DisableIS']) { $trigger['TRIGGER_NAME'] = $trigger['Trigger'];