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 Details

    • schemaName

      private final String schemaName
    • tableName

      private final String tableName
    • culprits

      private List<UUID> culprits
    • invalidatedDueToCompress

      private boolean invalidatedDueToCompress
  • Constructor Details

  • Method Details

    • setInvalidatedRowLocations

      public void setInvalidatedRowLocations()
    • isInvalidated

      public boolean isInvalidated()
    • addCulprits

      public void addCulprits(List<UUID> newCulprits)
    • getCulprints

      public List<UUID> getCulprints()
    • possiblyValidateOnReturn

      public void possiblyValidateOnReturn(LanguageConnectionContext lcc, SQLSessionContext nested, SQLSessionContext caller) throws StandardException
      Specified by:
      possiblyValidateOnReturn in class DeferredConstraintsMemory.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 class DeferredConstraintsMemory.ValidationInfo
      Parameters:
      lcc - The language connection context
      constraintId - If not null, check only for this constraint. This is used when switching mode to immediate. If null, we check all check constraints, i.e. at commit or if we have SET CONSTRAINT ALL IMMEDIATE.
      rollbackOnError - If true 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