Drop CASCADE for rules
authorchriskl <chriskl>
Wed, 30 Apr 2003 07:02:20 +0000 (07:02 +0000)
committerchriskl <chriskl>
Wed, 30 Apr 2003 07:02:20 +0000 (07:02 +0000)
classes/database/Postgres.php
classes/database/Postgres73.php
rules.php

index 64247ddf275b08c52ff195f284ea50b2408bb406..12377ee4aec8c478523e50d71cc560578f019718 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.83 2003/04/30 06:56:31 chriskl Exp $
+ * $Id: Postgres.php,v 1.84 2003/04/30 07:02:20 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -1262,12 +1262,14 @@ class Postgres extends BaseDB {
         * Removes a rule from a relation
         * @param $rule The rule to drop
         * @param $relation The relation from which to drop (unused)
+        * @param $cascade True to cascade drop, false to restrict
         * @return 0 success
         */
-       function dropRule($rule, $relation) {
+       function dropRule($rule, $relation, $cascade) {
                $this->fieldClean($rule);
 
                $sql = "DROP RULE \"{$rule}\"";
+               if ($cascade) $sql .= " CASCADE";
 
                return $this->execute($sql);
        }
index c72a9c267a5882802d81835066eda525cfaa397e..8bac6d1b524dd75c42028fd2768dd7406bf60557 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres73.php,v 1.36 2003/04/30 06:35:42 chriskl Exp $
+ * $Id: Postgres73.php,v 1.37 2003/04/30 07:02:22 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -615,13 +615,15 @@ class Postgres73 extends Postgres72 {
         * Removes a rule from a relation
         * @param $rule The rule to drop
         * @param $relation The relation from which to drop
+        * @param $cascade True to cascade drop, false to restrict
         * @return 0 success
         */
-       function dropRule($rule, $relation) {
+       function dropRule($rule, $relation, $cascade) {
                $this->fieldClean($rule);
                $this->fieldClean($relation);
 
                $sql = "DROP RULE \"{$rule}\" ON \"{$relation}\"";
+               if ($cascade) $sql .= " CASCADE";
 
                return $this->execute($sql);
        }
index 77c3333e64aa8c8c3a1e21bb487a62ce86ec3dad..b1ce79c1a83c0bfe161c1f63d23ce5a82c2768f0 100644 (file)
--- a/rules.php
+++ b/rules.php
@@ -3,7 +3,7 @@
        /**
         * List rules on a table
         *
-        * $Id: rules.php,v 1.9 2003/04/18 11:08:27 chriskl Exp $
+        * $Id: rules.php,v 1.10 2003/04/30 07:02:20 chriskl Exp $
         */
 
        // Include application functions
                        echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\">\n";
                        echo "<input type=\"hidden\" name=\"rule\" value=\"", htmlspecialchars($_REQUEST['rule']), "\">\n";
                        echo $misc->form;
+                       // 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->dropRule($_POST['rule'], $_POST['table']);
+                       $status = $localData->dropRule($_POST['rule'], $_POST['table'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strruledropped']);
                        else