diff --git a/adminer/db.inc.php b/adminer/db.inc.php index 3ec137e3..1a23b664 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -140,7 +140,7 @@ if ($adminer->homepage()) { echo "

" . lang('Move to other database') . ": "; echo ($databases ? html_select("target", $databases, $db) : ''); echo " "; - echo (support("copy") ? " " : ""); + echo (support("copy") ? " " . checkbox("overwrite", 1, $_POST["overwrite"], lang('overwrite')) : ""); echo "\n"; } echo ""; // used by trCheck() diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 5002caa9..170d57b7 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -810,7 +810,8 @@ if (!defined("DRIVER")) { queries("SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'"); foreach ($tables as $table) { $name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table)); - if (!queries("CREATE TABLE $name LIKE " . table($table)) + if (($_POST["overwrite"] && !queries("\nDROP TABLE IF EXISTS $name")) + || !queries("CREATE TABLE $name LIKE " . table($table)) || !queries("INSERT INTO $name SELECT * FROM " . table($table)) ) { return false; @@ -825,7 +826,8 @@ if (!defined("DRIVER")) { foreach ($views as $table) { $name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table)); $view = view($table); - if (!queries("CREATE VIEW $name AS $view[select]")) { //! USE to avoid db.table + if (($_POST["overwrite"] && !queries("DROP VIEW IF EXISTS $name")) + || !queries("CREATE VIEW $name AS $view[select]")) { //! USE to avoid db.table return false; } } diff --git a/adminer/lang/cs.inc.php b/adminer/lang/cs.inc.php index c515202d..9c861b1d 100644 --- a/adminer/lang/cs.inc.php +++ b/adminer/lang/cs.inc.php @@ -127,6 +127,7 @@ $translations = array( 'Tables have been moved.' => 'Tabulky byly přesunuty.', 'Copy' => 'Zkopírovat', 'Tables have been copied.' => 'Tabulky byly zkopírovány.', + 'overwrite' => 'přepsat', 'Routines' => 'Procedury a funkce', 'Routine has been called, %d row(s) affected.' => array('Procedura byla zavolána, byl změněn %d záznam.', 'Procedura byla zavolána, byly změněny %d záznamy.', 'Procedura byla zavolána, bylo změněno %d záznamů.'), diff --git a/adminer/lang/xx.inc.php b/adminer/lang/xx.inc.php index 25baa12a..f8f1af49 100644 --- a/adminer/lang/xx.inc.php +++ b/adminer/lang/xx.inc.php @@ -128,6 +128,7 @@ $translations = array( 'Tables have been moved.' => 'Xx.', 'Copy' => 'Xx', 'Tables have been copied.' => 'Xx.', + 'overwrite' => 'xx', 'Routines' => 'Xx', 'Routine has been called, %d row(s) affected.' => array('Xx, %d.', 'Xx, %d.'), diff --git a/changes.txt b/changes.txt index 8f4608a1..d194c2f0 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,7 @@ Adminer 4.7.2-dev: Do not attempt logging in without password (bug #676) Stretch footer over the whole table width (bug #624) +Allow overwriting tables when copying them MySQL: Fix creating users and changing password in MySQL 8 (bug #663) Adminer 4.7.1 (released 2019-01-24):