mirror of
https://github.com/MariaDB/server.git
synced 2026-05-05 22:55:32 +02:00
Merge mysql.com:/home/cps/mysql/trees/5.0-runtime-bug9191
into mysql.com:/home/cps/mysql/trees/5.1-runtime-bug9191
This commit is contained in:
commit
3df8165cf9
16 changed files with 356 additions and 68 deletions
|
|
@ -43,6 +43,12 @@ 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 TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1)
|
||||
#define TIMESTAMP_MAX_VALUE INT_MAX32
|
||||
#define TIMESTAMP_MIN_VALUE 1
|
||||
|
||||
/* two-digit years < this are 20..; >= this are 19.. */
|
||||
#define YY_PART_YEAR 70
|
||||
/* apply above magic to years < this */
|
||||
|
|
@ -76,6 +82,30 @@ uint calc_days_in_year(uint year);
|
|||
|
||||
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,
|
||||
my_bool *in_dst_time_gap);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue