bdr: lift restriction on DROP
authorAlvaro Herrera <[email protected]>
Tue, 8 Apr 2014 20:36:31 +0000 (17:36 -0300)
committerAndres Freund <[email protected]>
Thu, 3 Jul 2014 15:55:24 +0000 (17:55 +0200)
contrib/bdr/bdr_commandfilter.c

index f4a85461606155da44bf58f9020d7e03503c06f4..c413506f1060eaa8aa05df3979df5951f7d6256a 100644 (file)
@@ -1,7 +1,7 @@
 /* -------------------------------------------------------------------------
  *
- * bdr_forbid_utility_commands.c
- *     forbid utility commands not yet or never supported
+ * bdr_commandfilter.c
+ *     prevent execution of utility commands not yet or never supported
  *
  *
  * Copyright (C) 2012-2014, PostgreSQL Global Development Group
  *
  * -------------------------------------------------------------------------
  */
-
 #include "postgres.h"
 
+#include "access/heapam.h"
 #include "bdr.h"
-#include "fmgr.h"
-#include "tcop/utility.h"
+#include "catalog/namespace.h"
 #include "commands/dbcommands.h"
+#include "fmgr.h"
 #include "miscadmin.h"
+#include "tcop/utility.h"
 #include "utils/guc.h"
 #include "utils/rel.h"
-#include "access/heapam.h"
-#include "catalog/namespace.h"
 
 /*
 * bdr_commandfilter.c: a ProcessUtility_hook to prevent a cluster from running
@@ -78,7 +77,6 @@ bdr_commandfilter(Node *parsetree,
 {
    int         severity = ERROR;
    ListCell   *cell;
-   DropStmt   *dropStatement;
    RenameStmt *renameStatement;
    AlterTableStmt *alterTableStatement;
    bool hasInvalid;
@@ -152,46 +150,6 @@ bdr_commandfilter(Node *parsetree,
            }
            break;
 
-       case T_DropStmt:
-
-           /*
-            * DROP is fun to handle, since a DropStmt might be for a matview,
-            * index, etc, not just a table, per the comment on
-            * RemoveRelations in tablecmds.c
-            *
-            * For now we forbid DROP TABLE, DROP VIEW, DROP SEQUENCE, DROP
-            * TRIGGER, DROP RULE, DROP EXTENSION as well as DROP TYPE
-            */
-           dropStatement = (DropStmt *) parsetree;
-           if (dropStatement->removeType == OBJECT_TABLE ||
-               dropStatement->removeType == OBJECT_VIEW ||
-               dropStatement->removeType == OBJECT_SEQUENCE ||
-               dropStatement->removeType == OBJECT_TRIGGER ||
-               dropStatement->removeType == OBJECT_RULE ||
-               dropStatement->removeType == OBJECT_EXTENSION ||
-               dropStatement->removeType == OBJECT_TYPE)
-           {
-               foreach(cell, dropStatement->objects)
-               {
-                   /*
-                    * makeRangeVarFromNameList() reports an error if the cell
-                    * has more than three or less than 1 entries; thus we do
-                    * not validate here
-                    */
-                   error_on_persistent_rv(
-                            makeRangeVarFromNameList((List *) lfirst(cell)),
-                                          "DROP",
-                                          AccessExclusiveLock, severity,
-                                          dropStatement->missing_ok);
-               }
-           }
-           break;
-
-       case T_DropOwnedStmt:
-           ereport(severity,
-                   (errmsg("DROP OWNED is unsafe with BDR active")));
-           break;
-
        case T_AlterEnumStmt:
            ereport(severity,
             (errmsg("ALTER TYPE ... ADD VALUE is unsafe with BDR active")));