01: /*
02:
03: Derby - Class org.apache.derby.impl.sql.compile.DropTriggerNode
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.compile;
23:
24: import org.apache.derby.iapi.sql.compile.CompilerContext;
25: import org.apache.derby.iapi.sql.dictionary.DataDictionary;
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.TriggerDescriptor;
29: import org.apache.derby.iapi.reference.SQLState;
30: import org.apache.derby.iapi.sql.execute.ConstantAction;
31: import org.apache.derby.iapi.error.StandardException;
32: import org.apache.derby.iapi.services.context.ContextManager;
33: import org.apache.derby.iapi.services.sanity.SanityManager;
34:
35: /**
36: * A DropTriggerNode is the root of a QueryTree that represents a DROP TRIGGER
37: * statement.
38: *
39: * @author Jamie
40: */
41: public class DropTriggerNode extends DDLStatementNode {
42: private TableDescriptor td;
43:
44: public String statementToString() {
45: return "DROP TRIGGER";
46: }
47:
48: /**
49: * Bind this DropTriggerNode. This means looking up the trigger,
50: * verifying it exists and getting its table uuid.
51: *
52: * @return The bound query tree
53: *
54: * @exception StandardException Thrown on error
55: */
56: public QueryTreeNode bind() throws StandardException {
57: CompilerContext cc = getCompilerContext();
58: DataDictionary dd = getDataDictionary();
59:
60: SchemaDescriptor sd = getSchemaDescriptor();
61:
62: TriggerDescriptor triggerDescriptor = null;
63:
64: if (sd.getUUID() != null)
65: triggerDescriptor = dd.getTriggerDescriptor(
66: getRelativeName(), sd);
67:
68: if (triggerDescriptor == null) {
69: throw StandardException.newException(
70: SQLState.LANG_OBJECT_NOT_FOUND, "TRIGGER",
71: getFullName());
72: }
73:
74: /* Get the table descriptor */
75: td = triggerDescriptor.getTableDescriptor();
76: cc.createDependency(td);
77: cc.createDependency(triggerDescriptor);
78:
79: return this ;
80: }
81:
82: // inherit generate() method from DDLStatementNode
83:
84: /**
85: * Create the Constant information that will drive the guts of Execution.
86: *
87: * @exception StandardException Thrown on failure
88: */
89: public ConstantAction makeConstantAction() throws StandardException {
90: return getGenericConstantActionFactory()
91: .getDropTriggerConstantAction(getSchemaDescriptor(),
92: getRelativeName(), td.getUUID());
93: }
94: }
|