summaryrefslogtreecommitdiff
path: root/sql/field.h
diff options
context:
space:
mode:
authorunknown <tnurnberg@mysql.com/white.intern.koehntopp.de>2007-12-11 10:12:05 +0100
committerunknown <tnurnberg@mysql.com/white.intern.koehntopp.de>2007-12-11 10:12:05 +0100
commit08b256f9df73fab94cc662d83b14131c59056385 (patch)
treefedb6851ea468b3096b7c68285811f5fb96c0141 /sql/field.h
parent4618d68d6d85141cd2422c892ed5053c72aa097a (diff)
downloadmariadb-git-08b256f9df73fab94cc662d83b14131c59056385.tar.gz
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. Also fixes similar bug in Date-Field now. 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/r/type_date.result: Show that HOUR(), MINUTE(), ... return sensible values when used on DATE-fields. 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. mysql-test/t/type_date.test: Show that HOUR(), MINUTE(), ... return sensible values when used on DATE-fields. sql/field.cc: Add get_time() method to DATE-field object to overload the method in Field superclass that would return spurious results. Return zero-result. sql/field.h: Add get_time() declaration to date-field class 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.
Diffstat (limited to 'sql/field.h')
-rw-r--r--sql/field.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/field.h b/sql/field.h
index 8c01931fa21..8ae39f78558 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -933,6 +933,7 @@ public:
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
+ bool get_time(MYSQL_TIME *ltime);
bool send_binary(Protocol *protocol);
int cmp(const char *,const char*);
void sort_string(char *buff,uint length);