• Evgeny Potemkin's avatar
    Bug#57039: constant subtime expression returns incorrect result. · 4a5feb39
    Evgeny Potemkin authored
    The subtime function wasn't able to produce correct int representation of
    its result. For constant expressions the Item_datetime_cache is used to
    speedup evaluation and Item_datetime_cache expects underlying item to return
    correct int representation of DATETIME value. These two factors combined led
    to a wrong query result.
    
    Now the Item_func_add_time has function val_datetime which performs the
    calculation and saves result into given MYSQL_TIME struct, it also sets
    null_value to appropriate value. val_int and val_str member functions
    convert the result obtained from val_datetime to int or string respectively
    and returns it.
    
    mysql-test/r/func_time.result:
      Added a test case for the bug#57039.
    mysql-test/t/func_time.test:
      Added a test case for the bug#57039.
    sql/item_timefunc.cc:
      Bug#57039: constant subtime expression returns incorrect result.
      Now the Item_func_add_time has function val_datetime which performs the
      calculation and saves result into given MYSQL_TIME struct, it also sets
      null_value to appropriate value. val_int and val_str member functions
      convert the result obtained from val_datetime to int or string respectively
      and returns it.
    sql/item_timefunc.h:
      Bug#57039: constant subtime expression returns incorrect result.
    4a5feb39
item_timefunc.h 30 KB