Class ConstraintConstantAction
java.lang.Object
org.apache.derby.impl.sql.execute.DDLConstantAction
org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction
org.apache.derby.impl.sql.execute.ConstraintConstantAction
- All Implemented Interfaces:
ConstantAction
- Direct Known Subclasses:
AlterConstraintConstantAction, CreateConstraintConstantAction, DropConstraintConstantAction
This class describes actions that are ALWAYS performed for a
constraint creation at Execution time.
- Version:
- 0.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected UUIDprotected Stringprotected intprotected IndexConstantActionprotected UUIDprotected Stringprotected StringFields inherited from class DDLSingleTableConstantAction
tableIdFields inherited from interface ConstantAction
WHEN_MATCHED_THEN_DELETE, WHEN_MATCHED_THEN_UPDATE, WHEN_NOT_MATCHED_THEN_INSERT -
Constructor Summary
ConstructorsConstructorDescriptionConstraintConstantAction(String constraintName, int constraintType, String tableName, UUID tableId, String schemaName, IndexConstantAction indexAction) Make one of these puppies. -
Method Summary
Modifier and TypeMethodDescriptionGet the constraint id of the constraintGet the constraint nameintGet the constraint type.Get the associated index constant action.(package private) static booleanvalidateConstraint(String constraintName, String constraintText, UUID constraintId, TableDescriptor td, LanguageConnectionContext lcc, boolean isCheckConstraint, boolean isInitiallyDeferred) Evaluate a check constraint or not null column constraint.(package private) static voidvalidateFKConstraint(Activation activation, TransactionController tc, DataDictionary dd, ForeignKeyConstraintDescriptor fk, ReferencedKeyConstraintDescriptor refcd, ExecRow indexTemplateRow) Make sure that the foreign key constraint is valid with the existing data in the target table.Methods inherited from class DDLSingleTableConstantAction
dropConglomerate, dropConglomerate, dropConstraint, dropConstraint, dropConstraint, executeConglomReplacement, getConglomReplacementAction, recreateUniqueConstraintBackingIndexAsUniqueWhenNotNullMethods inherited from class DDLConstantAction
addColumnDependencies, adjustUDTDependencies, adjustUDTDependencies, constructToString, getAndCheckSchemaDescriptor, getSchemaDescriptorForCreate, lockTableForDDL, storeConstraintDependenciesOnPrivileges, storeViewTriggerDependenciesOnPrivilegesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ConstantAction
executeConstantAction
-
Field Details
-
constraintName
-
constraintType
protected int constraintType -
tableName
-
schemaName
-
schemaId
-
indexAction
-
constraintId
-
-
Constructor Details
-
ConstraintConstantAction
ConstraintConstantAction(String constraintName, int constraintType, String tableName, UUID tableId, String schemaName, IndexConstantAction indexAction) Make one of these puppies.- Parameters:
constraintName- Constraint name.constraintType- Constraint type.tableName- Table name.tableId- UUID of table.schemaName- schema that table and constraint lives in.indexAction- IndexConstantAction for constraint (if necessary) RESOLVE - the next parameter should go away once we use UUIDs (Generated constraint names will be based off of uuids)
-
-
Method Details
-
getConstraintType
public int getConstraintType()Get the constraint type.- Returns:
- The constraint type
-
getConstraintName
-
getConstraintId
-
getIndexAction
Get the associated index constant action.- Returns:
- the constant action for the backing index
-
validateFKConstraint
static void validateFKConstraint(Activation activation, TransactionController tc, DataDictionary dd, ForeignKeyConstraintDescriptor fk, ReferencedKeyConstraintDescriptor refcd, ExecRow indexTemplateRow) throws StandardException Make sure that the foreign key constraint is valid with the existing data in the target table. Open the table, if there aren't any rows, ok. If there are rows, open a scan on the referenced key with table locking at level 2. Pass in the scans to the BulkRIChecker. If any rows fail, barf.- Parameters:
tc- transaction controllerdd- data dictionaryfk- foreign key constraintrefcd- referenced keyindexTemplateRow- index template row- Throws:
StandardException- on error
-
validateConstraint
static boolean validateConstraint(String constraintName, String constraintText, UUID constraintId, TableDescriptor td, LanguageConnectionContext lcc, boolean isCheckConstraint, boolean isInitiallyDeferred) throws StandardException Evaluate a check constraint or not null column constraint. Generate a query of the form SELECT COUNT(*) FROM t where NOT() and run it by compiling and executing it. Will work ok if the table is empty and query returns null. - Parameters:
constraintName- constraint nameconstraintText- constraint textconstraintId- constraint idtd- referenced tablelcc- the language connection contextisCheckConstraint- the constraint is a check constraintisInitiallyDeferred-trueif the constraint is initially deferred- Returns:
- true if null constraint passes, false otherwise
- Throws:
StandardException- if check constraint fails
-