bug #1919808 [operations] Renaming a database fails to handle functions

This commit is contained in:
Marc Delisle
2008-04-14 14:32:06 +00:00
parent f11915a86c
commit 26abcac5e7
2 changed files with 41 additions and 20 deletions

View File

@@ -75,6 +75,7 @@ danbarry
thanks to tyman - acoustype thanks to tyman - acoustype
- bug #1935652 [auth] Access denied (show warning about mcrypt on login page) - bug #1935652 [auth] Access denied (show warning about mcrypt on login page)
- bug #1906983 [export] Reimport of FUNCTION fails - bug #1906983 [export] Reimport of FUNCTION fails
- bug #1919808 [operations] Renaming a database fails to handle functions
2.11.5.1 (2008-03-29) 2.11.5.1 (2008-03-29)
- bug #1909711 [security] Sensitive data in session files - bug #1909711 [security] Sensitive data in session files

View File

@@ -37,19 +37,6 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
$_error = false; $_error = false;
if ($move || if ($move ||
(isset($create_database_before_copying) && $create_database_before_copying)) { (isset($create_database_before_copying) && $create_database_before_copying)) {
/**
* @todo activate this with the correct version of MySQL
* if/when they offer this functionality
*
* Note: RENAME DATABASE was removed in 5.1.23
*/
//if (PMA_MYSQL_INT_VERSION >= XYYZZ) {
// $local_query = 'RENAME DATABASE ' . PMA_backquote($db) . ' TO ' . PMA_backquote($newname) . ';';
// $sql_query = $local_query;
// PMA_DBI_query($local_query);
//} else {
// please indent ->
// lower_case_table_names=1 `DB` becomes `db` // lower_case_table_names=1 `DB` becomes `db`
$lower_case_table_names = PMA_DBI_fetch_value('SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1); $lower_case_table_names = PMA_DBI_fetch_value('SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1);
if ($lower_case_table_names === '1') { if ($lower_case_table_names === '1') {
@@ -81,6 +68,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
// will handle them after the tables // will handle them after the tables
/** /**
* @todo support a view of a view * @todo support a view of a view
* @todo support triggers
*/ */
if (PMA_Table::isView($db, $each_table)) { if (PMA_Table::isView($db, $each_table)) {
$views[] = $each_table; $views[] = $each_table;
@@ -148,8 +136,40 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
$GLOBALS['sql_query'] .= "\n" . $GLOBALS['sql_constraints_query_full_db']; $GLOBALS['sql_query'] .= "\n" . $GLOBALS['sql_constraints_query_full_db'];
unset($GLOBALS['sql_constraints_query_full_db']); unset($GLOBALS['sql_constraints_query_full_db']);
} }
// see the previous todo
// } // end else MySQL < 50107 if (PMA_MYSQL_INT_VERSION >= 50000) {
// here I don't use DELIMITER because it's not part of the
// language; I have to send each statement one by one
// to avoid selecting alternatively the current and new db
// we would need to modify the CREATE definitions to qualify
// the db name
$procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
if ($procedure_names) {
foreach($procedure_names as $procedure_name) {
PMA_DBI_select_db($db);
$tmp_query = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name);
// collect for later display
$GLOBALS['sql_query'] .= "\n" . $tmp_query;
PMA_DBI_select_db($newname);
PMA_DBI_query($tmp_query);
}
}
$function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
if ($function_names) {
foreach($function_names as $function_name) {
PMA_DBI_select_db($db);
$tmp_query = PMA_DBI_get_definition($db, 'FUNCTION', $function_name);
// collect for later display
$GLOBALS['sql_query'] .= "\n" . $tmp_query;
PMA_DBI_select_db($newname);
PMA_DBI_query($tmp_query);
}
}
}
// go back to current db, just in case
PMA_DBI_select_db($db);
// Duplicate the bookmarks for this db (done once for each db) // Duplicate the bookmarks for this db (done once for each db)
if (! $_error && $db != $newname) { if (! $_error && $db != $newname) {
@@ -165,11 +185,11 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
require_once './libraries/relation_cleanup.lib.php'; require_once './libraries/relation_cleanup.lib.php';
PMA_relationsCleanupDatabase($db); PMA_relationsCleanupDatabase($db);
if (PMA_MYSQL_INT_VERSION < 50107) { // if someday the RENAME DATABASE reappears, do not DROP
$local_query = 'DROP DATABASE ' . PMA_backquote($db) . ';'; $local_query = 'DROP DATABASE ' . PMA_backquote($db) . ';';
$sql_query .= "\n" . $local_query; $sql_query .= "\n" . $local_query;
PMA_DBI_query($local_query); PMA_DBI_query($local_query);
}
$message = PMA_Message::success('strRenameDatabaseOK'); $message = PMA_Message::success('strRenameDatabaseOK');
$message->addParam($db); $message->addParam($db);
$message->addParam($newname); $message->addParam($newname);