diff options
author | petr/cps@outpost.site <> | 2006-11-10 15:05:38 +0300 |
---|---|---|
committer | petr/cps@outpost.site <> | 2006-11-10 15:05:38 +0300 |
commit | e06f74f9f9ad87a088fa6cf90c97c5b670f31636 (patch) | |
tree | b66a727b703588ca78df0c1428526178a483cba2 /include | |
parent | f8931288398b545a08af9b5aef2a690f6ccaeb57 (diff) | |
parent | 8de747b0c716e49898f7bf188dab1de5cf1a708e (diff) | |
download | mariadb-git-e06f74f9f9ad87a088fa6cf90c97c5b670f31636.tar.gz |
Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-4.1
into outpost.site:/home/cps/mysql/trees/4.1-runtime-bug9191
Diffstat (limited to 'include')
-rw-r--r-- | include/my_time.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/my_time.h b/include/my_time.h index 11c653f70d0..2fc45c8f874 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -38,6 +38,14 @@ typedef long my_time_t; #define MY_TIME_T_MAX LONG_MAX #define MY_TIME_T_MIN LONG_MIN + +/* Time handling defaults */ +#define TIMESTAMP_MAX_YEAR 2038 +#define YY_PART_YEAR 70 +#define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1) +#define TIMESTAMP_MAX_VALUE INT_MAX32 +#define TIMESTAMP_MIN_VALUE 1 + #define YY_PART_YEAR 70 /* Flags to str_to_datetime */ @@ -67,6 +75,30 @@ long calc_daynr(uint year,uint month,uint day); void init_time(void); + +/* + Function to check sanity of a TIMESTAMP value + + DESCRIPTION + Check if a given MYSQL_TIME value fits in TIMESTAMP range. + This function doesn't make precise check, but rather a rough + estimate. + + RETURN VALUES + FALSE The value seems sane + TRUE The MYSQL_TIME value is definitely out of range +*/ + +static inline bool validate_timestamp_range(const MYSQL_TIME *t) +{ + if ((t->year > TIMESTAMP_MAX_YEAR || t->year < TIMESTAMP_MIN_YEAR) || + (t->year == TIMESTAMP_MAX_YEAR && (t->month > 1 || t->day > 19)) || + (t->year == TIMESTAMP_MIN_YEAR && (t->month < 12 || t->day < 31))) + return FALSE; + + return TRUE; +} + my_time_t my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap); |