Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-4956

Cast from character types to int is different for literals and non-literals

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 10.7.1.1
    • Fix Version/s: None
    • Component/s: SQL
    • Urgency:
      Normal
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Deviation from standard

      Description

      A string representing a floating point number can be cast to int if the string is a literal, but not otherwise. Casting of literals and non-literals to int should behave the same way.

      Examples:

      ij> values cast('1.1' as integer);
      1
      -----------
      1

      1 row selected
      ij> values cast(cast('1.1' as char(3)) as integer);
      1
      -----------
      ERROR 22018: Invalid character string format for type INTEGER.
      ij> values cast(cast('1.1' as varchar(3)) as integer);
      1
      -----------
      ERROR 22018: Invalid character string format for type INTEGER.
      ij> values cast('1e3' as int);
      1
      -----------
      1000

      1 row selected
      ij> values cast(cast('1e3' as char(3)) as int);
      1
      -----------
      ERROR 22018: Invalid character string format for type INTEGER.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              knutanders Knut Anders Hatlen
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: