diff options
author | unknown <guilhem@mysql.com> | 2003-11-26 17:06:24 +0100 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2003-11-26 17:06:24 +0100 |
commit | 0b0a79e3718f2c78fea4a4122c0bfc406feb54c4 (patch) | |
tree | c88c787bab5b75c12ee8949f2ba3f48dcb9f982c /mysql-test | |
parent | e503dc2850de9ca1edad5169eca09ee437a3354d (diff) | |
download | mariadb-git-0b0a79e3718f2c78fea4a4122c0bfc406feb54c4.tar.gz |
Fix for BUG#1960 "date_format() returns spurious '-' for valid dates".
It was a forgotten ltime->neg=0 (neg was the only forgotten variable).
I scanned field.cc for other places where we would forget to set neg, found none.
A test for the bug.
mysql-test/r/date_formats.result:
result update
mysql-test/t/date_formats.test:
a test for BUG#1960 "date_format() returns spurious '-' for valid dates"
sql/field.cc:
When preparing ltime from the 3-byte date, don't forget to set ltime->neg to 0
(otherwise it remains unitialized).
Dates are not allowed to be negative (only times can be, when they mean a time interval),
so it's ok to always set neg to 0.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/date_formats.result | 7 | ||||
-rw-r--r-- | mysql-test/t/date_formats.test | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 5eb21c40a3e..ee4fa074477 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -330,3 +330,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 select high_priority makedate(1997,1) AS `makedate(1997,1)`,addtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,subtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,timediff(_latin1'01.01.97 11:59:59.000001 PM',_latin1'31.12.95 11:59:59.000002 PM') AS `timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM")`,cast(str_to_date(_latin1'15-01-2001 12:59:59',_latin1'%d-%m-%Y %H:%i:%S') as time) AS `cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME)`,maketime(23,11,12) AS `maketime(23,11,12)`,microsecond(_latin1'1997-12-31 23:59:59.000001') AS `microsecond("1997-12-31 23:59:59.000001")` +create table t1 (d date); +insert into t1 values ('2004-07-14'),('2005-07-14'); +select date_format(d,"%d") from t1 order by 1; +date_format(d,"%d") +14 +14 +drop table t1; diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index d9219d3ac2e..7b88c0ecf72 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -200,3 +200,12 @@ select get_format(DATE, 'TEST') as a; select str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA')); explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM"),cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME), maketime(23,11,12),microsecond("1997-12-31 23:59:59.000001"); + +# +# Test of date_format() +# + +create table t1 (d date); +insert into t1 values ('2004-07-14'),('2005-07-14'); +select date_format(d,"%d") from t1 order by 1; +drop table t1; |