• bar@mysql.com's avatar
    Bug#8663 cant use bgint unsigned as input to cast · a481a352
    bar@mysql.com 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.
    a481a352
cast.result 9.1 KB