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

pack-priv Class ModifyColumnNode

extends ColumnDefinitionNode
Class Inheritance
Imports
org.apache.derby.catalog.UUID, org.apache.derby.catalog.types.DefaultInfoImpl, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.dictionary.ColumnDescriptor, .ConstraintDescriptor, .ConstraintDescriptorList, .DataDictionary, .DefaultDescriptor, .KeyConstraintDescriptor, .TableDescriptor, org.apache.derby.iapi.types.DataTypeDescriptor, .TypeId, org.apache.derby.impl.sql.execute.ColumnInfo

A ModifyColumnNode represents a modify column in an ALTER TABLE statement.

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv final int
kind

This class is used to hold logically different objects for space efficiency.

pack-priv UUID
Inherited from org.apache.derby.impl.sql.compile.ColumnDefinitionNode:
autoinc_create_or_modify_Start_IncrementautoincrementCycleautoincrementIncrementautoincrementStartautoincrementVerifyCREATE_AUTOINCREMENTdefaultInfodefaultNodedefaultValuegenerationClauseNodeisAutoincrementkeepCurrentDefaultMODIFY_AUTOINCREMENT_ALWAYS_VS_DEFAULTMODIFY_AUTOINCREMENT_CYCLE_VALUEMODIFY_AUTOINCREMENT_INC_VALUEMODIFY_AUTOINCREMENT_RESTART_VALUEtype

Constructor Summary

AccessConstructor and Description
pack-priv
ModifyColumnNode(int kind, String name, ValueNode defaultNode, DataTypeDescriptor dataTypeServices, long[] autoIncrementInfo, ContextManager cm)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
bindAndValidateDefault(DataDictionary
The DataDictionary.
dd
,
TableDescriptor
The TableDescriptor.
td
)

Overrides org.apache.derby.impl.sql.compile.ColumnDefinitionNode.bindAndValidateDefault.

Check the validity of the default, if any, for this node.

pack-priv void
checkExistingConstraints(TableDescriptor
The Table Descriptor on which the ALTER is being done.
td
)

Check if the the column can be modified, and throw error if not.

pack-priv void
pack-priv int

Returns:

The action associated with this node.
getAction
()

Overrides org.apache.derby.impl.sql.compile.ColumnDefinitionNode.getAction.

Get the action associated with this node.

pack-priv int

Returns:

The column position for the column.
getColumnPosition
()

Get the column position for the column.

private ColumnDescriptor
pack-priv UUID

Returns:

The UUID of the old column default.
getOldDefaultUUID
()

Overrides org.apache.derby.impl.sql.compile.ColumnDefinitionNode.getOldDefaultUUID.

Get the UUID of the old column default.

pack-priv void
useExistingCollation(TableDescriptor
Table Descriptor that holds the column which is being altered
td
)

If the column being modified is of character string type, then it should get its collation from the corresponding column in the TableDescriptor.

pack-priv void
validateAutoincrement(DataDictionary
DataDictionary.
dd
,
TableDescriptor
table descriptor.
td
,
int
base table or declared global temporary table.
tableType
)

Overrides org.apache.derby.impl.sql.compile.ColumnDefinitionNode.validateAutoincrement.

check the validity of autoincrement values in the case that we are modifying an existing column (includes checking if autoincrement is set when making a column nullable)

Inherited from org.apache.derby.impl.sql.compile.ColumnDefinitionNode:
createDefaultInfoOfAutoIncdefaultTypeIsValidgetAutoinc_create_or_modify_Start_IncrementgetAutoincrementCyclegetAutoincrementIncrementgetAutoincrementStartgetColumnNamegetDefaultInfogetDefaultNodegetDefaultValuegetGenerationClauseNodegetTypehasGenerationClauseisAutoincrementColumnprintSubNodessetCollationTypesetDefaultInfosetNullabilitysetTypetoStringvalidateDefault

Field Detail

columnPositionback to summary
pack-priv int columnPosition
K_DROP_COLUMNback to summary
pack-priv static final int K_DROP_COLUMN
K_MODIFY_COLUMN_CONSTRAINTback to summary
pack-priv static final int K_MODIFY_COLUMN_CONSTRAINT
K_MODIFY_COLUMN_CONSTRAINT_NOT_NULLback to summary
pack-priv static final int K_MODIFY_COLUMN_CONSTRAINT_NOT_NULL
K_MODIFY_COLUMN_DEFAULTback to summary
pack-priv static final int K_MODIFY_COLUMN_DEFAULT
K_MODIFY_COLUMN_GENERATED_ALWAYSback to summary
pack-priv static final int K_MODIFY_COLUMN_GENERATED_ALWAYS
K_MODIFY_COLUMN_GENERATED_BY_DEFAULTback to summary
pack-priv static final int K_MODIFY_COLUMN_GENERATED_BY_DEFAULT
K_MODIFY_COLUMN_TYPEback to summary
pack-priv static final int K_MODIFY_COLUMN_TYPE
kindback to summary
pack-priv final int kind

This class is used to hold logically different objects for space efficiency. kind represents the logical object type. See also ValueNode#isSameNodeKind.

oldDefaultUUIDback to summary
pack-priv UUID oldDefaultUUID

Constructor Detail

ModifyColumnNodeback to summary
pack-priv ModifyColumnNode(int kind, String name, ValueNode defaultNode, DataTypeDescriptor dataTypeServices, long[] autoIncrementInfo, ContextManager cm) throws StandardException

Method Detail

bindAndValidateDefaultback to summary
pack-priv void bindAndValidateDefault(DataDictionary dd, TableDescriptor td) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ColumnDefinitionNode.bindAndValidateDefault.

Check the validity of the default, if any, for this node.

Parameters
dd:DataDictionary

The DataDictionary.

td:TableDescriptor

The TableDescriptor.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
checkExistingConstraintsback to summary
pack-priv void checkExistingConstraints(TableDescriptor td) throws StandardException

Check if the the column can be modified, and throw error if not. If the type of a column is being changed (for instance if the length of the column is being increased) then make sure that this does not violate any key constraints; the column being altered is 1. part of foreign key constraint ==> ERROR. This references a Primary Key constraint and the type and lengths of the pkey/fkey must match exactly. 2. part of a unique/primary key constraint ==> OK if no fkey references this constraint. ==> ERROR if any fkey in the system references this constraint.

Parameters
td:TableDescriptor

The Table Descriptor on which the ALTER is being done.

Exceptions
StandardException:
Thrown on Error.
checkUserTypeback to summary
pack-priv void checkUserType(TableDescriptor td) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ColumnDefinitionNode.checkUserType.

Check the validity of a user type. Checks that 1. the column type is either varchar, .... 2. is the same type after the alter. 3. length is greater than the old length.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
getActionback to summary
pack-priv int getAction()

Overrides org.apache.derby.impl.sql.compile.ColumnDefinitionNode.getAction.

Get the action associated with this node.

Returns:int

The action associated with this node.

Annotations
@Override
getColumnPositionback to summary
pack-priv int getColumnPosition()

Get the column position for the column.

Returns:int

The column position for the column.

getLocalColumnDescriptorback to summary
private ColumnDescriptor getLocalColumnDescriptor(String name, TableDescriptor td) throws StandardException
getOldDefaultUUIDback to summary
pack-priv UUID getOldDefaultUUID()

Overrides org.apache.derby.impl.sql.compile.ColumnDefinitionNode.getOldDefaultUUID.

Get the UUID of the old column default.

Returns:UUID

The UUID of the old column default.

Annotations
@Override
useExistingCollationback to summary
pack-priv void useExistingCollation(TableDescriptor td) throws StandardException

If the column being modified is of character string type, then it should get its collation from the corresponding column in the TableDescriptor. This will ensure that at alter table time, the existing character string type columns do not loose their collation type. If the alter table is doing a drop column, then we do not need to worry about collation info.

Parameters
td:TableDescriptor

Table Descriptor that holds the column which is being altered

validateAutoincrementback to summary
pack-priv void validateAutoincrement(DataDictionary dd, TableDescriptor td, int tableType) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ColumnDefinitionNode.validateAutoincrement.

check the validity of autoincrement values in the case that we are modifying an existing column (includes checking if autoincrement is set when making a column nullable)

Parameters
dd:DataDictionary

Doc from org.apache.derby.impl.sql.compile.ColumnDefinitionNode.validateAutoincrement.

DataDictionary.

td:TableDescriptor

Doc from org.apache.derby.impl.sql.compile.ColumnDefinitionNode.validateAutoincrement.

table descriptor.

tableType:int

Doc from org.apache.derby.impl.sql.compile.ColumnDefinitionNode.validateAutoincrement.

base table or declared global temporary table.

Annotations
@Override
Exceptions
StandardException:

Doc from org.apache.derby.impl.sql.compile.ColumnDefinitionNode.validateAutoincrement.

if autoincrement default is incorrect; i.e if increment is 0 or if initial or increment values are out of range for the datatype.