org.apache.derby.impl.sql.compile
Class ColumnDefinitionNode

java.lang.Object
  extended byorg.apache.derby.impl.sql.compile.QueryTreeNode
      extended byorg.apache.derby.impl.sql.compile.TableElementNode
          extended byorg.apache.derby.impl.sql.compile.ColumnDefinitionNode
All Implemented Interfaces:
Visitable
Direct Known Subclasses:
ModifyColumnNode

public class ColumnDefinitionNode
extends TableElementNode

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.

Author:
Jeff Lichtman

Field Summary
(package private)  long autoincrementIncrement
           
(package private)  long autoincrementStart
           
(package private)  boolean autoincrementVerify
           
(package private)  DataTypeDescriptor dataTypeServices
           
(package private)  DefaultInfoImpl defaultInfo
           
(package private)  DefaultNode defaultNode
           
(package private)  DataValueDescriptor defaultValue
           
(package private)  boolean isAutoincrement
           
 
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_UNKNOWN, elementType, name
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, beginOffset, endOffset
 
Constructor Summary
ColumnDefinitionNode()
           
 
Method Summary
private  void autoincrementCheckRange(long minValue, long maxValue, java.lang.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 bindAndValidateDefault(DataDictionary dd, TableDescriptor td)
          Check the validity of the default, if any, for this node.
 void checkUserType(TableDescriptor td)
          Check the validity of a user type.
private static DefaultInfoImpl createDefaultInfoOfAutoInc()
           
 boolean defaultTypeIsValid(TypeId columnType, DataTypeDescriptor columnDesc, TypeId defaultType, ValueNode defaultNode, java.lang.String defaultText)
          Check the validity of the default for this node
(package private)  int getAction()
          Get the action associated with this node.
(package private)  long getAutoincrementIncrement()
          Get the autoincrement increment value
(package private)  long getAutoincrementStart()
          Get the autoincrement start value
 java.lang.String getColumnName()
          Returns the unqualified name of the column being defined.
 DataTypeDescriptor getDataTypeServices()
          Returns the data type services of the column being defined.
 DefaultInfo getDefaultInfo()
          Return the DefaultInfo containing the default information for this column
 DefaultNode getDefaultNode()
          Return the DefaultNode, if any, associated with this node.
 DataValueDescriptor getDefaultValue()
          Return the DataValueDescriptor containing the default value for this column
(package private)  UUID getOldDefaultUUID()
          Get the UUID of the old column default.
 void init(java.lang.Object name, java.lang.Object defaultNode, java.lang.Object dataTypeServices, java.lang.Object autoIncrementInfo)
          Initializer for a ColumnDefinitionNode
 boolean isAutoincrementColumn()
          Is this an autoincrement column?
 java.lang.String toString()
          Convert this object to a String.
 void validateAutoincrement(DataDictionary dd, TableDescriptor td, int tableType)
          Check the validity of the autoincrement values for this node.
(package private)  void validateDefault(DataDictionary dd, TableDescriptor td)
          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, init, init
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, generate, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getSPSName, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeResultDescription, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, printSubNodes, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isAutoincrement

boolean isAutoincrement

dataTypeServices

DataTypeDescriptor dataTypeServices

defaultValue

DataValueDescriptor defaultValue

defaultInfo

DefaultInfoImpl defaultInfo

defaultNode

DefaultNode defaultNode

autoincrementIncrement

long autoincrementIncrement

autoincrementStart

long autoincrementStart

autoincrementVerify

boolean autoincrementVerify
Constructor Detail

ColumnDefinitionNode

public ColumnDefinitionNode()
Method Detail

init

public void init(java.lang.Object name,
                 java.lang.Object defaultNode,
                 java.lang.Object dataTypeServices,
                 java.lang.Object autoIncrementInfo)
          throws StandardException
Initializer for a ColumnDefinitionNode

Overrides:
init in class QueryTreeNode
Parameters:
name - The name of the column
defaultNode - The default value of the column
dataTypeServices - A DataTypeServices telling the type of the column
autoIncrementInfo - Info for autoincrement columns
Throws:
StandardException - Thrown on error

toString

public java.lang.String toString()
Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Overrides:
toString in class TableElementNode
Returns:
This object as a String

getColumnName

public java.lang.String getColumnName()
Returns the unqualified name of the column being defined.

Returns:
the name of the column

getDataTypeServices

public DataTypeDescriptor getDataTypeServices()
Returns the data type services of the column being defined.

Returns:
the data type services of the column

getDefaultValue

public DataValueDescriptor getDefaultValue()
Return the DataValueDescriptor containing the default value for this column

Returns:
The default value of the column

getDefaultInfo

public DefaultInfo getDefaultInfo()
Return the DefaultInfo containing the default information for this column

Returns:
The default info for the column

getDefaultNode

public DefaultNode getDefaultNode()
Return the DefaultNode, if any, associated with this node.

Returns:
The DefaultNode, if any, associated with this node.

isAutoincrementColumn

public 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.

checkUserType

public void checkUserType(TableDescriptor td)
                   throws StandardException
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.

Returns:
Nothing
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

void bindAndValidateDefault(DataDictionary dd,
                            TableDescriptor td)
                      throws StandardException
Check the validity of the default, if any, for this node.

Parameters:
dd - The DataDictionary.
td - The TableDescriptor.
Returns:
Nothing.
Throws:
StandardException - Thrown on error

validateAutoincrement

public 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,
                                     java.lang.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

void validateDefault(DataDictionary dd,
                     TableDescriptor td)
               throws StandardException
Check the validity of the default for this node.

Parameters:
td - The TableDescriptor.
Returns:
Nothing.
Throws:
StandardException - Thrown on error

createDefaultInfoOfAutoInc

private static DefaultInfoImpl createDefaultInfoOfAutoInc()

defaultTypeIsValid

public boolean defaultTypeIsValid(TypeId columnType,
                                  DataTypeDescriptor columnDesc,
                                  TypeId defaultType,
                                  ValueNode defaultNode,
                                  java.lang.String defaultText)
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.

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.