Class DeferredConstraintsMemory.CheckInfo
- Enclosing class:
DeferredConstraintsMemory
-
Field Summary
FieldsFields inherited from class org.apache.derby.impl.sql.execute.DeferredConstraintsMemory.ValidationInfo
infoRows
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCulprits
(List<UUID> newCulprits) boolean
void
possiblyValidateOnReturn
(LanguageConnectionContext lcc, SQLSessionContext nested, SQLSessionContext caller) void
private void
validateCheck
(LanguageConnectionContext lcc, UUID constraintId, boolean rollbackOnError) final void
validateConstraint
(LanguageConnectionContext lcc, UUID constraintId, boolean rollbackOnError) Validate one or more CHECK constraints on a table.
-
Field Details
-
schemaName
-
tableName
-
culprits
-
invalidatedDueToCompress
private boolean invalidatedDueToCompress
-
-
Constructor Details
-
CheckInfo
public CheckInfo(BackingStoreHashtable infoRows, String schemaName, String tableName, List<UUID> culprits)
-
-
Method Details
-
setInvalidatedRowLocations
public void setInvalidatedRowLocations() -
isInvalidated
public boolean isInvalidated() -
addCulprits
-
getCulprints
-
possiblyValidateOnReturn
public void possiblyValidateOnReturn(LanguageConnectionContext lcc, SQLSessionContext nested, SQLSessionContext caller) throws StandardException - Specified by:
possiblyValidateOnReturn
in classDeferredConstraintsMemory.ValidationInfo
- Throws:
StandardException
-
validateConstraint
public final void validateConstraint(LanguageConnectionContext lcc, UUID constraintId, boolean rollbackOnError) throws StandardException Validate one or more CHECK constraints on a table.Implementation note: We remember violations for a row by storing its row location in a disk based hash table, similar to what we do for the index location for primary key and unique constraints. As far as which constraints caused which violations, constraints are only presently remembered as having caused "one or more violations", i.e. for any violating row, we do not know at checking time exactly which constraint caused a problem for that exact row. So, for any given constraint which was violated in the transaction we visit all rows which had one or more violations and check again. This could be improved upon by remembering for each violating row the exact set of constraint(s) that saw a violation. Still, this is much faster than a full table scan in most use cases. We use a special internal query option to achieve this. The row locations may not be usable if Derby does a compress or otherwise makes them invalid. In that case we resort to a full table scan.
- Specified by:
validateConstraint
in classDeferredConstraintsMemory.ValidationInfo
- Parameters:
lcc
- The language connection contextconstraintId
- If notnull
, check only for this constraint. This is used when switching mode to immediate. Ifnull
, we check all check constraints, i.e. at commit or if we haveSET CONSTRAINT ALL IMMEDIATE
.rollbackOnError
- Iftrue
and a violation occurs, throw and exception that will cause rollback.- Throws:
StandardException
- Default error policy- See Also:
-
validateCheck
private void validateCheck(LanguageConnectionContext lcc, UUID constraintId, boolean rollbackOnError) throws StandardException - Throws:
StandardException
-