Class ConstraintDefinitionNode
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.QueryTreeNode
-
- org.apache.derby.impl.sql.compile.TableElementNode
-
- org.apache.derby.impl.sql.compile.ConstraintDefinitionNode
-
- All Implemented Interfaces:
Visitable
- Direct Known Subclasses:
FKConstraintDefinitionNode
public class ConstraintDefinitionNode extends TableElementNode
A ConstraintDefintionNode is a class for all nodes that can represent constraint definitions.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) ProviderListapl(package private) java.lang.StringbackingIndexName(package private) UUIDbackingIndexUUIDprivate intbehaviorprivate boolean[]characteristicsboolean[3]: {deferrable?(package private) ValueNodecheckCondition(package private) ResultColumnListcolumnListprivate TableNameconstraintName(package private) java.lang.StringconstraintTextprotected intconstraintTypestatic booleanDEFERRABLE_DEFAULTstatic booleanENFORCED_DEFAULTstatic booleanINITIALLY_DEFERRED_DEFAULTprotected java.util.Propertiesproperties(package private) UUIDFactoryuuidFactoryprivate intverifyType-
Fields inherited from class org.apache.derby.impl.sql.compile.TableElementNode
AT_ADD_CHECK_CONSTRAINT, AT_ADD_FOREIGN_KEY_CONSTRAINT, AT_ADD_PRIMARY_KEY_CONSTRAINT, AT_ADD_UNIQUE_CONSTRAINT, AT_DROP_COLUMN, AT_DROP_CONSTRAINT, AT_MODIFY_COLUMN, AT_MODIFY_CONSTRAINT, AT_UNKNOWN, elementType, name
-
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
-
-
Constructor Summary
Constructors Constructor Description ConstraintDefinitionNode(TableName constraintName, int constraintType, ResultColumnList rcl, java.util.Properties properties, ValueNode checkCondition, java.lang.String constraintText, int behavior, int verifyType, ContextManager cm)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidacceptChildren(Visitor v)Accept a visitor on all child nodes.(package private) voidbind(DDLStatementNode ddlNode, DataDictionary dd)Bind this constraint definition.(package private) ProviderListgetAuxiliaryProviderList()Return the auxiliary provider list.(package private) java.lang.StringgetBackingIndexName(DataDictionary dd)Gets a unique name for the backing index for this constraint of the form SQLyymmddhhmmssxxn yy - year, mm - month, dd - day of month, hh - hour, mm - minute, ss - second, xx - the first 2 digits of millisec because we don't have enough space to keep the exact millisec value, n - number between 0-9(package private) UUIDgetBackingIndexUUID()Allocates a UUID if one doesn't already exist for the index backing this constraint.(package private) boolean[]getCharacteristics()(package private) ValueNodegetCheckCondition()Get the check condition from this table constraint.(package private) ResultColumnListgetColumnList()Get the column list from this node.(package private) java.lang.StringgetConstraintMoniker()Get the name of the constraint.(package private) java.lang.StringgetConstraintText()Get the text of the constraint.(package private) intgetConstraintType()Get the constraint type(package private) intgetDropBehavior()Return the behavior of this constraint.(package private) java.lang.StringgetDropSchemaName()To support dropping existing constraints that may have mismatched schema names we need to support ALTER TABLE S1.T DROP CONSTRAINT S2.C.private static ModuleFactorygetMonitor()Privileged Monitor lookup.(package private) java.util.PropertiesgetProperties()Get the optional properties for the backing index to this constraint.(package private) intgetReferenceCount()Get the count of enabled fks that reference this constraintprivate UUIDFactorygetUUIDFactory()Get the UUID factory(package private) intgetVerifyType()(package private) booleanhasCheckConstraint()Does this element have a check constraint.(package private) booleanhasConstraint()Does this element have a constraint on it.(package private) booleanhasForeignKeyConstraint()Is this a foreign key constraint.(package private) booleanhasPrimaryKeyConstraint()Is this a primary key constraint.(package private) booleanhasUniqueKeyConstraint()Is this a unique key constraint.(package private) booleanisEnabled()Is this constraint enabled.(package private) booleanisReferenced()Is this constraint referenced.(package private) voidqualifyNames()Qualify all SQL object names in a CHECK constraint with schema name.(package private) booleanrequiresBackingIndex()Does this constraint require a backing index for its implementation?(package private) booleanrequiresUniqueIndex()Is this a primary key or unique constraint?(package private) voidsetAuxiliaryProviderList(ProviderList apl)Set the auxiliary provider list.(package private) voidsetCharacteristics(boolean[] cc)(package private) voidsetCheckCondition(ValueNode checkCondition)Set the check condition for this table constraint.(package private) voidsetColumnList(ResultColumnList columnList)Set the column list for this node.(package private) voidsetProperties(java.util.Properties properties)Set the optional properties for the backing index to this constraint.java.lang.StringtoString()Convert this object to a String.-
Methods inherited from class org.apache.derby.impl.sql.compile.TableElementNode
getElementType, getName
-
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, printSubNodes, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
-
-
-
-
Field Detail
-
constraintName
private TableName constraintName
-
constraintType
protected int constraintType
-
properties
protected java.util.Properties properties
-
apl
ProviderList apl
-
uuidFactory
UUIDFactory uuidFactory
-
backingIndexName
java.lang.String backingIndexName
-
backingIndexUUID
UUID backingIndexUUID
-
columnList
ResultColumnList columnList
-
constraintText
java.lang.String constraintText
-
checkCondition
ValueNode checkCondition
-
behavior
private int behavior
-
verifyType
private int verifyType
-
DEFERRABLE_DEFAULT
public static final boolean DEFERRABLE_DEFAULT
- See Also:
- Constant Field Values
-
INITIALLY_DEFERRED_DEFAULT
public static final boolean INITIALLY_DEFERRED_DEFAULT
- See Also:
- Constant Field Values
-
ENFORCED_DEFAULT
public static final boolean ENFORCED_DEFAULT
- See Also:
- Constant Field Values
-
characteristics
private boolean[] characteristics
boolean[3]: {deferrable?, initiallyDeferred?, enforced?}
-
-
Constructor Detail
-
ConstraintDefinitionNode
ConstraintDefinitionNode(TableName constraintName, int constraintType, ResultColumnList rcl, java.util.Properties properties, ValueNode checkCondition, java.lang.String constraintText, int behavior, int verifyType, ContextManager cm)
-
-
Method Detail
-
setCharacteristics
void setCharacteristics(boolean[] cc)
-
getCharacteristics
boolean[] getCharacteristics()
-
toString
public java.lang.String toString()
Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.- Overrides:
toStringin classTableElementNode- Returns:
- This object as a String
-
bind
void bind(DDLStatementNode ddlNode, DataDictionary dd) throws StandardException
Bind this constraint definition.- Parameters:
ddlNode- the create or alter table nodedd- the dd- Throws:
StandardException- on error
-
getConstraintMoniker
java.lang.String getConstraintMoniker()
Get the name of the constraint. If the user didn't provide one, we make one up. This allows Replication to agree with the core compiler on the names of constraints.- Returns:
- constraint name
-
getDropSchemaName
java.lang.String getDropSchemaName()
To support dropping existing constraints that may have mismatched schema names we need to support ALTER TABLE S1.T DROP CONSTRAINT S2.C. If a constraint name was specified this returns it, otherwise it returns null.
-
getBackingIndexUUID
UUID getBackingIndexUUID()
Allocates a UUID if one doesn't already exist for the index backing this constraint. This allows Replication logic to agree with the core compiler on what the UUIDs of indices are.- Returns:
- a UUID for the constraint. allocates one if this is the first time this method is called.
-
getBackingIndexName
java.lang.String getBackingIndexName(DataDictionary dd)
Gets a unique name for the backing index for this constraint of the form SQLyymmddhhmmssxxn yy - year, mm - month, dd - day of month, hh - hour, mm - minute, ss - second, xx - the first 2 digits of millisec because we don't have enough space to keep the exact millisec value, n - number between 0-9- Returns:
- name of backing index
-
setAuxiliaryProviderList
void setAuxiliaryProviderList(ProviderList apl)
Set the auxiliary provider list.- Parameters:
apl- The new auxiliary provider list.
-
getAuxiliaryProviderList
ProviderList getAuxiliaryProviderList()
Return the auxiliary provider list.- Returns:
- The auxiliary provider list.
-
hasPrimaryKeyConstraint
boolean hasPrimaryKeyConstraint()
Is this a primary key constraint.- Overrides:
hasPrimaryKeyConstraintin classTableElementNode- Returns:
- boolean Whether or not this is a primary key constraint
-
hasUniqueKeyConstraint
boolean hasUniqueKeyConstraint()
Is this a unique key constraint.- Overrides:
hasUniqueKeyConstraintin classTableElementNode- Returns:
- boolean Whether or not this is a unique key constraint
-
hasForeignKeyConstraint
boolean hasForeignKeyConstraint()
Is this a foreign key constraint.- Overrides:
hasForeignKeyConstraintin classTableElementNode- Returns:
- boolean Whether or not this is a unique key constraint
-
hasCheckConstraint
boolean hasCheckConstraint()
Does this element have a check constraint.- Overrides:
hasCheckConstraintin classTableElementNode- Returns:
- boolean Whether or not this element has a check constraint
-
hasConstraint
boolean hasConstraint()
Does this element have a constraint on it.- Overrides:
hasConstraintin classTableElementNode- Returns:
- boolean Whether or not this element has a constraint on it
-
requiresBackingIndex
boolean requiresBackingIndex()
Does this constraint require a backing index for its implementation?- Returns:
- boolean
trueif this constraint requires a backing index, i.e. if is a foreign key, primary key or unique key constraint
-
requiresUniqueIndex
boolean requiresUniqueIndex()
Is this a primary key or unique constraint?- Returns:
- boolean
trueif this is a primary key or unique key constraint
-
getConstraintType
int getConstraintType()
Get the constraint type- Returns:
- constraintType The constraint type.
-
setProperties
void setProperties(java.util.Properties properties)
Set the optional properties for the backing index to this constraint.- Parameters:
properties- The optional Properties for this constraint.
-
getProperties
java.util.Properties getProperties()
Get the optional properties for the backing index to this constraint.- Returns:
- The optional properties for the backing index to this constraint
-
isReferenced
boolean isReferenced()
Is this constraint referenced.- Returns:
- true/false
-
getReferenceCount
int getReferenceCount()
Get the count of enabled fks that reference this constraint- Returns:
- the number
-
isEnabled
boolean isEnabled()
Is this constraint enabled.- Returns:
- true/false
-
getColumnList
ResultColumnList getColumnList()
Get the column list from this node.- Returns:
- ResultColumnList The column list from this table constraint.
-
setColumnList
void setColumnList(ResultColumnList columnList)
Set the column list for this node. This is useful for check constraints where the list of referenced columns is built at bind time.- Parameters:
columnList- The new columnList.
-
getCheckCondition
ValueNode getCheckCondition()
Get the check condition from this table constraint.- Returns:
- The check condition from this node.
-
setCheckCondition
void setCheckCondition(ValueNode checkCondition)
Set the check condition for this table constraint.- Parameters:
checkCondition- The check condition
-
getConstraintText
java.lang.String getConstraintText()
Get the text of the constraint. (Only meaningful for check constraints.)- Returns:
- The constraint text.
-
getDropBehavior
int getDropBehavior()
Return the behavior of this constraint. SeeStatementType.DROP_CASCADEetc.- Returns:
- the behavior
-
getVerifyType
int getVerifyType()
- Returns:
- the expected type of the constraint, DataDictionary.DROP_CONSTRAINT if the constraint is to be dropped without checking its type.
-
getUUIDFactory
private UUIDFactory getUUIDFactory()
Get the UUID factory- Returns:
- the UUID factory
-
acceptChildren
void acceptChildren(Visitor v) throws StandardException
Description copied from class:QueryTreeNodeAccept a visitor on all child nodes. All sub-classes that add fields that should be visited, should override this method and callaccept(v)on all visitable fields, as well assuper.acceptChildren(v)to make sure all visitable fields defined by the super-class are accepted too.- Overrides:
acceptChildrenin classQueryTreeNode- Parameters:
v- the visitor- Throws:
StandardException- on errors raised by the visitor
-
qualifyNames
void qualifyNames() throws StandardExceptionQualify all SQL object names in a CHECK constraint with schema name.- Throws:
StandardException- if an error occurs
-
getMonitor
private static ModuleFactory getMonitor()
Privileged Monitor lookup. Must be private so that user code can't call this entry point.
-
-