private static int escapeFunctionArguments ( StringBuilder newsql , String functionName , char [ ] sql , int i , boolean stdStrings ) throws SQLException { // Maximum arity of functions in EscapedFunctions is 3 List < CharSequence > parsedArgs = new ArrayList < CharSequence > ( 3 ) ; while ( true ) { StringBuilder arg = new StringBuilder ( ) ; int lastPos = i ; i = parseSql ( sql , i , arg , true , stdStrings ) ; if ( i != lastPos ) { parsedArgs . add ( arg ) ; } if ( i >= sql . length // should not happen || sql [ i ] != ' ' ) { break ; } i ++ ; } Method method = EscapedFunctions2 . getFunction ( functionName ) ; if ( method == null ) { newsql . append ( functionName ) ; EscapedFunctions2 . appendCall ( newsql , "(" , "," , ")" , parsedArgs ) ; return i ; } try { method . invoke ( null , newsql , parsedArgs ) ; } catch ( InvocationTargetException e ) { Throwable targetException = e . getTargetException ( ) ; if ( targetException instanceof SQLException ) { throw ( SQLException ) targetException ; } else { throw new PSQLException ( targetException . getMessage ( ) , PSQLState . SYSTEM_ERROR ) ; } } catch ( IllegalAccessException e ) { throw new PSQLException ( e . getMessage ( ) , PSQLState . SYSTEM_ERROR ) ; } return i ; }
Generate sql for escaped functions .