summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorunknown <petr/cps@outpost.site>2006-11-10 15:05:38 +0300
committerunknown <petr/cps@outpost.site>2006-11-10 15:05:38 +0300
commitcb80733a898236445a0bcf893b1d7d3d64d2b03c (patch)
treeb66a727b703588ca78df0c1428526178a483cba2 /include
parentfacaaeb4c4fab01188b0e79ef1c3787a87e5d252 (diff)
parent6cf8ceebbfa7c73d933e970c38c3c6aa5a3483c7 (diff)
downloadmariadb-git-cb80733a898236445a0bcf893b1d7d3d64d2b03c.tar.gz
Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-4.1
into outpost.site:/home/cps/mysql/trees/4.1-runtime-bug9191 configure.in: Auto merged include/my_time.h: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/rename.result: Auto merged mysql-test/t/func_time.test: Auto merged sql-common/my_time.c: Auto merged sql/item_timefunc.cc: Auto merged sql/time.cc: Auto merged mysql-test/t/rename.test: choose one of the race problem solutions. It was solved differently in -runtime and mainstream
Diffstat (limited to 'include')
-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 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);