Buggy code:
public void bindStatement ( ) throws StandardException { getCompilerContext ( ) . pushCurrentPrivType ( SELECT_PRIV ) ; FromList fromList = ( ( FromList ) ( getNodeFactory ( ) . getNode ( FROM_LIST , getNodeFactory ( ) . doJoinOrderOptimization ( ) , getContextManager ( ) ) ) ) ; DataDictionary dataDictionary = getDataDictionary ( ) ; super . bindResultSetsWithTables ( dataDictionary ) ; verifyTargetTable ( ) ; if ( ( targetProperties ) != null ) { verifyTargetProperties ( dataDictionary ) ; } getResultColumnList ( ) ; if ( ( targetColumnList ) != null ) { if ( ( synonymTableName ) != null ) { normalizeSynonymColumns ( targetColumnList , targetTableName ) ; } getCompilerContext ( ) . pushCurrentPrivType ( getPrivType ( ) ) ; if ( ( targetTableDescriptor ) != null ) { targetColumnList . bindResultColumnsByName ( targetTableDescriptor , ( ( DMLStatementNode ) ( this ) ) ) ; } else { targetColumnList . bindResultColumnsByName ( targetVTI . getResultColumns ( ) , targetVTI , this ) ; } getCompilerContext ( ) . popCurrentPrivType ( ) ; } if ( SanityManager . DEBUG ) { SanityManager . ASSERT ( ( ( fromList . size ( ) ) == 0 ) , ( ( "fromList.size()<seq2seq4repair_space>is<seq2seq4repair_space>expected<seq2seq4repair_space>to<seq2seq4repair_space>be<seq2seq4repair_space>0,<seq2seq4repair_space>not<seq2seq4repair_space>" + ( fromList . size ( ) ) ) + "<seq2seq4repair_space>on<seq2seq4repair_space>return<seq2seq4repair_space>from<seq2seq4repair_space>RS.bindExpressions()" ) ) ; } resultSet . replaceDefaults ( targetTableDescriptor , targetColumnList ) ; super . bindExpressions ( ) ; if ( ( targetColumnList ) != null ) { if ( ( resultSet . getResultColumns ( ) . visibleSize ( ) ) > ( targetColumnList . size ( ) ) ) throw StandardException . newException ( LANG_DB2_INVALID_COLS_SPECIFIED ) ; resultSet . bindUntypedNullsToResultColumns ( targetColumnList ) ; resultSet . setTableConstructorTypes ( targetColumnList ) ; } else { if ( ( resultSet . getResultColumns ( ) . visibleSize ( ) ) > ( resultColumnList . size ( ) ) ) throw StandardException . newException ( LANG_DB2_INVALID_COLS_SPECIFIED ) ; resultSet . bindUntypedNullsToResultColumns ( resultColumnList ) ; resultSet . setTableConstructorTypes ( resultColumnList ) ; } resultSet . bindResultColumns ( fromList ) ; int resCols = resultSet . getResultColumns ( ) . visibleSize ( ) ; DataDictionary dd = getDataDictionary ( ) ; if ( ( targetColumnList ) != null ) { if ( ( targetColumnList . size ( ) ) != resCols ) throw StandardException . newException ( LANG_DB2_INVALID_COLS_SPECIFIED ) ; } else { if ( ( ( targetTableDescriptor ) != null ) && ( ( targetTableDescriptor . getNumberOfColumns ( ) ) != resCols ) ) throw StandardException . newException ( LANG_DB2_INVALID_COLS_SPECIFIED ) ; } boolean inOrder = true ; int numTableColumns = resultColumnList . size ( ) ; int [ ] colMap = new int [ numTableColumns ] ; for ( int i = 0 ; i < ( colMap . length ) ; i ++ ) { colMap [ i ] = - 1 ; } if ( ( targetColumnList ) != null ) { int targetSize = targetColumnList . size ( ) ; for ( int index = 0 ; index < targetSize ; index ++ ) { int position = ( ( ResultColumn ) ( targetColumnList . elementAt ( index ) ) ) . columnDescriptor . getPosition ( ) ; if ( index != ( position - 1 ) ) { inOrder = false ; } colMap [ ( position - 1 ) ] = index ; } } else { for ( int position = 0 ; position < ( resultSet . getResultColumns ( ) . visibleSize ( ) ) ; position ++ ) { colMap [ position ] = position ; } } enhanceAndCheckForAutoincrement ( resultSet , inOrder , numTableColumns , colMap , dataDictionary , targetTableDescriptor , targetVTI ) ; resultColumnList . checkStorableExpressions ( resultSet . getResultColumns ( ) ) ; if ( ! ( resultColumnList . columnTypesAndLengthsMatch ( resultSet . getResultColumns ( ) ) ) ) { <START_BUG> resultSet = resultSet . genNormalizeResultSetNode ( resultSet , false ) ; <END_BUG> resultColumnList . copyTypesAndLengthsToSource ( resultSet . getResultColumns ( ) ) ; } if ( ( targetTableDescriptor ) != null ) { ResultColumnList sourceRCL = resultSet . getResultColumns ( ) ; sourceRCL . copyResultColumnNames ( resultColumnList ) ; checkConstraints = bindConstraints ( dataDictionary , getNodeFactory ( ) , targetTableDescriptor , null , sourceRCL , ( ( int [ ] ) ( null ) ) , ( ( FormatableBitSet ) ( null ) ) , false , true ) ; if ( ( resultSet . referencesTarget ( targetTableDescriptor . getName ( ) , true ) ) || ( requiresDeferredProcessing ( ) ) ) { deferred = true ; if ( ( bulkInsertReplace ) && ( resultSet . referencesTarget ( targetTableDescriptor . getName ( ) , true ) ) ) { throw StandardException . newException ( LANG_INVALID_BULK_INSERT_REPLACE , targetTableDescriptor . getQualifiedName ( ) ) ; } } getAffectedIndexes ( targetTableDescriptor ) ; TransactionController tc = getLanguageConnectionContext ( ) . getTransactionCompile ( ) ; autoincRowLocation = dd . computeAutoincRowLocations ( tc , targetTableDescriptor ) ; if ( isPrivilegeCollectionRequired ( ) ) { getCompilerContext ( ) . pushCurrentPrivType ( getPrivType ( ) ) ; getCompilerContext ( ) . addRequiredTablePriv ( targetTableDescriptor ) ; getCompilerContext ( ) . popCurrentPrivType ( ) ; } } else { deferred = VTIDeferModPolicy . deferIt ( INSERT_STATEMENT , targetVTI , null , resultSet ) ; } getCompilerContext ( ) . popCurrentPrivType ( ) ; } private void enhanceAndCheckForAutoincrement ( ResultSetNode resultSet , boolean inOrder , int numTableColumns , int [ ] colMap , DataDictionary dataDictionary , TableDescriptor targetTableDescriptor , FromVTI targetVTI ) throws StandardException { } int getPrivType ( ) { } public boolean referencesSessionSchema ( ) throws StandardException { } private void verifyTargetProperties ( DataDictionary dd ) throws StandardException { } private boolean verifyBulkInsert ( DataDictionary dd , String mode ) throws StandardException { } public ConstantAction makeConstantAction ( ) throws StandardException { } public boolean [ ] getIndexedCols ( ) throws StandardException { } public void generate ( ActivationClassBuilder acb , MethodBuilder mb ) throws StandardException { }

Fix:
resultSet = resultSet . genNormalizeResultSetNode ( false ) ;