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

java.lang.Object
  extended by org.apache.derby.impl.sql.compile.QueryTreeNode
      extended by org.apache.derby.impl.sql.compile.TableElementNode
          extended by org.apache.derby.impl.sql.compile.ColumnDefinitionNode
              extended by org.apache.derby.impl.sql.compile.ModifyColumnNode
All Implemented Interfaces:
Visitable

public class ModifyColumnNode
extends ColumnDefinitionNode

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


Field Summary
(package private)  int columnPosition
           
(package private)  UUID oldDefaultUUID
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.ColumnDefinitionNode
autoinc_create_or_modify_Start_Increment, autoincrementIncrement, autoincrementStart, autoincrementVerify, CREATE_AUTOINCREMENT, defaultInfo, defaultNode, defaultValue, generationClauseNode, isAutoincrement, keepCurrentDefault, 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_UNKNOWN, elementType, name
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, isPrivilegeCollectionRequired
 
Constructor Summary
ModifyColumnNode()
           
 
Method Summary
(package private)  void bindAndValidateDefault(DataDictionary dd, TableDescriptor td)
          Check the validity of the default, if any, for this node.
 void checkExistingConstraints(TableDescriptor td)
          Check if the the column can be modified, and throw error if not.
 void checkUserType(TableDescriptor td)
          Check the validity of a user type.
(package private)  int getAction()
          Get the action associated with this node.
 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.
 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.
 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
defaultTypeIsValid, getAutoinc_create_or_modify_Start_Increment, getAutoincrementIncrement, getAutoincrementStart, getColumnName, getDefaultInfo, getDefaultNode, getDefaultValue, getGenerationClauseNode, getType, hasGenerationClause, init, 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, init, init
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, acceptChildren, bindOffsetFetch, bindRowMultiSet, bindUserType, checkReliability, checkReliability, convertDefaultNode, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, foundString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, orReliability, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, stackPrint, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

columnPosition

int columnPosition

oldDefaultUUID

UUID oldDefaultUUID
Constructor Detail

ModifyColumnNode

public ModifyColumnNode()
Method Detail

getOldDefaultUUID

UUID getOldDefaultUUID()
Get the UUID of the old column default.

Overrides:
getOldDefaultUUID in class ColumnDefinitionNode
Returns:
The UUID of the old column default.

getColumnPosition

public int getColumnPosition()
Get the column position for the column.

Returns:
The column position for the column.

checkUserType

public 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 class ColumnDefinitionNode
Throws:
StandardException - Thrown on error

checkExistingConstraints

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

public 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 class ColumnDefinitionNode
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 class ColumnDefinitionNode
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

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

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.