1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Bug#31990: MINUTE() and SECOND() return bogus results when used on a DATE

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.
This commit is contained in:
tnurnberg@mysql.com/white.intern.koehntopp.de
2007-11-08 06:08:44 +01:00
parent 6b92ec4acb
commit 5a5ed2a509
4 changed files with 54 additions and 0 deletions

View File

@@ -2645,6 +2645,13 @@ bool Item_date_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
}
bool Item_date_typecast::get_time(MYSQL_TIME *ltime)
{
bzero((char *)ltime, sizeof(MYSQL_TIME));
return args[0]->null_value;
}
String *Item_date_typecast::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);