• unknown's avatar
    Bug#28778: Wrong result of BETWEEN when comparing a DATETIME field with an · 0304a13e
    unknown authored
    integer constants.
    
    This bug is introduced by the fix for bug#16377. Before the fix the 
    Item_func_between::fix_length_and_dec method converted the second and third
    arguments to the type of the first argument if they were constant and the first
    argument is of the DATE/DATETIME type. That approach worked well for integer
    constants and sometimes produced bad result for string constants. The fix for
    the bug#16377 wrongly removed that code at all and as a result of this the
    comparison of a DATETIME field and an integer constant was carried out in a
    wrong way and sometimes led to wrong result sets.
    
    Now the Item_func_between::fix_length_and_dec method converts the second and
    third arguments to the type of the first argument if they are constant, the
    first argument is of the DATE/DATETIME type and the DATETIME comparator isn't
    applicable.
    
    
    sql/item_cmpfunc.cc:
      Bug#28778: Wrong result of BETWEEN when comparing a DATETIME field with an
      integer constants.
      Now the Item_func_between::fix_length_and_dec method converts the second and
      third arguments to the type of the first argument if they are constant, the
      first argument is of the DATE/DATETIME type and the DATETIME comparator isn't
      applicable.
    mysql-test/r/type_datetime.result:
      Added a test case for the bug#28778: Wrong result of BETWEEN when comparing a DATETIME
      field with an integer constants.
    mysql-test/t/type_datetime.test:
      Added a test case for the bug#28778: Wrong result of BETWEEN when comparing a DATETIME
      field with an integer constants.
    0304a13e
item_cmpfunc.cc 122 KB