Class DDUtils
- java.lang.Object
-
- org.apache.derby.iapi.sql.dictionary.DDUtils
-
public class DDUtils extends java.lang.Object
Static Data dictionary utilities.- Version:
- 0.1
-
-
Constructor Summary
Constructors Constructor Description DDUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
checkForAnyExistingDeleteConnectionViolations(DataDictionary dd, TableDescriptor td, int refActionType, java.util.Hashtable<java.lang.String,java.lang.Integer> newDconnHashTable, java.lang.String myConstraintName)
private static void
checkForMultiplePathInvalidCases(int currentRefAction, int refActionType, java.lang.String myConstraintName, java.lang.String currentRefTableName)
static boolean
columnNamesMatch(java.lang.String[] columnNames, ColumnDescriptorList cdl)
private static StandardException
generateError(java.lang.String messageId, java.lang.String myConstraintName)
private static StandardException
generateError(java.lang.String messageId, java.lang.String myConstraintName, int raRule)
private static StandardException
generateError(java.lang.String messageId, java.lang.String myConstraintName, java.lang.String refTableName)
static ColumnDescriptorList
getColumnDescriptors(DataDictionary dd, TableDescriptor td, java.lang.String[] columnNames)
private static int
getCurrentDeleteConnections(DataDictionary dd, TableDescriptor td, int refActionType, java.util.Hashtable<java.lang.String,java.lang.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.static ReferencedKeyConstraintDescriptor
locateReferencedConstraint(DataDictionary dd, TableDescriptor td, java.lang.String myConstraintName, java.lang.String[] myColumnNames, ConsInfo otherConstraintInfo)
private static void
validateDeleteConnection(DataDictionary dd, TableDescriptor actualTd, TableDescriptor refTd, int refActionType, java.util.Hashtable<java.lang.String,java.lang.Integer> dch, java.util.Hashtable<java.lang.String,java.lang.Integer> ech, boolean checkImmediateRefTable, java.lang.String myConstraintName, boolean prevNotCascade, java.lang.StringBuffer cycleString, java.lang.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, java.lang.String myConstraintName, ConsInfo otherConstraintInfo, java.lang.String[] columnNames)
-
-
-
Method Detail
-
locateReferencedConstraint
public static ReferencedKeyConstraintDescriptor locateReferencedConstraint(DataDictionary dd, TableDescriptor td, java.lang.String myConstraintName, java.lang.String[] myColumnNames, ConsInfo otherConstraintInfo) throws StandardException
- Throws:
StandardException
-
getColumnDescriptors
public static ColumnDescriptorList getColumnDescriptors(DataDictionary dd, TableDescriptor td, java.lang.String[] columnNames) throws StandardException
- Throws:
StandardException
-
columnNamesMatch
public static boolean columnNamesMatch(java.lang.String[] columnNames, ColumnDescriptorList cdl) throws StandardException
- Throws:
StandardException
-
validateReferentialActions
public static void validateReferentialActions(DataDictionary dd, TableDescriptor td, java.lang.String myConstraintName, ConsInfo otherConstraintInfo, java.lang.String[] columnNames) throws StandardException
- Throws:
StandardException
-
getCurrentDeleteConnections
private static int getCurrentDeleteConnections(DataDictionary dd, TableDescriptor td, int refActionType, java.util.Hashtable<java.lang.String,java.lang.Integer> dch, boolean prevNotCascade, boolean findSelfRef) throws StandardException
Finds 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, java.util.Hashtable<java.lang.String,java.lang.Integer> dch, java.util.Hashtable<java.lang.String,java.lang.Integer> ech, boolean checkImmediateRefTable, java.lang.String myConstraintName, boolean prevNotCascade, java.lang.StringBuffer cycleString, java.lang.String currentRefTableName, boolean isSelfReferencingFk, int currentSelfRefValue) throws StandardException
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, java.lang.String myConstraintName, java.lang.String currentRefTableName) throws StandardException
- Throws:
StandardException
-
checkForAnyExistingDeleteConnectionViolations
private static void checkForAnyExistingDeleteConnectionViolations(DataDictionary dd, TableDescriptor td, int refActionType, java.util.Hashtable<java.lang.String,java.lang.Integer> newDconnHashTable, java.lang.String myConstraintName) throws StandardException
- Throws:
StandardException
-
generateError
private static StandardException generateError(java.lang.String messageId, java.lang.String myConstraintName)
-
generateError
private static StandardException generateError(java.lang.String messageId, java.lang.String myConstraintName, int raRule)
-
generateError
private static StandardException generateError(java.lang.String messageId, java.lang.String myConstraintName, java.lang.String refTableName)
-
-