From 58a8df7c86b75bf3bc8a9a63ca83181421ef5e46 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Wed, 3 Apr 2013 10:46:51 -0700 Subject: [PATCH] Export SQLite indexes (bug #3609741) --- adminer/drivers/sqlite.inc.php | 19 +++++++++++++++++-- changes.txt | 5 +++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index 79da3a93..f6ac0e1e 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -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) { diff --git a/changes.txt b/changes.txt index 440ef9a8..159945c2 100644 --- a/changes.txt +++ b/changes.txt @@ -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