Top Description Constructors Methods
org.apache.derby.iapi.sql.dictionary

public Class DDUtils

extends Object
Class Inheritance
Imports
java.util.Enumeration, .Hashtable, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.sql.StatementType

Static Data dictionary utilities.
Version
0.1

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private 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)

public static boolean
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)

public static ColumnDescriptorList
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.

public static ReferencedKeyConstraintDescriptor
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.

public static void
validateReferentialActions(DataDictionary dd, TableDescriptor td, String myConstraintName, ConsInfo otherConstraintInfo, String[] columnNames)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DDUtilsback to summary
public DDUtils()

Method Detail

checkForAnyExistingDeleteConnectionViolationsback to summary
private static void checkForAnyExistingDeleteConnectionViolations(DataDictionary dd, TableDescriptor td, int refActionType, Hashtable<String, Integer> newDconnHashTable, String myConstraintName) throws StandardException
Annotations
@SuppressWarnings:UseOfObsoleteCollectionType
checkForMultiplePathInvalidCasesback to summary
private static void checkForMultiplePathInvalidCases(int currentRefAction, int refActionType, String myConstraintName, String currentRefTableName) throws StandardException
columnNamesMatchback to summary
public static boolean columnNamesMatch(String[] columnNames, ColumnDescriptorList cdl) throws StandardException
generateErrorback to summary
private static StandardException generateError(String messageId, String myConstraintName)
generateErrorback to summary
private static StandardException generateError(String messageId, String myConstraintName, int raRule)
generateErrorback to summary
private static StandardException generateError(String messageId, String myConstraintName, String refTableName)
getColumnDescriptorsback to summary
public static ColumnDescriptorList getColumnDescriptors(DataDictionary dd, TableDescriptor td, String[] columnNames) throws StandardException
getCurrentDeleteConnectionsback to summary
private static int getCurrentDeleteConnections(DataDictionary dd, TableDescriptor td, int refActionType, Hashtable<String, 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] )

Annotations
@SuppressWarnings:UseOfObsoleteCollectionType
locateReferencedConstraintback to summary
public static ReferencedKeyConstraintDescriptor locateReferencedConstraint(DataDictionary dd, TableDescriptor td, String myConstraintName, String[] myColumnNames, ConsInfo otherConstraintInfo) throws StandardException
validateDeleteConnectionback to summary
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) 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).

Annotations
@SuppressWarnings:UseOfObsoleteCollectionType
validateReferentialActionsback to summary
public static void validateReferentialActions(DataDictionary dd, TableDescriptor td, String myConstraintName, ConsInfo otherConstraintInfo, String[] columnNames) throws StandardException
Annotations
@SuppressWarnings:UseOfObsoleteCollectionType