[
https://issues.apache.org/jira/browse/CALCITE-5810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17740709#comment-17740709
]
Tanner Clary commented on CALCITE-5810:
---------------------------------------
I disrupted the commit chain so the more accurate commit link is
[here|https://github.com/apache/calcite/commit/1dd1b4ac85bd16ecb5acb77a4649c869e3267e35].
> 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)