summaryrefslogtreecommitdiff
path: root/include/my_time.h
diff options
context:
space:
mode:
authorunknown <tnurnberg@mysql.com>2006-05-16 03:32:24 +0200
committerunknown <tnurnberg@mysql.com>2006-05-16 03:32:24 +0200
commitb41b0fd62baec0e09ac4dcb0733f3d092694f4dc (patch)
tree2e5e872fb3ab41cbe007ca6345f66bfd46672ad6 /include/my_time.h
parente8c981c7a5176bf3d108a4e33cbd5be24e16f3ce (diff)
downloadmariadb-git-b41b0fd62baec0e09ac4dcb0733f3d092694f4dc.tar.gz
Bug#18997: DATE_ADD and DATE_SUB perform year2K autoconversion magic on 4-digit year value
if input year for date_add() / date_sub() with INTERVAL is low enough for calc_daynr() to possibly return incorrect results (calc_daynr() has no information on whether the year is low because it was a two-digit year ('77) or because it was a really low four-digit year (0077) and will indiscriminately try to turn the value into a four-digit year by adding 1900 or 2000 respectively), the functions will now throw NULL. include/my_time.h: new define YY_MAGIC_BELOW: if year is below this threshold, magic kicks in in calc_daynr(). the idea is to convert two-digit years to four-digit ones, adding 1900 to values >= YY_PART_YEAR or adding 2000 otherwise. current value of YY_MAGIC_BELOW derived from original code in calc_daynr() mysql-test/r/func_time.result: test where 2 digit -> 4 digit year magic kicks in, and whether we throw NULL when it happens mysql-test/t/func_time.test: test where 2 digit -> 4 digit year magic kicks in, and whether we throw NULL when it happens sql-common/my_time.c: use new const YY_MAGIC_BELOW, apply 2-digit -> 4-digit magic only to years below this threshold. sql/item_timefunc.cc: throw NULL when year in date_add() / date_sub() would be affected by 2 digit -> 4 digit magic.
Diffstat (limited to 'include/my_time.h')
-rw-r--r--include/my_time.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/my_time.h b/include/my_time.h
index 2b0dc4ac6ff..df500dc501b 100644
--- a/include/my_time.h
+++ b/include/my_time.h
@@ -38,7 +38,10 @@ typedef long my_time_t;
#define MY_TIME_T_MAX LONG_MAX
#define MY_TIME_T_MIN LONG_MIN
+/* two-digit years < this are 20..; >= this are 19.. */
#define YY_PART_YEAR 70
+/* apply above magic to years < this */
+#define YY_MAGIC_BELOW 200
/* Flags to str_to_datetime */
#define TIME_FUZZY_DATE 1