diff options
author | msvensson@neptunus.(none) <> | 2006-11-24 12:12:25 +0100 |
---|---|---|
committer | msvensson@neptunus.(none) <> | 2006-11-24 12:12:25 +0100 |
commit | 86f0d1bb03de2bb068ecee62b833e6d39bb27f5d (patch) | |
tree | 857a75fef3cd023ca835be3648bb195609b13cdb /include | |
parent | 354e9c4ea4a6827937dc1e4d08f57548eb8207c1 (diff) | |
parent | a6801d4fe44b8471c7f1c51f6a9e7945a533716b (diff) | |
download | mariadb-git-86f0d1bb03de2bb068ecee62b833e6d39bb27f5d.tar.gz |
Merge neptunus.(none):/home/msvensson/mysql/mysql-4.1
into neptunus.(none):/home/msvensson/mysql/mysql-4.1-maint
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); |