Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-18175

SQL: value out of type bounds is converted into 0 during implicit casting

    XMLWordPrintableJSON

Details

    • Docs Required, Release Notes Required

    Description

      A simple scenario:

      create table test_e011_INTEGER_from (key_field INT PRIMARY KEY, field1 INTEGER);
      insert into test_e011_INTEGER_from (key_field, field1) values (1, -2147483648);
      
      create table test_e011_SMALLINT (key_field INT PRIMARY KEY, field1_SMALLINT SMALLINT);
      insert into test_e011_SMALLINT (key_field, field1_SMALLINT) values (1, (select field1 from test_e011_INTEGER_from where key_field=1));
      
      select * from test_e011_SMALLINT;
      

      I expect it either to return '1, null' (like in postrgres or sqlite3) or to raise an error on insert (like in GG8) as value of -2147483648 is out of bounds for SMALLINT data type.
      Instead, '1, 0' is stored within test_e011_SMALLINT table and returned from select. In other words, -2147483648 was converted into 0. Such behavior seems as incorrect.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              akhitrin Andrey Khitrin
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: