diff options
author | Georgi Kodinov <Georgi.Kodinov@Oracle.com> | 2011-02-02 18:51:35 +0200 |
---|---|---|
committer | Georgi Kodinov <Georgi.Kodinov@Oracle.com> | 2011-02-02 18:51:35 +0200 |
commit | a70c34bf0f34703fd330f8cb828e48b303c5296a (patch) | |
tree | 15a94e6095dd7f48a3a40e2c6d798d5f7b728b0e /include/my_time.h | |
parent | 7083cb0bd99c352dfb37828bee1c9de1d1edb068 (diff) | |
download | mariadb-git-a70c34bf0f34703fd330f8cb828e48b303c5296a.tar.gz |
Fixes for Bug #55755 and Bug #52315 part 2
Bug #55755 : Date STD variable signness breaks server on FreeBSD and OpenBSD
* Added a check to configure on the size of time_t
* Created a macro to check for a valid time_t that is safe to use with datetime
functions and store in TIMESTAMP columns.
* Used the macro consistently instead of the ad-hoc checks introduced by 52315
* Fixed compliation warnings on platforms where the size of time_t is smaller than
the size of a long (e.g. OpenBSD 4.8 64 amd64).
Bug #52315: utc_date() crashes when system time > year 2037
* Added a correct check for the timestamp range instead of just variable size check to
SET TIMESTAMP.
* Added overflow checking before converting to time_t.
* Using a correct localized error message in this case instead of the generic error.
* Added a test suite.
* fixed the checks so that they check for unsigned time_t as well. Used the checks
consistently across the source code.
* fixed the original test case to expect the new error code.
Diffstat (limited to 'include/my_time.h')
-rw-r--r-- | include/my_time.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/my_time.h b/include/my_time.h index 014327d6fd8..5603535e0b7 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -53,6 +53,19 @@ typedef long my_time_t; #define YY_PART_YEAR 70 +/* + check for valid times only if the range of time_t is greater than + the range of my_time_t +*/ +#if SIZEOF_TIME_T > 4 || defined(TIME_T_UNSIGNED) +# define IS_TIME_T_VALID_FOR_TIMESTAMP(x) \ + ((x) <= TIMESTAMP_MAX_VALUE && \ + (x) >= TIMESTAMP_MIN_VALUE) +#else +# define IS_TIME_T_VALID_FOR_TIMESTAMP(x) \ + ((x) >= TIMESTAMP_MIN_VALUE) +#endif + /* Flags to str_to_datetime */ #define TIME_FUZZY_DATE 1 #define TIME_DATETIME_ONLY 2 |