diff options
author | unknown <ramil/ram@mysql.com/myoffice.izhnet.ru> | 2006-07-12 11:38:11 +0500 |
---|---|---|
committer | unknown <ramil/ram@mysql.com/myoffice.izhnet.ru> | 2006-07-12 11:38:11 +0500 |
commit | 97a3d52682e9e92d2526b5260521d3a35bdce311 (patch) | |
tree | 4d9763aadeb02a1ab65d1606d49622eea1ad9360 /sql-common/my_time.c | |
parent | 4d71b8f8f91fae06641a4913c3cfba6ba8929f57 (diff) | |
download | mariadb-git-97a3d52682e9e92d2526b5260521d3a35bdce311.tar.gz |
Fix for bug #19370: DateTime datatype in MySQL has two bugs in it
mysql-test/r/date_formats.result:
Fix for bug #19370: DateTime datatype in MySQL has two bugs in it
- results adjusted
mysql-test/r/strict.result:
Fix for bug #19370: DateTime datatype in MySQL has two bugs in it
- results adjusted
mysql-test/r/type_datetime.result:
Fix for bug #19370: DateTime datatype in MySQL has two bugs in it
- results adjusted
mysql-test/t/strict.test:
Fix for bug #19370: DateTime datatype in MySQL has two bugs in it
- tests adjusted
sql-common/my_time.c:
Fix for bug #19370: DateTime datatype in MySQL has two bugs in it
- Regardless of the title of the bug the only real bug is that it
doesn't make sense to have only some invalid parts in a date.
E.g. a valid day among invalid years or months is totally ambiguous
and we should refuse to guess what it means.
To fix it, we add a check that both the year is zero and either day
or month are zero (year and (day or month)), and if they are then we
reject such dates. Doing so should adequately fix the reported problem.
Diffstat (limited to 'sql-common/my_time.c')
-rw-r--r-- | sql-common/my_time.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c index c9d39260761..93bf23ed284 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -69,6 +69,7 @@ uint calc_days_in_year(uint year) Here we assume that year and month is ok ! If month is 0 we allow any date. (This only happens if we allow zero date parts in str_to_datetime()) + Disallow dates with zero year and non-zero month and/or day. RETURN 0 ok @@ -85,7 +86,8 @@ static my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, (!(flags & TIME_INVALID_DATES) && ltime->month && ltime->day > days_in_month[ltime->month-1] && (ltime->month != 2 || calc_days_in_year(ltime->year) != 366 || - ltime->day != 29))) + ltime->day != 29)) || + (ltime->year == 0 && (ltime->month != 0 || ltime->day != 0))) { *was_cut= 2; return TRUE; |