MySQL: Allow moving views to other DB and renaming DB with views (bug #783)
This commit is contained in:
parent
5a1498d160
commit
e9e61fce26
|
@ -797,12 +797,27 @@ if (!defined("DRIVER")) {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function move_tables($tables, $views, $target) {
|
function move_tables($tables, $views, $target) {
|
||||||
|
global $connection;
|
||||||
$rename = array();
|
$rename = array();
|
||||||
foreach (array_merge($tables, $views) as $table) { // views will report SQL error
|
foreach ($tables as $table) {
|
||||||
$rename[] = table($table) . " TO " . idf_escape($target) . "." . table($table);
|
$rename[] = table($table) . " TO " . idf_escape($target) . "." . table($table);
|
||||||
}
|
}
|
||||||
return queries("RENAME TABLE " . implode(", ", $rename));
|
if (!$rename || queries("RENAME TABLE " . implode(", ", $rename))) {
|
||||||
|
$definitions = array();
|
||||||
|
foreach ($views as $table) {
|
||||||
|
$definitions[table($table)] = view($table);
|
||||||
|
}
|
||||||
|
$connection->select_db($target);
|
||||||
|
$db = idf_escape(DB);
|
||||||
|
foreach ($definitions as $name => $view) {
|
||||||
|
if (!queries("CREATE VIEW $name AS " . str_replace(" $db.", " ", $view["select"])) || !queries("DROP VIEW $db.$name")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
//! move triggers
|
//! move triggers
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copy tables to other schema
|
/** Copy tables to other schema
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
Adminer 4.8.1-dev:
|
Adminer 4.8.1-dev:
|
||||||
Fix more PHP 8 warnings (bug #781)
|
Fix more PHP 8 warnings (bug #781)
|
||||||
|
MySQL: Allow moving views to other DB and renaming DB with views (bug #783)
|
||||||
|
|
||||||
Adminer 4.8.0 (released 2021-02-10):
|
Adminer 4.8.0 (released 2021-02-10):
|
||||||
Support function default values in insert (bug #713)
|
Support function default values in insert (bug #713)
|
||||||
|
|
Loading…
Reference in a new issue