summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorpetr/cps@mysql.com/owlet.local <>2006-11-01 17:35:35 +0300
committerpetr/cps@mysql.com/owlet.local <>2006-11-01 17:35:35 +0300
commit7974bf90aab8337cb6b68955a3e5db68bcd3e081 (patch)
tree943fb5e51a9978101520019d70d4771a9085dfab /include
parent643606cac9ee6e7ca3deefaf2a98af85223eff29 (diff)
parent3ec542dfbdd08c13a6c33b07f7ddd9650c0e0ad8 (diff)
downloadmariadb-git-7974bf90aab8337cb6b68955a3e5db68bcd3e081.tar.gz
Merge mysql.com:/home/cps/mysql/trees/4.1-runtime-bug9191
into mysql.com:/home/cps/mysql/trees/5.0-runtime-bug9191
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 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);