1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 import org.apache.derby.iapi.error.StandardException; 26 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 27 28 import org.apache.derby.iapi.sql.dictionary.TableDescriptor; 29 import org.apache.derby.iapi.sql.dictionary.AliasDescriptor; 30 import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator; 31 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 32 import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext; 33 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor; 34 35 import org.apache.derby.iapi.types.DataValueFactory; 36 37 import org.apache.derby.iapi.sql.depend.DependencyManager; 38 39 import org.apache.derby.iapi.reference.SQLState; 40 41 import org.apache.derby.iapi.sql.execute.ConstantAction; 42 43 import org.apache.derby.iapi.sql.Activation; 44 45 import org.apache.derby.iapi.store.access.TransactionController; 46 47 import org.apache.derby.catalog.AliasInfo; 48 49 55 56 class DropAliasConstantAction extends DDLConstantAction 57 { 58 59 private SchemaDescriptor sd; 60 private final String schemaName; 61 private final String aliasName; 62 private final char nameSpace; 63 64 66 67 75 DropAliasConstantAction(SchemaDescriptor sd, String aliasName, char nameSpace) 76 { 77 this.sd = sd; 78 this.schemaName = sd.getSchemaName(); 79 this.aliasName = aliasName; 80 this.nameSpace = nameSpace; 81 } 82 83 85 public String toString() 86 { 87 return "DROP ALIAS " + aliasName; 90 } 91 92 94 95 102 public void executeConstantAction( Activation activation ) 103 throws StandardException 104 { 105 LanguageConnectionContext lcc = activation.getLanguageConnectionContext(); 106 DataDictionary dd = lcc.getDataDictionary(); 107 TransactionController tc = lcc.getTransactionExecute(); 108 DependencyManager dm = dd.getDependencyManager(); 109 110 111 120 dd.startWriting(lcc); 121 122 if (sd == null) { 123 sd = dd.getSchemaDescriptor(schemaName, lcc.getTransactionExecute(), true); 124 } 125 126 127 130 AliasDescriptor ad = dd.getAliasDescriptor(sd.getUUID().toString(), aliasName, nameSpace); 131 132 if (ad == null) 134 { 135 throw StandardException.newException(SQLState.LANG_OBJECT_NOT_FOUND, ad.getAliasType(nameSpace), aliasName); 136 } 137 138 146 int invalidationType = 0; 147 switch (ad.getAliasType()) 148 { 149 case AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR: 150 case AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR: 151 invalidationType = DependencyManager.DROP_METHOD_ALIAS; 152 break; 153 154 case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR: 155 invalidationType = DependencyManager.DROP_SYNONYM; 156 break; 157 } 158 159 dm.invalidateFor(ad, invalidationType, lcc); 160 161 if (ad.getAliasType() == AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR) 162 { 163 DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator(); 165 TableDescriptor td = ddg.newTableDescriptor(aliasName, sd, 166 TableDescriptor.SYNONYM_TYPE, TableDescriptor.DEFAULT_LOCK_GRANULARITY); 167 dd.dropTableDescriptor(td, sd, tc); 168 } 169 else 170 dd.dropAllRoutinePermDescriptors(ad.getUUID(), tc); 171 172 173 dd.dropAliasDescriptor(ad, tc); 174 175 } 176 } 177 | Popular Tags |