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
A ModifyColumnNode represents a modify column in an ALTER TABLE statement.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) final int
This class is used to hold logically different objects for space efficiency.(package private) UUID
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
ConstructorsConstructorDescriptionModifyColumnNode
(int kind, String name, ValueNode defaultNode, DataTypeDescriptor dataTypeServices, long[] autoIncrementInfo, ContextManager cm) -
Method Summary
Modifier and TypeMethodDescription(package private) void
Check the validity of the default, if any, for this node.(package private) void
Check if the the column can be modified, and throw error if not.(package private) void
Check the validity of a user type.(package private) int
Get the action associated with this node.(package private) int
Get the column position for the column.private ColumnDescriptor
getLocalColumnDescriptor
(String name, TableDescriptor td) (package private) UUID
Get the UUID of the old column default.(package private) void
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 Details
-
columnPosition
int columnPosition -
oldDefaultUUID
UUID oldDefaultUUID -
K_MODIFY_COLUMN_TYPE
static final int K_MODIFY_COLUMN_TYPE- See Also:
-
K_MODIFY_COLUMN_DEFAULT
static final int K_MODIFY_COLUMN_DEFAULT- See Also:
-
K_MODIFY_COLUMN_CONSTRAINT
static final int K_MODIFY_COLUMN_CONSTRAINT- See Also:
-
K_MODIFY_COLUMN_CONSTRAINT_NOT_NULL
static final int K_MODIFY_COLUMN_CONSTRAINT_NOT_NULL- See Also:
-
K_DROP_COLUMN
static final int K_DROP_COLUMN- See Also:
-
K_MODIFY_COLUMN_GENERATED_ALWAYS
static final int K_MODIFY_COLUMN_GENERATED_ALWAYS- See Also:
-
K_MODIFY_COLUMN_GENERATED_BY_DEFAULT
static final int K_MODIFY_COLUMN_GENERATED_BY_DEFAULT- See Also:
-
kind
final int kindThis 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 Details
-
ModifyColumnNode
ModifyColumnNode(int kind, String name, ValueNode defaultNode, DataTypeDescriptor dataTypeServices, long[] autoIncrementInfo, ContextManager cm) throws StandardException - Throws:
StandardException
-
-
Method Details
-
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
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
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
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
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(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.
-