• unknown's avatar
    Bug#31990: MINUTE() and SECOND() return bogus results when used on a DATE · b1fc4b9e
    unknown authored
    HOUR(), MINUTE(), ... returned spurious results when used on a DATE-cast.
    This happened because DATE-cast object did not overload get_time() method
    in superclass Item. The default method was inappropriate here and
    misinterpreted the data.
    
    Patch adds missing method; get_time() on DATE-casts now returns SQL-NULL
    on NULL input, 0 otherwise. This coincides with the way DATE-columns
    behave.
    
    
    mysql-test/r/cast.result:
      Show that HOUR(), MINUTE(), ... return sensible values when used
      on DATE-cast objects, namely NULL for NULL-dates and 0 otherwise.
      Show that this coincides with how DATE-columns behave.
    mysql-test/t/cast.test:
      Show that HOUR(), MINUTE(), ... return sensible values when used
      on DATE-cast objects, namely NULL for NULL-dates and 0 otherwise.
      Show that this coincides with how DATE-columns behave.
    sql/item_timefunc.cc:
      Add get_time() method to DATE-cast object to overload
      the method in Item superclass that would return spurious
      results. Return zero-result; flag NULL if input was NULL.
    sql/item_timefunc.h:
      Add get_time() declaration to DATE-cast object.
    b1fc4b9e
cast.test 8.02 KB