Skip to content

Call to STRINGDECODE results in StringIndexOutOfBoundsException #2841

@mrigger

Description

@mrigger

Consider the following statement:

SELECT STRINGDECODE(X'5c38'); -- StringIndexOutOfBoundsException

Unexpectedly, the call to STRINGDECODE results in an StringIndexOutOfBoundsException:

Caused by: java.lang.StringIndexOutOfBoundsException: begin 1, end 4, length 2
    at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
    at java.base/java.lang.String.substring(String.java:1874)
    at org.h2.util.StringUtils.javaDecode(StringUtils.java:327)
    at org.h2.expression.function.StringFunction1.getValue(StringFunction1.java:137)
    at org.h2.expression.function.StringFunction1.optimize(StringFunction1.java:273)
    at org.h2.command.query.Select.prepare(Select.java:1170)
    at org.h2.command.Parser.prepareCommand(Parser.java:951)
    at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:618)
    at org.h2.engine.SessionLocal.prepareCommand(SessionLocal.java:556)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1139)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:221)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:207)

I found this based on commit 2b77de6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions