Buggy code:
throw StandardException . newException ( LANG_STOP_AFTER_PARSING ) ; } } DataDictionary dataDictionary = lcc . getDataDictionary ( ) ; int ddMode = ( dataDictionary == null ) ? 0 : dataDictionary . startReading ( lcc ) ; try { lcc . beginNestedTransaction ( true ) ; qt . bindStatement ( ) ; bindTime = GenericStatement . getCurrentTimeMillis ( lcc ) ; walkAST ( lcc , qt , AFTER_BIND ) ; if ( SanityManager . DEBUG ) { if ( SanityManager . DEBUG_ON ( "DumpBindTree" ) ) { SanityManager . GET_DEBUG_STREAM ( ) . print ( "\n\n============BIND===========\n\n" ) ; qt . treePrint ( ) ; lcc . getPrintedObjectsMap ( ) . clear ( ) ; } if ( SanityManager . DEBUG_ON ( "StopAfterBinding" ) ) { throw StandardException . newException ( LANG_STOP_AFTER_BINDING ) ; } } if ( preparedStmt . referencesSessionSchema ( qt ) ) { if ( foundInCache ) ( ( org . apache . derby . impl . sql . conn . GenericLanguageConnectionContext ) ( lcc ) ) . removeStatement ( this ) ; } qt . optimizeStatement ( ) ; optimizeTime = GenericStatement . getCurrentTimeMillis ( lcc ) ; walkAST ( lcc , qt , AFTER_OPTIMIZE ) ; if ( istream != null ) { String xactId = lcc . getTransactionExecute ( ) . getActiveStateTxIdString ( ) ; istream . printlnWithHeader ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( LanguageConnectionContext . xidStr ) + xactId ) + "),<seq2seq4repair_space>" ) + ( LanguageConnectionContext . lccStr ) ) + ( lcc . getInstanceNumber ( ) ) ) + "),<seq2seq4repair_space>" ) + ( LanguageConnectionContext . dbnameStr ) ) + ( lcc . getDbname ( ) ) ) + "),<seq2seq4repair_space>" ) + ( LanguageConnectionContext . drdaStr ) ) + ( lcc . getDrdaID ( ) ) ) + "),<seq2seq4repair_space>End<seq2seq4repair_space>compiling<seq2seq4repair_space>prepared<seq2seq4repair_space>statement:<seq2seq4repair_space>" ) + ( getSource ( ) ) ) + "<seq2seq4repair_space>:End<seq2seq4repair_space>prepared<seq2seq4repair_space>statement" ) ) ; } } catch ( StandardException se ) { lcc . commitNestedTransaction ( ) ; if ( istream != null ) { String xactId = lcc . getTransactionExecute ( ) . getActiveStateTxIdString ( ) ; istream . printlnWithHeader ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( LanguageConnectionContext . xidStr ) + xactId ) + "),<seq2seq4repair_space>" ) + ( LanguageConnectionContext . lccStr ) ) + ( lcc . getInstanceNumber ( ) ) ) + "),<seq2seq4repair_space>" ) + ( LanguageConnectionContext . dbnameStr ) ) + ( lcc . getDbname ( ) ) ) + "),<seq2seq4repair_space>" ) + ( LanguageConnectionContext . drdaStr ) ) + ( lcc . getDrdaID ( ) ) ) + "),<seq2seq4repair_space>Error<seq2seq4repair_space>compiling<seq2seq4repair_space>prepared<seq2seq4repair_space>statement:<seq2seq4repair_space>" ) + ( getSource ( ) ) ) + "<seq2seq4repair_space>:End<seq2seq4repair_space>prepared<seq2seq4repair_space>statement" ) ) ; } throw se ; } finally { if ( dataDictionary != null ) dataDictionary . doneReading ( ddMode , lcc ) ; } try { if ( SanityManager . DEBUG ) { if ( SanityManager . DEBUG_ON ( "DumpOptimizedTree" ) ) { SanityManager . GET_DEBUG_STREAM ( ) . print ( "\n\n============OPT===========\n\n" ) ; qt . treePrint ( ) ; lcc . getPrintedObjectsMap ( ) . clear ( ) ; } if ( SanityManager . DEBUG_ON ( "StopAfterOptimizing" ) ) { throw StandardException . newException ( LANG_STOP_AFTER_OPTIMIZING ) ; } } GeneratedClass ac = qt . generate ( preparedStmt . getByteCodeSaver ( ) ) ; generateTime = GenericStatement . getCurrentTimeMillis ( lcc ) ; if ( generateTime != 0 ) { endTimestamp = new Timestamp ( generateTime ) ; } if ( SanityManager . DEBUG ) { if ( SanityManager . DEBUG_ON ( "StopAfterGenerating" ) ) { throw StandardException . newException ( LANG_STOP_AFTER_GENERATING ) ; } } preparedStmt . setConstantAction ( qt . makeConstantAction ( ) ) ; preparedStmt . setSavedObjects ( cc . getSavedObjects ( ) ) ; preparedStmt . setRequiredPermissionsList ( cc . getRequiredPermissionsList ( ) ) ; preparedStmt . setActivationClass ( ac ) ; preparedStmt . setNeedsSavepoint ( qt . needsSavepoint ( ) ) ; preparedStmt . setCursorInfo ( ( ( CursorInfo ) ( cc . getCursorInfo ( ) ) ) ) ; preparedStmt . setIsAtomic ( qt . isAtomic ( ) ) ; preparedStmt . setExecuteStatementNameAndSchema ( qt . executeStatementName ( ) , qt . executeSchemaName ( ) ) ; preparedStmt . setSPSName ( qt . getSPSName ( ) ) ; preparedStmt . completeCompile ( qt ) ; preparedStmt . setCompileTimeWarnings ( cc . getWarnings ( ) ) ; } catch ( StandardException e ) { lcc . commitNestedTransaction ( ) ; throw e ; } if ( lcc . getRunTimeStatisticsMode ( ) ) { <START_BUG> preparedStmt . setCompileTimeMillis ( ( parseTime - beginTime ) , ( bindTime - parseTime ) , ( optimizeTime - bindTime ) , ( generateTime - optimizeTime ) , GenericStatement . getElapsedTimeMillis ( beginTime ) , beginTimestamp , endTimestamp ) ; <END_BUG> } } finally { lcc . popCompilerContext ( cc ) ; } } catch ( StandardException se ) { if ( foundInCache ) ( ( org . apache . derby . impl . sql . conn . GenericLanguageConnectionContext ) ( lcc ) ) . removeStatement ( this ) ; throw se ; } finally { synchronized ( preparedStmt ) { preparedStmt . compilingStatement = false ; preparedStmt . notifyAll ( ) ; } } lcc . commitNestedTransaction ( ) ; if ( statementContext != null ) lcc . popStatementContext ( statementContext , null ) ; return preparedStmt ; } private void walkAST ( LanguageConnectionContext lcc , Visitable queryTree , int phase ) throws StandardException { } public PreparedStatement prepareStorable ( LanguageConnectionContext lcc , PreparedStatement ps , Object [ ] paramDefaults , SchemaDescriptor spsSchema , boolean internalSQL ) throws StandardException { } public String getSource ( ) { } public String getCompilationSchema ( ) { } private static long getCurrentTimeMillis ( LanguageConnectionContext lcc ) { } private static long getElapsedTimeMillis ( long beginTime ) { } public PreparedStatement getPreparedStatement ( ) { } public boolean equals ( Object other ) { } public int hashCode ( ) { } }

Fix:
preparedStmt . setCompileTimeMillis ( ( parseTime - beginTime ) , ( bindTime - parseTime ) , ( optimizeTime - bindTime ) , ( generateTime - optimizeTime ) , ( generateTime - beginTime ) , beginTimestamp , endTimestamp ) ;