• unknown's avatar
    Bug#23656: Wrong conversion result of a DATETIME to integer using CAST function. · 4fd339b2
    unknown authored
    The generic string to int conversion was used by the Item_func_signed and
    the Item_func_unsigned classes to convert DATE/DATETIME values to the
    SIGNED/UNSIGNED type. But this conversion produces wrong results for such
    values.
    
    Now if the item which result has to be converted can return its result as
    longlong then the item->val_int() method is used to allow the item to carry
    out the conversion itself and return the correct result.
    This condition is checked in the Item_func_signed::val_int() and the
    Item_func_unsigned::val_int() functions.
    
    
    mysql-test/t/cast.test:
      Added a test case for the bug#23656: Wrong conversion result of a DATETIME to integer using CAST function.
    mysql-test/r/cast.result:
      Added a test case for the bug#23656: Wrong conversion result of a DATETIME to integer using CAST function.
    sql/item_func.cc:
      Bug#23656: Wrong conversion result of a DATETIME to integer using CAST function.
      Now if the item which result has to be converted can return its result as
      longlong then the item->val_int() method is used to allow the item to carry
      out the conversion itself and return the correct result.
      This condition is checked in the Item_func_signed::val_int() and the
      Item_func_unsigned::val_int() functions.
    4fd339b2
item_func.cc 80.7 KB