1
0
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:
Monty
2023-09-11 17:58:22 +03:00
committed by Sergei Golubchik
parent ce6cce85d4
commit dfdedd46e4
90 changed files with 1227 additions and 354 deletions

View File

@@ -169,7 +169,7 @@ set @now= now(6);
insert into t1 values (1);
set @str= concat('select x, row_start < @now as A, row_end > @now as B from t1 partition (p0)');
prepare select_p0 from @str;
set @str= concat('select x, row_start > @now as C, row_end = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn)');
set @str= concat("select x, row_start > @now as C, row_end = SYS_TIME_MAX as D from t1 partition (pn)");;
prepare select_pn from @str;
execute select_p0;
x A B
@@ -302,7 +302,7 @@ create table t1 (i int) with system versioning
partition by system_time interval 6 day limit 98;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'limit 98' at line 2
create or replace table t1 (pk int) with system versioning
partition by system_time interval 10 year partitions 3;
partition by system_time interval 60 year partitions 3;
ERROR 22003: TIMESTAMP value is out of range in 'INTERVAL'
# INTERVAL and ALTER TABLE
create or replace table t1 (i int) with system versioning
@@ -3409,7 +3409,7 @@ insert into t1 (a,row_start,row_end) values
('p0', '2021-09-30', '2021-09-30 10:00:00'),
('p1', '2021-09-30', '2021-10-01 10:00:00'),
('overflows, so also p1','2021-09-30', '2021-10-10 10:00:00'),
('pn, current', '2021-09-30', '2038-01-19 03:14:07.999999');
('pn, current', '2021-09-30', SYS_TIME_MAX);
select table_name,partition_name,partition_ordinal_position,partition_method,partition_description,table_rows
from information_schema.partitions where table_schema='test';
table_name partition_name partition_ordinal_position partition_method partition_description table_rows