Export SQLite indexes (bug #3609741)

This commit is contained in:
Jakub Vrana 2013-04-03 10:46:51 -07:00
parent cb57afd0e5
commit 58a8df7c86
2 changed files with 20 additions and 4 deletions

View 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) {

View 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