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.dictionary.ConglomerateDescriptor; 27 import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator; 28 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 29 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor; 30 31 import org.apache.derby.iapi.sql.depend.DependencyManager; 32 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 33 import org.apache.derby.iapi.store.access.TransactionController; 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.Activation; 40 41 import org.apache.derby.catalog.UUID; 42 43 49 50 class DropSchemaConstantAction extends DDLConstantAction 51 { 52 53 54 private final String schemaName; 55 56 57 59 65 DropSchemaConstantAction(String schemaName) 66 { 67 this.schemaName = schemaName; 68 } 69 70 76 public String toString() 77 { 78 return "DROP SCHEMA " + schemaName; 81 } 82 83 85 86 93 public void executeConstantAction( Activation activation ) 94 throws StandardException 95 { 96 SchemaDescriptor sd; 97 98 LanguageConnectionContext lcc = activation.getLanguageConnectionContext(); 99 DataDictionary dd = lcc.getDataDictionary(); 100 DependencyManager dm = dd.getDependencyManager(); 101 TransactionController tc = lcc.getTransactionExecute(); 102 103 112 dd.startWriting(lcc); 113 114 sd = dd.getSchemaDescriptor(schemaName, null, true); 115 116 if (schemaName.equals(SchemaDescriptor.STD_DECLARED_GLOBAL_TEMPORARY_TABLES_SCHEMA_NAME) && (sd != null) && (sd.getUUID() == null)) 122 throw StandardException.newException(SQLState.LANG_SCHEMA_DOES_NOT_EXIST, schemaName); 123 124 129 if (!dd.isSchemaEmpty(sd)) 130 { 131 throw StandardException.newException(SQLState.LANG_SCHEMA_NOT_EMPTY, schemaName); 132 } 133 134 142 dm.invalidateFor(sd, DependencyManager.DROP_SCHEMA, lcc); 143 144 dd.dropSchemaDescriptor(schemaName, tc); 145 146 152 sd = lcc.getDefaultSchema(); 153 if ((sd != null) && 154 schemaName.equals(sd.getSchemaName())) 155 { 156 lcc.setDefaultSchema((SchemaDescriptor)null); 157 } 158 159 } 160 161 } 162 | Popular Tags |