dynamobi/dynamobi — Issue #553: [FRG-319] TRIM function throws StringIndexOutOfBoundsException when result would be empty string
Author: dynamobi-build
Created: 2011-12-30 03:35:01+00:00
State: open
Labels: FRG, Runtime

[reporter="elin", created="Mon, 5 May 2008 19:22:43 -0500 (GMT-05:00)"]
Looks like anything which would result in an empty string output for the TRIM function give a StringIndexOutOfBoundsException. We should return empty string instead.

Here's the repro/stack trace:

0: jdbc:luciddb:> values (trim(' '));

Error: java.lang.StringIndexOutOfBoundsException: String index out of range: -2 (state=,code=0)

net.sf.farrago.jdbc.FarragoJdbcUtil$FarragoSqlException: java.lang.StringIndexOutOfBoundsException: String index out of range: -2

at java.lang.String.checkBounds(String.java:368)

at java.lang.String.(String.java:404)

at net.sf.farrago.type.runtime.EncodedCharPointer.toString(EncodedCharPointer.java:49)

at net.sf.farrago.type.runtime.EncodedCharPointer.getNullableData(EncodedCharPointer.java:77)

at net.sf.farrago.runtime.FarragoTupleIterResultSet.getRaw(FarragoTupleIterResultSet.java:227)

at org.eigenbase.util14.AbstractResultSet.getString(AbstractResultSet.java:195)

at net.sf.farrago.query.FarragoReentrantStmtExecutor.getResultRow(FarragoReentrantStmtExecutor.java:154)

at net.sf.farrago.query.FarragoReentrantStmtExecutor.executePlan(FarragoReentrantStmtExecutor.java:133)

at net.sf.farrago.query.FarragoReduceExpressionsRule$ReentrantValuesStmt.executeImpl(FarragoReduceExpressionsRule.java:425)

at net.sf.farrago.query.FarragoReentrantStmt.execute(FarragoReentrantStmt.java:104)

at net.sf.farrago.query.FarragoReduceExpressionsRule.reduceExpressions(FarragoReduceExpressionsRule.java:295)

at net.sf.farrago.query.FarragoReduceExpressionsRule$2.onMatch(FarragoReduceExpressionsRule.java:119)

at org.eigenbase.relopt.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:272)

at org.eigenbase.relopt.hep.HepPlanner.applyRule(HepPlanner.java:470)

at org.eigenbase.relopt.hep.HepPlanner.applyRules(HepPlanner.java:356)

at org.eigenbase.relopt.hep.HepPlanner.executeInstruction(HepPlanner.java:248)

at org.eigenbase.relopt.hep.HepInstruction$RuleClass.execute(HepInstruction.java:72)

at org.eigenbase.relopt.hep.HepPlanner.executeProgram(HepPlanner.java:173)

at org.eigenbase.relopt.hep.HepPlanner.findBestExp(HepPlanner.java:159)

at org.eigenbase.oj.stmt.OJPreparingStmt.optimize(OJPreparingStmt.java:364)

at net.sf.farrago.query.FarragoPreparingStmt.optimize(FarragoPreparingStmt.java:842)

at org.eigenbase.oj.stmt.OJPreparingStmt.prepareSql(OJPreparingStmt.java:329)

at net.sf.farrago.query.FarragoPreparingStmt.prepare(FarragoPreparingStmt.java:332)

at net.sf.farrago.db.FarragoDatabase$2.initializeEntry(FarragoDatabase.java:902)

at net.sf.farrago.util.FarragoObjectCache.tryPin(FarragoObjectCache.java:187)

at net.sf.farrago.util.FarragoObjectCache.pin(FarragoObjectCache.java:146)

at net.sf.farrago.db.FarragoDatabase.prepareStmtImpl(FarragoDatabase.java:931)

at net.sf.farrago.db.FarragoDatabase.prepareStmt(FarragoDatabase.java:777)

at net.sf.farrago.db.FarragoDbSession.prepareImpl(FarragoDbSession.java:1068)

at net.sf.farrago.db.FarragoDbSession.prepare(FarragoDbSession.java:993)

at net.sf.farrago.db.FarragoDbStmtContext.prepare(FarragoDbStmtContext.java:129)

at net.sf.farrago.jdbc.engine.FarragoJdbcEngineStatement.execute(FarragoJdbcEngineStatement.java:109)

at sqlline.SqlLine$Commands.execute(Unknown Source)

at sqlline.SqlLine$Commands.sql(Unknown Source)

at sqlline.SqlLine.dispatch(Unknown Source)

at sqlline.SqlLine.begin(Unknown Source)

at sqlline.SqlLine.mainWithInputRedirection(Unknown Source)

at sqlline.SqlLine.main(Unknown Source)

0: jdbc:luciddb:>