1 21 22 package org.apache.derby.impl.sql.catalog; 23 24 import org.apache.derby.iapi.types.DataValueDescriptor; 25 26 import org.apache.derby.iapi.types.DataValueFactory; 27 28 import org.apache.derby.iapi.types.TypeId; 29 import org.apache.derby.iapi.types.RowLocation; 30 31 import org.apache.derby.iapi.types.DataTypeDescriptor; 32 33 import org.apache.derby.iapi.sql.dictionary.SystemColumn; 34 import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory; 35 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor; 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.SubCheckConstraintDescriptor; 40 import org.apache.derby.iapi.sql.dictionary.CheckConstraintDescriptor; 41 import org.apache.derby.iapi.sql.dictionary.TupleDescriptor; 42 import org.apache.derby.iapi.sql.dictionary.ViewDescriptor; 43 44 import org.apache.derby.iapi.sql.execute.ExecutionContext; 45 import org.apache.derby.iapi.sql.execute.ExecIndexRow; 46 import org.apache.derby.iapi.sql.execute.ExecRow; 47 import org.apache.derby.iapi.sql.execute.ExecutionFactory; 48 49 import org.apache.derby.iapi.error.StandardException; 50 51 import org.apache.derby.iapi.services.sanity.SanityManager; 52 53 import org.apache.derby.catalog.ReferencedColumns; 54 import org.apache.derby.catalog.TypeDescriptor; 55 import org.apache.derby.iapi.services.uuid.UUIDFactory; 56 import org.apache.derby.catalog.UUID; 57 58 import java.sql.Types ; 59 import java.util.Properties ; 60 61 66 67 class SYSCHECKSRowFactory extends CatalogRowFactory 68 { 69 private static final String TABLENAME_STRING = "SYSCHECKS"; 70 71 private static final int SYSCHECKS_COLUMN_COUNT = 3; 72 private static final int SYSCHECKS_CONSTRAINTID = 1; 73 private static final int SYSCHECKS_CHECKDEFINITION = 2; 74 private static final int SYSCHECKS_REFERENCEDCOLUMNS = 3; 75 76 static final int SYSCHECKS_INDEX1_ID = 0; 77 78 private static final boolean[] uniqueness = null; 80 81 private static final int[][] indexColumnPositions = 82 { 83 {SYSCHECKS_CONSTRAINTID} 84 }; 85 86 private static final String [] uuids = 87 { 88 "80000056-00d0-fd77-3ed8-000a0a0b1900" ,"80000059-00d0-fd77-3ed8-000a0a0b1900" ,"80000058-00d0-fd77-3ed8-000a0a0b1900" }; 92 93 94 95 101 SYSCHECKSRowFactory(UUIDFactory uuidf, ExecutionFactory ef, DataValueFactory dvf, 102 boolean convertIdToLower) 103 { 104 super(uuidf,ef,dvf,convertIdToLower); 105 initInfo(SYSCHECKS_COLUMN_COUNT, TABLENAME_STRING, indexColumnPositions, uniqueness, uuids ); 106 } 107 108 114 123 public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) 124 throws StandardException 125 { 126 DataValueDescriptor col; 127 ExecIndexRow row; 128 ReferencedColumns rcd = null; 129 String checkDefinition = null; 130 String constraintID = null; 131 132 if (td != null) 133 { 134 CheckConstraintDescriptor cd = (CheckConstraintDescriptor)td; 135 139 constraintID = cd.getUUID().toString(); 140 141 checkDefinition = cd.getConstraintText(); 142 143 rcd = cd.getReferencedColumnsDescriptor(); 144 } 145 146 147 row = getExecutionFactory().getIndexableRow(SYSCHECKS_COLUMN_COUNT); 148 149 150 row.setColumn(SYSCHECKS_CONSTRAINTID, dvf.getCharDataValue(constraintID)); 151 152 153 row.setColumn(SYSCHECKS_CHECKDEFINITION, 154 dvf.getLongvarcharDataValue(checkDefinition)); 155 156 159 row.setColumn(SYSCHECKS_REFERENCEDCOLUMNS, 160 dvf.getDataValue(rcd)); 161 162 return row; 163 } 164 165 171 180 public TupleDescriptor buildDescriptor( 181 ExecRow row, 182 TupleDescriptor parentTupleDescriptor, 183 DataDictionary dd ) 184 throws StandardException 185 { 186 SubCheckConstraintDescriptor checkDesc = null; 187 188 if (SanityManager.DEBUG) 189 { 190 SanityManager.ASSERT( 191 row.nColumns() == SYSCHECKS_COLUMN_COUNT, 192 "Wrong number of columns for a SYSCHECKS row"); 193 } 194 195 DataValueDescriptor col; 196 DataDescriptorGenerator ddg; 197 ReferencedColumns referencedColumns; 198 String constraintText; 199 String constraintUUIDString; 200 UUID constraintUUID; 201 202 ddg = dd.getDataDescriptorGenerator(); 203 204 205 col = row.getColumn(SYSCHECKS_CONSTRAINTID); 206 constraintUUIDString = col.getString(); 207 constraintUUID = getUUIDFactory().recreateUUID(constraintUUIDString); 208 209 210 col = row.getColumn(SYSCHECKS_CHECKDEFINITION); 211 constraintText = col.getString(); 212 213 214 col = row.getColumn(SYSCHECKS_REFERENCEDCOLUMNS); 215 referencedColumns = 216 (ReferencedColumns) col.getObject(); 217 218 219 220 checkDesc = new SubCheckConstraintDescriptor( 221 constraintUUID, 222 constraintText, 223 referencedColumns); 224 return checkDesc; 225 } 226 227 233 234 public SystemColumn[] buildColumnList() { 235 236 return new SystemColumn[] { 237 SystemColumnImpl.getUUIDColumn("CONSTRAINTID", false), 238 SystemColumnImpl.getColumn("CHECKDEFINITION", Types.LONGVARCHAR, false), 239 SystemColumnImpl.getJavaColumn("REFERENCEDCOLUMNS", 240 "org.apache.derby.catalog.ReferencedColumns", false) 241 }; 242 } 243 } 244 | Popular Tags |