1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.services.context.ContextManager; 25 26 import org.apache.derby.iapi.sql.compile.CompilerContext; 27 28 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor; 29 import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor; 30 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 31 import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext; 32 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor; 33 import org.apache.derby.iapi.sql.dictionary.TableDescriptor; 34 35 import org.apache.derby.iapi.reference.SQLState; 36 37 import org.apache.derby.iapi.sql.execute.ConstantAction; 38 39 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor; 40 41 import org.apache.derby.iapi.error.StandardException; 42 43 49 50 public class DropIndexNode extends DDLStatementNode 51 { 52 private ConglomerateDescriptor cd; 53 private TableDescriptor td; 54 55 public String statementToString() 56 { 57 return "DROP INDEX"; 58 } 59 60 68 public QueryTreeNode bind() throws StandardException 69 { 70 CompilerContext cc = getCompilerContext(); 71 DataDictionary dd = getDataDictionary(); 72 SchemaDescriptor sd; 73 74 sd = getSchemaDescriptor(); 75 76 if (sd.getUUID() != null) 77 cd = dd.getConglomerateDescriptor(getRelativeName(), sd, false); 78 79 if (cd == null) 80 { 81 throw StandardException.newException(SQLState.LANG_INDEX_NOT_FOUND, getFullName()); 82 } 83 84 85 td = getTableDescriptor(cd.getTableID()); 86 87 93 if (cd.isConstraint()) 94 { 95 ConstraintDescriptor conDesc; 96 String constraintName; 97 98 conDesc = dd.getConstraintDescriptor(td, cd.getUUID()); 99 if (conDesc != null) 100 { 101 constraintName = conDesc.getConstraintName(); 102 throw StandardException.newException(SQLState.LANG_CANT_DROP_BACKING_INDEX, 103 getFullName(), constraintName); 104 } 105 } 106 107 108 cc.createDependency(td); 109 cc.createDependency(cd); 110 111 return this; 112 } 113 114 116 121 public ConstantAction makeConstantAction() throws StandardException 122 { 123 return getGenericConstantActionFactory().getDropIndexConstantAction( getFullName(), 124 getRelativeName(), 125 getRelativeName(), 126 getSchemaDescriptor().getSchemaName(), 127 td.getUUID(), 128 td.getHeapConglomerateId()); 129 } 130 } 131 | Popular Tags |