summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2011-02-02 18:51:35 +0200
committerGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2011-02-02 18:51:35 +0200
commita70c34bf0f34703fd330f8cb828e48b303c5296a (patch)
tree15a94e6095dd7f48a3a40e2c6d798d5f7b728b0e /include
parent7083cb0bd99c352dfb37828bee1c9de1d1edb068 (diff)
downloadmariadb-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')
-rw-r--r--include/config-win.h5
-rw-r--r--include/my_time.h13
2 files changed, 18 insertions, 0 deletions
diff --git a/include/config-win.h b/include/config-win.h
index 84705809d7a..5e37d9e3a20 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -167,6 +167,11 @@ typedef uint rf_SetTimer;
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define SIZEOF_OFF_T 8
+/*
+ The size of time_t depends on the compiler.
+ But it's 8 for all the supported VC versions.
+*/
+#define SIZEOF_TIME_T 8
#ifdef _WIN64
#define SIZEOF_CHARP 8
#else
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