Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5810

SUBSTRING compile-time evaluation gives wrong result for large lengths

    XMLWordPrintableJSON

Details

    Description

      This program

      SELECT SUBSTRING('string' FROM 2 FOR 2147483646) 
      

      returns "" instead of "tring".
      This happens because of an overflow in the SqlFunctions substring function:

      public static String substring(String c, int s, int l) {
          int lc = c.length();
          int e = s + l;  // <<<< OVERFLOW here
      

      Attachments

        Issue Links

          Activity

            People

              mbudiu Mihai Budiu
              mbudiu Mihai Budiu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: