Class DeferredConstraintsMemory.CheckInfo
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.DeferredConstraintsMemory.ValidationInfo
-
- org.apache.derby.impl.sql.execute.DeferredConstraintsMemory.CheckInfo
-
- Enclosing class:
- DeferredConstraintsMemory
public static class DeferredConstraintsMemory.CheckInfo extends DeferredConstraintsMemory.ValidationInfo
Info needed for check constraints
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<UUID>
culprits
private boolean
invalidatedDueToCompress
private java.lang.String
schemaName
private java.lang.String
tableName
-
Fields inherited from class org.apache.derby.impl.sql.execute.DeferredConstraintsMemory.ValidationInfo
infoRows
-
-
Constructor Summary
Constructors Constructor Description CheckInfo(BackingStoreHashtable infoRows, java.lang.String schemaName, java.lang.String tableName, java.util.List<UUID> culprits)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCulprits(java.util.List<UUID> newCulprits)
java.util.List<UUID>
getCulprints()
boolean
isInvalidated()
void
possiblyValidateOnReturn(LanguageConnectionContext lcc, SQLSessionContext nested, SQLSessionContext caller)
void
setInvalidatedRowLocations()
private void
validateCheck(LanguageConnectionContext lcc, UUID constraintId, boolean rollbackOnError)
void
validateConstraint(LanguageConnectionContext lcc, UUID constraintId, boolean rollbackOnError)
Validate one or more CHECK constraints on a table.
-
-
-
Field Detail
-
schemaName
private final java.lang.String schemaName
-
tableName
private final java.lang.String tableName
-
culprits
private java.util.List<UUID> culprits
-
invalidatedDueToCompress
private boolean invalidatedDueToCompress
-
-
Constructor Detail
-
CheckInfo
public CheckInfo(BackingStoreHashtable infoRows, java.lang.String schemaName, java.lang.String tableName, java.util.List<UUID> culprits)
-
-
Method Detail
-
setInvalidatedRowLocations
public void setInvalidatedRowLocations()
-
isInvalidated
public boolean isInvalidated()
-
addCulprits
public void addCulprits(java.util.List<UUID> newCulprits)
-
getCulprints
public java.util.List<UUID> 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:
ValidateCheckConstraintResultSet
-
validateCheck
private void validateCheck(LanguageConnectionContext lcc, UUID constraintId, boolean rollbackOnError) throws StandardException
- Throws:
StandardException
-
-