Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

public Class ConstraintDefinitionNode

extends TableElementNode
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.compile.FKConstraintDefinitionNode
Imports
java.util.Properties, org.apache.derby.catalog.UUID, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.monitor.ModuleFactory, .Monitor, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.services.uuid.UUIDFactory, org.apache.derby.iapi.sql.compile.Visitor, org.apache.derby.iapi.sql.depend.ProviderList, org.apache.derby.iapi.sql.dictionary.DataDictionary

A ConstraintDefintionNode is a class for all nodes that can represent constraint definitions.

Field Summary

Modifier and TypeField and Description
pack-priv ProviderList
pack-priv String
pack-priv UUID
private int
private boolean[]
characteristics

boolean[3]: {deferrable?, initiallyDeferred?, enforced?}

pack-priv ValueNode
pack-priv ResultColumnList
private TableName
pack-priv String
protected int
public static final boolean
public static final boolean
public static final boolean
protected Properties
pack-priv UUIDFactory
private int
Inherited from org.apache.derby.impl.sql.compile.TableElementNode:
AT_ADD_CHECK_CONSTRAINTAT_ADD_FOREIGN_KEY_CONSTRAINTAT_ADD_PRIMARY_KEY_CONSTRAINTAT_ADD_UNIQUE_CONSTRAINTAT_DROP_COLUMNAT_DROP_CONSTRAINTAT_MODIFY_COLUMNAT_MODIFY_CONSTRAINTAT_UNKNOWNelementTypename

Constructor Summary

AccessConstructor and Description
pack-priv
ConstraintDefinitionNode(TableName constraintName, int constraintType, ResultColumnList rcl, Properties properties, ValueNode checkCondition, String constraintText, int behavior, int verifyType, ContextManager cm)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
acceptChildren(Visitor
the visitor
v
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Accept a visitor on all child nodes.

pack-priv void
bind(DDLStatementNode
the create or alter table node
ddlNode
,
DataDictionary
the dd
dd
)

Bind this constraint definition.

pack-priv ProviderList

Returns:

The auxiliary provider list.
getAuxiliaryProviderList
()

Return the auxiliary provider list.

pack-priv String

Returns:

name of backing index
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

pack-priv UUID

Returns:

a UUID for the constraint. allocates one if this is the first time this method is called.
getBackingIndexUUID
()

Allocates a UUID if one doesn't already exist for the index backing this constraint.

pack-priv boolean[]
pack-priv ValueNode

Returns:

The check condition from this node.
getCheckCondition
()

Get the check condition from this table constraint.

pack-priv ResultColumnList

Returns:

ResultColumnList The column list from this table constraint.
getColumnList
()

Get the column list from this node.

pack-priv String

Returns:

constraint name
getConstraintMoniker
()

Get the name of the constraint.

pack-priv String

Returns:

The constraint text.
getConstraintText
()

Get the text of the constraint.

pack-priv int

Returns:

constraintType The constraint type.
getConstraintType
()

Get the constraint type

pack-priv int

Returns:

the behavior
getDropBehavior
()

Return the behavior of this constraint.

pack-priv 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.

private static ModuleFactory
getMonitor()

Must be private so that user code can't call this entry point.

pack-priv Properties

Returns:

The optional properties for the backing index to this constraint
getProperties
()

Get the optional properties for the backing index to this constraint.

pack-priv int

Returns:

the number
getReferenceCount
()

Get the count of enabled fks that reference this constraint

private UUIDFactory

Returns:

the UUID factory
getUUIDFactory
()

Get the UUID factory

pack-priv int

Returns:

the expected type of the constraint, DataDictionary.DROP_CONSTRAINT if the constraint is to be dropped without checking its type.
getVerifyType
()

pack-priv boolean

Returns:

boolean Whether or not this element has a check constraint
hasCheckConstraint
()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.hasCheckConstraint.

Does this element have a check constraint.

pack-priv boolean

Returns:

boolean Whether or not this element has a constraint on it
hasConstraint
()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.hasConstraint.

Does this element have a constraint on it.

pack-priv boolean

Returns:

boolean Whether or not this is a unique key constraint
hasForeignKeyConstraint
()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.hasForeignKeyConstraint.

Is this a foreign key constraint.

pack-priv boolean

Returns:

boolean Whether or not this is a primary key constraint
hasPrimaryKeyConstraint
()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.hasPrimaryKeyConstraint.

Is this a primary key constraint.

pack-priv boolean

Returns:

boolean Whether or not this is a unique key constraint
hasUniqueKeyConstraint
()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.hasUniqueKeyConstraint.

Is this a unique key constraint.

pack-priv boolean

Returns:

true/false
isEnabled
()

Is this constraint enabled.

pack-priv boolean

Returns:

true/false
isReferenced
()

Is this constraint referenced.

pack-priv void
qualifyNames()

Qualify all SQL object names in a CHECK constraint with schema name.

pack-priv boolean

Returns:

boolean true if this constraint requires a backing index, i.e. if is a foreign key, primary key or unique key constraint
requiresBackingIndex
()

Does this constraint require a backing index for its implementation?

pack-priv boolean

Returns:

boolean true if this is a primary key or unique key constraint
requiresUniqueIndex
()

Is this a primary key or unique constraint?

pack-priv void
setAuxiliaryProviderList(ProviderList
The new auxiliary provider list.
apl
)

Set the auxiliary provider list.

pack-priv void
setCharacteristics(boolean[] cc)

pack-priv void
setCheckCondition(ValueNode
The check condition
checkCondition
)

Set the check condition for this table constraint.

pack-priv void
setColumnList(ResultColumnList
The new columnList.
columnList
)

Set the column list for this node.

pack-priv void
setProperties(Properties
The optional Properties for this constraint.
properties
)

Set the optional properties for the backing index to this constraint.

public String

Returns:

This object as a String
toString
()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.toString.

Convert this object to a String.

Inherited from org.apache.derby.impl.sql.compile.TableElementNode:
getElementTypegetName

Field Detail

aplback to summary
pack-priv ProviderList apl
backingIndexNameback to summary
pack-priv String backingIndexName
backingIndexUUIDback to summary
pack-priv UUID backingIndexUUID
behaviorback to summary
private int behavior
characteristicsback to summary
private boolean[] characteristics

boolean[3]: {deferrable?, initiallyDeferred?, enforced?}

checkConditionback to summary
pack-priv ValueNode checkCondition
columnListback to summary
pack-priv ResultColumnList columnList
constraintNameback to summary
private TableName constraintName
constraintTextback to summary
pack-priv String constraintText
constraintTypeback to summary
protected int constraintType
DEFERRABLE_DEFAULTback to summary
public static final boolean DEFERRABLE_DEFAULT
ENFORCED_DEFAULTback to summary
public static final boolean ENFORCED_DEFAULT
INITIALLY_DEFERRED_DEFAULTback to summary
public static final boolean INITIALLY_DEFERRED_DEFAULT
propertiesback to summary
protected Properties properties
uuidFactoryback to summary
pack-priv UUIDFactory uuidFactory
verifyTypeback to summary
private int verifyType

Constructor Detail

ConstraintDefinitionNodeback to summary
pack-priv ConstraintDefinitionNode(TableName constraintName, int constraintType, ResultColumnList rcl, Properties properties, ValueNode checkCondition, String constraintText, int behavior, int verifyType, ContextManager cm)

Method Detail

acceptChildrenback to summary
pack-priv void acceptChildren(Visitor v) throws StandardException

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Doc from org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Accept a visitor on all child nodes. All sub-classes that add fields that should be visited, should override this method and call accept(v) on all visitable fields, as well as super.acceptChildren(v) to make sure all visitable fields defined by the super-class are accepted too.

Parameters
v:Visitor

the visitor

Annotations
@Override
Exceptions
StandardException:
on errors raised by the visitor
bindback to summary
pack-priv void bind(DDLStatementNode ddlNode, DataDictionary dd) throws StandardException

Bind this constraint definition.

Parameters
ddlNode:DDLStatementNode

the create or alter table node

dd:DataDictionary

the dd

Exceptions
StandardException:
on error
getAuxiliaryProviderListback to summary
pack-priv ProviderList getAuxiliaryProviderList()

Return the auxiliary provider list.

Returns:ProviderList

The auxiliary provider list.

getBackingIndexNameback to summary
pack-priv 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:String

name of backing index

getBackingIndexUUIDback to summary
pack-priv 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:UUID

a UUID for the constraint. allocates one if this is the first time this method is called.

getCharacteristicsback to summary
pack-priv boolean[] getCharacteristics()
getCheckConditionback to summary
pack-priv ValueNode getCheckCondition()

Get the check condition from this table constraint.

Returns:ValueNode

The check condition from this node.

getColumnListback to summary
pack-priv ResultColumnList getColumnList()

Get the column list from this node.

Returns:ResultColumnList

ResultColumnList The column list from this table constraint.

getConstraintMonikerback to summary
pack-priv 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:String

constraint name

getConstraintTextback to summary
pack-priv String getConstraintText()

Get the text of the constraint. (Only meaningful for check constraints.)

Returns:String

The constraint text.

getConstraintTypeback to summary
pack-priv int getConstraintType()

Get the constraint type

Returns:int

constraintType The constraint type.

getDropBehaviorback to summary
pack-priv int getDropBehavior()

Return the behavior of this constraint. See org.apache.derby.iapi.sql.StatementType#DROP_CASCADE etc.

Returns:int

the behavior

getDropSchemaNameback to summary
pack-priv 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.

getMonitorback to summary
private static ModuleFactory getMonitor()

Must be private so that user code can't call this entry point.

getPropertiesback to summary
pack-priv Properties getProperties()

Get the optional properties for the backing index to this constraint.

Returns:Properties

The optional properties for the backing index to this constraint

getReferenceCountback to summary
pack-priv int getReferenceCount()

Get the count of enabled fks that reference this constraint

Returns:int

the number

getUUIDFactoryback to summary
private UUIDFactory getUUIDFactory()

Get the UUID factory

Returns:UUIDFactory

the UUID factory

getVerifyTypeback to summary
pack-priv int getVerifyType()
Returns:int

the expected type of the constraint, DataDictionary.DROP_CONSTRAINT if the constraint is to be dropped without checking its type.

hasCheckConstraintback to summary
pack-priv boolean hasCheckConstraint()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.hasCheckConstraint.

Does this element have a check constraint.

Returns:boolean

boolean Whether or not this element has a check constraint

Annotations
@Override
hasConstraintback to summary
pack-priv boolean hasConstraint()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.hasConstraint.

Does this element have a constraint on it.

Returns:boolean

boolean Whether or not this element has a constraint on it

Annotations
@Override
hasForeignKeyConstraintback to summary
pack-priv boolean hasForeignKeyConstraint()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.hasForeignKeyConstraint.

Is this a foreign key constraint.

Returns:boolean

boolean Whether or not this is a unique key constraint

Annotations
@Override
hasPrimaryKeyConstraintback to summary
pack-priv boolean hasPrimaryKeyConstraint()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.hasPrimaryKeyConstraint.

Is this a primary key constraint.

Returns:boolean

boolean Whether or not this is a primary key constraint

Annotations
@Override
hasUniqueKeyConstraintback to summary
pack-priv boolean hasUniqueKeyConstraint()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.hasUniqueKeyConstraint.

Is this a unique key constraint.

Returns:boolean

boolean Whether or not this is a unique key constraint

Annotations
@Override
isEnabledback to summary
pack-priv boolean isEnabled()

Is this constraint enabled.

Returns:boolean

true/false

isReferencedback to summary
pack-priv boolean isReferenced()

Is this constraint referenced.

Returns:boolean

true/false

qualifyNamesback to summary
pack-priv void qualifyNames() throws StandardException

Qualify all SQL object names in a CHECK constraint with schema name.

Exceptions
StandardException:
if an error occurs
requiresBackingIndexback to summary
pack-priv boolean requiresBackingIndex()

Does this constraint require a backing index for its implementation?

Returns:boolean

boolean true if this constraint requires a backing index, i.e. if is a foreign key, primary key or unique key constraint

requiresUniqueIndexback to summary
pack-priv boolean requiresUniqueIndex()

Is this a primary key or unique constraint?

Returns:boolean

boolean true if this is a primary key or unique key constraint

setAuxiliaryProviderListback to summary
pack-priv void setAuxiliaryProviderList(ProviderList apl)

Set the auxiliary provider list.

Parameters
apl:ProviderList

The new auxiliary provider list.

setCharacteristicsback to summary
pack-priv void setCharacteristics(boolean[] cc)
setCheckConditionback to summary
pack-priv void setCheckCondition(ValueNode checkCondition)

Set the check condition for this table constraint.

Parameters
checkCondition:ValueNode

The check condition

setColumnListback to summary
pack-priv 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:ResultColumnList

The new columnList.

setPropertiesback to summary
pack-priv void setProperties(Properties properties)

Set the optional properties for the backing index to this constraint.

Parameters
properties:Properties

The optional Properties for this constraint.

toStringback to summary
public String toString()

Overrides org.apache.derby.impl.sql.compile.TableElementNode.toString.

Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Returns:String

This object as a String

Annotations
@Override