summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorunknown <petr/cps@outpost.site>2006-11-06 00:05:02 +0300
committerunknown <petr/cps@outpost.site>2006-11-06 00:05:02 +0300
commit6cf8ceebbfa7c73d933e970c38c3c6aa5a3483c7 (patch)
tree2ea2865a3f7ab2aa574df1b7ebb91036b1e2dce8 /include
parent0d92b17851f8a42f25bcb44695a5a653b85750a5 (diff)
parente32e7ca0603a70a260194de269899882dd5b8f3a (diff)
downloadmariadb-git-6cf8ceebbfa7c73d933e970c38c3c6aa5a3483c7.tar.gz
Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-4.1-runtime
into outpost.site:/home/cps/mysql/trees/4.1-runtime-bug9191 mysql-test/r/func_time.result: Auto merged mysql-test/t/func_time.test: Auto merged sql/item_timefunc.cc: Auto merged sql/mysql_priv.h: Auto merged
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 94701e159c4..dd149d19b10 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 */
@@ -55,6 +63,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);