1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.sql.execute.ConstantAction; 25 26 import org.apache.derby.iapi.store.access.TransactionController; 27 28 import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator; 29 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 30 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor; 31 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 32 33 import org.apache.derby.iapi.reference.SQLState; 34 35 import org.apache.derby.iapi.sql.Activation; 36 37 import org.apache.derby.iapi.error.StandardException; 38 39 import org.apache.derby.iapi.services.sanity.SanityManager; 40 41 import org.apache.derby.catalog.UUID; 42 43 49 50 class CreateSchemaConstantAction extends DDLConstantAction 51 { 52 53 private final String aid; private final String schemaName; 55 56 57 59 68 CreateSchemaConstantAction( 69 String schemaName, 70 String aid) 71 { 72 this.schemaName = schemaName; 73 this.aid = aid; 74 } 75 76 82 public String toString() 83 { 84 return "CREATE SCHEMA " + schemaName; 87 } 88 89 91 92 99 public void executeConstantAction( Activation activation ) 100 throws StandardException 101 { 102 LanguageConnectionContext lcc = activation.getLanguageConnectionContext(); 103 DataDictionary dd = lcc.getDataDictionary(); 104 TransactionController tc = lcc.getTransactionExecute(); 105 DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator(); 106 107 SchemaDescriptor sd = dd.getSchemaDescriptor(schemaName, lcc.getTransactionExecute(), false); 108 109 if ((sd != null) && (sd.getUUID() != null)) 112 { 113 throw StandardException.newException(SQLState.LANG_OBJECT_ALREADY_EXISTS, "Schema" , schemaName); 114 } 115 116 UUID tmpSchemaId = dd.getUUIDFactory().createUUID(); 117 118 124 String thisAid = aid; 125 if (thisAid == null) 126 { 127 thisAid = lcc.getAuthorizationId(); 128 } 129 130 139 dd.startWriting(lcc); 140 141 sd = ddg.newSchemaDescriptor(schemaName, 142 thisAid, 143 tmpSchemaId); 144 145 dd.addDescriptor(sd, null, DataDictionary.SYSSCHEMAS_CATALOG_NUM, false, tc); 146 } 147 } 148 | Popular Tags |