01: /*
02:
03: Derby - Class org.apache.derby.impl.sql.execute.DropStatisticsConstantAction
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (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: import org.apache.derby.catalog.UUID;
35:
36: /**
37: * this class drops all statistics for a particular table or index.
38: *
39: * @author manish.
40: */
41:
42: class DropStatisticsConstantAction extends DDLConstantAction {
43: private final String objectName;
44: private final boolean forTable;
45: private final SchemaDescriptor sd;
46: private final String fullTableName;
47:
48: DropStatisticsConstantAction(SchemaDescriptor sd,
49: String fullTableName, String objectName, boolean forTable) {
50: this .objectName = objectName;
51: this .sd = sd;
52: this .forTable = forTable;
53: this .fullTableName = fullTableName;
54: }
55:
56: public void executeConstantAction(Activation activation)
57: throws StandardException {
58: TableDescriptor td;
59: ConglomerateDescriptor cd = null;
60:
61: LanguageConnectionContext lcc = activation
62: .getLanguageConnectionContext();
63: DataDictionary dd = lcc.getDataDictionary();
64: DependencyManager dm = dd.getDependencyManager();
65: TransactionController tc = lcc.getTransactionExecute();
66:
67: dd.startWriting(lcc);
68:
69: if (forTable) {
70: td = dd.getTableDescriptor(objectName, sd);
71: }
72:
73: else {
74: cd = dd.getConglomerateDescriptor(objectName, sd, false);
75: td = dd.getTableDescriptor(cd.getTableID());
76: }
77:
78: /* invalidate all SPS's on the table-- bad plan on SPS, so user drops
79: * statistics and would want SPS's invalidated so that recompile would
80: * give good plans; thats the theory anyways....
81: */
82: dm.invalidateFor(td, DependencyManager.DROP_STATISTICS, lcc);
83:
84: dd.dropStatisticsDescriptors(td.getUUID(), ((cd != null) ? cd
85: .getUUID() : null), tc);
86: }
87:
88: public String toString() {
89: return "DROP STATISTICS FOR "
90: + ((forTable) ? "table " : "index ") + fullTableName;
91: }
92: }
|