Class ColumnDefinitionNode
java.lang.Object
org.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.TableElementNode
org.apache.derby.impl.sql.compile.ColumnDefinitionNode
- All Implemented Interfaces:
Visitable
- Direct Known Subclasses:
ModifyColumnNode
A ColumnDefinitionNode represents a column definition in a DDL statement.
There will be a ColumnDefinitionNode for each column in a CREATE TABLE
statement, and for the column in an ALTER TABLE ADD COLUMN statement.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) long
(package private) boolean
(package private) long
(package private) long
(package private) boolean
static final int
(package private) DefaultInfoImpl
(package private) DefaultNode
(package private) DataValueDescriptor
(package private) GenerationClauseNode
(package private) boolean
(package private) boolean
static final int
static final int
static final int
static final int
(package private) DataTypeDescriptor
The data type of this column.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
ConstructorsConstructorDescriptionColumnDefinitionNode
(String name, ValueNode defaultNode, DataTypeDescriptor dataTypeServices, long[] autoIncrementInfo, ContextManager cm) Constructor for a ColumnDefinitionNode -
Method Summary
Modifier and TypeMethodDescriptionprivate void
autoincrementCheckRange
(long minValue, long maxValue, String typeName) checks to see if autoincrementIncrement and autoincrementInitial are within the bounds of the type whose min and max values are passed into this routine.(package private) void
Check the validity of the default, if any, for this node.(package private) void
Check the validity of a user type.protected static DefaultInfoImpl
(package private) boolean
defaultTypeIsValid
(TypeId columnType, DataTypeDescriptor columnDesc, TypeId defaultType, ValueNode defaultNode, String defaultText) Check the validity of the default for this node(package private) int
Get the action associated with this node.(package private) long
Get the status of this autoincrement column(package private) boolean
Get the autoincrement cycle value(package private) long
Get the autoincrement increment value(package private) long
Get the autoincrement start value(package private) String
Returns the unqualified name of the column being defined.(package private) DefaultInfo
Return the DefaultInfo containing the default information for this column(package private) DefaultNode
Return the DefaultNode, if any, associated with this node.(package private) DataValueDescriptor
Return the DataValueDescriptor containing the default value for this column(package private) GenerationClauseNode
Get the generation clause.(package private) UUID
Get the UUID of the old column default.(package private) final DataTypeDescriptor
getType()
Returns the data type of the column being defined.boolean
Return true if this column has a generation clause.(package private) boolean
Is this an autoincrement column?(package private) void
printSubNodes
(int depth) Prints the sub-nodes of this object.(package private) void
setCollationType
(int collationType) Set the collation type, note derivation is always implicit for any catalog item.void
Set the generation clause (Default) bound to this column.(package private) final void
setNullability
(boolean nullable) Set the nullability of the column definition node.void
Set the type of this columntoString()
Convert this object to a String.(package private) void
validateAutoincrement
(DataDictionary dd, TableDescriptor td, int tableType) Check the validity of the autoincrement values for this node.(package private) void
Check the validity of the default for this node.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
-
isAutoincrement
boolean isAutoincrement -
type
DataTypeDescriptor typeThe data type of this column. -
defaultValue
DataValueDescriptor defaultValue -
defaultInfo
DefaultInfoImpl defaultInfo -
defaultNode
DefaultNode defaultNode -
keepCurrentDefault
boolean keepCurrentDefault -
generationClauseNode
GenerationClauseNode generationClauseNode -
autoincrementIncrement
long autoincrementIncrement -
autoincrementStart
long autoincrementStart -
autoincrementCycle
boolean autoincrementCycle -
autoinc_create_or_modify_Start_Increment
long autoinc_create_or_modify_Start_Increment -
autoincrementVerify
boolean autoincrementVerify -
CREATE_AUTOINCREMENT
public static final int CREATE_AUTOINCREMENT- See Also:
-
MODIFY_AUTOINCREMENT_RESTART_VALUE
public static final int MODIFY_AUTOINCREMENT_RESTART_VALUE- See Also:
-
MODIFY_AUTOINCREMENT_INC_VALUE
public static final int MODIFY_AUTOINCREMENT_INC_VALUE- See Also:
-
MODIFY_AUTOINCREMENT_ALWAYS_VS_DEFAULT
public static final int MODIFY_AUTOINCREMENT_ALWAYS_VS_DEFAULT- See Also:
-
MODIFY_AUTOINCREMENT_CYCLE_VALUE
public static final int MODIFY_AUTOINCREMENT_CYCLE_VALUE- See Also:
-
-
Constructor Details
-
ColumnDefinitionNode
ColumnDefinitionNode(String name, ValueNode defaultNode, DataTypeDescriptor dataTypeServices, long[] autoIncrementInfo, ContextManager cm) throws StandardException Constructor for a ColumnDefinitionNode- Parameters:
name
- The name of the columndefaultNode
- The default value of the columndataTypeServices
- A DataTypeServices telling the type of the columnautoIncrementInfo
- Info for auto-increment columnscm
- The context manager- Throws:
StandardException
-
-
Method Details
-
toString
Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.- Overrides:
toString
in classTableElementNode
- Returns:
- This object as a String
-
getColumnName
String getColumnName()Returns the unqualified name of the column being defined.- Returns:
- the name of the column
-
getType
Returns the data type of the column being defined.- Returns:
- the data type of the column
-
setType
Set the type of this column -
setNullability
final void setNullability(boolean nullable) Set the nullability of the column definition node. -
setCollationType
void setCollationType(int collationType) Set the collation type, note derivation is always implicit for any catalog item. -
getDefaultValue
DataValueDescriptor getDefaultValue()Return the DataValueDescriptor containing the default value for this column- Returns:
- The default value of the column
-
getDefaultInfo
DefaultInfo getDefaultInfo()Return the DefaultInfo containing the default information for this column- Returns:
- The default info for the column
-
setDefaultInfo
Set the generation clause (Default) bound to this column. -
getDefaultNode
DefaultNode getDefaultNode()Return the DefaultNode, if any, associated with this node.- Returns:
- The DefaultNode, if any, associated with this node.
-
hasGenerationClause
public boolean hasGenerationClause()Return true if this column has a generation clause. -
getGenerationClauseNode
GenerationClauseNode getGenerationClauseNode()Get the generation clause. -
isAutoincrementColumn
boolean isAutoincrementColumn()Is this an autoincrement column?- Returns:
- Whether or not this is an autoincrement column.
-
getAutoincrementStart
long getAutoincrementStart()Get the autoincrement start value- Returns:
- Autoincrement start value.
-
getAutoincrementIncrement
long getAutoincrementIncrement()Get the autoincrement increment value- Returns:
- Autoincrement increment value.
-
getAutoincrementCycle
boolean getAutoincrementCycle()Get the autoincrement cycle value- Returns:
- Autoincrement cycle value.
-
getAutoinc_create_or_modify_Start_Increment
long getAutoinc_create_or_modify_Start_Increment()Get the status of this autoincrement column- Returns:
- ColumnDefinitionNode.CREATE_AUTOINCREMENT - if this definition is for autoincrement column creatoin ColumnDefinitionNode.MODIFY_AUTOINCREMENT_RESTART_VALUE - if this definition is for alter sutoincrement column to change the start value ColumnDefinitionNode.MODIFY_AUTOINCREMENT_INC_VALUE if this definition is for alter autoincrement column to change the increment value
-
checkUserType
Check the validity of a user type. Checks whether this column definition describes a user type that either doesn't exist or is inaccessible, or that doesn't implement Serializable.- Throws:
StandardException
- Thrown on error
-
getOldDefaultUUID
UUID getOldDefaultUUID()Get the UUID of the old column default.- Returns:
- The UUID of the old column default.
-
getAction
int getAction()Get the action associated with this node.- Returns:
- The action associated with this node.
-
bindAndValidateDefault
Check the validity of the default, if any, for this node.- Parameters:
dd
- The DataDictionary.td
- The TableDescriptor.- Throws:
StandardException
- Thrown on error
-
validateAutoincrement
void validateAutoincrement(DataDictionary dd, TableDescriptor td, int tableType) throws StandardException Check the validity of the autoincrement values for this node. The following errors are thrown by this routine. 1. 42z21 Invalid Increment; i.e 0. 2. 42z22 Invalid Type; autoincrement created on a non-exact-numeric type 3. 42995 The requested function does not apply to global temporary tables- 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.
-
autoincrementCheckRange
private void autoincrementCheckRange(long minValue, long maxValue, String typeName) throws StandardException checks to see if autoincrementIncrement and autoincrementInitial are within the bounds of the type whose min and max values are passed into this routine.- Throws:
StandardException
-
validateDefault
Check the validity of the default for this node.- Parameters:
td
- The TableDescriptor.- Throws:
StandardException
- Thrown on error
-
createDefaultInfoOfAutoInc
-
defaultTypeIsValid
boolean defaultTypeIsValid(TypeId columnType, DataTypeDescriptor columnDesc, TypeId defaultType, ValueNode defaultNode, String defaultText) throws StandardException Check the validity of the default for this node- Parameters:
columnType
- TypeId of the target column.columnDesc
- Description of the type of the target column.defaultType
- TypeId of the default node.defaultNode
- Parsed ValueNode for the default value.defaultText
- Unparsed default value (as entered by user).- Returns:
- True if the defaultNode abides by the restrictions imposed by DB2 on default constants; false otherwise.
- Throws:
StandardException
-
printSubNodes
void printSubNodes(int depth) Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.- Overrides:
printSubNodes
in classQueryTreeNode
- Parameters:
depth
- The depth of this node in the tree
-