• Alexander Barkov's avatar
    MDEV-23838 Possibly wrong result or Assertion `0' failed in Item_func_round::native_op · 9e5c1fb5
    Alexander Barkov authored
    Change history in the affected code:
    
    - Since 10.4.8 (MDEV-20397 and MDEV-23311), functions ROUND(), CEILING(),
      FLOOR() return a TIME value for a TIME input.
    - Since 10.4.14 (MDEV-23525), MIN() and MAX() calculate a result for a TIME
      input using val_native() rather than val_str().
    
    Problem:
    
    The patch for MDEV-23525 did not take into account combinations like
    MIN(ROUND(time)), MAX(FLOOR(time)), etc.
    
    MIN() and MAX() with ROUND(time), CEILING(time), FLOOR(time) as an argument
    call the method val_native() of the undelying classes Item_func_round and
    Item_func_int_val. However these classes implemented the method val_native()
    as DBUG_ASSERT(0).
    
    Fix:
    
    This patch adds a TIME-specific code inside:
    - Item_func_round::val_native()
    - Item_func_int_val::val_native()
    still with DBUG_ASSERT(0) for all other data types,
    as other data types do not call val_native() of these classes.
    
    We'll need a more generic solition eventualy, e.g.
    turn Item_func_round and Item_func_int_val into Item_handled_func.
    However, this change would be too risky for 10.4 at this point.
    9e5c1fb5
item_func.h 109 KB