diff options
author | unknown <tnurnberg@mysql.com/white.intern.koehntopp.de> | 2007-12-11 10:12:05 +0100 |
---|---|---|
committer | unknown <tnurnberg@mysql.com/white.intern.koehntopp.de> | 2007-12-11 10:12:05 +0100 |
commit | 08b256f9df73fab94cc662d83b14131c59056385 (patch) | |
tree | fedb6851ea468b3096b7c68285811f5fb96c0141 /mysql-test/t/type_date.test | |
parent | 4618d68d6d85141cd2422c892ed5053c72aa097a (diff) | |
download | mariadb-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 'mysql-test/t/type_date.test')
-rw-r--r-- | mysql-test/t/type_date.test | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index 507537457d3..3f2ee4234bd 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -190,4 +190,12 @@ INSERT INTO t1 VALUES ('0000-00-00'); SET SQL_MODE=DEFAULT; DROP TABLE t1,t2; +# +# Bug #31990: MINUTE() and SECOND() return bogus results when used on a DATE +# + +CREATE TABLE t1 SELECT curdate() AS f1; +SELECT hour(f1), minute(f1), second(f1) FROM t1; +DROP TABLE t1; + --echo End of 5.0 tests |