Class ModifyColumnNode
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.QueryTreeNode
-
- org.apache.derby.impl.sql.compile.TableElementNode
-
- org.apache.derby.impl.sql.compile.ColumnDefinitionNode
-
- org.apache.derby.impl.sql.compile.ModifyColumnNode
-
- All Implemented Interfaces:
Visitable
class ModifyColumnNode extends ColumnDefinitionNode
A ModifyColumnNode represents a modify column in an ALTER TABLE statement.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
columnPosition
(package private) static int
K_DROP_COLUMN
(package private) static int
K_MODIFY_COLUMN_CONSTRAINT
(package private) static int
K_MODIFY_COLUMN_CONSTRAINT_NOT_NULL
(package private) static int
K_MODIFY_COLUMN_DEFAULT
(package private) static int
K_MODIFY_COLUMN_GENERATED_ALWAYS
(package private) static int
K_MODIFY_COLUMN_GENERATED_BY_DEFAULT
(package private) static int
K_MODIFY_COLUMN_TYPE
(package private) int
kind
This class is used to hold logically different objects for space efficiency.(package private) UUID
oldDefaultUUID
-
Fields inherited from class org.apache.derby.impl.sql.compile.ColumnDefinitionNode
autoinc_create_or_modify_Start_Increment, autoincrementCycle, autoincrementIncrement, autoincrementStart, autoincrementVerify, CREATE_AUTOINCREMENT, defaultInfo, defaultNode, defaultValue, generationClauseNode, isAutoincrement, keepCurrentDefault, MODIFY_AUTOINCREMENT_ALWAYS_VS_DEFAULT, MODIFY_AUTOINCREMENT_CYCLE_VALUE, MODIFY_AUTOINCREMENT_INC_VALUE, MODIFY_AUTOINCREMENT_RESTART_VALUE, type
-
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 ModifyColumnNode(int kind, java.lang.String name, ValueNode defaultNode, DataTypeDescriptor dataTypeServices, long[] autoIncrementInfo, ContextManager cm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
bindAndValidateDefault(DataDictionary dd, TableDescriptor td)
Check the validity of the default, if any, for this node.(package private) void
checkExistingConstraints(TableDescriptor td)
Check if the the column can be modified, and throw error if not.(package private) void
checkUserType(TableDescriptor td)
Check the validity of a user type.(package private) int
getAction()
Get the action associated with this node.(package private) int
getColumnPosition()
Get the column position for the column.private ColumnDescriptor
getLocalColumnDescriptor(java.lang.String name, TableDescriptor td)
(package private) UUID
getOldDefaultUUID()
Get the UUID of the old column default.(package private) void
useExistingCollation(TableDescriptor td)
If the column being modified is of character string type, then it should get its collation from the corresponding column in the TableDescriptor.(package private) void
validateAutoincrement(DataDictionary dd, TableDescriptor td, int tableType)
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)-
Methods inherited from class org.apache.derby.impl.sql.compile.ColumnDefinitionNode
createDefaultInfoOfAutoInc, defaultTypeIsValid, getAutoinc_create_or_modify_Start_Increment, getAutoincrementCycle, getAutoincrementIncrement, getAutoincrementStart, getColumnName, getDefaultInfo, getDefaultNode, getDefaultValue, getGenerationClauseNode, getType, hasGenerationClause, isAutoincrementColumn, printSubNodes, setCollationType, setDefaultInfo, setNullability, setType, toString, validateDefault
-
Methods inherited from class org.apache.derby.impl.sql.compile.TableElementNode
getElementType, getName, hasCheckConstraint, hasConstraint, hasForeignKeyConstraint, hasPrimaryKeyConstraint, hasUniqueKeyConstraint
-
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, acceptChildren, 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, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
-
-
-
-
Field Detail
-
columnPosition
int columnPosition
-
oldDefaultUUID
UUID oldDefaultUUID
-
K_MODIFY_COLUMN_TYPE
static final int K_MODIFY_COLUMN_TYPE
- See Also:
- Constant Field Values
-
K_MODIFY_COLUMN_DEFAULT
static final int K_MODIFY_COLUMN_DEFAULT
- See Also:
- Constant Field Values
-
K_MODIFY_COLUMN_CONSTRAINT
static final int K_MODIFY_COLUMN_CONSTRAINT
- See Also:
- Constant Field Values
-
K_MODIFY_COLUMN_CONSTRAINT_NOT_NULL
static final int K_MODIFY_COLUMN_CONSTRAINT_NOT_NULL
- See Also:
- Constant Field Values
-
K_DROP_COLUMN
static final int K_DROP_COLUMN
- See Also:
- Constant Field Values
-
K_MODIFY_COLUMN_GENERATED_ALWAYS
static final int K_MODIFY_COLUMN_GENERATED_ALWAYS
- See Also:
- Constant Field Values
-
K_MODIFY_COLUMN_GENERATED_BY_DEFAULT
static final int K_MODIFY_COLUMN_GENERATED_BY_DEFAULT
- See Also:
- Constant Field Values
-
kind
final int kind
This class is used to hold logically different objects for space efficiency.kind
represents the logical object type. See alsoValueNode.isSameNodeKind(org.apache.derby.impl.sql.compile.ValueNode)
.
-
-
Constructor Detail
-
ModifyColumnNode
ModifyColumnNode(int kind, java.lang.String name, ValueNode defaultNode, DataTypeDescriptor dataTypeServices, long[] autoIncrementInfo, ContextManager cm) throws StandardException
- Throws:
StandardException
-
-
Method Detail
-
getOldDefaultUUID
UUID getOldDefaultUUID()
Get the UUID of the old column default.- Overrides:
getOldDefaultUUID
in classColumnDefinitionNode
- Returns:
- The UUID of the old column default.
-
getColumnPosition
int getColumnPosition()
Get the column position for the column.- Returns:
- The column position for the column.
-
checkUserType
void checkUserType(TableDescriptor td) throws StandardException
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.- Overrides:
checkUserType
in classColumnDefinitionNode
- Throws:
StandardException
- Thrown on error
-
checkExistingConstraints
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
- The Table Descriptor on which the ALTER is being done.- Throws:
StandardException
- Thrown on Error.
-
useExistingCollation
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
- Table Descriptor that holds the column which is being altered- Throws:
StandardException
-
getAction
int getAction()
Get the action associated with this node.- Overrides:
getAction
in classColumnDefinitionNode
- Returns:
- The action associated with this node.
-
bindAndValidateDefault
void bindAndValidateDefault(DataDictionary dd, TableDescriptor td) throws StandardException
Check the validity of the default, if any, for this node.- Overrides:
bindAndValidateDefault
in classColumnDefinitionNode
- Parameters:
dd
- The DataDictionary.td
- The TableDescriptor.- Throws:
StandardException
- Thrown on error
-
getLocalColumnDescriptor
private ColumnDescriptor getLocalColumnDescriptor(java.lang.String name, TableDescriptor td) throws StandardException
- Throws:
StandardException
-
validateAutoincrement
void validateAutoincrement(DataDictionary dd, TableDescriptor td, int tableType) throws StandardException
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)- Overrides:
validateAutoincrement
in classColumnDefinitionNode
- Parameters:
dd
- DataDictionary.td
- table descriptor.tableType
- base table or declared global temporary table.- Throws:
StandardException
- if autoincrement default is incorrect; i.e if increment is 0 or if initial or increment values are out of range for the datatype.
-
-