• unknown's avatar
    Bug#8663 cant use bgint unsigned as input to cast · 15b4b00e
    unknown authored
    Problem: cast to unsigned limited result to 
    max signed bigint 9223372036854775808,
    instead of max unsigned bigint 18446744073709551615.
    
    Fix: don't use args[0]->val_int() when casting from
    a floating point number, use val() instead, with range checkings,
    special to unsigned data type.
    
    item_func.cc:
      Special handling of cast from REAL_RESULT
      to unsigned int: we cannot execute args[0]->val_int()
      because it cuts max allowed value to LONGLONG_INT,
      instead of ULONGLONG_INT required.
    count_distinct3.test:
      Getting rid of "Data truncated; out of range ..." warnings.
    cast.test, cast.result:
      Adding test case.
    ps.result:
      Fixing that cast from 6570515219.6535 
      to unsigned didn't round to 6570515220,
      and returned 6570515219 instead.
    
    
    mysql-test/r/cast.result:
      Adding test case.
    mysql-test/r/ps.result:
      Fixing that cast from 6570515219.6535 
      to unsigned didn't round to 6570515220,
      and returned 6570515219 instead.
    mysql-test/t/cast.test:
      Adding test case.
    mysql-test/t/count_distinct3.test:
      Get rid of "wring unsigned value"
      warnings.
    sql/item_func.cc:
      Special handling of cast from REAL)RESULT
      to unsigned int: we cannot execute args[0]->val_int()
      because it cuts max allowed value to LONGLONG_INT,
      instead of ULONGLONG_INT required.
    15b4b00e
cast.result 9.1 KB