summaryrefslogtreecommitdiff
path: root/mysql-test/t/date_formats.test
diff options
context:
space:
mode:
authorTatiana A. Nurnberg <azundris@mysql.com>2009-01-08 10:25:31 +0100
committerTatiana A. Nurnberg <azundris@mysql.com>2009-01-08 10:25:31 +0100
commitc42892d61413adea81c174a90d458c07a8ddd52c (patch)
tree852b3f5c961cbd640ea97deb0fed925abe3ba174 /mysql-test/t/date_formats.test
parent374f49b2629114a9473268da4321af405a9d2394 (diff)
downloadmariadb-git-c42892d61413adea81c174a90d458c07a8ddd52c.tar.gz
Bug#41470: DATE_FORMAT() crashes the complete server with a valid date
Passing dubious "year zero" in non-zero date (not "0000-00-00") could lead to negative value for year internally, while variable was unsigned. This led to Really Bad Things further down the line. Now doing calculations with signed type for year internally. mysql-test/r/date_formats.result: show that very early dates no longer break DATE_FORMAT(..., '%W') mysql-test/t/date_formats.test: show that very early dates no longer break DATE_FORMAT(..., '%W') sql-common/my_time.c: Allow negative years numbers internally while keeping the interface. otherwise if somebody passes year zero for whatever reason, we'll get an integer wrap-around that can lead to Really Bad Things further down the line. Note that amusingly, calcday_nr() already had signed output and calc_weekday() already had signed input, anyway.
Diffstat (limited to 'mysql-test/t/date_formats.test')
-rw-r--r--mysql-test/t/date_formats.test12
1 files changed, 12 insertions, 0 deletions
diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test
index faa6d4242db..0c02398acc1 100644
--- a/mysql-test/t/date_formats.test
+++ b/mysql-test/t/date_formats.test
@@ -337,3 +337,15 @@ select str_to_date('04/30 /2004', '%m /%d /%Y');
select str_to_date('04/30/2004 ', '%m/%d/%Y ');
--echo "End of 4.1 tests"
+
+#
+# Bug #41470: DATE_FORMAT() crashes the complete server with a valid date
+#
+
+# show that these two do not crash the server:
+SELECT DATE_FORMAT("0000-01-01",'%W %d %M %Y') as valid_date;
+SELECT DATE_FORMAT("0000-02-28",'%W %d %M %Y') as valid_date;
+# show that date within the Gregorian range render correct results: (THU)
+SELECT DATE_FORMAT("2009-01-01",'%W %d %M %Y') as valid_date;
+
+--echo "End of 5.0 tests"