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 27 import org.apache.derby.iapi.sql.StatementUtil; 28 import org.apache.derby.iapi.sql.execute.ExecRow; 29 import org.apache.derby.iapi.sql.execute.ExecIndexRow; 30 import org.apache.derby.iapi.reference.SQLState; 31 import org.apache.derby.iapi.store.access.ScanController; 32 import org.apache.derby.iapi.store.access.TransactionController; 33 34 41 public class ForeignKeyRIChecker extends GenericRIChecker 42 { 43 49 ForeignKeyRIChecker(TransactionController tc, FKInfo fkinfo) 50 throws StandardException 51 { 52 super(tc, fkinfo); 53 54 if (SanityManager.DEBUG) 55 { 56 if (fkInfo.type != FKInfo.FOREIGN_KEY) 57 { 58 SanityManager.THROWASSERT("invalid type "+fkInfo.type+" for a ForeignKeyRIChecker"); 59 } 60 } 61 } 62 63 76 void doCheck(ExecRow row, boolean restrictCheckOnly) throws StandardException 77 { 78 79 if(restrictCheckOnly) return; 81 82 86 if (isAnyFieldNull(row)) 87 { 88 return; 89 } 90 91 95 ScanController scan = getScanController(fkInfo.refConglomNumber, refScoci, refDcoci, row); 96 if (!scan.next()) 97 { 98 close(); 99 StandardException se = StandardException.newException(SQLState.LANG_FK_VIOLATION, fkInfo.fkConstraintNames[0], 100 fkInfo.tableName, 101 StatementUtil.typeName(fkInfo.stmtType), 102 RowUtil.toString(row, fkInfo.colArray)); 103 104 throw se; 105 } 106 107 112 } 113 114 124 int getRICheckIsolationLevel() 125 { 126 return TransactionController.ISOLATION_READ_COMMITTED; 127 } 128 } 129 | Popular Tags |