KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > execute > DropStatisticsConstantAction


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.DropStatisticsConstantAction
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.execute;
23
24 import org.apache.derby.iapi.sql.Activation;
25 import org.apache.derby.iapi.error.StandardException;
26 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
27 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
28 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
29 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
30 import org.apache.derby.iapi.sql.depend.DependencyManager;
31 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
32 import org.apache.derby.iapi.store.access.TransactionController;
33
34
35 import org.apache.derby.catalog.UUID;
36
37 /**
38  * this class drops all statistics for a particular table or index.
39  *
40  * @author manish.
41  */

42
43 class DropStatisticsConstantAction extends DDLConstantAction
44 {
45     private final String JavaDoc objectName;
46     private final boolean forTable;
47     private final SchemaDescriptor sd;
48     private final String JavaDoc fullTableName;
49
50     DropStatisticsConstantAction(SchemaDescriptor sd,
51                                         String JavaDoc fullTableName,
52                                         String JavaDoc objectName,
53                                         boolean forTable)
54     {
55         this.objectName = objectName;
56         this.sd = sd;
57         this.forTable = forTable;
58         this.fullTableName = fullTableName;
59     }
60     
61     public void executeConstantAction(Activation activation)
62         throws StandardException
63     {
64         TableDescriptor td;
65         ConglomerateDescriptor cd = null;
66
67         LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
68         DataDictionary dd = lcc.getDataDictionary();
69         DependencyManager dm = dd.getDependencyManager();
70         TransactionController tc = lcc.getTransactionExecute();
71
72
73         dd.startWriting(lcc);
74
75         if (forTable)
76         {
77             td = dd.getTableDescriptor(objectName, sd);
78         }
79         
80         else
81         {
82             cd = dd.getConglomerateDescriptor(objectName,
83                                              sd, false);
84             td = dd.getTableDescriptor(cd.getTableID());
85         }
86
87         /* invalidate all SPS's on the table-- bad plan on SPS, so user drops
88          * statistics and would want SPS's invalidated so that recompile would
89          * give good plans; thats the theory anyways....
90          */

91         dm.invalidateFor(td, DependencyManager.DROP_STATISTICS, lcc);
92
93         dd.dropStatisticsDescriptors(td.getUUID(), ((cd != null) ? cd.getUUID() :
94                                      null), tc);
95     }
96     
97     public String JavaDoc toString()
98     {
99         return "DROP STATISTICS FOR " + ((forTable) ? "table " : "index ") +
100             fullTableName;
101     }
102 }
103
104
Popular Tags