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

public abstract Class ConstraintConstantAction

extends DDLSingleTableConstantAction
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.execute.CreateConstraintConstantAction, org.apache.derby.impl.sql.execute.DropConstraintConstantAction, org.apache.derby.impl.sql.execute.AlterConstraintConstantAction
Imports
java.util.ArrayList, .List, org.apache.derby.catalog.UUID, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.io.FormatableBitSet, org.apache.derby.iapi.sql.Activation, .PreparedStatement, .ResultSet, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.dictionary.DataDictionary, .ForeignKeyConstraintDescriptor, .ReferencedKeyConstraintDescriptor, .TableDescriptor, org.apache.derby.iapi.sql.execute.ExecRow, org.apache.derby.iapi.store.access.ConglomerateController, .GroupFetchScanController, .ScanController, .TransactionController, org.apache.derby.iapi.types.DataValueDescriptor, .NumberDataValue, org.apache.derby.impl.sql.execute.DeferredConstraintsMemory.CheckInfo, org.apache.derby.impl.store.access.heap.HeapRowLocation, org.apache.derby.shared.common.sanity.SanityManager

This class describes actions that are ALWAYS performed for a constraint creation at Execution time.
Version
0.1

Field Summary

Modifier and TypeField and Description
protected UUID
protected String
protected int
protected IndexConstantAction
protected UUID
protected String
protected String
Inherited from org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction:
tableId

Constructor Summary

AccessConstructor and Description
pack-priv
ConstraintConstantAction(String
Constraint name.
constraintName
,
int
Constraint type.
constraintType
,
String
Table name.
tableName
,
UUID
UUID of table.
tableId
,
String
schema that table and constraint lives in.
schemaName
,
IndexConstantAction
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)
indexAction
)

Make one of these puppies.

Method Summary

Modifier and TypeMethod and Description
public UUID

Returns:

constraint id
getConstraintId
()

Get the constraint id of the constraint

public String

Returns:

the constraint name
getConstraintName
()

Get the constraint name

public int

Returns:

The constraint type
getConstraintType
()

Get the constraint type.

public IndexConstantAction

Returns:

the constant action for the backing index
getIndexAction
()

Get the associated index constant action.

pack-priv static boolean

Returns:

true if null constraint passes, false otherwise
validateConstraint
(String
constraint name
constraintName
,
String
constraint text
constraintText
,
UUID
constraint id
constraintId
,
TableDescriptor
referenced table
td
,
LanguageConnectionContext
the language connection context
lcc
,
boolean
the constraint is a check constraint
isCheckConstraint
,
boolean
true if the constraint is initially deferred
isInitiallyDeferred
)

Evaluate a check constraint or not null column constraint.

pack-priv static void
validateFKConstraint(Activation activation, TransactionController
transaction controller
tc
,
DataDictionary
data dictionary
dd
,
ForeignKeyConstraintDescriptor
foreign key constraint
fk
,
ReferencedKeyConstraintDescriptor
referenced key
refcd
,
ExecRow
index template row
indexTemplateRow
)

Make sure that the foreign key constraint is valid with the existing data in the target table.

Inherited from org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction:
dropConglomeratedropConglomeratedropConstraintdropConstraintdropConstraintexecuteConglomReplacementgetConglomReplacementActionrecreateUniqueConstraintBackingIndexAsUniqueWhenNotNull

Field Detail

constraintIdback to summary
protected UUID constraintId
constraintNameback to summary
protected String constraintName
constraintTypeback to summary
protected int constraintType
indexActionback to summary
protected IndexConstantAction indexAction
schemaIdback to summary
protected UUID schemaId
schemaNameback to summary
protected String schemaName
tableNameback to summary
protected String tableName

Constructor Detail

ConstraintConstantActionback to summary
pack-priv ConstraintConstantAction(String constraintName, int constraintType, String tableName, UUID tableId, String schemaName, IndexConstantAction indexAction)

Make one of these puppies.

Parameters
constraintName:String

Constraint name.

constraintType:int

Constraint type.

tableName:String

Table name.

tableId:UUID

UUID of table.

schemaName:String

schema that table and constraint lives in.

indexAction:IndexConstantAction

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 Detail

getConstraintIdback to summary
public UUID getConstraintId()

Get the constraint id of the constraint

Returns:UUID

constraint id

getConstraintNameback to summary
public String getConstraintName()

Get the constraint name

Returns:String

the constraint name

getConstraintTypeback to summary
public int getConstraintType()

Get the constraint type.

Returns:int

The constraint type

getIndexActionback to summary
public IndexConstantAction getIndexAction()

Get the associated index constant action.

Returns:IndexConstantAction

the constant action for the backing index

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

constraint name

constraintText:String

constraint text

constraintId:UUID

constraint id

td:TableDescriptor

referenced table

lcc:LanguageConnectionContext

the language connection context

isCheckConstraint:boolean

the constraint is a check constraint

isInitiallyDeferred:boolean

true if the constraint is initially deferred

Returns:boolean

true if null constraint passes, false otherwise

Exceptions
StandardException:
if check constraint fails
validateFKConstraintback to summary
pack-priv 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:TransactionController

transaction controller

dd:DataDictionary

data dictionary

fk:ForeignKeyConstraintDescriptor

foreign key constraint

refcd:ReferencedKeyConstraintDescriptor

referenced key

indexTemplateRow:ExecRow

index template row

Exceptions
StandardException:
on error