--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.sql.compile.DropSchemaNode\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.sql.compile;\r
+\r
+import org.apache.derby.iapi.sql.compile.CompilerContext;\r
+import org.apache.derby.iapi.sql.conn.Authorizer;\r
+import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;\r
+import org.apache.derby.iapi.sql.execute.ConstantAction;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+import org.apache.derby.iapi.reference.SQLState;\r
+\r
+/**\r
+ * A DropSchemaNode is the root of a QueryTree that represents \r
+ * a DROP SCHEMA statement.\r
+ *\r
+ */\r
+\r
+public class DropSchemaNode extends DDLStatementNode\r
+{\r
+ private int dropBehavior;\r
+ private String schemaName;\r
+\r
+ /**\r
+ * Initializer for a DropSchemaNode\r
+ *\r
+ * @param schemaName The name of the object being dropped\r
+ * @param dropBehavior Drop behavior (RESTRICT | CASCADE)\r
+ *\r
+ */\r
+ public void init(Object schemaName, Object dropBehavior)\r
+ throws StandardException\r
+ {\r
+ initAndCheck(null);\r
+ this.schemaName = (String) schemaName;\r
+ this.dropBehavior = ((Integer) dropBehavior).intValue();\r
+ }\r
+\r
+ public void bindStatement() throws StandardException\r
+ {\r
+ \r
+ LanguageConnectionContext lcc = getLanguageConnectionContext();\r
+\r
+ /* \r
+ ** Users are not permitted to drop\r
+ ** the SYS or APP schemas.\r
+ */\r
+ if (getDataDictionary().isSystemSchemaName(schemaName))\r
+ {\r
+ throw(StandardException.newException(\r
+ SQLState.LANG_CANNOT_DROP_SYSTEM_SCHEMAS, this.schemaName));\r
+ }\r
+ \r
+ /* \r
+ ** In SQL authorization mode, the current authorization identifier\r
+ ** must be either the owner of the schema or the database owner \r
+ ** in order for the schema object to be dropped.\r
+ */\r
+ if (isPrivilegeCollectionRequired())\r
+ {\r
+ getCompilerContext().addRequiredSchemaPriv(schemaName, \r
+ lcc.getAuthorizationId(), \r
+ Authorizer.DROP_SCHEMA_PRIV);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Convert this object to a String. See comments in QueryTreeNode.java\r
+ * for how this should be done for tree printing.\r
+ *\r
+ * @return This object as a String\r
+ */\r
+\r
+ public String toString()\r
+ {\r
+ if (SanityManager.DEBUG)\r
+ {\r
+ return super.toString() +\r
+ "dropBehavior: " + "\n" + dropBehavior + "\n";\r
+ }\r
+ else\r
+ {\r
+ return "";\r
+ }\r
+ }\r
+\r
+ public String statementToString()\r
+ {\r
+ return "DROP SCHEMA";\r
+ }\r
+\r
+ // inherit generate() method from DDLStatementNode\r
+\r
+\r
+ /**\r
+ * Create the Constant information that will drive the guts of Execution.\r
+ *\r
+ * @exception StandardException Thrown on failure\r
+ */\r
+ public ConstantAction makeConstantAction() throws StandardException\r
+ {\r
+ return getGenericConstantActionFactory().getDropSchemaConstantAction(schemaName);\r
+ }\r
+}\r