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

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

     [ https://issues.apache.org/jira/browse/CALCITE-5810?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tanner Clary resolved CALCITE-5810.
-----------------------------------
    Fix Version/s: 1.35.0
         Assignee: Mihai Budiu
       Resolution: Fixed

Merged via [301f77|https://github.com/apache/calcite/commit/301f770a66ef3d26c9d4e8d274eae0f92a819e00], thanks for the PR, [~mbudiu]!

> 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
>            Assignee: Mihai Budiu
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.35.0
>
>
> 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)