Drop CASCADE for indexes
authorchriskl <chriskl>
Wed, 30 Apr 2003 06:56:31 +0000 (06:56 +0000)
committerchriskl <chriskl>
Wed, 30 Apr 2003 06:56:31 +0000 (06:56 +0000)
classes/database/Postgres.php
indexes.php

index 9c34f0a2e7e0414503550ea2304a57a8948a558d..64247ddf275b08c52ff195f284ea50b2408bb406 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.82 2003/04/30 06:49:11 chriskl Exp $
+ * $Id: Postgres.php,v 1.83 2003/04/30 06:56:31 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -1244,12 +1244,14 @@ class Postgres extends BaseDB {
        /**
         * Removes an index from the database
         * @param $index The index to drop
+        * @param $cascade True to cascade drop, false to restrict
         * @return 0 success
         */
-       function dropIndex($index) {
+       function dropIndex($index, $cascade) {
                $this->fieldClean($index);
 
                $sql = "DROP INDEX \"{$index}\"";
+               if ($cascade) $sql .= " CASCADE";
 
                return $this->execute($sql);
        }
index 1cb61d853f040186dd58d6d9d90ad3db1112f1ba..3824aec34a83d6564a7dc72534129f8937111021 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List indexes on a table
         *
-        * $Id: indexes.php,v 1.11 2003/04/23 08:58:27 chriskl Exp $
+        * $Id: indexes.php,v 1.12 2003/04/30 06:56:31 chriskl Exp $
         */
 
        // Include application functions
                        echo "<p>", sprintf($lang['strconfdropindex'], htmlspecialchars($_REQUEST['index'])), "</p>\n";
 
                        echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
-                       echo "<input type=hidden name=action value=drop_index>\n";
-                       echo "<input type=hidden name=table value=\"", htmlspecialchars($_REQUEST['table']), "\">\n";
-                       echo "<input type=hidden name=index value=\"", htmlspecialchars($_REQUEST['index']), "\">\n";
+                       echo "<input type=\"hidden\" name=\"action\" value=\"drop_index\">\n";
+                       echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\">\n";
+                       echo "<input type=\"hidden\" name=\"index\" value=\"", htmlspecialchars($_REQUEST['index']), "\">\n";
                        echo $misc->form;
-                       echo "<input type=submit name=yes value=\"{$lang['stryes']}\"> <input type=submit name=no value=\"{$lang['strno']}\">\n";
+                       // Show cascade drop option if supportd
+                       if ($localData->hasDropBehavior()) {
+                               echo "<p><input type=\"checkbox\" name=\"cascade\"> {$lang['strcascade']}</p>\n";
+                       }
+                       echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\"> <input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\">\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropIndex($_POST['index'], 'RESTRICT');
+                       $status = $localData->dropIndex($_POST['index'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strindexdropped']);
                        else