mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-32188 make TIMESTAMP use whole 32-bit unsigned range
This patch extends the timestamp from 2038-01-19 03:14:07.999999 to 2106-02-07 06:28:15.999999 for 64 bit hardware and OS where 'long' is 64 bits. This is true for 64 bit Linux but not for Windows. This is done by treating the 32 bit stored int as unsigned instead of signed. This is safe as MariaDB has never accepted dates before the epoch (1970). The benefit of this approach that for normal timestamp the storage is compatible with earlier version. However for tables using system versioning we before stored a timestamp with the year 2038 as the 'max timestamp', which is used to detect current values. This patch stores the new 2106 year max value as the max timestamp. This means that old tables using system versioning needs to be updated with mariadb-upgrade when moving them to 11.4. That will be done in a separate commit.
This commit is contained in:
@@ -16,10 +16,10 @@ create trigger tr before insert on t for each row set new.b=1, new.s = '2022-03-
|
||||
insert into t (a) values (3),(4);
|
||||
select * from t for system_time all;
|
||||
a b s e
|
||||
1 2 2010-10-10 10:10:10.000000 2038-01-19 03:14:07.999999
|
||||
2 3 2010-10-10 10:10:10.000000 2038-01-19 03:14:07.999999
|
||||
3 4 2010-10-10 10:10:10.000000 2038-01-19 03:14:07.999999
|
||||
4 5 2010-10-10 10:10:10.000000 2038-01-19 03:14:07.999999
|
||||
1 2 2010-10-10 10:10:10.000000 SYS_TIME_MAX
|
||||
2 3 2010-10-10 10:10:10.000000 SYS_TIME_MAX
|
||||
3 4 2010-10-10 10:10:10.000000 SYS_TIME_MAX
|
||||
4 5 2010-10-10 10:10:10.000000 SYS_TIME_MAX
|
||||
drop table t;
|
||||
set sql_mode=default, timestamp=default;
|
||||
#
|
||||
@@ -38,12 +38,12 @@ insert t1 values (5,'2020-01-01',default), (6,'2020-02-02',ignore),(7,default,'2
|
||||
set timestamp=default;
|
||||
select * from t1 for system_time all;
|
||||
a s e
|
||||
1 2020-01-01 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
2 2020-02-02 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
1 2020-01-01 00:00:00.000000 SYS_TIME_MAX
|
||||
2 2020-02-02 00:00:00.000000 SYS_TIME_MAX
|
||||
3 2010-10-10 10:10:10.000000 2020-03-03 00:00:00.000000
|
||||
4 2010-10-10 10:10:10.000000 2020-04-04 00:00:00.000000
|
||||
5 2020-01-01 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
6 2020-02-02 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
5 2020-01-01 00:00:00.000000 SYS_TIME_MAX
|
||||
6 2020-02-02 00:00:00.000000 SYS_TIME_MAX
|
||||
7 2010-11-11 11:11:11.000000 2020-03-03 00:00:00.000000
|
||||
8 2010-11-11 11:11:11.000000 2020-04-04 00:00:00.000000
|
||||
drop table t1;
|
||||
|
Reference in New Issue
Block a user