$relname = $row["relname"];
$return[$relname]["type"] = ($row["indispartial"] ? "INDEX" : ($row["indisprimary"] ? "PRIMARY" : ($row["indisunique"] ? "UNIQUE" : "INDEX")));
$return[$relname]["columns"] = array();
- foreach (explode(" ", $row["indkey"]) as $indkey) {
- $return[$relname]["columns"][] = $columns[$indkey];
- }
$return[$relname]["descs"] = array();
- foreach (explode(" ", $row["indoption"]) as $indoption) {
- $return[$relname]["descs"][] = ($indoption & 1 ? '1' : null); // 1 - INDOPTION_DESC
+ if ($row["indkey"]) {
+ foreach (explode(" ", $row["indkey"]) as $indkey) {
+ $return[$relname]["columns"][] = $columns[$indkey];
+ }
+ foreach (explode(" ", $row["indoption"]) as $indoption) {
+ $return[$relname]["descs"][] = ($indoption & 1 ? '1' : null); // 1 - INDOPTION_DESC
+ }
}
$return[$relname]["lengths"] = array();
}
}
}
- if ($columns) {
- $existing = $indexes[$name];
- if ($existing) {
- ksort($existing["columns"]);
- ksort($existing["lengths"]);
- ksort($existing["descs"]);
- if ($index["type"] == $existing["type"]
- && array_values($existing["columns"]) === $columns
- && (!$existing["lengths"] || array_values($existing["lengths"]) === $lengths)
- && array_values($existing["descs"]) === $descs
- ) {
- // skip existing index
- unset($indexes[$name]);
- continue;
- }
+ $existing = $indexes[$name];
+ if ($existing) {
+ ksort($existing["columns"]);
+ ksort($existing["lengths"]);
+ ksort($existing["descs"]);
+ if ($index["type"] == $existing["type"]
+ && array_values($existing["columns"]) === $columns
+ && (!$existing["lengths"] || array_values($existing["lengths"]) === $lengths)
+ && array_values($existing["descs"]) === $descs
+ ) {
+ // skip existing index
+ unset($indexes[$name]);
+ continue;
}
+ }
+ if ($columns) {
$alter[] = array($index["type"], $name, $set);
}
}
Adminer dev:
+PostgreSQL: Do not alter indexes with expressions
PostgreSQL: Fix export of indexes with expressions (bug #768)
SQLite: Support CHECK constraint
SQLite: Add command Check tables