1 21 22 package org.apache.derby.impl.sql.catalog; 23 24 import org.apache.derby.iapi.types.TypeId; 25 import org.apache.derby.iapi.sql.dictionary.SystemColumn; 26 import org.apache.derby.catalog.TypeDescriptor; 27 28 import org.apache.derby.iapi.types.DataValueDescriptor; 29 30 import org.apache.derby.iapi.types.DataValueFactory; 31 import org.apache.derby.iapi.types.RowLocation; 32 33 import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory; 34 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor; 35 import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor; 36 import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator; 37 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 38 import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext; 39 import org.apache.derby.iapi.sql.dictionary.KeyConstraintDescriptor; 40 import org.apache.derby.iapi.sql.dictionary.SubKeyConstraintDescriptor; 41 import org.apache.derby.iapi.sql.dictionary.TupleDescriptor; 42 43 import org.apache.derby.iapi.sql.execute.ExecIndexRow; 44 import org.apache.derby.iapi.sql.execute.ExecutionContext; 45 import org.apache.derby.iapi.sql.execute.ExecRow; 46 import org.apache.derby.iapi.sql.execute.ExecutionFactory; 47 48 import org.apache.derby.iapi.error.StandardException; 49 50 import org.apache.derby.iapi.services.sanity.SanityManager; 51 52 import org.apache.derby.iapi.services.monitor.Monitor; 53 import org.apache.derby.catalog.UUID; 54 import org.apache.derby.iapi.services.uuid.UUIDFactory; 55 56 import org.apache.derby.catalog.IndexDescriptor; 57 58 63 64 public class SYSKEYSRowFactory extends CatalogRowFactory 65 { 66 private static final String TABLENAME_STRING = "SYSKEYS"; 67 68 protected static final int SYSKEYS_COLUMN_COUNT = 2; 69 protected static final int SYSKEYS_CONSTRAINTID = 1; 70 protected static final int SYSKEYS_CONGLOMERATEID = 2; 71 72 protected static final int SYSKEYS_INDEX1_ID = 0; 73 74 private static final boolean[] uniqueness = null; 75 76 private static final int[][] indexColumnPositions = 77 { 78 {SYSKEYS_CONSTRAINTID} 79 }; 80 81 private static final String [] uuids = 82 { 83 "80000039-00d0-fd77-3ed8-000a0a0b1900" ,"8000003c-00d0-fd77-3ed8-000a0a0b1900" ,"8000003b-00d0-fd77-3ed8-000a0a0b1900" }; 87 88 94 public SYSKEYSRowFactory(UUIDFactory uuidf, ExecutionFactory ef, DataValueFactory dvf, 95 boolean convertIdToLower) 96 { 97 super(uuidf,ef,dvf,convertIdToLower); 98 initInfo(SYSKEYS_COLUMN_COUNT, TABLENAME_STRING, indexColumnPositions, uniqueness, uuids ); 99 } 100 101 107 114 public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) 115 throws StandardException 116 { 117 DataValueDescriptor col; 118 ExecRow row; 119 UUID oid; 120 String constraintID = null; 121 String conglomerateID = null; 122 123 if (td != null) 124 { 125 KeyConstraintDescriptor constraint = (KeyConstraintDescriptor)td; 126 127 131 oid = constraint.getUUID(); 132 constraintID = oid.toString(); 133 134 conglomerateID = constraint.getIndexUUIDString(); 135 } 136 137 138 139 142 143 144 row = getExecutionFactory().getValueRow(SYSKEYS_COLUMN_COUNT); 145 146 147 row.setColumn(SYSKEYS_CONSTRAINTID, dvf.getCharDataValue(constraintID)); 148 149 row.setColumn(SYSKEYS_CONGLOMERATEID, dvf.getCharDataValue(conglomerateID)); 150 151 return row; 152 } 153 154 155 156 162 171 public TupleDescriptor buildDescriptor( 172 ExecRow row, 173 TupleDescriptor parentTupleDescriptor, 174 DataDictionary dd ) 175 throws StandardException 176 { 177 SubKeyConstraintDescriptor keyDesc = null; 178 179 if (SanityManager.DEBUG) 180 { 181 SanityManager.ASSERT( 182 row.nColumns() == SYSKEYS_COLUMN_COUNT, 183 "Wrong number of columns for a SYSKEYS row"); 184 } 185 186 DataValueDescriptor col; 187 DataDescriptorGenerator ddg; 188 UUID constraintUUID; 189 UUID conglomerateUUID; 190 String constraintUUIDString; 191 String conglomerateUUIDString; 192 193 ddg = dd.getDataDescriptorGenerator(); 194 195 196 col = row.getColumn(SYSKEYS_CONSTRAINTID); 197 constraintUUIDString = col.getString(); 198 constraintUUID = getUUIDFactory().recreateUUID(constraintUUIDString); 199 200 201 col = row.getColumn(SYSKEYS_CONGLOMERATEID); 202 conglomerateUUIDString = col.getString(); 203 conglomerateUUID = getUUIDFactory().recreateUUID(conglomerateUUIDString); 204 205 206 207 keyDesc = new SubKeyConstraintDescriptor( 208 constraintUUID, 209 conglomerateUUID); 210 return keyDesc; 211 } 212 213 219 public SystemColumn[] buildColumnList() 220 { 221 int index = 0; 222 SystemColumn[] columnList = new SystemColumn[SYSKEYS_COLUMN_COUNT]; 223 224 226 columnList[index++] = 227 new SystemColumnImpl( 228 convertIdCase( "CONSTRAINTID"), SYSKEYS_CONSTRAINTID, 0, 0, false, "CHAR", true, 36 ); 237 238 columnList[index++] = 239 new SystemColumnImpl( 240 convertIdCase( "CONGLOMERATEID"), SYSKEYS_CONGLOMERATEID, 0, 0, false, "CHAR", true, 36 ); 249 250 return columnList; 251 } 252 253 } 254 | Popular Tags |