Class ReferencedKeyConstraintDescriptor

    • Field Detail

      • constraintType

        private final int constraintType
        public interface to this descriptor:
        1. public boolean hasSelfReferencingFK(ConstraintDescriptorList cdl, int type) throws StandardException;
        2. public ConstraintDescriptorList getForeignKeyConstraints(int type) throws StandardException;
        3. public boolean isReferenced();
        4. public int getReferenceCount();
        5. public int incrementReferenceCount();
        6. public int decrementReferenceCount();
      • referenceCount

        int referenceCount
      • checkedSelfReferencing

        private boolean checkedSelfReferencing
      • hasSelfReferencing

        private boolean hasSelfReferencing
    • Constructor Detail

      • ReferencedKeyConstraintDescriptor

        protected ReferencedKeyConstraintDescriptor​(int constraintType,
                                                    DataDictionary dataDictionary,
                                                    TableDescriptor table,
                                                    java.lang.String constraintName,
                                                    boolean deferrable,
                                                    boolean initiallyDeferred,
                                                    int[] columns,
                                                    UUID constraintId,
                                                    UUID indexId,
                                                    SchemaDescriptor schemaDesc,
                                                    boolean enforced,
                                                    int referenceCount)
        Constructor for a KeyConstraintDescriptorImpl
        Parameters:
        constraintType - The type of the constraint
        dataDictionary - The data dictionary that this descriptor lives in
        table - The descriptor of the table the constraint is on
        constraintName - The name of the constraint.
        deferrable - If the constraint can be deferred.
        initiallyDeferred - If the constraint starts life deferred.
        columns - columns involved in the constraint
        constraintId - UUID of constraint
        indexId - The UUID for the backing index
        schemaDesc - The SchemaDescriptor for the constraint
        enforced - is the constraint enforced?
        referenceCount - number of FKs (enforced only)
    • Method Detail

      • getConstraintType

        public final int getConstraintType()
        Description copied from class: ConstraintDescriptor
        Gets an identifier telling what type of descriptor it is (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).
        Specified by:
        getConstraintType in class ConstraintDescriptor
        Returns:
        An identifier telling what type of descriptor it is (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).
      • hasSelfReferencingFK

        public boolean hasSelfReferencingFK​(ConstraintDescriptorList cdl,
                                            int type)
                                     throws StandardException
        Am I referenced by a FK on the same table?
        Parameters:
        cdl - ConstraintDescriptorList for the table
        type - ConstraintDescriptor.(ENABLED|DISABLED|ALL)
        Returns:
        true/false
        Throws:
        StandardException - on error
      • getNonSelfReferencingFK

        public ConstraintDescriptorList getNonSelfReferencingFK​(int type)
                                                         throws StandardException
        Am I referenced by a FK on another table? Return the list of those foreign constraints.
        Parameters:
        type - ConstraintDescriptor.(ENABLED|DISABLED|ALL)
        Returns:
        list of constraints
        Throws:
        StandardException - on error
      • getForeignKeyConstraints

        public ConstraintDescriptorList getForeignKeyConstraints​(int type)
                                                          throws StandardException
        Get the referencing foreign key constraints
        Parameters:
        type - ConstraintDescriptor.(ENABLED|DISABLED|ALL)
        Returns:
        the list of constraints (ConstraintDescriptorListImpl)
        Throws:
        StandardException - on error
      • isReferenced

        public boolean isReferenced()
        Is this constraint referenced? Returns true if there are enforced fks that reference this constraint.
        Overrides:
        isReferenced in class ConstraintDescriptor
        Returns:
        false
      • getReferenceCount

        public int getReferenceCount()
        Get the number of enforced fks that reference this key.
        Overrides:
        getReferenceCount in class ConstraintDescriptor
        Returns:
        the number of fks
      • incrementReferenceCount

        public int incrementReferenceCount()
        Bump the reference count by one.
        Returns:
        the number of fks
      • decrementReferenceCount

        public int decrementReferenceCount()
        Decrement the reference count by one.
        Returns:
        the number of fks
      • needsToFire

        public boolean needsToFire​(int stmtType,
                                   int[] modifiedCols)
        Does this constraint need to fire on this type of DML? For referenced keys, fire if referenced by a fk, and stmt is delete or bulk insert replace, or stmt is update and columns intersect.
        Specified by:
        needsToFire in class ConstraintDescriptor
        Parameters:
        stmtType - the type of DML (StatementType.INSERT|StatementType.UPDATE|StatementType.DELETE)
        modifiedCols - the columns modified, or null for all
        Returns:
        true/false