diff options
author | unknown <tnurnberg@mysql.com/white.intern.koehntopp.de> | 2007-11-10 13:33:42 +0100 |
---|---|---|
committer | unknown <tnurnberg@mysql.com/white.intern.koehntopp.de> | 2007-11-10 13:33:42 +0100 |
commit | ac3ef6c75925c7e543c8ee1cbd5d0cd78a004d78 (patch) | |
tree | 79715a3335f5e74367695dce0f92b1c4cc8b2656 /sql-common | |
parent | 9e6bb07d3845566ffa7274bb14df544c8147f594 (diff) | |
download | mariadb-git-ac3ef6c75925c7e543c8ee1cbd5d0cd78a004d78.tar.gz |
Bug#31800: Date comparison fails with timezone and slashes for greater than comparison
BETWEEN was more lenient with regard to what it accepted as a DATE/DATETIME
in comparisons than greater-than and less-than were. ChangeSet makes < >
comparisons similarly robust with regard to trailing garbage (" GMT-1")
and "missing" leading zeros. Now all three comparators behave similarly
in that they throw a warning for "junk" at the end of the data, but then
proceed anyway if possible. Before < > fell back on a string- (rather than
date-) comparison when a warning-condition was raised in the string-to-date
conversion. Now the fallback only happens on actual errors, while warning-
conditions still result in a warning being to delivered to the client.
mysql-test/r/select.result:
Show that we compare DATE/DATETIME-like strings as date(time)s
now, rather than as bin-strings.
Adjust older result as "2005-09-3a" is now correctly seen as
"2005-09-3" + trailing garbage, rather than as "2005-09-30".
mysql-test/t/select.test:
Show that we compare DATE/DATETIME-like strings as date(time)s
now, rather than as bin-strings.
sql-common/my_time.c:
correct/clarify date-related comments, particulary for check_date().
doxygenize comment while at it.
sql/item_cmpfunc.cc:
get_date_from_str() no longer signals an error when all we had
was a warning-condition -- and one we already gave the user a
warning for at that. Preamble doxygenized.
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/my_time.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 3c08db6bf97..453c7b73008 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -54,24 +54,24 @@ uint calc_days_in_year(uint year) 366 : 365); } -/* - Check datetime value for validity according to flags. - - SYNOPSIS - check_date() - ltime Date to check. - not_zero_date ltime is not the zero date - flags flags to check - was_cut set to 2 if value was truncated. - NOTE: This is not touched if value was not truncated - NOTES - Here we assume that year and month is ok ! +/** + @brief Check datetime value for validity according to flags. + + @param[in] ltime Date to check. + @param[in] not_zero_date ltime is not the zero date + @param[in] flags flags to check + (see str_to_datetime() flags in my_time.h) + @param[out] was_cut set to 2 if value was invalid according to flags. + (Feb 29 in non-leap etc.) This remains unchanged + if value is not invalid. + + @details 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 + @return + 0 OK 1 error */ @@ -117,9 +117,9 @@ my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, TIME_NO_ZERO_IN_DATE Don't allow partial dates TIME_NO_ZERO_DATE Don't allow 0000-00-00 date TIME_INVALID_DATES Allow 2000-02-31 - was_cut 0 Value ok + was_cut 0 Value OK 1 If value was cut during conversion - 2 Date part was within ranges but date was wrong + 2 check_date(date,flags) considers date invalid DESCRIPTION At least the following formats are recogniced (based on number of digits) @@ -1087,7 +1087,7 @@ int my_TIME_to_str(const MYSQL_TIME *l_time, char *to) flags - flags to use in validating date, as in str_to_datetime() was_cut 0 Value ok 1 If value was cut during conversion - 2 Date part was within ranges but date was wrong + 2 check_date(date,flags) considers date invalid DESCRIPTION Convert a datetime value of formats YYMMDD, YYYYMMDD, YYMMDDHHMSS, |