Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / derby-10.3.2.1 / java / engine / org / apache / derby / impl / sql / execute / DropStatisticsConstantAction.java
diff --git a/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/sql/execute/DropStatisticsConstantAction.java b/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/sql/execute/DropStatisticsConstantAction.java
new file mode 100644 (file)
index 0000000..a43c172
--- /dev/null
@@ -0,0 +1,102 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.sql.execute.DropStatisticsConstantAction\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.execute;\r
+\r
+import org.apache.derby.iapi.sql.Activation;\r
+import org.apache.derby.iapi.error.StandardException;\r
+import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.TableDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;\r
+import org.apache.derby.iapi.sql.depend.DependencyManager;\r
+import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;\r
+import org.apache.derby.iapi.store.access.TransactionController;\r
+\r
+\r
+import org.apache.derby.catalog.UUID;\r
+\r
+/**\r
+ * this class drops all statistics for a particular table or index.\r
+ *\r
+ */\r
+\r
+class DropStatisticsConstantAction extends DDLConstantAction\r
+{\r
+       private final String objectName;\r
+       private final boolean forTable;\r
+       private final SchemaDescriptor sd;\r
+       private final String fullTableName;\r
+\r
+       DropStatisticsConstantAction(SchemaDescriptor sd,\r
+                                                                               String fullTableName,\r
+                                                                               String objectName,\r
+                                                                               boolean forTable)\r
+       {\r
+               this.objectName = objectName;\r
+               this.sd = sd;\r
+               this.forTable = forTable;\r
+               this.fullTableName = fullTableName;\r
+       }\r
+       \r
+       public void executeConstantAction(Activation activation)\r
+               throws StandardException\r
+       {\r
+               TableDescriptor td;\r
+               ConglomerateDescriptor cd = null;\r
+\r
+               LanguageConnectionContext lcc = activation.getLanguageConnectionContext();\r
+               DataDictionary dd = lcc.getDataDictionary();\r
+               DependencyManager dm = dd.getDependencyManager();\r
+               TransactionController tc = lcc.getTransactionExecute();\r
+\r
+\r
+               dd.startWriting(lcc);\r
+\r
+               if (forTable)\r
+               {\r
+                       td = dd.getTableDescriptor(objectName, sd);\r
+               }\r
+               \r
+               else\r
+               {\r
+                       cd = dd.getConglomerateDescriptor(objectName,\r
+                                                                                        sd, false);\r
+                       td = dd.getTableDescriptor(cd.getTableID());\r
+               }\r
+\r
+               /* invalidate all SPS's on the table-- bad plan on SPS, so user drops\r
+                * statistics and would want SPS's invalidated so that recompile would\r
+                * give good plans; thats the theory anyways....\r
+                */\r
+               dm.invalidateFor(td, DependencyManager.DROP_STATISTICS, lcc);\r
+\r
+               dd.dropStatisticsDescriptors(td.getUUID(), ((cd != null) ? cd.getUUID() :\r
+                                                                        null), tc);\r
+       }\r
+       \r
+       public String toString()\r
+       {\r
+               return "DROP STATISTICS FOR " + ((forTable) ? "table " : "index ") +\r
+                       fullTableName;\r
+       }\r
+}\r
+\r