]> git.joonet.de Git - adminer.git/commitdiff
PostgreSQL: Do not alter indexes with expressions
authorJakub Vrana <jakub@vrana.cz>
Wed, 26 Feb 2025 20:24:47 +0000 (21:24 +0100)
committerJakub Vrana <jakub@vrana.cz>
Wed, 26 Feb 2025 20:24:47 +0000 (21:24 +0100)
adminer/drivers/pgsql.inc.php
adminer/indexes.inc.php
changes.txt

index 8fe22073a30758e8e47222ee62cbbfe3a163f5eb..f4caf71afa9c7668809bcf5cfceef34681dee321 100644 (file)
@@ -423,12 +423,14 @@ ORDER BY a.attnum"
                        $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();
                }
index 4aed4a49e3a88b0d97145a2eb065a2768073fd2f..119e59fe823c343f98bfc4c89d61ecf24924e3f4 100644 (file)
@@ -40,22 +40,22 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
                                }
                        }
 
-                       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);
                        }
                }
index b5bb54d69ff672f1e03c8fe401d267e77e420a9e..1d657c3efdd3a9041ea849cd64710369ad3beee9 100644 (file)
@@ -1,4 +1,5 @@
 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