Class ReferencedKeyRIChecker
java.lang.Object
org.apache.derby.impl.sql.execute.GenericRIChecker
org.apache.derby.impl.sql.execute.ReferencedKeyRIChecker
A Referential Integrity checker for a change
to a referenced key (primary or unique). Makes
sure that all the referenced key row is not
referenced by any of its foreign keys. see
ForeignKeyRIChecker for the code that validates
changes to foreign keys.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BackingStoreHashtable
We save away keys with a counter in this hash table, so we know how many instances of a key (duplicates) have been deleted/modified, cf usage inpostCheck()
.private final DataValueDescriptor[]
Key mapping used when storing referenced (PK, unique) keys under deferred row processing and deferred key constraint (PK, unique).private ScanController
Fields inherited from class org.apache.derby.impl.sql.execute.GenericRIChecker
deferredRowsHashTable, fkDcocis, fkInfo, fkScocis, identityMap, indexQualifierRow, lcc, numColumns, refDcoci, refScoci, tc
-
Constructor Summary
ConstructorsConstructorDescriptionReferencedKeyRIChecker
(LanguageConnectionContext lcc, TransactionController tc, FKInfo fkinfo) -
Method Summary
Modifier and TypeMethodDescription(package private) void
close()
Clean up all scan controllers and other resources(package private) void
doCheck
(Activation a, ExecRow row, boolean restrictCheckOnly, int deferredRowReq) Check that the row either has a null column(s), or has no corresponding foreign keys.private boolean
isDuplicated
(ExecRow row, int deferredRowReq) private boolean
isDuplicated
(DataValueDescriptor[] key, long deferredRowReq) void
Check that we have at least one more row in the referenced table table containing a key than the number of projected deletes of that key.private void
rememberKey
(ExecRow rememberRow) Remember the deletion of this key, it may cause a RESTRICT foreign key violation, cf. logic in @{link #postCheck}.Methods inherited from class org.apache.derby.impl.sql.execute.GenericRIChecker
getRICheckIsolationLevel, getScanController, isAnyFieldNull
-
Field Details
-
refKeyIndexScan
-
refKey
Key mapping used when storing referenced (PK, unique) keys under deferred row processing and deferred key constraint (PK, unique). -
deletedKeys
We save away keys with a counter in this hash table, so we know how many instances of a key (duplicates) have been deleted/modified, cf usage inpostCheck()
. Initialized on demand.
-
-
Constructor Details
-
ReferencedKeyRIChecker
ReferencedKeyRIChecker(LanguageConnectionContext lcc, TransactionController tc, FKInfo fkinfo) throws StandardException - Parameters:
lcc
- the language connection contexttc
- the xact controllerfkinfo
- the foreign key information- Throws:
StandardException
- Thrown on failure
-
-
Method Details
-
doCheck
void doCheck(Activation a, ExecRow row, boolean restrictCheckOnly, int deferredRowReq) throws StandardException Check that the row either has a null column(s), or has no corresponding foreign keys.If a foreign key is found, an exception is thrown. If not, the scan is closed.
- Specified by:
doCheck
in classGenericRIChecker
- Parameters:
a
- the activationrow
- the row to checkrestrictCheckOnly
-true
if the check is relevant only for RESTRICTED referential action.deferredRowReq
- For referenced keys: The required number of duplicates that need to be present. Only used ifpostCheck==false
.- Throws:
StandardException
- on unexpected error, or on a primary/unique key violation
-
rememberKey
Remember the deletion of this key, it may cause a RESTRICT foreign key violation, cf. logic in @{link #postCheck}.- Parameters:
rememberRow
-- Throws:
StandardException
-
postCheck
Check that we have at least one more row in the referenced table table containing a key than the number of projected deletes of that key. Only used when the referenced constraint id deferred and with RESTRICT mode- Throws:
StandardException
- Standard error policy
-
isDuplicated
- Throws:
StandardException
-
isDuplicated
private boolean isDuplicated(DataValueDescriptor[] key, long deferredRowReq) throws StandardException - Throws:
StandardException
-
close
Clean up all scan controllers and other resources- Overrides:
close
in classGenericRIChecker
- Throws:
StandardException
- on error
-