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 import org.apache.derby.iapi.sql.StatementType; 34 35 43 public class ReferencedKeyRIChecker extends GenericRIChecker 44 { 45 51 ReferencedKeyRIChecker(TransactionController tc, FKInfo fkinfo) 52 throws StandardException 53 { 54 super(tc, fkinfo); 55 56 if (SanityManager.DEBUG) 57 { 58 if (fkInfo.type != FKInfo.REFERENCED_KEY) 59 { 60 SanityManager.THROWASSERT("invalid type "+fkInfo.type+ 61 " for a ReferencedKeyRIChecker"); 62 } 63 } 64 } 65 66 78 void doCheck(ExecRow row, boolean restrictCheckOnly) throws StandardException 79 { 80 84 if (isAnyFieldNull(row)) 85 { 86 return; 87 } 88 89 93 ScanController scan; 94 95 for (int i = 0; i < fkInfo.fkConglomNumbers.length; i++) 96 { 97 98 if(restrictCheckOnly) 99 { 100 if(fkInfo.raRules[i] != StatementType.RA_RESTRICT) 101 continue; 102 } 103 104 scan = getScanController(fkInfo.fkConglomNumbers[i], fkScocis[i], fkDcocis[i], row); 105 if (scan.next()) 106 { 107 close(); 108 StandardException se = StandardException.newException(SQLState.LANG_FK_VIOLATION, fkInfo.fkConstraintNames[i], 109 fkInfo.tableName, 110 StatementUtil.typeName(fkInfo.stmtType), 111 RowUtil.toString(row, fkInfo.colArray)); 112 113 throw se; 114 } 115 118 scan.next(); 119 } 120 } 121 } 122 123 124 125 126 127 | Popular Tags |