]> git.joonet.de Git - adminer.git/commitdiff
PostgreSQL: Support indexes on materialized views (PR #467)
authorJakub Vrana <jakub@vrana.cz>
Fri, 7 Mar 2025 12:13:53 +0000 (13:13 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 7 Mar 2025 12:13:58 +0000 (13:13 +0100)
adminer/drivers/pgsql.inc.php
adminer/include/driver.inc.php
adminer/table.inc.php
changes.txt

index 4438e4a2350dc4f7bed8e75f8d870f8f7df17d50..cafbbbd6462e81f92934c2b356d347fb184780e1 100644 (file)
@@ -293,6 +293,10 @@ if (isset($_GET["pgsql"])) {
                        }
                }
 
+               function supportsIndex($table_status) {
+                       return $table_status["Engine"] != "view";
+               }
+
                function hasCStyleEscapes() {
                        static $c_style;
                        if ($c_style === null) {
index 2687a9d253cfcf2618baf93f2409f39246722907..7e75edacad9d555104e704d6c212c3af0d52b477 100644 (file)
@@ -230,6 +230,14 @@ abstract class SqlDriver {
                return false;
        }
 
+       /** Check whether table supports indexes
+       * @param array result of table_status()
+       * @return bool
+       */
+       function supportsIndex($table_status) {
+               return !is_view($table_status);
+       }
+
        /** Get defined check constraints
        * @param string
        * @return array [$name => $clause]
index b459816b8ba21b8ae0057d956e2cf1ed99d61ed5..f3f388a112581e3873cf11fcc713fb8c4c231efb 100644 (file)
@@ -26,16 +26,16 @@ if ($fields) {
        $adminer->tableStructurePrint($fields);
 }
 
-if (!is_view($table_status)) {
-       if (support("indexes")) {
-               echo "<h3 id='indexes'>" . lang('Indexes') . "</h3>\n";
-               $indexes = indexes($TABLE);
-               if ($indexes) {
-                       $adminer->tableIndexesPrint($indexes);
-               }
-               echo '<p class="links"><a href="' . h(ME) . 'indexes=' . urlencode($TABLE) . '">' . lang('Alter indexes') . "</a>\n";
+if (support("indexes") && $driver->supportsIndex($table_status)) {
+       echo "<h3 id='indexes'>" . lang('Indexes') . "</h3>\n";
+       $indexes = indexes($TABLE);
+       if ($indexes) {
+               $adminer->tableIndexesPrint($indexes);
        }
+       echo '<p class="links"><a href="' . h(ME) . 'indexes=' . urlencode($TABLE) . '">' . lang('Alter indexes') . "</a>\n";
+}
 
+if (!is_view($table_status)) {
        if (fk_support($table_status)) {
                echo "<h3 id='foreign-keys'>" . lang('Foreign keys') . "</h3>\n";
                $foreign_keys = foreign_keys($TABLE);
index 72c9f163b4a602a339ba0a14f644c2e847ae3a5c..3fa110691c0423a174e4d362184b344877bf3a70 100644 (file)
@@ -2,6 +2,7 @@ Adminer dev:
 Fix bulk operations with tables
 Remove duplicate columns from select (bug #670)
 MariaDB: Fix link to status variable doc (bug #658)
+PostgreSQL: Support indexes on materialized views (PR #467)
 
 Adminer 5.0.0 (released 2025-03-07):
 Speed up with disabled output buffering