mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +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:
@ -116,11 +116,10 @@ create table t1 (ts timestamp);
|
||||
set time_zone='UTC';
|
||||
insert into t1 values ('0000-00-00 00:00:00'),('1969-12-31 23:59:59'),
|
||||
('1970-01-01 00:00:00'),('1970-01-01 00:00:01'),
|
||||
('2038-01-19 03:14:07'),('2038-01-19 03:14:08');
|
||||
('2038-01-19 03:14:07');
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'ts' at row 2
|
||||
Warning 1264 Out of range value for column 'ts' at row 3
|
||||
Warning 1264 Out of range value for column 'ts' at row 6
|
||||
select * from t1;
|
||||
ts
|
||||
0000-00-00 00:00:00
|
||||
@ -128,16 +127,14 @@ ts
|
||||
0000-00-00 00:00:00
|
||||
1970-01-01 00:00:01
|
||||
2038-01-19 03:14:07
|
||||
0000-00-00 00:00:00
|
||||
truncate table t1;
|
||||
set time_zone='MET';
|
||||
insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 00:30:00'),
|
||||
('1970-01-01 01:00:00'),('1970-01-01 01:00:01'),
|
||||
('2038-01-19 04:14:07'),('2038-01-19 04:14:08');
|
||||
('2038-01-19 04:14:07');
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'ts' at row 2
|
||||
Warning 1264 Out of range value for column 'ts' at row 3
|
||||
Warning 1264 Out of range value for column 'ts' at row 6
|
||||
select * from t1;
|
||||
ts
|
||||
0000-00-00 00:00:00
|
||||
@ -145,16 +142,14 @@ ts
|
||||
0000-00-00 00:00:00
|
||||
1970-01-01 01:00:01
|
||||
2038-01-19 04:14:07
|
||||
0000-00-00 00:00:00
|
||||
truncate table t1;
|
||||
set time_zone='+01:30';
|
||||
insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 01:00:00'),
|
||||
('1970-01-01 01:30:00'),('1970-01-01 01:30:01'),
|
||||
('2038-01-19 04:44:07'),('2038-01-19 04:44:08');
|
||||
('2038-01-19 04:44:07');
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'ts' at row 2
|
||||
Warning 1264 Out of range value for column 'ts' at row 3
|
||||
Warning 1264 Out of range value for column 'ts' at row 6
|
||||
select * from t1;
|
||||
ts
|
||||
0000-00-00 00:00:00
|
||||
@ -162,7 +157,6 @@ ts
|
||||
0000-00-00 00:00:00
|
||||
1970-01-01 01:30:01
|
||||
2038-01-19 04:44:07
|
||||
0000-00-00 00:00:00
|
||||
drop table t1;
|
||||
show variables like 'time_zone';
|
||||
Variable_name Value
|
||||
@ -226,12 +220,6 @@ convert_tz('2003-10-26 04:00:00', 'MET', 'UTC')
|
||||
select convert_tz('2038-01-19 04:14:07', 'MET', 'UTC');
|
||||
convert_tz('2038-01-19 04:14:07', 'MET', 'UTC')
|
||||
2038-01-19 03:14:07
|
||||
select convert_tz('2038-01-19 04:14:08', 'MET', 'UTC');
|
||||
convert_tz('2038-01-19 04:14:08', 'MET', 'UTC')
|
||||
2038-01-19 04:14:08
|
||||
select convert_tz('2103-01-01 04:00:00', 'MET', 'UTC');
|
||||
convert_tz('2103-01-01 04:00:00', 'MET', 'UTC')
|
||||
2103-01-01 04:00:00
|
||||
create table t1 (tz varchar(3));
|
||||
insert into t1 (tz) values ('MET'), ('UTC');
|
||||
select tz, convert_tz('2003-12-31 00:00:00',tz,'UTC'), convert_tz('2003-12-31 00:00:00','UTC',tz) from t1 order by tz;
|
||||
|
Reference in New Issue
Block a user