Buggy code:
public class AlterTableNode extends DDLStatementNode { public TableElementList tableElementList = null ; public char lockGranularity ; private boolean updateStatistics = false ; private boolean updateStatisticsAll = false ; private String indexNameForUpdateStatistics ; public boolean compressTable = false ; public boolean sequential = false ; public boolean purge = false ; public boolean defragment = false ; public boolean truncateEndOfTable = false ; public int behavior ; public TableDescriptor baseTable ; protected int numConstraints ; private int changeType = UNKNOWN_TYPE ; private boolean truncateTable = false ; protected SchemaDescriptor schemaDescriptor = null ; protected ColumnInfo [ ] colInfos = null ; protected ConstraintConstantAction [ ] conActions = null ; public void init ( Object objectName ) throws StandardException { } public void init ( Object objectName , Object updateStatisticsAll , Object indexName ) throws StandardException { } public void init ( Object objectName , Object sequential ) throws StandardException { } public void init ( Object objectName , Object purge , Object defragment , Object truncateEndOfTable ) throws StandardException { } public void init ( Object objectName , Object tableElementList , Object lockGranularity , Object changeType , Object behavior ) throws StandardException { } public String toString ( ) { } public String statementToString ( ) { } public int getChangeType ( ) { } public void bindStatement ( ) throws StandardException { DataDictionary dd = getDataDictionary ( ) ; int numCheckConstraints = 0 ; int numReferenceConstraints = 0 ; int numGenerationClauses = 0 ; int numBackingIndexes = 0 ; if ( ( compressTable ) && ( ( ( purge ) || ( defragment ) ) || ( truncateEndOfTable ) ) ) { baseTable = getTableDescriptor ( false ) ; } else baseTable = getTableDescriptor ( ) ; if ( ( baseTable . getTableType ( ) ) == ( TableDescriptor . GLOBAL_TEMPORARY_TABLE_TYPE ) ) { throw StandardException . newException ( LANG_NOT_ALLOWED_FOR_DECLARED_GLOBAL_TEMP_TABLE ) ; } getCompilerContext ( ) . createDependency ( baseTable ) ; if ( ( changeType ) == ( ADD_TYPE ) ) { if ( ( tableElementList ) != null ) { for ( int i = 0 ; i < ( tableElementList . size ( ) ) ; i ++ ) { if ( ( tableElementList . elementAt ( i ) ) instanceof ColumnDefinitionNode ) { ColumnDefinitionNode cdn = ( ( ColumnDefinitionNode ) ( tableElementList . elementAt ( i ) ) ) ; if ( ( cdn . hasGenerationClause ( ) ) && ( ( cdn . getType ( ) ) == null ) ) { continue ; } if ( cdn . getType ( ) . getTypeId ( ) . isStringTypeId ( ) ) { cdn . setCollationType ( schemaDescriptor . getCollationType ( ) ) ; } } } } } if ( ( tableElementList ) != null ) { tableElementList . validate ( this , dd , baseTable ) ; if ( ( ( tableElementList . countNumberOfColumns ( ) ) + ( baseTable . getNumberOfColumns ( ) ) ) > ( Limits . DB2_MAX_COLUMNS_IN_TABLE ) ) { throw StandardException . newException ( LANG_TOO_MANY_COLUMNS_IN_TABLE_OR_VIEW , String . valueOf ( ( ( tableElementList . countNumberOfColumns ( ) ) + ( baseTable . getNumberOfColumns ( ) ) ) ) , getRelativeName ( ) , String . valueOf ( DB2_MAX_COLUMNS_IN_TABLE ) ) ; } numBackingIndexes = ( ( tableElementList . countConstraints ( PRIMARYKEY_CONSTRAINT ) ) + ( tableElementList . countConstraints ( FOREIGNKEY_CONSTRAINT ) ) ) + ( tableElementList . countConstraints ( UNIQUE_CONSTRAINT ) ) ; numCheckConstraints = tableElementList . countConstraints ( CHECK_CONSTRAINT ) ; numReferenceConstraints = tableElementList . countConstraints ( FOREIGNKEY_CONSTRAINT ) ; numGenerationClauses = tableElementList . countGenerationClauses ( ) ; } if ( ( numBackingIndexes + ( baseTable . getTotalNumberOfIndexes ( ) ) ) > ( Limits . DB2_MAX_INDEXES_ON_TABLE ) ) { throw StandardException . newException ( LANG_TOO_MANY_INDEXES_ON_TABLE , String . valueOf ( ( numBackingIndexes + ( baseTable . getTotalNumberOfIndexes ( ) ) ) ) , getRelativeName ( ) , String . valueOf ( DB2_MAX_INDEXES_ON_TABLE ) ) ; } if ( ( ( numCheckConstraints > 0 ) || ( numGenerationClauses > 0 ) ) || ( numReferenceConstraints > 0 ) ) { FromList fromList = makeFromList ( dd , tableElementList , false ) ; FormatableBitSet generatedColumns = baseTable . makeColumnMap ( baseTable . getGeneratedColumns ( ) ) ; if ( numGenerationClauses > 0 ) { <START_BUG> tableElementList . bindAndValidateGenerationClauses ( schemaDescriptor , fromList , generatedColumns ) ; <END_BUG> } if ( numCheckConstraints > 0 ) { tableElementList . bindAndValidateCheckConstraints ( fromList ) ; } if ( numReferenceConstraints > 0 ) { tableElementList . validateForeignKeysOnGenerationClauses ( fromList , generatedColumns ) ; } } if ( ( tableElementList ) != null ) { tableElementList . validatePrimaryKeyNullability ( ) ; } if ( ( updateStatistics ) && ( ! ( updateStatisticsAll ) ) ) { ConglomerateDescriptor cd = null ; if ( ( schemaDescriptor . getUUID ( ) ) != null ) cd = dd . getConglomerateDescriptor ( indexNameForUpdateStatistics , schemaDescriptor , false ) ; if ( cd == null ) { throw StandardException . newException ( LANG_INDEX_NOT_FOUND , ( ( ( schemaDescriptor . getSchemaName ( ) ) + "." ) + ( indexNameForUpdateStatistics ) ) ) ; } } getCompilerContext ( ) . createDependency ( baseTable ) ; } public boolean referencesSessionSchema ( ) throws StandardException { } public ConstantAction makeConstantAction ( ) throws StandardException { } private void prepConstantAction ( ) throws StandardException { } public void genColumnInfo ( ) throws StandardException { } }

Fix:
tableElementList . bindAndValidateGenerationClauses ( schemaDescriptor , fromList , generatedColumns , baseTable ) ;