Mihai Budiu created CALCITE-5810:
------------------------------------

             Summary: SUBSTRING compile-time evaluation gives wrong result for 
large lengths
                 Key: CALCITE-5810
                 URL: https://issues.apache.org/jira/browse/CALCITE-5810
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.34.0
            Reporter: Mihai Budiu


This program 
{code:sql}
SELECT SUBSTRING('string' FROM 2 FOR 2147483646) 
{code}
returns "" instead of "tring".
This happens because of an overflow in the SqlFunctions substring function:
{code:java}
public static String substring(String c, int s, int l) {
    int lc = c.length();
    int e = s + l;  // <<<< OVERFLOW here
{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to