Buggy code:
private boolean onRollbackDeleteRows ; private Properties properties ; private TableElementList tableElementList ; protected int tableType ; private ResultColumnList resultColumns ; private ResultSetNode queryExpression ; public void init ( Object newObjectName , Object tableElementList , Object properties , Object lockGranularity ) throws StandardException { } public void init ( Object newObjectName , Object tableElementList , Object properties , Object onCommitDeleteRows , Object onRollbackDeleteRows ) throws StandardException { } public void init ( Object newObjectName , Object resultColumns , Object queryExpression ) throws StandardException { } private Object tempTableSchemaNameCheck ( Object objectName ) throws StandardException { } public String toString ( ) { } public String statementToString ( ) { } public void bindStatement ( ) throws StandardException { DataDictionary dataDictionary = getDataDictionary ( ) ; int numPrimaryKeys = 0 ; int numCheckConstraints = 0 ; int numReferenceConstraints = 0 ; int numUniqueConstraints = 0 ; int numGenerationClauses = 0 ; SchemaDescriptor sd = getSchemaDescriptor ( ( ( tableType ) != ( TableDescriptor . GLOBAL_TEMPORARY_TABLE_TYPE ) ) , true ) ; if ( ( queryExpression ) != null ) { FromList fromList = ( ( FromList ) ( getNodeFactory ( ) . getNode ( FROM_LIST , getNodeFactory ( ) . doJoinOrderOptimization ( ) , getContextManager ( ) ) ) ) ; CompilerContext cc = getCompilerContext ( ) ; ProviderList prevAPL = cc . getCurrentAuxiliaryProviderList ( ) ; ProviderList apl = new ProviderList ( ) ; try { cc . setCurrentAuxiliaryProviderList ( apl ) ; cc . pushCurrentPrivType ( SELECT_PRIV ) ; queryExpression = queryExpression . bindNonVTITables ( dataDictionary , fromList ) ; queryExpression = queryExpression . bindVTITables ( fromList ) ; queryExpression . bindExpressions ( fromList ) ; queryExpression . bindResultColumns ( fromList ) ; queryExpression . bindUntypedNullsToResultColumns ( null ) ; } finally { cc . popCurrentPrivType ( ) ; cc . setCurrentAuxiliaryProviderList ( prevAPL ) ; } ResultColumnList qeRCL = queryExpression . getResultColumns ( ) ; if ( ( resultColumns ) != null ) { if ( ( resultColumns . size ( ) ) != ( qeRCL . visibleSize ( ) ) ) { throw StandardException . newException ( LANG_TABLE_DEFINITION_R_C_L_MISMATCH , getFullName ( ) ) ; } qeRCL . copyResultColumnNames ( resultColumns ) ; } int schemaCollationType = sd . getCollationType ( ) ; tableElementList = new TableElementList ( ) ; for ( int index = 0 ; index < ( qeRCL . size ( ) ) ; index ++ ) { ResultColumn rc = ( ( ResultColumn ) ( qeRCL . elementAt ( index ) ) ) ; if ( rc . isGenerated ( ) ) { continue ; } if ( rc . isNameGenerated ( ) ) { throw StandardException . newException ( LANG_TABLE_REQUIRES_COLUMN_NAMES ) ; } DataTypeDescriptor dtd = rc . getExpression ( ) . getTypeServices ( ) ; if ( ( dtd != null ) && ( ! ( dtd . isUserCreatableType ( ) ) ) ) { throw StandardException . newException ( LANG_INVALID_COLUMN_TYPE_CREATE_TABLE , dtd . getFullSQLTypeName ( ) , rc . getName ( ) ) ; } if ( ( dtd . getTypeId ( ) . isStringTypeId ( ) ) && ( ( dtd . getCollationType ( ) ) != schemaCollationType ) ) { String schemaCollationName = ( schemaCollationType == ( StringDataValue . COLLATION_TYPE_UCS_BASIC ) ) ? Property . UCS_BASIC_COLLATION : Property . TERRITORY_BASED_COLLATION ; throw StandardException . newException ( LANG_CAN_NOT_CREATE_TABLE , dtd . getCollationName ( ) , schemaCollationName ) ; } ColumnDefinitionNode column = new ColumnDefinitionNode ( ) ; column . init ( rc . getName ( ) , null , rc . getType ( ) , null ) ; tableElementList . addTableElement ( column ) ; } } else { tableElementList . setCollationTypesOnCharacterStringColumns ( getSchemaDescriptor ( ( ( tableType ) != ( TableDescriptor . GLOBAL_TEMPORARY_TABLE_TYPE ) ) , true ) ) ; } tableElementList . validate ( this , dataDictionary , ( ( TableDescriptor ) ( null ) ) ) ; if ( ( tableElementList . countNumberOfColumns ( ) ) > ( Limits . DB2_MAX_COLUMNS_IN_TABLE ) ) { throw StandardException . newException ( LANG_TOO_MANY_COLUMNS_IN_TABLE_OR_VIEW , String . valueOf ( tableElementList . countNumberOfColumns ( ) ) , getRelativeName ( ) , String . valueOf ( DB2_MAX_COLUMNS_IN_TABLE ) ) ; } numPrimaryKeys = tableElementList . countConstraints ( PRIMARYKEY_CONSTRAINT ) ; if ( numPrimaryKeys > 1 ) { throw StandardException . newException ( LANG_TOO_MANY_PRIMARY_KEY_CONSTRAINTS , getRelativeName ( ) ) ; } numCheckConstraints = tableElementList . countConstraints ( CHECK_CONSTRAINT ) ; numReferenceConstraints = tableElementList . countConstraints ( FOREIGNKEY_CONSTRAINT ) ; numUniqueConstraints = tableElementList . countConstraints ( UNIQUE_CONSTRAINT ) ; numGenerationClauses = tableElementList . countGenerationClauses ( ) ; if ( ( ( tableType ) == ( TableDescriptor . GLOBAL_TEMPORARY_TABLE_TYPE ) ) && ( ( ( ( numPrimaryKeys > 0 ) || ( numCheckConstraints > 0 ) ) || ( numReferenceConstraints > 0 ) ) || ( numUniqueConstraints > 0 ) ) ) throw StandardException . newException ( LANG_NOT_ALLOWED_FOR_DECLARED_GLOBAL_TEMP_TABLE ) ; if ( ( ( numPrimaryKeys + numReferenceConstraints ) + numUniqueConstraints ) > ( Limits . DB2_MAX_INDEXES_ON_TABLE ) ) { throw StandardException . newException ( LANG_TOO_MANY_INDEXES_ON_TABLE , String . valueOf ( ( ( numPrimaryKeys + numReferenceConstraints ) + numUniqueConstraints ) ) , getRelativeName ( ) , String . valueOf ( DB2_MAX_INDEXES_ON_TABLE ) ) ; } if ( ( ( numCheckConstraints > 0 ) || ( numGenerationClauses > 0 ) ) || ( numReferenceConstraints > 0 ) ) { FromList fromList = makeFromList ( null , tableElementList , true ) ; FormatableBitSet generatedColumns = new FormatableBitSet ( ) ; if ( numGenerationClauses > 0 ) { <START_BUG> tableElementList . bindAndValidateGenerationClauses ( sd , fromList , generatedColumns ) ; <END_BUG> } if ( numCheckConstraints > 0 ) { tableElementList . bindAndValidateCheckConstraints ( fromList ) ; } if ( numReferenceConstraints > 0 ) { tableElementList . validateForeignKeysOnGenerationClauses ( fromList , generatedColumns ) ; } } if ( numPrimaryKeys > 0 ) { tableElementList . validatePrimaryKeyNullability ( ) ; } } public boolean referencesSessionSchema ( ) throws StandardException { } public ConstantAction makeConstantAction ( ) throws StandardException { } }

Fix:
tableElementList . bindAndValidateGenerationClauses ( sd , fromList , generatedColumns , null ) ;