From dcbc526a20c36b836d90dcba7d3b5519b3687dbf Mon Sep 17 00:00:00 2001 From: Anson Chung Date: Thu, 25 Apr 2024 17:44:43 +0000 Subject: [PATCH] Alter thr_timer to allow server startup past 2038 In previous commits, changes were made to use the entire 32 bit unsigned range in order to support timestamps past 2038 on 64 bit systems. Without changing set_max_time on thr_timer to also match this new range, the server will crash when attempting to startup past 2038-01-19. Like the previous commits, this only applies to 64 bit systems. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- mysql-test/main/long_unique_bugs.result | 4 ++-- mysql-test/main/long_unique_bugs.test | 2 +- mysql-test/main/sp.result | 2 +- mysql-test/main/sp.test | 2 +- mysys/thr_timer.c | 8 +++++++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 6ea126665c3..95d4864e14c 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -59,8 +59,8 @@ update t1 set f = 'foo'; select * from t1; pk f 1 foo -select pk, f, row_end > DATE'2030-01-01' from t1 for system_time all; -pk f row_end > DATE'2030-01-01' +select pk, f, row_end > DATE'2106-01-01' from t1 for system_time all; +pk f row_end > DATE'2106-01-01' 1 foo 1 1 foo 0 1 bar 0 diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 8acb5e9e080..8fe3bb41a43 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -59,7 +59,7 @@ update t1 set f = 'bar'; select * from t1; update t1 set f = 'foo'; select * from t1; -select pk, f, row_end > DATE'2030-01-01' from t1 for system_time all; +select pk, f, row_end > DATE'2106-01-01' from t1 for system_time all; drop table t1; --echo # diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index 518c672d619..60bd5d9135f 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -2734,7 +2734,7 @@ drop table t3| drop procedure if exists bug6857| create procedure bug6857() begin -declare t0, t1 int; +declare t0, t1 bigint; declare plus bool default 0; set t0 = unix_timestamp(); select sleep(1.1); diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index 97626570519..65baffc97fb 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -3365,7 +3365,7 @@ drop procedure if exists bug6857| --enable_warnings create procedure bug6857() begin - declare t0, t1 int; + declare t0, t1 bigint; declare plus bool default 0; set t0 = unix_timestamp(); select sleep(1.1); diff --git a/mysys/thr_timer.c b/mysys/thr_timer.c index d3627fea983..76517c52d8b 100644 --- a/mysys/thr_timer.c +++ b/mysys/thr_timer.c @@ -35,9 +35,15 @@ static mysql_cond_t COND_timer; static QUEUE timer_queue; pthread_t timer_thread; +#if SIZEOF_VOIDP == 4 +/* 32 bit system, using old timestamp */ #define set_max_time(abs_time) \ { (abs_time)->MY_tv_sec= INT_MAX32; (abs_time)->MY_tv_nsec= 0; } - +#else +/* 64 bit system. Use 4 byte unsigned timestamp */ +#define set_max_time(abs_time) \ + { (abs_time)->MY_tv_sec= UINT_MAX32; (abs_time)->MY_tv_nsec= 0; } +#endif static void *timer_handler(void *arg __attribute__((unused)));