]> git.joonet.de Git - adminer.git/commitdiff
Export SQLite indexes (bug #3609741)
authorJakub Vrana <jakub@vrana.cz>
Wed, 3 Apr 2013 17:46:51 +0000 (10:46 -0700)
committerJakub Vrana <jakub@vrana.cz>
Wed, 3 Apr 2013 17:46:51 +0000 (10:46 -0700)
adminer/drivers/sqlite.inc.php
changes.txt

index 79da3a93528b5b63643f6dd5b78367bf8c1a611d..f6ac0e1e249a06a160acdddb13db0a7b5e40db61 100644 (file)
@@ -505,11 +505,19 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                return true;
        }
        
+       function index_sql($table, $type, $name, $columns) {
+               return "CREATE $type " . ($type != "INDEX" ? "INDEX " : "")
+                       . idf_escape($name != "" ? $name : uniqid($table . "_"))
+                       . " ON " . table($table)
+                       . " $columns"
+               ;
+       }
+       
        function alter_indexes($table, $alter) {
                foreach ($alter as $val) {
                        if (!queries($val[2] == "DROP"
                                ? "DROP INDEX " . idf_escape($val[1])
-                               : "CREATE $val[0] " . ($val[0] != "INDEX" ? "INDEX " : "") . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table) . " $val[2]"
+                               : index_sql($table, $val[0], $val[1], $val[2])
                        )) {
                                return false;
                        }
@@ -612,7 +620,14 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
        
        function create_sql($table, $auto_increment) {
                global $connection;
-               return $connection->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . q($table));
+               $return = $connection->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . q($table));
+               foreach (indexes($table) as $name => $index) {
+                       if ($name == '') {
+                               continue;
+                       }
+                       $return .= ";\n\n" . index_sql($table, $index['type'], $name, "(" . implode(", ", array_map('idf_escape', $index['columns'])) . ")");
+               }
+               return $return;
        }
        
        function truncate_sql($table) {
index 440ef9a8f46b83d1017ba1115b669f8b7380cedd..159945c20e6b001f87ef0b4201b1dae3402de453 100644 (file)
@@ -1,12 +1,13 @@
 Adminer 3.6.4-dev:
 Display pagination on a fixed position
 Display select SQL edit form inline
-Compatibility with MySQL 5.6
 Recover original view, trigger, routine if creating fails
 Allow loading more data with inline edit (bug #3605531)
 Stay on the same page after deleting rows (bug #3605845)
 Handle max_input_vars
-Disable autocapitalize in identifiers
+Disable autocapitalize in identifiers on mobile browsers
+MySQL: Compatibility with MySQL 5.6
+SQLite: Export indexes
 
 Adminer 3.6.3 (released 2013-01-23):
 Display error code in SQL query