From 447a2dc3e0be80195b423903a6323a03a89f7ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Wed, 22 Mar 2017 10:52:57 +0100 Subject: [PATCH] Allow dates beyond 2038 --- include/my_time.h | 12 +++++++----- sql/tztime.cc | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/my_time.h b/include/my_time.h index 77c90a7..1714f8b 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -31,13 +31,13 @@ extern const char my_zero_datetime6[]; /* "0000-00-00 00:00:00.000000" */ /* Portable time_t replacement. - Should be signed and hold seconds for 1902 -- 2038-01-19 range - i.e at least a 32bit variable + Should be signed and hold seconds for 1902 -- 9999 range + i.e at least a 64bit variable Using the system built in time_t is not an option as we rely on the above requirements in the time functions */ -typedef long my_time_t; +typedef long long my_time_t; typedef enum enum_mysql_timestamp_type timestamp_type; @@ -45,9 +45,11 @@ typedef enum enum_mysql_timestamp_type timestamp_type; #define MY_TIME_T_MIN LONG_MIN /* Time handling defaults */ -#define TIMESTAMP_MAX_YEAR 2038 +#define TIMESTAMP_MAX_YEAR 9999 #define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1) -#define TIMESTAMP_MAX_VALUE INT_MAX32 + +/* 253370764800 = 9999-01-01 */ +#define TIMESTAMP_MAX_VALUE 253370764800 #define TIMESTAMP_MIN_VALUE 1 /* two-digit years < this are 20..; >= this are 19.. */ diff --git a/sql/tztime.cc b/sql/tztime.cc index 2261144..920bf62 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2422,7 +2422,7 @@ print_tz_as_sql(const char* tz_name, const TIME_ZONE_INFO *sp) printf("INSERT INTO time_zone_transition \ (Time_zone_id, Transition_time, Transition_type_id) VALUES\n"); for (i= 0; i < sp->timecnt; i++) - printf("%s(@time_zone_id, %ld, %u)\n", (i == 0 ? " " : ","), sp->ats[i], + printf("%s(@time_zone_id, %lld, %u)\n", (i == 0 ? " " : ","), sp->ats[i], (uint)sp->types[i]); printf(";\n"); } @@ -2467,7 +2467,7 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp) printf("INSERT INTO time_zone_leap_second \ (Transition_time, Correction) VALUES\n"); for (i= 0; i < sp->leapcnt; i++) - printf("%s(%ld, %ld)\n", (i == 0 ? " " : ","), + printf("%s(%lld, %ld)\n", (i == 0 ? " " : ","), sp->lsis[i].ls_trans, sp->lsis[i].ls_corr); printf(";\n"); }