mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +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:
@@ -85,7 +85,7 @@ drop table t2;
|
||||
--echo # MDEV-16546 System versioning setting to allow history modification
|
||||
--echo #
|
||||
set @@session.time_zone='+00:00';
|
||||
let $MAX_TIMESTAMP= TIMESTAMP'2038-01-19 03:14:07.999999';
|
||||
let $MAX_TIMESTAMP= $sys_time_max;
|
||||
|
||||
create table t1(x int primary key) with system versioning;
|
||||
create table t2(y int primary key,
|
||||
@@ -108,7 +108,7 @@ show create table t1;
|
||||
insert into t1(x, row_start, row_end) values (3, '1980-01-01 00:00:00', '1980-01-01 00:00:01');
|
||||
insert into t2(y, row_start, row_end) values (4, '1980-01-01 00:00:00', '1980-01-01 00:00:01');
|
||||
insert into t3 values (5, '1980-01-01 00:00:00', '1980-01-01 00:00:01');
|
||||
--error ER_WRONG_VALUE
|
||||
--error ER_WRONG_VERSIONING_RANGE
|
||||
insert into t3 values (5, '1980-01-02 00:00:00', '1980-01-01 00:00:01');
|
||||
|
||||
select x, row_start, row_end from t1 for system_time all;
|
||||
@@ -132,16 +132,19 @@ insert t2 (y,row_end) values (1, '1970-01-01 00:00:00') on duplicate key update
|
||||
# this should work, row_start/row_end must be mentioned explicitly:
|
||||
insert into t1 values (4);
|
||||
insert into t1 set x= 5, row_start= '1980-01-01 00:00:00', row_end= '1980-01-01 00:00:01';
|
||||
--error ER_WRONG_VALUE
|
||||
--error ER_WRONG_VERSIONING_RANGE
|
||||
insert into t1(x, row_start, row_end) values (6, '1980-01-01 00:00:01', '1980-01-01 00:00:00');
|
||||
--error ER_WRONG_VALUE
|
||||
--error ER_WRONG_VERSIONING_RANGE
|
||||
insert into t1(x, row_start, row_end) values (7, '1980-01-01 00:00:11', '1980-01-01 00:00:11');
|
||||
insert into t1(x, row_start) values (8, '1980-01-01 00:00:22');
|
||||
--replace_regex /'202\d-\d\d-\d\d .*'/'now'/
|
||||
--error ER_WRONG_VALUE
|
||||
--error ER_WRONG_VERSIONING_RANGE
|
||||
insert into t1(x, row_end) values (9, '1980-01-01 00:00:33');
|
||||
|
||||
--replace_result $MAX_TIMESTAMP MAX_TIMESTAMP
|
||||
eval insert into t1(x, row_end) values (10, $MAX_TIMESTAMP);
|
||||
select x, check_row_ts(row_start, row_end) from t1 for system_time all order by x;
|
||||
--replace_result $MAX_TIMESTAMP MAX_TIMESTAMP
|
||||
eval select x, row_start, row_end from t1 for system_time all
|
||||
where x > 1 and row_end < $MAX_TIMESTAMP order by x, row_start, row_end;
|
||||
--echo # Direct insert is not possible for TRX_ID versioning
|
||||
@@ -159,6 +162,7 @@ create or replace table t2 like t1;
|
||||
set @@system_versioning_insert_history= 1;
|
||||
insert into t2 (x, row_start, row_end) select x, row_start, row_end from t1 for system_time all;
|
||||
select x, check_row_ts(row_start, row_end) from t2 for system_time all order by x;
|
||||
--replace_result $MAX_TIMESTAMP MAX_TIMESTAMP
|
||||
eval select x, row_start, row_end from t2 for system_time all
|
||||
where x > 1 and row_end < $MAX_TIMESTAMP order by x, row_start, row_end;
|
||||
set @@system_versioning_insert_history= 0;
|
||||
|
Reference in New Issue
Block a user