Class DDUtils
java.lang.Object
org.apache.derby.iapi.sql.dictionary.DDUtils
Static Data dictionary utilities.
- Version:
- 0.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
checkForAnyExistingDeleteConnectionViolations
(DataDictionary dd, TableDescriptor td, int refActionType, Hashtable<String, Integer> newDconnHashTable, String myConstraintName) private static void
checkForMultiplePathInvalidCases
(int currentRefAction, int refActionType, String myConstraintName, String currentRefTableName) static boolean
columnNamesMatch
(String[] columnNames, ColumnDescriptorList cdl) private static StandardException
generateError
(String messageId, String myConstraintName) private static StandardException
generateError
(String messageId, String myConstraintName, int raRule) private static StandardException
generateError
(String messageId, String myConstraintName, String refTableName) static ColumnDescriptorList
getColumnDescriptors
(DataDictionary dd, TableDescriptor td, String[] columnNames) private static int
getCurrentDeleteConnections
(DataDictionary dd, TableDescriptor td, int refActionType, Hashtable<String, Integer> dch, boolean prevNotCascade, boolean findSelfRef) Finds the existing delete connection for the table and the referential actions that will occur and stores the information in the hash table.locateReferencedConstraint
(DataDictionary dd, TableDescriptor td, String myConstraintName, String[] myColumnNames, ConsInfo otherConstraintInfo) private static void
validateDeleteConnection
(DataDictionary dd, TableDescriptor actualTd, TableDescriptor refTd, int refActionType, Hashtable<String, Integer> dch, Hashtable<String, Integer> ech, boolean checkImmediateRefTable, String myConstraintName, boolean prevNotCascade, StringBuffer cycleString, String currentRefTableName, boolean isSelfReferencingFk, int currentSelfRefValue) The following function validates whether the new foreign key relationship violates any restriction on the referential actions.static void
validateReferentialActions
(DataDictionary dd, TableDescriptor td, String myConstraintName, ConsInfo otherConstraintInfo, String[] columnNames)
-
Constructor Details
-
DDUtils
public DDUtils()
-
-
Method Details
-
locateReferencedConstraint
public static ReferencedKeyConstraintDescriptor locateReferencedConstraint(DataDictionary dd, TableDescriptor td, String myConstraintName, String[] myColumnNames, ConsInfo otherConstraintInfo) throws StandardException - Throws:
StandardException
-
getColumnDescriptors
public static ColumnDescriptorList getColumnDescriptors(DataDictionary dd, TableDescriptor td, String[] columnNames) throws StandardException - Throws:
StandardException
-
columnNamesMatch
public static boolean columnNamesMatch(String[] columnNames, ColumnDescriptorList cdl) throws StandardException - Throws:
StandardException
-
validateReferentialActions
public static void validateReferentialActions(DataDictionary dd, TableDescriptor td, String myConstraintName, ConsInfo otherConstraintInfo, String[] columnNames) throws StandardException - Throws:
StandardException
-
getCurrentDeleteConnections
private static int getCurrentDeleteConnections(DataDictionary dd, TableDescriptor td, int refActionType, Hashtable<String, Integer> dch, boolean prevNotCascade, boolean findSelfRef) throws StandardExceptionFinds the existing delete connection for the table and the referential actions that will occur and stores the information in the hash table. HashTable (key , value) = ( table name that this table is delete connected to, referential action that will occur if there is a delete on the table this table connected to [CASCADE, SET NULL, RESTRICT, NO ACTION] )- Throws:
StandardException
-
validateDeleteConnection
private static void validateDeleteConnection(DataDictionary dd, TableDescriptor actualTd, TableDescriptor refTd, int refActionType, Hashtable<String, Integer> dch, Hashtable<String, throws StandardExceptionInteger> ech, boolean checkImmediateRefTable, String myConstraintName, boolean prevNotCascade, StringBuffer cycleString, String currentRefTableName, boolean isSelfReferencingFk, int currentSelfRefValue) The following function validates whether the new foreign key relationship violates any restriction on the referential actions. The current refAction implementation does not allow cases where we can possible land up having multiple action for the same row in a table. This could happen because the user can possibly define different actions through multiple foreign key paths. The following function throws an error while creating foreign keys if the new releationship leads to any such conditions. NOTE: The SQL99 standard also does not clearly says what we are supposed to do in these cases. Our implementation just follows what is done in DB2 and throws error messaged similar to DB2 (sql0632N, sql0633N, sql0634N).- Throws:
StandardException
-
checkForMultiplePathInvalidCases
private static void checkForMultiplePathInvalidCases(int currentRefAction, int refActionType, String myConstraintName, String currentRefTableName) throws StandardException - Throws:
StandardException
-
checkForAnyExistingDeleteConnectionViolations
private static void checkForAnyExistingDeleteConnectionViolations(DataDictionary dd, TableDescriptor td, int refActionType, Hashtable<String, Integer> newDconnHashTable, String myConstraintName) throws StandardException- Throws:
StandardException
-
generateError
-
generateError
private static StandardException generateError(String messageId, String myConstraintName, int raRule) -
generateError
private static StandardException generateError(String messageId, String myConstraintName, String refTableName)
-