SQLite: Display auto-created unique indexes
This commit is contained in:
parent
f4592e3603
commit
3e2288eee5
|
@ -352,20 +352,24 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
|||
$sqls = get_key_vals("SELECT name, sql FROM sqlite_master WHERE type = 'index' AND tbl_name = " . q($table), $connection2);
|
||||
foreach (get_rows("PRAGMA index_list(" . table($table) . ")", $connection2) as $row) {
|
||||
$name = $row["name"];
|
||||
if (!preg_match("~^sqlite_~", $name)) {
|
||||
$return[$name]["type"] = ($row["unique"] ? "UNIQUE" : "INDEX");
|
||||
$return[$name]["lengths"] = array();
|
||||
foreach (get_rows("PRAGMA index_info(" . idf_escape($name) . ")", $connection2) as $row1) {
|
||||
$return[$name]["columns"][] = $row1["name"];
|
||||
}
|
||||
$return[$name]["descs"] = array();
|
||||
if (preg_match('~^CREATE( UNIQUE)? INDEX ' . preg_quote(idf_escape($name) . ' ON ' . idf_escape($table), '~') . ' \((.*)\)$~i', $sqls[$name], $regs)) {
|
||||
preg_match_all('/("[^"]*+")+( DESC)?/', $regs[2], $matches);
|
||||
foreach ($matches[2] as $val) {
|
||||
$return[$name]["descs"][] = ($val ? '1' : null);
|
||||
$index = array("type" => ($row["unique"] ? "UNIQUE" : "INDEX"));
|
||||
$index["lengths"] = array();
|
||||
$index["descs"] = array();
|
||||
foreach (get_rows("PRAGMA index_info(" . idf_escape($name) . ")", $connection2) as $row1) {
|
||||
$index["columns"][] = $row1["name"];
|
||||
$index["descs"][] = null;
|
||||
}
|
||||
if (preg_match('~^CREATE( UNIQUE)? INDEX ' . preg_quote(idf_escape($name) . ' ON ' . idf_escape($table), '~') . ' \((.*)\)$~i', $sqls[$name], $regs)) {
|
||||
preg_match_all('/("[^"]*+")+( DESC)?/', $regs[2], $matches);
|
||||
foreach ($matches[2] as $key => $val) {
|
||||
if ($val) {
|
||||
$index["descs"][$key] = '1';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$return[""] || $index["type"] != "UNIQUE" || $index["columns"] != $return[""]["columns"] || $index["descs"] != $return[""]["descs"] || !preg_match("~^sqlite_~", $name)) {
|
||||
$return[$name] = $index;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Adminer 4.0.4-dev:
|
||||
SQLite: Display auto-created unique indexes, bug since Adminer 3.5.0
|
||||
|
||||
Adminer 4.0.3 (released 2014-02-01)
|
||||
MongoDB: insert, truncate, indexes
|
||||
|
|
Loading…
Reference in a new issue