]> git.joonet.de Git - adminer.git/commitdiff
Allow overwriting tables when copying them
authorJakub Vrana <jakub@vrana.cz>
Tue, 14 May 2019 07:56:29 +0000 (09:56 +0200)
committerJakub Vrana <jakub@vrana.cz>
Tue, 14 May 2019 07:56:29 +0000 (09:56 +0200)
adminer/db.inc.php
adminer/drivers/mysql.inc.php
adminer/lang/cs.inc.php
adminer/lang/xx.inc.php
changes.txt

index 3ec137e39b17ef38cbf4323662e46e7c8ec0607d..1a23b6641d8f70eb76224c16ae6a35209c5cb967 100644 (file)
@@ -140,7 +140,7 @@ if ($adminer->homepage()) {
                                        echo "<p>" . lang('Move to other database') . ": ";
                                        echo ($databases ? html_select("target", $databases, $db) : '<input name="target" value="' . h($db) . '" autocapitalize="off">');
                                        echo " <input type='submit' name='move' value='" . lang('Move') . "'>";
-                                       echo (support("copy") ? " <input type='submit' name='copy' value='" . lang('Copy') . "'>" : "");
+                                       echo (support("copy") ? " <input type='submit' name='copy' value='" . lang('Copy') . "'> " . checkbox("overwrite", 1, $_POST["overwrite"], lang('overwrite')) : "");
                                        echo "\n";
                                }
                                echo "<input type='hidden' name='all' value=''>"; // used by trCheck()
index 5002caa91b456cb70a80265548e2a4d927e903af..170d57b77a383c97181b285e33dfe1a2dae36ab7 100644 (file)
@@ -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;
                        }
                }
index c515202d57944aa15f6befd0244e136dd0ccd733..9c861b1dce61c404182a9b786da73ec73794f596 100644 (file)
@@ -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ů.'),
index 25baa12a39224aa1dd1a990bfb7012f1c9b4a9f0..f8f1af4947657b74e0ba1d7d8f32565dfe5d8fbb 100644 (file)
@@ -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.'),
index 8f4608a19436e34e26f2d85ee30c8deb9c33fd2a..d194c2f0897c06f0553a4624e936045ac4bebc12 100644 (file)
@@ -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):