summaryrefslogtreecommitdiff
path: root/include/my_time.h
diff options
context:
space:
mode:
authorunknown <petr/cps@mysql.com/owlet.local>2006-11-01 17:35:35 +0300
committerunknown <petr/cps@mysql.com/owlet.local>2006-11-01 17:35:35 +0300
commitb2c40c169869f7df93342b434b84af4fb26acbe2 (patch)
tree943fb5e51a9978101520019d70d4771a9085dfab /include/my_time.h
parent8db4dc3f91dfbe03181e63ed45bdf35a5d65aeb0 (diff)
parent8a7bc052885494b83fed51d785d9fc4b1cfa9df1 (diff)
downloadmariadb-git-b2c40c169869f7df93342b434b84af4fb26acbe2.tar.gz
Merge mysql.com:/home/cps/mysql/trees/4.1-runtime-bug9191
into mysql.com:/home/cps/mysql/trees/5.0-runtime-bug9191 configure.in: Auto merged include/my_time.h: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/timezone2.result: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/timezone2.test: Auto merged sql/mysql_priv.h: Auto merged sql/time.cc: Auto merged BitKeeper/deleted/.del-acinclude.m4~f4ab416bac5003: Auto merged sql-common/my_time.c: manual merge sql/item_timefunc.cc: manual merge sql/tztime.cc: manual merge
Diffstat (limited to 'include/my_time.h')
-rw-r--r--include/my_time.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/my_time.h b/include/my_time.h
index e52ef69475d..3f6d033d689 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 */
@@ -68,6 +76,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);