]> git.joonet.de Git - adminer.git/commitdiff
Support altering indexes
authorTakashi SHIRAI <shirai@nintendo.co.jp>
Tue, 26 Mar 2019 04:53:54 +0000 (13:53 +0900)
committerJakub Vrana <jakub@vrana.cz>
Tue, 9 Feb 2021 08:57:27 +0000 (09:57 +0100)
Signed-off-by: Takashi SHIRAI <shirai@nintendo.co.jp>
adminer/drivers/oracle.inc.php
changes.txt

index 1bd1a1e9754495891ca858060748daac6c523fc0..c88096c625f567edeac366d1d2836491cbc285dd 100644 (file)
@@ -370,6 +370,38 @@ ORDER BY ac.constraint_type, aic.column_position", $connection2) as $row) {
                ;
        }
 
+       function alter_indexes($table, $alter) {
+               $create = array();
+               $drop = array();
+               $queries = array();
+               foreach ($alter as $val) {
+                       $val[2] = preg_replace('~ DESC$~', '', $val[2]);
+                       if ($val[0] != "INDEX") {
+                               //! descending UNIQUE indexes results in syntax error
+                               $create[] = ($val[2] == "DROP"
+                                       ? "\nDROP CONSTRAINT " . idf_escape($val[1])
+                                       : "\nADD" . ($val[1] != "" ? " CONSTRAINT " . idf_escape($val[1]) : "") . " $val[0] " . ($val[0] == "PRIMARY" ? "KEY " : "") . "(" . implode(", ", $val[2]) . ")"
+                               );
+                       } elseif ($val[2] == "DROP") {
+                               $drop[] = idf_escape($val[1]);
+                       } else {
+                               $queries[] = "CREATE INDEX " . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table) . " (" . implode(", ", $val[2]) . ")";
+                       }
+               }
+               if ($create) {
+                       array_unshift($queries, "ALTER TABLE " . table($table) . implode(",", $create));
+               }
+               if ($drop) {
+                       array_unshift($queries, "DROP INDEX " . implode(", ", $drop));
+               }
+               foreach ($queries as $query) {
+                       if (!queries($query)) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
        function foreign_keys($table) {
                $return = array();
                $query = "SELECT c_list.CONSTRAINT_NAME as NAME,
index 1bfdd4daebaca517b6892f47840ef2ee569f4441..a3975510a405e6d8677e677b4a5d4c11e6882b7f 100644 (file)
@@ -10,6 +10,7 @@ PostgreSQL: Avoid exporting empty sequence last value (bug #768)
 PostgreSQL: Do not show triggers from other schemas (PR #412)
 PostgreSQL: Fix multi-parameter functions in default values (bug #736)
 PostgreSQL PDO: Do not select NULL function for false values in edit
+Oracle: Alter indexes
 Oracle: Count tables
 Oracle: Import from CSV
 Oracle: Fix column size with string type