mirror of
https://github.com/MariaDB/server.git
synced 2025-08-30 11:22:14 +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:

parent
6b92ec4acb
commit
5a5ed2a509
@@ -414,4 +414,28 @@ NULL
|
||||
NULL
|
||||
20070719
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (f1 DATE);
|
||||
INSERT INTO t1 VALUES ('2007-07-19'), (NULL);
|
||||
SELECT HOUR(f1),
|
||||
MINUTE(f1),
|
||||
SECOND(f1) FROM t1;
|
||||
HOUR(f1) MINUTE(f1) SECOND(f1)
|
||||
0 0 0
|
||||
NULL NULL NULL
|
||||
SELECT HOUR(CAST('2007-07-19' AS DATE)),
|
||||
MINUTE(CAST('2007-07-19' AS DATE)),
|
||||
SECOND(CAST('2007-07-19' AS DATE));
|
||||
HOUR(CAST('2007-07-19' AS DATE)) MINUTE(CAST('2007-07-19' AS DATE)) SECOND(CAST('2007-07-19' AS DATE))
|
||||
0 0 0
|
||||
SELECT HOUR(CAST(NULL AS DATE)),
|
||||
MINUTE(CAST(NULL AS DATE)),
|
||||
SECOND(CAST(NULL AS DATE));
|
||||
HOUR(CAST(NULL AS DATE)) MINUTE(CAST(NULL AS DATE)) SECOND(CAST(NULL AS DATE))
|
||||
NULL NULL NULL
|
||||
SELECT HOUR(NULL),
|
||||
MINUTE(NULL),
|
||||
SECOND(NULL);
|
||||
HOUR(NULL) MINUTE(NULL) SECOND(NULL)
|
||||
NULL NULL NULL
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
|
Reference in New Issue
Block a user