Class Constraint

    • Field Detail

      • table

        protected Table table
        The table for which this constraint is defined.
    • Constructor Detail

      • Constraint

        Constraint​(Schema schema,
                   int id,
                   java.lang.String name,
                   Table table)
    • Method Detail

      • getConstraintType

        public abstract Constraint.Type getConstraintType()
        The constraint type name
        Returns:
        the name
      • checkRow

        public abstract void checkRow​(SessionLocal session,
                                      Table t,
                                      Row oldRow,
                                      Row newRow)
        Check if this row fulfils the constraint. This method throws an exception if not.
        Parameters:
        session - the session
        t - the table
        oldRow - the old row
        newRow - the new row
      • usesIndex

        public abstract boolean usesIndex​(Index index)
        Check if this constraint needs the specified index.
        Parameters:
        index - the index
        Returns:
        true if the index is used
      • setIndexOwner

        public abstract void setIndexOwner​(Index index)
        This index is now the owner of the specified index.
        Parameters:
        index - the index
      • getReferencedColumns

        public abstract java.util.HashSet<Column> getReferencedColumns​(Table table)
        Get all referenced columns.
        Parameters:
        table - the table
        Returns:
        the set of referenced columns
      • getExpression

        public Expression getExpression()
        Returns the CHECK expression or null.
        Returns:
        the CHECK expression or null.
      • getCreateSQLWithoutIndexes

        public abstract java.lang.String getCreateSQLWithoutIndexes()
        Get the SQL statement to create this constraint.
        Returns:
        the SQL statement
      • isBefore

        public abstract boolean isBefore()
        Check if this constraint needs to be checked before updating the data.
        Returns:
        true if it must be checked before updating
      • checkExistingData

        public abstract void checkExistingData​(SessionLocal session)
        Check the existing data. This method is called if the constraint is added after data has been inserted into the table.
        Parameters:
        session - the session
      • rebuild

        public abstract void rebuild()
        This method is called after a related table has changed (the table was renamed, or columns have been renamed).
      • getIndex

        public Index getIndex()
        Get the index of this constraint in the source table, or null if no index is used.
        Returns:
        the index
      • getReferencedConstraint

        public ConstraintUnique getReferencedConstraint()
        Returns the referenced unique constraint, or null.
        Returns:
        the referenced unique constraint, or null
      • getType

        public int getType()
        Description copied from class: DbObject
        Get the object type.
        Specified by:
        getType in class DbObject
        Returns:
        the object type
      • getTable

        public Table getTable()
      • getRefTable

        public Table getRefTable()
      • compareTo

        public int compareTo​(Constraint other)
        Specified by:
        compareTo in interface java.lang.Comparable<Constraint>
      • isHidden

        public boolean isHidden()
        Description copied from class: SchemaObject
        Check whether this is a hidden object that doesn't appear in the meta data and in the script, and is not dropped on DROP ALL OBJECTS.
        Overrides:
        isHidden in class SchemaObject
        Returns:
        true if it is hidden
      • isEverything

        public boolean isEverything​(ExpressionVisitor visitor)
        Visit all elements in the constraint.
        Parameters:
        visitor - the visitor
        Returns:
        true if every visited expression returned true, or if there are no expressions