You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Mihai Budiu (Jira)" <ji...@apache.org> on 2023/06/29 03:56:00 UTC

[jira] [Created] (CALCITE-5810) SUBSTRING compile-time evaluation gives wrong result for large lengths

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)